/* YouTube-inspired design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

html {
    scroll-behavior: auto;
}

:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9F9F9;
    --text-primary: #0F0F0F;
    --text-secondary: #606060;
    --text-muted: #909090;
    --icon-color: #606060;
    --border-color: #D9D9D9;
    --border-light: #E5E5E5;
    --accent-default: #FFF0F0;
    --accent-hover: #FFE0E0;
    --accent-highlight: #FF0000;
    --correct: #39FF14;
    --incorrect: #FF073A;
    --disabled-bg: #F0F0F0;
    --surface-inverse: #0F0F0F;
    --text-inverse: #FFFFFF;
    --media-background: #000000;
    --surface-scrim: rgba(255, 255, 255, 0.55);
    --surface-overlay: rgba(255, 255, 255, 0.84);
    --surface-overlay-raised: rgba(255, 255, 255, 0.90);
    --surface-overlay-border: rgba(255, 255, 255, 0.76);
    --surface-inverse-overlay: rgba(15, 15, 15, 0.88);
    --avatar-color-1: #FF0000;
    --avatar-color-2: #606060;
    --avatar-color-3: #909090;
    --avatar-color-4: #CC0000;
    --avatar-color-5: #D9D9D9;
    --avatar-color-6: #0F0F0F;
    --avatar-color-7: #FFE0E0;
    --avatar-color-8: #E5E5E5;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-top: 72px;
    position: relative;
}
body.game-page {
    padding-top: 0;
}

/* ── Fullscreen game pages — responsive layout ────────────────────────────── */
.game-page .container {
    max-width: 100%;
    padding: 16px 20px;
    box-sizing: border-box;
}

/* Cards fill the full available width on game pages */
.game-page .host-card,
.game-page .question-card,
.game-page .results-card {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Tablet (≥ 600px): 2-column answer grid */
@media (min-width: 600px) {
    .game-page .answers-grid {
        grid-template-columns: 1fr 1fr;
    }
    .game-page .question-text {
        font-size: 22px;
    }
    .game-page .container {
        padding: 20px 32px;
    }
}

/* Desktop (≥ 900px): larger text, roomier padding */
@media (min-width: 900px) {
    .game-page .question-text {
        font-size: 26px;
    }
    .game-page .answer-text {
        font-size: 17px;
    }
    .game-page .answer-btn,
    .game-page .answer-display {
        padding: 18px 24px;
    }
    .game-page .container {
        padding: 24px 48px;
    }
    .game-page .host-card,
    .game-page .question-card {
        padding: 32px 40px;
    }
}

.container { width: 100%; max-width: 500px; margin: 0 auto; padding: 20px; }
.home-container { display: flex; align-items: center; min-height: calc(100vh - 72px); padding: 20px; }

/* Navigation Bar */
.nav-header {
    position: fixed; 
    top: 0 !important; 
    left: 0 !important; 
    right: 0 !important;
    width: 100%;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    z-index: 9999; 
    padding: 12px 0;
    box-shadow: var(--shadow-sm);
    margin: 0 !important;
    transform: none !important;
    transition: none !important;
}
.nav-container {
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 16px;
    display: flex; 
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
}
.nav-left {
    display: flex; align-items: center; gap: 12px;
}
.nav-brand {
    display: flex; align-items: center;
}
.nav-logo-link {
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.nav-logo {
    font-size: 32px; font-weight: 800;
    color: var(--text-primary);
    transition: color 0.3s ease;
    letter-spacing: -0.5px;
}
.nav-logo-link:hover .nav-logo { color: var(--accent-highlight); }
.nav-actions {
    display: flex; align-items: center; gap: 8px;
}
.search-btn, .hamburger-btn, .user-btn {
    width: 40px; height: 40px; border-radius: 12px;
    border: none; background: transparent;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all 0.3s ease; padding: 0;
}
.search-btn:hover, .hamburger-btn:hover, .user-btn:hover {
    background: var(--accent-default);
}
.search-btn svg, .hamburger-btn svg {
    stroke: var(--icon-color);
    transition: stroke 0.3s ease;
}
.search-btn:hover svg, .hamburger-btn:hover svg {
    stroke: var(--accent-highlight);
}
.user-btn {
    width: 48px; height: 48px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    overflow: hidden;
}
.user-btn:hover {
    border-color: var(--accent-highlight);
    transform: scale(1.05);
}
.user-btn svg { stroke: var(--icon-color); transition: stroke 0.3s ease; position: relative; z-index: 0; }
.user-btn:hover svg { stroke: var(--accent-highlight); }
.user-avatar { 
    width: 100%; 
    height: 100%; 
    border-radius: 10px; 
    object-fit: cover; 
    display: block;
    position: relative;
    z-index: 1;
}
.user-btn:has(.user-avatar) svg {
    display: none;
}
.user-menu-wrapper {
    position: relative;
}
.user-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    min-width: 220px; overflow: hidden;
    transition: all 0.3s ease; opacity: 1; transform: translateY(0);
}
.user-menu.hidden { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.user-menu-header { 
    padding: 20px; 
    background: var(--accent-highlight); 
    color: white; 
}
.user-menu-header-link {
    display: block;
    text-decoration: none;
    transition: background 0.2s ease;
    cursor: pointer;
}
.user-menu-header-link:hover {
    background: var(--accent-hover);
}
.user-menu-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.user-menu-email { font-size: 12px; opacity: 0.95; word-break: break-word; }
.user-menu-divider { height: 1px; background: var(--border-light); }
.user-menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; color: var(--text-primary);
    text-decoration: none; transition: background 0.2s; cursor: pointer;
}
.user-menu-item:hover { background: var(--accent-default); }
.user-menu-item svg { width: 20px; height: 20px; stroke: var(--text-secondary); }

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.search-overlay.hidden {
    display: none;
}

.search-overlay.active {
    transform: translateY(0);
}

.search-overlay-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    border-bottom: 2px solid var(--accent-highlight);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-input-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--accent-default);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
    position: relative;
}

