/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── DESIGN TOKENS ── */
:root {
    --bg: #0d0d12;
    --surface: #16161f;
    --surface2: #1e1e2a;
    --surface3: #252535;
    --border: rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);
    --text: #f0f0f6;
    --text-muted: #8888a8;
    --text-faint: #4a4a68;
    --accent: #e35b4c;
    --accent2: #7c6ef5;
    --accent3: #3dd68c;
    --danger: #e35b4c;
    --warning: #f5a623;
    --success: #3dd68c;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 12px rgba(0,0,0,0.25);
}

/* ── BASE ── */
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ── */
.screen {
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 16px 40px;
}
.screen.hidden { display: none; }

/* ── MENU ── */
.menu-wrap {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-top: 40px;
}

.menu-header { text-align: center; }
.logo { width: 120px; margin-bottom: 16px; }

.menu-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 7vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text);
}
.menu-title .accent { color: var(--accent); }

.menu-subtitle {
    margin-top: 10px;
    font-size: 0.95rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

/* ── MODE CARDS ── */
.mode-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
    text-align: left;
    width: 100%;
    color: var(--text);
    position: relative;
    overflow: hidden;
}
.mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124,110,245,0.04) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.2s;
}
.mode-card:hover:not(.disabled)::before { opacity: 1; }
.mode-card:hover:not(.disabled) {
    background: var(--surface2);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}
.mode-card:active:not(.disabled) { transform: translateY(0); }
.mode-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mode-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 1.4rem;
}
.mode-icon img { width: 28px; height: 28px; object-fit: contain; }
.mode-icon .fallback-icon { font-size: 1.4rem; }

.mode-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mode-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.mode-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mode-arrow {
    font-size: 1.4rem;
    color: var(--text-faint);
    transition: color 0.15s, transform 0.15s;
}
.mode-card:hover:not(.disabled) .mode-arrow {
    color: var(--accent2);
    transform: translateX(3px);
}

.lives-badge {
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(227,91,76,0.2);
    color: var(--accent);
    border-radius: 20px;
    padding: 3px 10px;
}
.soon-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: var(--surface3);
    color: var(--text-faint);
    border-radius: 20px;
    padding: 3px 10px;
}

/* ── SOUND TOGGLE ── */
.sound-toggle-wrap { display: flex; justify-content: center; }
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.toggle-label.small .toggle-track { width: 36px; height: 20px; }
.toggle-label.small .toggle-track::after { width: 14px; height: 14px; }
.toggle-label.small input:checked + .toggle-track::after { transform: translateX(16px); }

.toggle-label input { display: none; }
.toggle-track {
    width: 44px;
    height: 24px;
    background: var(--surface3);
    border-radius: 99px;
    position: relative;
    transition: background 0.2s;
    border: 1px solid var(--border-hover);
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}
.toggle-label input:checked + .toggle-track { background: rgba(124,110,245,0.25); }
.toggle-label input:checked + .toggle-track::after {
    transform: translateX(20px);
    background: var(--accent2);
}
.toggle-text { font-size: 0.85rem; color: var(--text-muted); }

/* ── QUIZ WRAP ── */
.quiz-wrap {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 8px;
}

/* ── TOP BAR ── */
.quiz-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
}
.btn-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 7px 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.btn-back:hover { background: var(--surface2); color: var(--text); }
.mode-label {
    flex: 1;
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sound-inline { flex-shrink: 0; }

/* ── LIVES BAR ── */
.lives-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 20px;
}
.lives-bar.hidden { display: none; }
.lives-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.hearts { display: flex; gap: 6px; }
.heart {
    font-size: 1.2rem;
    opacity: 0.2;
    transition: opacity 0.3s, transform 0.3s;
}
.heart.active { opacity: 1; }
.heart.pulse { animation: heartPulse 0.3s ease; }

/* ── TIMER ── */
.timer-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}
.timer-wrap.hidden { display: none; }
.timer-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.timer-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.timer-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    transition: color 0.3s;
    min-width: 40px;
    text-align: right;
}
.timer-value.warning { color: var(--warning); }
.timer-value.danger { color: var(--danger); animation: timerPulse 0.5s infinite; }

.timer-bar-track {
    height: 4px;
    background: var(--surface3);
    border-radius: 99px;
    overflow: hidden;
}
.timer-bar-fill {
    height: 100%;
    background: var(--accent2);
    border-radius: 99px;
    transition: width 1s linear, background 0.3s;
    width: 100%;
}
.timer-bar-fill.warning { background: var(--warning); }
.timer-bar-fill.danger { background: var(--danger); }

/* ── QUESTION CARD ── */
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.question-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.question-icon svg { width: 20px; height: 20px; color: var(--text-muted); }
.question-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}
.type-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.type-icon-lg {
    width: 40px;
    height: 40px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.type-icon-lg:hover { transform: scale(1.15) rotate(8deg); }
.type-name {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 5vw, 2rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ── OPTIONS GRID ── */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s, filter 0.2s;
    text-align: left;
    background: var(--surface);
}
.option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.option-btn:active:not(:disabled) { transform: translateY(0); }
.option-btn:disabled { cursor: not-allowed; }
.option-btn .opt-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
}
.option-btn .opt-label { flex: 1; }

.option-btn.correct {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(61,214,140,0.15);
}
.option-btn.incorrect {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(227,91,76,0.15);
}
.option-btn.dimmed { opacity: 0.35; filter: saturate(0.4); }

/* ── FEEDBACK ── */
.feedback-box {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.5;
    background: var(--surface2);
    border: 1px solid var(--border);
    animation: fadeSlideIn 0.2s ease;
}
.feedback-box.hidden { display: none; }
.feedback-box.correct { border-color: rgba(61,214,140,0.3); background: rgba(61,214,140,0.08); color: #7eedb8; }
.feedback-box.incorrect { border-color: rgba(227,91,76,0.3); background: rgba(227,91,76,0.08); color: #f4a49c; }
.feedback-box strong { color: inherit; font-weight: 600; }

/* ── STATS BAR ── */
.stats-bar {
    display: flex;
    gap: 8px;
}
.stat-chip {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-label { font-size: 0.7rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; }
.stat-value {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

/* ── GAME OVER OVERLAY ── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}
.overlay.hidden { display: none; }

.result-card {
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl);
    padding: 36px 28px;
    text-align: center;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-icon { font-size: 3rem; }
.result-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.result-stat {
    background: var(--surface2);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result-stat-label { font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.result-stat-value {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.btn-primary {
    background: var(--accent2);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 24px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); }

/* ── ANIMATIONS ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
@keyframes heartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
@keyframes questionIn {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.question-animate { animation: questionIn 0.25s ease forwards; }

/* ── RESPONSIVE ── */
@media (max-width: 380px) {
    .options-grid { grid-template-columns: 1fr; }
    .result-stats { grid-template-columns: 1fr; }
    .menu-title { font-size: 2rem; }
}

/* ── ACCESSIBILITY ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
button:focus-visible {
    outline: 2px solid var(--accent2);
    outline-offset: 3px;
}
