/* ============================================
   UNCLE MOE'S FAMILY FRAMEBAG
   Modern Simpsons-themed UI
   ============================================ */

/* --- Fonts --- */
@font-face {
    font-family: 'SimpsonsFont';
    src: url('fonts/simpsonsFont.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    unicode-range: U+0020-007E;
}

@font-face {
    font-family: 'akbarFont';
    src: url('fonts/akbar.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* --- Custom Properties --- */
:root {
    --simpsons-yellow: #FFD521;
    --simpsons-yellow-dark: #E5BE00;
    --simpsons-blue: #2A7FFF;
    --simpsons-blue-dark: #1A5FCC;
    --submit-green: #28a745;
    --submit-green-dark: #1e7e34;
    --giveup-gray: #6c757d;
    --giveup-gray-dark: #545b62;
    --danger-red: #dc3545;
    --danger-red-dark: #b02a37;
    --correct-green: #00c853;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.3);
    --glass-blur: 16px;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.2);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 50px;
    --transition-fast: 0.2s ease;
    --transition-med: 0.35s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    background: url('/static/images/clouds.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #222;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(135, 206, 250, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
    pointer-events: none;
    z-index: 0;
}

/* --- Shared Button Base --- */
.btn {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 15px;
    font-weight: bold;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    padding: 12px 28px;
    letter-spacing: 0.5px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--simpsons-yellow), var(--simpsons-yellow-dark));
    color: #222;
    box-shadow: 0 4px 14px rgba(255, 213, 33, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(255, 213, 33, 0.6);
    transform: translateY(-2px);
}

.btn-disabled {
    background: #aaa;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-large {
    font-size: 18px;
    padding: 14px 40px;
    width: 100%;
    max-width: 320px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInCorrect {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    70% { transform: translate(-50%, -50%) scale(0.95); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

@keyframes slideInCorrectHold {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    70% { transform: translate(-50%, -50%) scale(0.95); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
}

@keyframes shakeX {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    10%, 50%, 90% { transform: translate(calc(-50% - 8px), -50%) scale(1.1); }
    30%, 70% { transform: translate(calc(-50% + 8px), -50%) scale(1.1); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(0, 200, 83, 0); }
    50% { box-shadow: 0 0 30px rgba(0, 200, 83, 0.5); }
}

@keyframes shakeCard {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-6px); }
    30%, 60%, 90% { transform: translateX(6px); }
}

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

@keyframes pointsPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); color: var(--simpsons-yellow); }
    100% { transform: scale(1); }
}

@keyframes overlayIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(8px); }
}

.fade-in {
    animation: fadeIn 0.6s ease both;
}

/* ============================================
   HOME PAGE
   ============================================ */

.home-body {
    justify-content: center;
    padding: 20px;
}

.home-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 40px 36px;
    text-align: center;
    max-width: 520px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.home-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 2.4em;
    color: #222;
    text-shadow: 2px 2px 0 var(--simpsons-yellow), 4px 4px 0 rgba(0,0,0,0.08);
    line-height: 1.15;
    margin-bottom: 24px;
}

.home-image-wrapper {
    margin: 0 auto 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    border: 3px solid var(--simpsons-yellow);
    max-width: 420px;
}

.home-gif {
    display: block;
    width: 100%;
    height: auto;
}

.home-tagline {
    font-size: 1em;
    color: #555;
    margin-bottom: 28px;
}

.home-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.bmc-link {
    display: inline-block;
    margin-top: 24px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.85;
}

.bmc-link:hover {
    transform: scale(1.05);
    opacity: 1;
}

.bmc-button {
    height: 40px;
    width: auto;
    border-radius: 8px;
}

/* --- Auth Area (in-card, home page) --- */
.auth-area {
    text-align: center;
    margin-top: 24px;
}

/* --- Auth Area (fixed top-right, game pages) --- */
.auth-area-fixed {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 1000;
    margin-top: 0;
    text-align: right;
}

.btn-google-signin {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #444;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-pill);
    padding: 8px 20px;
    font-size: 0.85em;
    font-family: 'Segoe UI', Arial, sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow var(--transition-fast), background var(--transition-fast);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.btn-google-signin:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    background: rgba(255, 255, 255, 1);
}