.search-input-container::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    padding: 2px;
    background: linear-gradient(135deg, var(--accent-highlight), var(--accent-hover));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.search-input-container:focus-within {
    border-color: var(--accent-highlight);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px var(--accent-default);
}

.search-input-container:focus-within::before {
    opacity: 1;
}

.search-icon {
    stroke: var(--accent-highlight);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.search-input-container:focus-within .search-icon {
    stroke: var(--accent-highlight);
    transform: scale(1.1);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: var(--accent-default);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.search-close-btn:hover {
    background: var(--accent-highlight);
    border-color: var(--accent-highlight);
    transform: scale(1.05);
}

.search-close-btn:active {
    transform: scale(0.95);
}

.search-close-btn svg {
    stroke: var(--text-primary);
    transition: stroke 0.2s ease;
}

.search-close-btn:hover svg {
    stroke: white;
}

.search-overlay-content {
    padding: 16px;
}

.search-results {
    max-width: 800px;
    margin: 0 auto;
}

.search-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.search-empty-state svg {
    stroke: var(--accent-highlight);
    margin-bottom: 16px;
    opacity: 0.6;
    filter: drop-shadow(0 2px 4px var(--accent-default));
}

.search-empty-state p {
    color: var(--text-secondary);
    font-size: 16px;
    margin: 8px 0;
}

.search-empty-state p:first-of-type {
    color: var(--text-primary);
    font-weight: 600;
}

.search-coming-soon {
    font-size: 14px !important;
    color: var(--accent-highlight) !important;
    font-weight: 600;
    background: var(--accent-default);
    padding: 6px 16px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 8px;
}

/* Search Loading */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--accent-default);
    border-top-color: var(--accent-highlight);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* User Search Results */
.search-user-results {
    padding: 8px 0;
}

.search-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    border: 2px solid transparent;
}

