* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

body.room-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Landing Page */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-link {
    display: inline-block;
    margin-bottom: 1rem;
}

.kubilo-logo {
    height: 40px;
    width: auto;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.kubilo-logo:hover {
    opacity: 1;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

input::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    width: 100%;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 2rem;
}

.footer-links {
    margin-top: 1rem;
    font-size: 0.8rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-links .separator {
    margin: 0 0.5rem;
    opacity: 0.5;
}

.kubilo-brand {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.kubilo-brand a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.kubilo-brand a:hover {
    text-decoration: underline;
}

.version {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* Legal Pages */
.legal-page {
    max-width: 700px;
}

.legal-content {
    text-align: left;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
}

.legal-content section {
    margin-bottom: 2rem;
}

.legal-content section:last-child {
    margin-bottom: 0;
}

.legal-content h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.legal-content p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.legal-content ul {
    color: var(--text-muted);
    margin-left: 1.5rem;
    line-height: 1.8;
}

.legal-content li {
    margin-bottom: 0.25rem;
}

.legal-page footer {
    margin-top: 2rem;
}

.legal-page footer .btn {
    display: inline-block;
    margin-bottom: 1rem;
}

/* Consent Modal */
.consent-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.consent-subtitle {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.consent-info {
    text-align: left;
    margin-bottom: 1.5rem;
}

.consent-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.consent-item:last-child {
    margin-bottom: 0;
}

.consent-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.consent-item p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.4;
}

.consent-links {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.consent-links a {
    color: var(--primary);
    text-decoration: none;
}

.consent-links a:hover {
    text-decoration: underline;
}

/* Chat Room */
.room-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.room-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.room-info h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.room-info h1 span {
    font-family: monospace;
    color: var(--primary);
}

.room-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.room-meta .separator {
    margin: 0 0.5rem;
}

.room-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-own {
    align-self: flex-end;
    background: var(--primary);
}

.message-other {
    align-self: flex-start;
    background: var(--bg-card);
}

.message-sender {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.message-own .message-sender {
    color: rgba(255, 255, 255, 0.7);
}

.message-content {
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

.message-own .message-time {
    color: rgba(255, 255, 255, 0.6);
}

.message-system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.5rem;
}

.input-container {
    flex-shrink: 0;
    padding: 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-container form {
    display: flex;
    gap: 0.5rem;
}

.input-container input {
    flex: 1;
}

.input-container .btn {
    width: auto;
}

.connection-status {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-muted);
    display: none;
}

.connection-status.visible {
    display: block;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
}

.overlay-content h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.overlay-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.overlay-content .btn {
    width: auto;
    display: inline-block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Nickname Modal */
.nickname-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.nickname-modal .form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.nickname-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.room-code-display {
    font-family: monospace;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: bold;
}

.current-users {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.error-text {
    display: block;
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

.back-link {
    display: block;
    margin-top: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--text);
}

input.error {
    border-color: var(--danger);
}

/* Confirm Modal */
.confirm-modal {
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-modal h2 {
    margin-bottom: 0.75rem;
    color: var(--text);
}

.confirm-modal p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-buttons .btn {
    flex: 1;
    max-width: 150px;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .room-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .room-actions {
        width: 100%;
    }

    .room-actions .btn {
        flex: 1;
    }

    .message {
        max-width: 90%;
    }
}