.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-logged-in {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.auth-area-fixed .auth-logged-in {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-pill);
    padding: 4px 6px 4px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.auth-display-name {
    font-family: 'SimpsonsFont', Arial, sans-serif;
    font-size: 1.1em;
    color: #222;
}

.btn-edit-name {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    color: #888;
    padding: 2px 6px;
    transition: color var(--transition-fast);
}

.btn-edit-name:hover {
    color: var(--simpsons-blue);
}

.btn-signout {
    font-size: 0.8em;
    color: #888;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid #ddd;
    transition: all var(--transition-fast);
}

.btn-signout:hover {
    color: var(--danger-red);
    border-color: var(--danger-red);
}

/* Leaderboard login prompt on game-over */
.lb-login-prompt {
    margin-top: 16px;
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

.lb-login-prompt a {
    color: var(--simpsons-blue);
    text-decoration: underline;
}

.multiplayer-wrapper {
    position: relative;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.coming-soon-badge {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================
   MODE SELECTION
   ============================================ */

.mode-select-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 36px 32px;
    text-align: center;
    max-width: 560px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.mode-select-card.hidden {
    display: none;
}

.mode-select-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.8em;
    color: #222;
    margin-bottom: 24px;
}

.mode-options {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.mode-option {
    flex: 1;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.mode-option > .btn {
    margin-top: auto;
}

.mode-option:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

.mode-normal:hover {
    border-color: var(--simpsons-yellow);
}

.mode-expert {
    border-color: #e8c0c0;
}

.mode-expert:hover {
    border-color: var(--danger-red);
    box-shadow: 0 8px 32px rgba(220, 53, 69, 0.15);
}

.mode-icon {
    font-size: 2.4em;
    line-height: 1;
}

.mode-name {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.3em;
    color: #222;
}

.mode-desc {
    font-size: 0.85em;
    color: #777;
    line-height: 1.4;
}

.mode-lifelines {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.mode-badge {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: #f0f0f0;
    color: #555;
    letter-spacing: 0.5px;
}

.mode-badge-expert {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-red);
}

.btn-expert-play {
    background: linear-gradient(135deg, var(--danger-red), var(--danger-red-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(220, 53, 69, 0.3);
}

.btn-expert-play:hover {
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.5);
    transform: translateY(-2px);
}

.mode-expert-plus {
    border-color: #c0b0e8;
}

.mode-expert-plus:hover {
    border-color: #7c3aed;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.15);
}

.mode-badge-expert-plus {
    background: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
}

.btn-expert-plus-play {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: white;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-expert-plus-play:hover {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
    transform: translateY(-2px);
}

.frame-image.expert-plus-effects {
    filter: invert(1);
}

.btn-back {
    background: transparent;
    color: #888;
    font-size: 14px;
    padding: 8px 20px;
}

.btn-back:hover {
    color: #444;
}

/* Variants heading */
.variants-heading {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 18px;
    color: #555;
    text-align: center;
    margin: 20px 0 8px;
    letter-spacing: 1px;
}

/* Speed toggle */
.speed-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 20px;
    background: rgba(255, 152, 0, 0.08);
    border: 1px solid rgba(255, 152, 0, 0.2);
    border-radius: var(--radius-sm);
}

/* LMS toggle */
.lms-toggle {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.speed-switch input:checked + .lms-slider {
    background: var(--danger-red);
}

.one-sec-toggle {
    background: rgba(42, 127, 255, 0.08);
    border: 1px solid rgba(42, 127, 255, 0.2);
}

.speed-switch input:checked + .one-sec-slider {
    background: var(--simpsons-blue);
}

.speed-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.speed-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.speed-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: background var(--transition-fast);
}

.speed-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.speed-switch input:checked + .speed-slider {
    background: #ff9800;
}

.speed-switch input:checked + .speed-slider::before {
    transform: translateX(20px);
}

.speed-label {
    display: flex;
    flex-direction: column;
    text-align: left;
    flex: 1;
}

.speed-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1em;
    color: #333;
}

.speed-desc {
    font-size: 0.75em;
    color: #888;
}

/* ============================================
   GAME PAGE
   ============================================ */

.game-body {
    padding: 16px 16px 40px;
    gap: 14px;
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 48px;
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-soft);
    padding: 12px 20px;
    max-width: 520px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.btn-menu {
    font-size: 0.8em;
    color: #888;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-menu:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

.stat-item {
    display: grid;
    grid-template-rows: 13px minmax(30px, auto);
    justify-items: center;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

/* Frame progress pips */
.frame-pips {
    display: flex;
    gap: 6px;
}

.pip {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ddd;
    border: 2px solid #ccc;
    transition: all var(--transition-fast);
}

.pip.completed {
    background: var(--correct-green);
    border-color: var(--correct-green);
    box-shadow: 0 0 6px rgba(0, 200, 83, 0.4);
}

.pip.active {
    background: var(--simpsons-yellow);
    border-color: var(--simpsons-yellow-dark);
    box-shadow: 0 0 8px rgba(255, 213, 33, 0.5);
}

.pip.failed {
    background: var(--danger-red);
    border-color: var(--danger-red-dark);
}

/* Streak counter (LMS) */
.streak-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.streak-counter.hidden {
    display: none;
}

.streak-value {
    font-size: 22px;
    font-weight: bold;
    color: #222;
}

.streak-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

/* Points */
.points-value {
    font-size: 20px;
    font-weight: bold;
    color: #222;
    transition: all var(--transition-fast);
}

.points-value.pop {
    animation: pointsPop 0.4s ease;
}

/* Timer */
.timer-display {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-value {
    font-size: 14px;
    font-weight: bold;
    color: #222;
    z-index: 1;
    transition: color var(--transition-fast);
}

.timer-value.urgent {
    color: var(--danger-red);
}

.timer-ring {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 3;
}

.timer-ring-progress {
    fill: none;
    stroke: #ff9800;
    stroke-width: 3;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke var(--transition-fast);
}

.timer-ring-progress.urgent {
    stroke: var(--danger-red);
}

/* --- Game Card --- */
.game-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    max-width: 680px;
    width: 100%;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.game-card.correct-flash {
    animation: pulseGlow 0.6s ease;
}

.game-card.incorrect-shake {
    animation: shakeCard 0.5s ease;
}

.quiz-title {
    font-size: 1.3em;
    color: #333;
}

.question-mark {
    font-family: 'akbarFont', 'Arial', sans-serif;
    font-weight: bold;
    font-size: 1.1em;
}

/* --- Frame Display --- */
.frame-wrapper {
    position: relative;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border: 3px solid #333;
    background: #111;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frame-image {
    display: block;
    width: 100%;
    height: auto;
    opacity: 1;
    transition: opacity var(--transition-med), transform 0.5s ease;
    transform-origin: center center;
}

.frame-image.loading {
    opacity: 0;
}

.frame-image.blacked-out {
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* Loading spinner */
.loading-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #ccc;
    font-size: 14px;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.loading-spinner.visible {
    opacity: 1;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--simpsons-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Feedback overlays */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-weight: bold;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
}

.correct-overlay {
    font-size: 3.5em;
    color: var(--correct-green);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.correct-overlay.show {
    animation: slideInCorrect 1.8s ease forwards;
}

.correct-overlay.show.hold {
    animation: slideInCorrectHold 1.8s ease forwards;
}

.incorrect-overlay {
    font-size: 5em;
    color: var(--danger-red);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.incorrect-overlay.show {
    animation: shakeX 0.6s ease forwards;
    opacity: 1;
}

/* Quote overlay */
.quote-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    color: white;
    padding: 40px 16px 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-med);
    z-index: 15;
}

.quote-overlay.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Episode Info --- */
.episode-info {
    background: rgba(255, 213, 33, 0.15);
    border: 1px solid rgba(255, 213, 33, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    text-align: center;
    font-size: 0.95em;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all var(--transition-med);
}

.episode-info.hidden {
    display: none;
}

.episode-meta {
    font-size: 0.85em;
    color: #777;
}

/* --- Lifelines --- */
.lifelines-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.btn-lifeline {
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    color: #444;
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #d0d0d0;
}

.btn-lifeline:hover:not(:disabled) {
    background: linear-gradient(135deg, #e8e8e8, #d8d8d8);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.btn-lifeline:disabled {
    cursor: not-allowed;
}

.btn-lifeline.used {
    background: linear-gradient(135deg, var(--danger-red), var(--danger-red-dark));
    color: white;
    border-color: var(--danger-red-dark);
    opacity: 0.7;
}

.lifeline-icon {
    font-size: 15px;
    line-height: 1;
}

/* Expert mode lifeline grid (2x2 for 4 buttons) */
.lifelines-bar.expert-grid {
    grid-template-columns: repeat(2, 1fr);
}

.lifeline-count {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.15);
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    margin-left: 2px;
}

.btn-lifeline.used .lifeline-count {
    background: rgba(255, 255, 255, 0.25);
}

/* --- Guess Form --- */
.guess-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-wrapper {
    width: 100%;
}

.input-wrapper input[type="text"] {
    width: 100%;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 15px;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: white;
}

.input-wrapper input[type="text"]:focus {
    border-color: var(--simpsons-yellow);
    box-shadow: 0 0 0 3px rgba(255, 213, 33, 0.25);
}

/* Custom Autocomplete Dropdown */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 2px solid #ddd;
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 360px;
    overflow-y: auto;
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--transition-fast);
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(255, 213, 33, 0.15);
}

.autocomplete-item .episode-code {
    font-size: 0.8em;
    color: #999;
    flex-shrink: 0;
    min-width: 52px;
}

.autocomplete-item .episode-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.95em;
    color: #333;
}

.form-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item-frame {
    order: 1;
}

.stat-item-points {
    order: 2;
}

.stat-item-timer {
    order: 3;
}

.points-value {
    line-height: 1;
}

.btn-submit {
    background: linear-gradient(135deg, var(--submit-green), var(--submit-green-dark));
    color: white;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
}

.btn-submit:hover {
    box-shadow: 0 4px 14px rgba(40, 167, 69, 0.35);
    transform: translateY(-1px);
}

.btn-giveup {
    background: linear-gradient(135deg, var(--danger-red), var(--danger-red-dark));
    color: white;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
}

.btn-giveup:hover {
    box-shadow: 0 4px 14px rgba(220, 53, 69, 0.35);
    transform: translateY(-1px);
}

/* Result text */
.result-text {
    font-size: 0.9em;
    min-height: 1.2em;
    color: #888;
}

/* ============================================
   GAME OVER OVERLAY
   ============================================ */

.game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: overlayIn 0.4s ease;
}

.game-over-overlay.hidden {
    display: none;
}

.sudden-death-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(42, 127, 255, 0.32), rgba(0, 0, 0, 0.72));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    padding: 20px;
    animation: overlayIn 0.35s ease;
}

.sudden-death-overlay.hidden {
    display: none;
}

.leave-game-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 160;
    padding: 20px;
    animation: overlayIn 0.25s ease;
}

.leave-game-dialog.hidden {
    display: none;
}

.leave-game-card {
    width: min(500px, 92vw);
    text-align: center;
    padding: 26px 24px 22px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.leave-game-title {
    font-size: 1.4em;
    color: #222;
    margin-bottom: 8px;
}

.leave-game-desc {
    font-size: 0.95em;
    color: #666;
    margin-bottom: 16px;
}

.leave-game-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.leave-game-actions .btn {
    border-radius: var(--radius-pill);
    padding: 12px 28px;
}

.sudden-death-card {
    width: min(520px, 92vw);
    text-align: center;
    padding: 28px 24px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    animation: suddenDeathPop 0.5s ease;
}

.sudden-death-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2A7FFF, #1A5FCC);
    color: #fff;
    font-size: 0.85em;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.sudden-death-gif {
    width: min(360px, 100%);
    max-height: 180px;
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid rgba(42, 127, 255, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    margin: 2px auto 12px;
}

.sudden-death-gif.hidden {
    display: none;
}

.sudden-death-title {
    font-size: 2.5em;
    color: #1a5fcc;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.sudden-death-message {
    color: #333;
    font-size: 1.05em;
    line-height: 1.35;
}

@keyframes suddenDeathPop {
    0% {
        transform: translateY(14px) scale(0.94);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.game-over-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    padding: 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: fadeIn 0.5s ease;
}

.game-over-image-wrapper {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    max-width: 320px;
    width: 100%;
}

.game-over-image-wrapper img {
    display: block;
    width: 100%;
    height: auto;
}

.game-over-title {
    font-size: 2em;
}

.game-over-title.win {
    color: var(--correct-green);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.game-over-title.mid {
    color: #f0a500;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.game-over-title.lose {
    color: var(--danger-red);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.game-over-stats {
    font-size: 1em;
    color: #555;
    display: flex;
    gap: 24px;
}

.game-over-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-over-stat-value {
    font-size: 1.6em;
    font-weight: bold;
    color: #222;
}

.game-over-stat-label {
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-over-episode {
    font-size: 0.9em;
    color: #666;
}

.game-over-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.game-over-buttons .btn {
    flex: 1;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Utility --- */
.hidden {
    display: none;
}

/* ============================================
   LEADERBOARD
   ============================================ */

/* --- Single Player Name Input --- */
.sp-name-section {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sp-name-section .mp-input {
    max-width: 240px;
}

.sp-name-label {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.9em;
    color: #555;
    letter-spacing: 0.5px;
}

.sp-name-error {
    color: var(--danger-red);
    font-size: 0.85em;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
}

.sp-name-error.hidden {
    display: none;
}

.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* --- Leaderboard Tabs --- */
.lb-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.lb-tab-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.lb-tab {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 13px;
    padding: 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-pill);
    background: white;
    color: #555;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lb-tab:hover {
    border-color: var(--simpsons-yellow);
    background: rgba(255, 213, 33, 0.08);
}

.lb-tab.active {
    background: linear-gradient(135deg, var(--simpsons-yellow), var(--simpsons-yellow-dark));
    color: #222;
    border-color: var(--simpsons-yellow-dark);
    box-shadow: 0 2px 8px rgba(255, 213, 33, 0.3);
}

/* --- Leaderboard Table --- */
.lb-table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 16px;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.lb-table thead th {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    padding: 8px 12px;
    border-bottom: 2px solid #e0e0e0;
    text-align: left;
}

.lb-table tbody tr {
    transition: background var(--transition-fast);
}

.lb-table tbody tr:hover {
    background: rgba(255, 213, 33, 0.08);
}

.lb-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.lb-rank {
    font-weight: bold;
    color: #888;
    width: 32px;
    text-align: center;
}

.lb-table tbody tr:nth-child(1) .lb-rank { color: #FFD700; }
.lb-table tbody tr:nth-child(2) .lb-rank { color: #C0C0C0; }
.lb-table tbody tr:nth-child(3) .lb-rank { color: #CD7F32; }

.lb-name {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-weight: bold;
}

.lb-points {
    font-weight: bold;
    color: var(--simpsons-blue);
}

.lb-date {
    color: #999;
}

.lb-empty {
    text-align: center;
    color: #999;
    padding: 24px 12px;
    font-style: italic;
}

.lb-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.lb-user-rank {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.95em;
    color: #666;
    text-align: center;
}

/* ============================================
   STATS CARD
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-tile {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-md);
    padding: 20px 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-tile-value {
    display: block;
    font-family: 'SimpsonsFont', Arial, sans-serif;
    font-size: 2em;
    color: var(--simpsons-blue);
    margin-bottom: 4px;
}

.stat-tile-label {
    display: block;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
}

.stats-empty {
    text-align: center;
    color: #999;
    padding: 32px 16px;
    font-style: italic;
    font-size: 0.95em;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
}

@media (min-width: 500px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   RULES CARD
   ============================================ */

.rules-content {
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 20px;
}

.rules-content::-webkit-scrollbar {
    width: 6px;
}

.rules-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.rules-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.rules-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.rules-section-icon {
    font-size: 1.6em;
    margin-bottom: 6px;
}

.rules-section-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.15em;
    color: #222;
    margin-bottom: 8px;
}

.rules-text {
    font-family: 'akbarFont', 'Arial', sans-serif;
    font-size: 0.92em;
    line-height: 1.5;
    color: #444;
}

.rules-text strong {
    color: #222;
}

.rules-text-note {
    margin-top: 10px;
    font-size: 0.85em;
    color: #777;
    font-style: italic;
}

/* Modes list within rules */
.rules-modes,
.rules-lifelines,
.rules-challenges {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.rules-mode-item,
.rules-lifeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rules-mode-icon,
.rules-lifeline-icon {
    font-size: 1.4em;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.rules-mode-item p,
.rules-lifeline-item p {
    font-family: 'akbarFont', 'Arial', sans-serif;
    font-size: 0.85em;
    line-height: 1.4;
    color: #555;
    margin-top: 2px;
}

.rules-mode-item strong,
.rules-lifeline-item strong {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1em;
    color: #222;
}

/* Challenge badges */
.rules-challenge-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rules-challenge-badge {
    display: inline-block;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.85em;
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    margin-bottom: 6px;
    color: #fff;
}

.rules-badge-speed {
    background: linear-gradient(135deg, #2A7FFF, #1A5FCC);
}

.rules-badge-lms {
    background: linear-gradient(135deg, #dc3545, #b02a37);
}

.rules-badge-1sec {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
}

.rules-challenge-item p {
    font-family: 'akbarFont', 'Arial', sans-serif;
    font-size: 0.85em;
    line-height: 1.4;
    color: #555;
}

.rules-badge-mode {
    font-family: 'akbarFont', 'Arial', sans-serif;
    font-size: 0.75em;
    background: rgba(0, 0, 0, 0.08);
    color: #888;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    margin-left: 6px;
    vertical-align: middle;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .home-title {
        font-size: 1.8em;
    }

    .home-card {
        padding: 28px 20px;
    }

    .stats-bar {
        gap: 20px;
        padding: 10px 20px 10px 14px;
        flex-wrap: nowrap;
    }

    .stat-item-points {
        min-width: 54px;
        padding-right: 4px;
    }

    .game-card {
        padding: 16px;
        gap: 12px;
    }

    .quiz-title {
        font-size: 1.1em;
    }

    .correct-overlay {
        font-size: 2.5em;
    }

    .incorrect-overlay {
        font-size: 3.5em;
    }

    .btn-lifeline {
        font-size: 12px;
        padding: 8px 4px;
    }

    .lifeline-icon {
        font-size: 13px;
    }

    .game-over-card {
        padding: 24px 16px;
    }

    .game-over-stats {
        gap: 16px;
    }

    .mode-select-card {
        padding: 28px 16px;
    }

    .mode-options {
        flex-direction: column;
    }

    .mode-option {
        padding: 20px 14px;
    }

    .lb-tabs {
        gap: 6px;
    }

    .lb-tab-row {
        gap: 4px;
    }

    .lb-tab {
        font-size: 11px;
        padding: 6px 10px;
    }

    .lb-table {
        font-size: 0.8em;
    }

    .lb-table thead th,
    .lb-table tbody td {
        padding: 8px 6px;
    }
}

/* ============================================
   MULTIPLAYER
   ============================================ */

/* --- Multiplayer Choice Card --- */
.mp-choice-options {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.mp-option {
    flex: 1;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.mp-option:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
    border-color: var(--simpsons-yellow);
}

.mp-input {
    width: 100%;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 15px;
    padding: 10px 14px;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    text-align: center;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.mp-input:focus {
    border-color: var(--simpsons-yellow);
    box-shadow: 0 0 0 3px rgba(255, 213, 33, 0.25);
}

.mp-code-input {
    text-transform: uppercase;
    font-size: 20px;
    letter-spacing: 6px;
    font-weight: bold;
}

.mp-error {
    color: var(--danger-red);
    font-size: 0.9em;
    margin-top: 8px;
}

/* --- Lobby --- */
.room-code-display {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.room-code-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.room-code-value {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 2.5em;
    letter-spacing: 8px;
    color: var(--simpsons-blue);
    font-weight: bold;
}

.btn-invite {
    background: linear-gradient(135deg, var(--simpsons-blue), var(--simpsons-blue-dark));
    color: #fff;
    font-size: 13px;
    padding: 8px 24px;
    margin-top: 4px;
    box-shadow: 0 4px 14px rgba(42, 127, 255, 0.3);
    align-self: center;
}

.btn-invite:hover {
    box-shadow: 0 6px 20px rgba(42, 127, 255, 0.5);
    transform: translateY(-2px);
}

.invite-feedback {
    font-size: 12px;
    color: var(--correct-green);
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.lobby-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.lobby-player {
    background: rgba(255, 213, 33, 0.1);
    border: 1px solid rgba(255, 213, 33, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1em;
}

.lobby-player.host::after {
    content: 'HOST';
    font-size: 10px;
    background: var(--simpsons-yellow);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    margin-left: auto;
    font-weight: bold;
    letter-spacing: 1px;
}

.lobby-section-title {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.2em;
    margin-bottom: 12px;
    color: #333;
}

.lobby-mode-option {
    cursor: pointer;
}

.lobby-mode-option.selected {
    border-color: var(--simpsons-yellow);
    box-shadow: 0 0 0 3px rgba(255, 213, 33, 0.25);
}

.lobby-mode-option.mode-expert.selected {
    border-color: var(--danger-red);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.lobby-mode-option.mode-expert-plus.selected {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.lobby-waiting-text {
    color: #888;
    font-size: 1em;
    padding: 20px 0;
}

/* --- Multiplayer Game Layout --- */
.mp-game-layout {
    display: flex;
    gap: 16px;
    max-width: 680px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.mp-main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

/* --- Right Column (opponents + chat) --- */
.mp-right-column {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    left: 100%;
    margin-left: 16px;
    top: 0;
    bottom: 0;
}

/* --- Opponents Panel (dynamic, multi-opponent) --- */
.opponents-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 80vh;
    overflow-y: auto;
}

/* --- Opponent Panel (legacy compat) --- */
.opponent-panel {
    width: 200px;
    flex-shrink: 0;
}

.opponent-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 16px;
}

.opponent-name {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.1em;
    text-align: center;
    color: #333;
    margin: 0;
}

.opponent-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opponent-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    color: #555;
    gap: 10px;
}

.opponent-stat-label {
    color: #666;
}

.opponent-stat-value {
    font-weight: 700;
    min-width: 2ch;
    text-align: right;
    color: #333;
}

.opponent-activity {
    font-size: 0.85em;
    color: #888;
    text-align: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-sm);
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

/* --- Waiting Message --- */
.waiting-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 213, 33, 0.1);
    border: 1px solid rgba(255, 213, 33, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: #666;
    width: 100%;
}

.waiting-message.hidden {
    display: none;
}

.spinner-small {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 213, 33, 0.3);
    border-top-color: var(--simpsons-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- Multiplayer Game Over --- */
.mp-game-over-card {
    max-width: 600px;
}

.mp-game-over-players {
    display: flex;
    gap: 16px;
    width: 100%;
}

.mp-player-result {
    flex: 1;
    text-align: center;
    padding: 20px 12px;
    background: white;
    border-radius: var(--radius-md);
    border: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mp-player-result.winner {
    border-color: var(--simpsons-yellow);
    box-shadow: 0 0 20px rgba(255, 213, 33, 0.3);
}

.crown-icon {
    font-size: 2em;
    line-height: 1;
}

.mp-player-name {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.1em;
    color: #333;
}

.mp-player-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.mp-player-stats .game-over-stat-value {
    font-size: 1.3em;
}

.vote-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.vote-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.vote-buttons .btn {
    border-radius: var(--radius-pill);
    width: min(186px, 100%);
    padding: 12px 18px;
    text-align: center;
}

.vote-status {
    text-align: center;
    color: #666;
    font-size: 0.92em;
    min-height: 44px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.75);
    line-height: 1.35;
}

.vote-status:empty {
    display: none;
}

.vote-status.muted {
    color: #666;
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.78);
}

.vote-status.success {
    color: #165c2f;
    border-color: rgba(22, 92, 47, 0.25);
    background: rgba(0, 200, 83, 0.12);
}

.vote-status.warning {
    color: #8a4b00;
    border-color: rgba(138, 75, 0, 0.25);
    background: rgba(255, 213, 33, 0.2);
}

.btn-return-lobby {
    background: linear-gradient(135deg, #6ec1ff, #2A7FFF);
    color: #fff;
    box-shadow: 0 4px 14px rgba(42, 127, 255, 0.35);
}

.btn-return-lobby:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 127, 255, 0.45);
}

/* --- Eliminated Styling --- */
.opponent-card.eliminated {
    opacity: 0.5;
    border-color: var(--danger-red);
}

.eliminated-badge {
    display: inline-block;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 10px;
    background: var(--danger-red);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 1px;
    font-weight: bold;
    vertical-align: middle;
    margin-left: 6px;
}

.eliminated-badge-large {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.2em;
    color: var(--danger-red);
    font-weight: bold;
    letter-spacing: 2px;
}

.eliminated-overlay {
    background: rgba(220, 53, 69, 0.08);
    border: 2px solid rgba(220, 53, 69, 0.3);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    width: 100%;
}

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

.eliminated-message {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 1.6em;
    color: var(--danger-red);
    margin-bottom: 6px;
}

.eliminated-sub {
    font-size: 0.85em;
    color: #888;
}

.mp-player-result.eliminated {
    opacity: 0.6;
    border-color: var(--danger-red);
}

/* --- Game Recap --- */
.game-recap {
    margin-top: 16px;
    width: 100%;
}

.recap-title {
    font-family: 'SimpsonsFont', Arial, sans-serif;
    font-size: 1.1em;
    color: #555;
    text-align: center;
    margin-bottom: 10px;
}

.recap-frames {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.recap-frame {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.recap-frame-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.recap-thumbnail {
    width: 120px;
    height: auto;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.recap-episode {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recap-frame-num {
    font-size: 0.75em;
    color: #888;
    text-transform: uppercase;
}

.recap-episode-title {
    font-family: 'SimpsonsFont', Arial, sans-serif;
    font-size: 0.95em;
    color: #333;
}

.recap-episode-meta {
    font-size: 0.8em;
    color: #666;
}

.recap-players {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recap-player-result {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    padding: 3px 6px;
    border-radius: 4px;
}

.recap-player-result.correct {
    background: rgba(34, 197, 94, 0.1);
}

.recap-player-result.wrong {
    background: rgba(239, 68, 68, 0.08);
}

.recap-player-name {
    flex: 1;
    color: #555;
}

.recap-player-name.me {
    font-weight: 700;
    color: #333;
}

.recap-guess {
    flex: 2;
    font-size: 0.9em;
    color: #777;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recap-result-icon {
    font-size: 0.9em;
}

.recap-points {
    font-size: 0.8em;
    color: var(--simpsons-blue);
    font-weight: 600;
    min-width: 30px;
    text-align: right;
}

/* --- Chat Widget --- */
.chat-widget {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.chat-widget:has(.chat-box:not(.hidden)) {
    flex: 1;
}

.btn-chat-toggle {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
    text-align: center;
}

.btn-chat-toggle:hover {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.chat-box {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-box.hidden {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-msg {
    font-size: 0.82em;
    color: #333;
    line-height: 1.3;
    word-wrap: break-word;
}

.chat-msg-name {
    font-weight: 700;
    color: var(--simpsons-blue);
    margin-right: 4px;
}

.chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    padding: 6px;
    border-top: 1px solid var(--card-border);
    overflow: hidden;
}

.chat-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-family: Arial, sans-serif;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input::placeholder {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 13px;
    color: #888;
    letter-spacing: 0;
}

.chat-input:focus {
    border-color: var(--simpsons-blue);
}

.btn-chat-send {
    padding: 6px 10px;
    font-size: 0.8em;
    background: var(--simpsons-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
    min-width: 54px;
}

.btn-chat-send:hover {
    background: #2563eb;
}

/* Typing indicator */
.chat-typing-indicator {
    padding: 2px 8px 4px;
    font-size: 0.75em;
    color: #888;
    font-style: italic;
    min-height: 0;
    line-height: 1.3;
}

.chat-typing-indicator.hidden {
    display: none;
}

.typing-dots span {
    animation: typingDot 1.4s infinite;
    opacity: 0;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* Lobby chat overrides */
.lobby-chat {
    margin-top: 12px;
}

.lobby-chat .chat-box {
    max-height: 200px;
}

.lobby-chat .chat-messages {
    max-height: 140px;
}

/* --- Multiplayer Responsive --- */
@media (max-width: 700px) {
    .mp-game-layout {
        flex-direction: column;
    }

    .mp-right-column {
        position: static;
        width: 100%;
        order: 1;
        margin-left: 0;
    }

    .mp-right-column > * {
        width: 100%;
    }

    .opponents-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
    }

    .opponents-panel .opponent-card {
        flex: 1;
        min-width: 140px;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 10px;
        position: static;
    }

    .opponent-panel {
        width: 100%;
    }

    .opponent-card {
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 10px;
        position: static;
    }

    .opponent-name {
        width: 100%;
    }

    .opponent-stats {
        flex-direction: column;
        gap: 6px;
        width: 100%;
    }

    .opponent-stat {
        width: 100%;
        padding-inline: 4px;
    }

    .opponent-activity {
        flex: 0 0 auto;
        min-width: 0;
        width: 100%;
    }

    .mp-choice-options {
        flex-direction: column;
    }

    .mp-game-over-players {
        flex-direction: column;
    }

    .mp-player-stats {
        gap: 12px;
    }

    .game-over-overlay {
        align-items: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .recap-frames {
        max-height: none;
        overflow-y: visible;
    }

    .leave-game-actions {
        flex-direction: column;
    }

    .leave-game-actions .btn {
        width: 100%;
    }
}

/* ============================================
   GAME INTRO OVERLAY
   ============================================ */

.intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: url('/static/images/clouds.jpg') no-repeat center center;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.5s ease;
}

.intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

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

.intro-content {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    padding: 40px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.intro-mode-icon {
    font-size: 4em;
    line-height: 1;
    margin-bottom: 4px;
}

.intro-mode-name {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 2.2em;
    color: var(--simpsons-blue);
    margin: 0;
}

.intro-mode-desc {
    font-size: 1em;
    color: #666;
    margin: 0 0 8px;
}

.intro-challenges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.intro-challenge-tag {
    background: var(--simpsons-yellow);
    color: #333;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 0.85em;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.intro-countdown {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 5em;
    font-weight: 700;
    color: var(--simpsons-blue);
    line-height: 1;
    min-height: 1.2em;
}

.intro-countdown.pop {
    animation: countdownPop 0.6s ease-out;
}

@keyframes countdownPop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .intro-content {
        padding: 32px 20px;
    }

    .intro-mode-icon {
        font-size: 3em;
    }

    .intro-mode-name {
        font-size: 1.8em;
    }

    .intro-countdown {
        font-size: 4em;
    }
}

/* ============================================
   BOTTOM SHEET EPISODE PICKER (MOBILE)
   ============================================ */

.episode-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.episode-sheet-backdrop.visible {
    opacity: 1;
}

.episode-sheet-backdrop.hidden {
    display: none;
}

.episode-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: white;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.episode-sheet.visible {
    transform: translateY(0);
}

.episode-sheet.hidden {
    display: none;
}

.episode-sheet-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.episode-sheet-handle {
    width: 36px;
    height: 5px;
    background: #ccc;
    border-radius: 3px;
}

.episode-sheet-search-wrapper {
    width: 100%;
}

.episode-sheet-search {
    width: 100%;
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 16px;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    outline: none;
    background: #f5f5f5;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-sizing: border-box;
}

.episode-sheet-search:focus {
    border-color: var(--simpsons-yellow);
    box-shadow: 0 0 0 3px rgba(255, 213, 33, 0.25);
    background: white;
}

.episode-sheet-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.episode-sheet-hint {
    font-size: 0.8em;
    color: #999;
}

.episode-sheet-hint.hidden {
    display: none;
}

.episode-sheet-close-btn {
    font-family: 'SimpsonsFont', 'Arial', sans-serif;
    font-size: 14px;
    color: var(--simpsons-blue);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
}

.episode-sheet-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.episode-sheet-list .autocomplete-item {
    padding: 14px 16px;
    min-height: 48px;
}

.episode-sheet-list .autocomplete-item:active {
    background: rgba(255, 213, 33, 0.25);
}

.episode-sheet-empty {
    padding: 24px 16px;
    text-align: center;
    color: #888;
    font-size: 0.95em;
}