.search-user-item:hover {
    background: var(--accent-default);
    border-color: var(--accent-highlight);
    transform: translateX(4px);
}

.search-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border-light);
    background: var(--bg-secondary);
}

.search-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-user-info {
    flex: 1;
    min-width: 0;
}

.search-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-user-handle {
    font-size: 14px;
    color: var(--text-secondary);
}

.search-user-meta {
    text-align: right;
}

.search-user-followers {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 8px;
    display: inline-block;
}

.search-user-item:hover .search-user-followers {
    background: var(--bg-primary);
    color: var(--accent-highlight);
}

/* Cards */
.home-card, .landing-card, .login-card, .results-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 24px; padding: 48px 32px;
    box-shadow: var(--shadow-md);
    text-align: center; width: 100%;
    max-width: 440px; margin: 0 auto;
    transition: box-shadow 0.3s ease;
}
/* results-card on game page should not be constrained to 440px */
.game-page .results-card {
    max-width: 100%;
    text-align: left;
}
.home-card:hover, .landing-card:hover { box-shadow: var(--shadow-lg); }
.question-card, .host-card, .waiting-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 24px; padding: 32px 24px;
    box-shadow: var(--shadow-md);
}
.waiting-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 24px; padding: 40px;
    box-shadow: var(--shadow-md);
    max-width: 600px; width: 100%; margin: 0 auto;
}

/* Typography */
h1 { font-size: 32px; font-weight: 800; color: var(--text-primary); margin-bottom: 32px; }
h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; }
.subtitle { color: var(--text-secondary); font-size: 16px; margin-bottom: 32px; }
.footer-text { margin-top: 32px; font-size: 13px; color: var(--text-secondary); }
.note { font-size: 14px; color: var(--text-secondary); font-style: italic; }
.logo {
    width: 80px; height: 80px; margin: 0 auto 24px;
    background: var(--accent-highlight);
    border-radius: 20px; display: flex;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
}
.logo svg { width: 48px; height: 48px; stroke: white; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 12px; padding: 16px 24px; border-radius: 16px;
    border: none; font-size: 16px; font-weight: 700;
    font-family: 'Inter', sans-serif; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none; width: 100%;
    position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--accent-highlight);
    color: white; box-shadow: var(--shadow-sm);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: var(--accent-default); color: var(--text-primary); border: 2px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent-highlight); background: var(--accent-hover); }
.btn-join, .btn-join-large { background: var(--accent-default); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.btn-join:hover, .btn-join-large:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--accent-hover); }
.btn-host, .btn-host-large { background: var(--accent-highlight); color: white; box-shadow: var(--shadow-sm); }
.btn-host:hover, .btn-host-large:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.05); }
.btn-join-large, .btn-host-large { padding: 20px 32px; font-size: 18px; }
.btn-google { background: white; color: #333; border: 1px solid var(--border-color); }
.btn-google:hover { background: var(--bg-secondary); }
.btn-apple { background: #000; color: white; }
.btn-cloudforge { background: #4285f4; color: white; }
.btn-apple:hover { background: #333; }
.button-group, .game-actions { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }

/* Modals */
.modal {
    display: none; position: fixed; z-index: 2000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}
.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    padding: 40px 32px; border-radius: 24px;
    width: 90%; max-width: 400px; position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 { margin-bottom: 12px; font-size: 28px; }
.modal-subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.close {
    position: absolute; top: 20px; right: 20px;
    width: 32px; height: 32px; display: flex;
    align-items: center; justify-content: center;
    font-size: 24px; font-weight: 400;
    color: var(--icon-color); cursor: pointer;
    line-height: 1; transition: all 0.3s; border-radius: 8px;
}
.close:hover { color: var(--text-primary); background: var(--accent-default); }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal input[type="text"], .modal-form input {
    padding: 16px; background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px; font-size: 16px;
    color: var(--text-primary); transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
}
.modal-form input[name="nickname"] { text-align: left; font-family: 'Inter', sans-serif; }
.modal-form input[name="game_code"], .modal input[type="text"] {
    text-align: center; font-size: 24px;
    letter-spacing: 6px; font-weight: 700;
    font-family: 'Courier New', monospace;
}
.modal input:focus, .modal-form input:focus {
    outline: none; border-color: var(--accent-highlight);
    background: var(--accent-default);
}
.modal-form button { margin-top: 8px; width: 100%; box-sizing: border-box; }

/* Game Screens */
.game-screen {
    min-height: 100vh; padding: 20px;
    display: flex; flex-direction: column;
    gap: 16px;
    width: 100%; margin: 0 auto;
    max-width: 600px;
    position: relative;
    z-index: 1;
}
.helmet-cam-effect {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}
.code-card {
    background: var(--accent-highlight);
    border-radius: 24px; padding: 0 0 32px;
    text-align: center; box-shadow: var(--shadow-md);
    position: relative; overflow: hidden;
}
.code-details {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.code-label {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.9); margin-bottom: 8px;
}
.code-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
.code-display {
    font-size: 48px; font-weight: 800;
    letter-spacing: 8px; font-family: 'Courier New', monospace;
    color: #FFFFFF; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.join-qr {
    flex: 0 0 auto;
    line-height: 0;
}
.join-qr img {
    width: 144px;
    height: 144px;
    padding: 8px;
    background: #FFFFFF;
    border-radius: 8px;
}
.players-section { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.section-header { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.player-count-badge {
    background: var(--accent-default);
    border: 1px solid var(--border-light);
    border-radius: 12px; padding: 8px 16px;
    font-size: 14px; font-weight: 700;
    color: var(--accent-highlight);
}
.waiting-text { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.players-list { display: flex; flex-direction: column; gap: 8px; padding: 4px; }
@media (min-width: 1024px) {
    .game-screen {
        max-width: 900px;
        padding: 32px 48px;
        gap: 20px;
    }
    .players-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}
.player-item {
    display: flex; align-items: center; gap: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 16px; padding: 12px 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.player-item:hover {
    border-color: var(--accent-highlight);
    box-shadow: var(--shadow-sm);
    background: var(--accent-default);
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
.player-avatar {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700; color: white;
    flex-shrink: 0; box-shadow: var(--shadow-sm);
    background: var(--accent-highlight);
    overflow: hidden;
    position: relative;
}
.player-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}
.player-info { display: flex; align-items: center; gap: 8px; flex: 1; }
.player-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.player-badge {
    padding: 3px 10px; font-size: 10px; font-weight: 700;
    text-transform: uppercase; border-radius: 8px; letter-spacing: 0.5px;
}
.host-badge { background: var(--accent-highlight); color: white; }
.you-badge { background: var(--accent-default); color: var(--accent-highlight); border: 1px solid var(--accent-highlight); }
.action-stack { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.game-btn {
    width: 100%; padding: 18px 24px; border: none;
    border-radius: 16px; font-size: 16px; font-weight: 700;
    font-family: 'Inter', sans-serif; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; justify-content: space-between;
    position: relative; overflow: hidden;
}
.game-btn-primary { background: var(--accent-highlight); color: white; box-shadow: var(--shadow-sm); }
.game-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.05); }
.game-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.game-btn-ghost { background: transparent; border: 2px solid var(--border-color); color: var(--text-secondary); }
.game-btn-ghost:hover { border-color: var(--incorrect); color: var(--incorrect); background: rgba(255, 7, 58, 0.05); }
.btn-text { font-size: 16px; }
.btn-icon { font-size: 20px; transition: transform 0.3s; }
.game-btn:hover .btn-icon { transform: translateX(4px); }

/* Questions */
.question-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.question-number { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.difficulty-badge {
    padding: 4px 12px; border-radius: 8px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; background: var(--accent-default);
    color: var(--accent-highlight); border: 1px solid var(--border-light);
}
.question-content {
    margin-bottom: 32px;
    padding: 20px 24px;
    border: 2px solid var(--accent-highlight);
    border-radius: 20px;
    background: var(--accent-highlight);
    box-shadow: var(--shadow-sm);
}
.question-text { font-size: 20px; font-weight: 700; color: #fff; line-height: 1.5; }
.answers-grid { display: grid; gap: 12px; margin-bottom: 24px; }
.answer-btn {
    display: flex; align-items: center; gap: 16px; padding: 16px 20px;
    background: var(--accent-default); border: 2px solid var(--border-light);
    border-radius: 16px; cursor: pointer; transition: all 0.3s; text-align: left;
}
.answer-btn:hover { border-color: var(--accent-highlight); background: var(--accent-hover); transform: translateX(4px); }
.answer-btn.selected { border-color: var(--accent-highlight); background: var(--accent-highlight); }
.answer-btn.selected .answer-text { color: white; }
.answer-btn.correct { border-color: var(--correct); background: var(--correct); }
.answer-btn.correct .answer-text { color: white; }
.answer-btn.incorrect { border-color: var(--incorrect); background: var(--incorrect); }
.answer-btn.incorrect .answer-text { color: white; }
.answer-btn:disabled { cursor: not-allowed; opacity: 0.8; }
.answer-label {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: var(--accent-highlight); color: white; font-weight: 700;
    font-size: 14px; border-radius: 8px;
}
.answer-btn.correct .answer-label, .answer-btn.incorrect .answer-label { background: rgba(255, 255, 255, 0.3); }
.answer-text { flex: 1; font-size: 16px; font-weight: 600; color: var(--text-primary); }
.feedback-message { text-align: center; padding: 16px; border-radius: 12px; font-weight: 600; margin-top: 16px; }
.points-display { text-align: center; font-size: 18px; font-weight: 700; margin-top: 16px; }
.points-value { color: var(--accent-highlight); }
.points-earned { color: var(--correct); }
.points-missed { color: var(--incorrect); }
.answers-grid.host-view { pointer-events: none; }

/* Host-plays toggle in lobby */
.host-plays-label {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); padding: 12px 16px;
    background: var(--accent-default); border: 2px solid var(--border-light);
    border-radius: 12px; margin-bottom: 8px; user-select: none;
    transition: border-color 0.2s;
}
.host-plays-label:has(input:checked) {
    border-color: var(--accent-highlight);
    color: var(--text-primary);
}
.host-plays-label input[type=checkbox] {
    width: 18px; height: 18px; accent-color: var(--accent-highlight);
    cursor: pointer; flex-shrink: 0;
}
.answer-display {
    display: flex; align-items: center; gap: 16px; padding: 16px 20px;
    background: var(--accent-default); border: 2px solid var(--border-light); border-radius: 16px;
}
.answer-display.correct-answer { border-color: var(--correct); background: var(--correct); }
.answer-display.correct-answer .answer-text { color: white; }
.check-mark { margin-left: auto; color: white; font-size: 24px; }
.player-status { margin: 24px 0; text-align: center; }
.player-status h3 { font-size: 16px; color: var(--text-secondary); }
.host-controls { display: flex; gap: 12px; margin-top: 24px; }

/* Results & Leaderboard */
.final-score { text-align: center; margin: 32px 0; }
.score-label { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.score-value { font-size: 56px; font-weight: 800; color: var(--accent-highlight); }
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px; margin: 32px 0;
}
.stat-item {
    background: var(--bg-primary); border: 1px solid var(--border-light);
    padding: 20px 16px; border-radius: 16px; text-align: center; transition: all 0.3s;
}
.stat-item:hover { box-shadow: var(--shadow-sm); border-color: var(--accent-highlight); }
.stat-item.warning { border-color: rgba(255, 160, 0, 0.3); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent-highlight); margin-bottom: 8px; }
.stat-label { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.performance-message { text-align: center; margin: 32px 0; }
.performance-message p { font-size: 18px; font-weight: 600; }
.excellent { color: var(--correct); }
.great { color: var(--accent-highlight); }
.good { color: #FFA07A; }
.needs-work { color: var(--text-secondary); }
.answer-review { margin: 32px 0; }
.answer-review h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.review-item {
    background: var(--bg-primary); border: 1px solid var(--border-light);
    border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.review-item.correct { border-color: var(--correct); background: rgba(57, 255, 20, 0.05); }
.review-item.incorrect { border-color: var(--incorrect); background: rgba(255, 7, 58, 0.05); }
.review-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.question-num { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.answer-badge { padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.review-item.correct .answer-badge { background: var(--correct); color: white; }
.review-item.incorrect .answer-badge { background: var(--incorrect); color: white; }
.review-details { display: flex; flex-direction: column; gap: 8px; }
.review-row { display: flex; justify-content: space-between; font-size: 14px; }
.review-row .label { color: var(--text-secondary); }
.review-row .value { color: var(--text-primary); font-weight: 600; }

/* ── Results screen — lobby-themed ────────────────────────────────────────── */
.results-screen {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    box-sizing: border-box;
}

.results-hero {
    background: var(--accent-highlight);
    border-radius: 24px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.results-hero-eyebrow {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
}
.results-hero-trophy { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.results-hero-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.results-leaderboard-section { display: flex; flex-direction: column; gap: 8px; }

.leaderboard {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 14px 16px;
    transition: all 0.3s ease;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.leaderboard-first {
    border-color: var(--accent-highlight);
    background: var(--accent-default);
    box-shadow: var(--shadow-sm);
}
.leaderboard-medal {
    font-size: 24px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}
.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-highlight);
    color: white;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.leaderboard-name {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.leaderboard-score {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-highlight);
    white-space: nowrap;
}

/* Winner banner on player view */
.winner-banner {
    background: var(--accent-highlight);
    border-radius: 24px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-md);
    color: white;
}
.winner-banner-icon { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.winner-banner-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.winner-banner-sub { font-size: 15px; opacity: 0.9; }

@media (min-width: 1024px) {
    .results-screen {
        max-width: 960px;
        padding: 32px 48px;
        gap: 20px;
    }
    .leaderboard {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .leaderboard-first {
        grid-column: 1 / -1;
    }
}

/* Preferences */
.preferences-section { margin: 24px 0; }
.preference-item { padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.preference-item:last-child { border-bottom: none; }
.preference-item label { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.preference-item input, .preference-item select {
    width: 100%; padding: 12px; background: var(--bg-primary);
    border: 2px solid var(--border-color); border-radius: 12px;
    font-size: 14px; color: var(--text-primary); font-family: 'Inter', sans-serif;
}
.preference-item input:focus, .preference-item select:focus {
    outline: none; border-color: var(--accent-highlight);
    background: var(--accent-default);
}
.preferences-note {
    margin-top: 24px; padding: 16px; background: var(--accent-default);
    border-radius: 12px; font-size: 13px; color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 640px) {
    .nav-container { padding: 0 12px; }
    .nav-left { gap: 8px; }
    .nav-logo { font-size: 28px; }
    .search-btn, .hamburger-btn { width: 36px; height: 36px; }
    .user-btn { width: 44px; height: 44px; }
    .home-card, .landing-card, .login-card { padding: 32px 24px; }
    h1 { font-size: 28px; }
    .code-display { font-size: 36px; letter-spacing: 4px; }
    .code-card { padding: 24px 20px; }
    .code-content { gap: 16px; }
    .join-qr img { width: 115.2px; height: 115.2px; }
    .game-screen { padding: 16px; gap: 20px; }
    .players-list { gap: 6px; }
    .player-item { padding: 10px 12px; }
    .player-avatar { width: 40px; height: 40px; font-size: 18px; }
    .player-name { font-size: 14px; }
    .stats-grid { grid-template-columns: 1fr; }
    .host-controls { flex-direction: column; }
    .game-btn { padding: 16px 20px; }
}
@media (max-width: 480px) {
    .nav-left { gap: 6px; }
    .nav-logo { font-size: 24px; }
    .nav-actions { gap: 4px; }
    .game-screen { padding: 12px; gap: 16px; }
    .code-display { font-size: 28px; letter-spacing: 2px; }
    .code-content { gap: 12px; }
    .join-qr img { width: 96px; height: 96px; padding: 6px; }
    .section-header { flex-wrap: wrap; }
    .player-count-badge { padding: 6px 12px; font-size: 12px; }
    
    /* Modal adjustments for small screens */
    .modal-content { padding: 32px 20px; width: 95%; }
    .modal-form input[name="game_code"], .modal input[type="text"] {
        font-size: 20px;
        letter-spacing: 4px;
        padding: 14px 8px;
    }
    .modal h2 { font-size: 24px; }
}

/* ===== Reaction System ===== */
.reaction-button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}
.reaction-button:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.reaction-picker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid var(--accent-highlight);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}
.reaction-picker.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.reaction-emojis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.reaction-emoji {
    width: 100%;
    aspect-ratio: 1;
    min-height: 48px;
    border: 2px solid var(--accent-default);
    border-radius: 12px;
    background: white;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.reaction-emoji:hover {
    transform: scale(1.1);
    border-color: var(--accent-highlight);
    background: var(--accent-tint);
}
.reaction-emoji:active {
    transform: scale(0.95);
}

.player-avatar-container {
    position: relative;
}

.reaction-emitter {
    position: absolute;
    top: -10px;
    right: -10px;
    pointer-events: none;
    z-index: 100;
}

.reaction-burst {
    position: absolute;
    font-size: 32px;
    animation: burstAnimation 1.2s ease-out forwards;
    pointer-events: none;
}

@keyframes burstAnimation {
    0% {
        transform: scale(0.7) translateY(0);
        opacity: 1;
    }
    40% {
        transform: scale(1.1) translateY(-10px);
        opacity: 1;
    }
    100% {
        transform: scale(1.0) translateY(-30px);
        opacity: 0;
    }
}

@media (min-width: 768px) {
    .reaction-picker {
        position: absolute;
        bottom: auto;
        left: auto;
        right: 16px;
        top: 60px;
        width: fit-content;
        border-radius: 12px;
        border: 2px solid var(--accent-highlight);
        padding: 12px;
        z-index: 100;
    }

    .reaction-emojis {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }

    .reaction-emoji {
        width: auto;
        aspect-ratio: unset;
        min-height: unset;
        font-size: 20px;
        line-height: 1;
        border-radius: 6px;
        border-width: 1px;
        padding: 4px 8px;
    }
}

/* ── game-reactions.js – fixed floating widget ─────────────────────────────── */
.reaction-button--fixed {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: auto;
    left: auto;
    z-index: 8000;
    /* Visible on light backgrounds — override transparent-white base style */
    background: var(--accent-highlight);
    border-color: var(--accent-highlight);
    color: white;
}

.reaction-picker--fixed {
    position: fixed;
    /* top/right set dynamically by JS via getBoundingClientRect */
    border-radius: 12px;
    border: 2px solid var(--accent-highlight);
    padding: 12px;
    width: fit-content;
    z-index: 8001;
    /* override the bottom-slide animation from base .reaction-picker */
    animation: none;
}

#gameReactionBursts {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    overflow: hidden;
}

.game-reaction-burst {
    position: absolute;
    bottom: 80px;
    font-size: 28px;
    line-height: 1;
    animation: gameReactionRise 1.4s ease-out forwards;
    pointer-events: none;
    user-select: none;
}

@keyframes gameReactionRise {
    0%   { transform: translateY(0) scale(1);    opacity: 1; }
    60%  { transform: translateY(-120px) scale(1.3); opacity: 1; }
    100% { transform: translateY(-200px) scale(0.8); opacity: 0; }
}

/* ── Realm Hero ────────────────────────────────────────────────────────────── */
.realm-hero {
    max-width: 960px;
    margin: 0 auto;
    padding: 4rem 1.5rem 3rem;
}
.realm-hero--compact {
    padding-top: 2rem;
}
.realm-selected-header {
    margin-top: 0;
    padding: 2rem;
    background: var(--bg-primary);
    border-radius: 16px;
    border: 1px solid var(--border-light);
}
.realm-selected-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 0.4rem;
}
.realm-selected-desc {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
}

/* ── Realm quiz selection ─────────────────────────────────────────────────── */
.realm-quiz-section {
    margin-top: 2rem;
}
.realm-quiz-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem;
    text-align: center;
    letter-spacing: -0.01em;
}
.realm-quiz-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.realm-quiz-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem 1.1rem 1.4rem;
    background: color-mix(in srgb, var(--card-accent, var(--accent-highlight)) 12%, var(--bg-primary));
    border: 1px solid color-mix(in srgb, var(--card-accent, var(--accent-highlight)) 28%, transparent);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    text-decoration: none;
    color: inherit;
}
.realm-quiz-card:hover {
    background: color-mix(in srgb, var(--card-accent, var(--accent-highlight)) 20%, var(--bg-primary));
    transform: translateY(-2px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--card-accent, var(--accent-highlight)) 22%, transparent);
}
.realm-quiz-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    min-width: 0;
}
.realm-quiz-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.realm-quiz-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.realm-quiz-card-chevron {
    flex-shrink: 0;
    color: color-mix(in srgb, var(--card-accent, var(--accent-highlight)) 70%, var(--text-secondary));
    transition: transform 0.18s ease;
}
.realm-quiz-card:hover .realm-quiz-card-chevron {
    transform: translateX(3px);
}
.realm-quiz-empty {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Full-bleed background image */
.quiz-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.quiz-bg-img {
    display: block;
    width: 100%;
    height: 100dvh;
    object-fit: cover;
    object-position: center center;
}

/* Subtle scrim — just enough contrast for white text */
.quiz-bg-scrim {
    display: none;
}

.quiz-group-session {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    cursor: pointer;
    user-select: none;
}
.quiz-group-session input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent-highlight);
    cursor: pointer;
}
.quiz-group-session-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.quiz-btn-primary {
    padding: 0.85rem 2.25rem;
    border-radius: 12px;
    border: none;
    background: var(--accent-highlight);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}
.quiz-btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }

.quiz-launch {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    align-items: flex-start;
}

.quiz-hero--over-bg {
    position: relative;
    z-index: 1;
}

@media (max-width: 640px) {
    .realm-hero { padding: 2rem 1rem 2rem; }
}

/* ── Login Modal ────────────────────────────────────────────────────────────── */
.login-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.login-modal-overlay.open {
    display: flex;
    opacity: 1;
}

.login-modal-card {
    position: relative;
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 48px 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.login-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.login-modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.login-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}
.login-modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    text-align: center;
}

.login-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.login-provider-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.18s, box-shadow 0.18s;
    cursor: pointer;
}
.login-provider-btn:hover {
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.login-provider-btn--apple {
    background: #000;
    color: #fff;
    border-color: #000;
}
.login-provider-btn--apple:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
}

.login-provider-btn--cloudforge {
    background: #4285f4;
    color: #fff;
    border-color: #4285f4;
}
.login-provider-btn--cloudforge:hover {
    background: #3b78e0;
    border-color: #3b78e0;
}

.login-modal-legal {
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .login-modal-card {
        padding: 44px 24px 28px;
        border-radius: 16px;
    }
}
