/* =========================================
   NEURO-TRAINER UNIFIED THEME
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --font: 'Rubik', -apple-system, sans-serif;
    --radius-card: 20px;
    --radius-btn: 100px;
}

html, body {
    min-height: 100%;
    overscroll-behavior: none;
}

body {
    font-family: var(--font);
    background: #fdfbfb;
    background-image:
      radial-gradient(ellipse at top left, rgba(255, 182, 193, 0.5), transparent 55%),
      radial-gradient(ellipse at bottom right, rgba(173, 216, 230, 0.5), transparent 55%);
    background-attachment: fixed;
    color: #333;
    -webkit-user-select: none;
    user-select: none;
    padding: 64px 16px 40px;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* NOISE TEXTURE */
.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
}

/* SCREENS */
.screen {
    display: none;
    flex-direction: column;
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}

.screen.active {
    display: flex;
}

/* HOME HEADER */
.home-header {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 10px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(0,0,0,0.4);
    margin-bottom: 8px;
    display: block;
}

h1 {
    font-family: var(--font);
    font-weight: 900;
    font-size: clamp(32px, 8vw, 42px);
    line-height: 0.95;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ff7eb3 0%, #ff758c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(255,117,140,0.3));
    display: inline-block;
    position: relative;
}
.home-subtitle {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(0,0,0,0.5);
}

/* Sound source attribution at the bottom of the home screen. */
.sound-credit {
    margin-top: 40px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--pdg-fg-subtle);
}
.sound-credit a {
    color: var(--pdg-accent);
    text-decoration: none;
    font-weight: 400;
}
.sound-credit a:hover { text-decoration: underline; }

/* CATEGORIES GRID */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.category-card {
    background: rgba(255,255,255,0.65) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.05);
    border-radius: var(--radius-card);
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.category-card:hover {
    background: rgba(255,255,255,0.9) !important;
    border-color: #ff7eb3;
    box-shadow: 0 12px 40px rgba(255,126,179,0.15);
}
.category-card:active { transform: scale(0.96); }

.cat-emoji {
    font-size: 42px;
    margin-bottom: 4px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.cat-name {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.cat-count {
    font-size: 11px;
    font-weight: 700;
    color: rgba(0,0,0,0.4);
    text-transform: uppercase;
}
.cat-play-btn { display: none; } /* hide ugly old btn */

/* GAME TOPBAR */
.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.back-btn {
    background: var(--pdg-surface);
    border: 1px solid var(--pdg-border);
    color: var(--pdg-fg);
    border-radius: 999px;
    padding: 8px 14px;
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.back-btn svg {
    margin-left: -2px;
}
.back-btn:hover { background: var(--pdg-surface-hover); }

.game-meta { text-align: center; }
.category-label {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: #333;
}
.round-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: rgba(0,0,0,0.4);
    text-transform: uppercase;
    margin-top: 4px;
}
.score-display {
    font-size: 18px;
    font-weight: 900;
    color: #ff758c;
}

/* PROGRESS */
.progress-wrap {
    margin-bottom: 24px;
}
.progress-bar-bg {
    height: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ff7eb3, #ff758c);
    border-radius: 10px;
    transition: width 0.3s ease;
}
/* Used as `class="result-action-btn result-action-btn--spaced"`. */
.result-action-btn--spaced { margin-top: 16px; }
.progress-label {
    display: block;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: rgba(0,0,0,0.4);
    margin-top: 8px;
    text-transform: uppercase;
}

/* GAME CENTER */
.game-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.speaker-wrap { margin-top: 10px; }
.play-btn {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(52,211,153,0.12), rgba(34,197,94,0.12));
    border: 1px solid rgba(34,197,94,0.45);
    color: #22c55e;
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(34,197,94,0.25);
    transition: all 0.2s ease;
    position: relative;
}
.play-btn:hover {
    background: linear-gradient(135deg, rgba(52,211,153,0.22), rgba(34,197,94,0.22));
    border-color: rgba(34,197,94,0.75);
    color: #22c55e;
    transform: scale(1.05);
}
.play-btn:active { transform: scale(0.95); }
.play-btn.playing {
    border-color: #34d399;
    color: #34d399;
    animation: glow-pulse 1.5s infinite alternate;
}
@keyframes glow-pulse {
    0% { box-shadow: 0 0 20px rgba(34,197,94,0.25); }
    100% { box-shadow: 0 0 60px rgba(34,197,94,0.65); }
}
.speaker-icon {
    transform: translateX(4px);
    transition: transform 0.2s;
}
.play-btn.playing .speaker-icon { transform: translateX(0); font-size: 38px; }

/* ANSWER GRID */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.answer-card {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,1);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.answer-card:hover:not(.disabled) {
    border-color: #ff7eb3;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 12px 32px rgba(255,126,179,0.15);
}
.answer-card:active:not(.disabled) { transform: scale(0.96); }

.answer-img, .answer-img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.answer-name {
    padding: 12px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    color: #333;
}

.answer-card.disabled { opacity: 0.5; cursor: not-allowed; }
.answer-card.correct {
    background: rgba(34,197,94,0.2);
    border-color: rgba(34,197,94,0.6);
    box-shadow: 0 0 24px rgba(34,197,94,0.4), inset 0 0 12px rgba(34,197,94,0.2);
    animation: pop 0.4s ease;
    opacity: 1 !important;
}
.answer-card.wrong {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.6);
    box-shadow: 0 0 24px rgba(239,68,68,0.4);
    animation: shake 0.35s ease;
}

/* MODALS (Overlays) */
.feedback-overlay, #resultScreen, #winScreen {
    position: fixed;
    inset: 0;
    max-width: none;
    margin: 0;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.feedback-overlay.hidden { display: none; }
#resultScreen:not(.active), #winScreen:not(.active) { display: none; }

.feedback-box, .result-box, .win-box {
    position: relative;
    z-index: 2; /* sit above rays */
    background: #fff;
    border-radius: 32px;
    padding: 32px 24px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.02);
    text-align: center;
    width: 100%;
    max-width: 340px;
    animation: modalSpringIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSpringIn {
    0% { transform: scale(0.6) translateY(40px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* RAYS BACKGROUND (Only visible on success) */
.rays {
    display: none;
    position: absolute;
    top: 50%; left: 50%;
    width: 250vmax; height: 250vmax;
    margin-left: -125vmax; margin-top: -125vmax;
    background: repeating-conic-gradient(
        from 0deg,
        rgba(255, 255, 255, 0) 0deg 15deg,
        rgba(255, 255, 255, 0.6) 15deg 30deg
    );
    animation: spinRays 24s linear infinite;
    z-index: 1;
    pointer-events: none;
    -webkit-mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 15%, rgba(0,0,0,0) 50%);
    mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 15%, rgba(0,0,0,0) 50%);
}
.success .rays { display: block; }

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

.feedback-emoji, .result-emoji, .win-emoji {
    font-size: 64px;
    margin-bottom: 16px;
    display: inline-block;
    animation: emojiBurstIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes emojiBurstIn {
    0% { transform: scale(0.1) translateY(40px) rotate(-15deg); opacity: 0; }
    50% { transform: scale(1.4) translateY(-15px) rotate(10deg); opacity: 1; }
    75% { transform: scale(0.9) translateY(5px) rotate(-5deg); }
    100% { transform: scale(1) translateY(0) rotate(0deg); opacity: 1; }
}

.feedback-title, .result-title, .win-title {
    font-weight: 900;
    font-size: 32px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 12px;
    color: #f0ecf7;
    background: linear-gradient(135deg, #ff7eb3, #ff758c);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.feedback-sub, .result-sub, .win-sub {
    font-size: 15px;
    font-weight: 600;
    color: rgba(0,0,0,0.5);
    margin-bottom: 24px;
    line-height: 1.4;
}

/* BUTTONS */
.next-btn, .result-action-btn {
    width: 100%;
    padding: 16px;
    border-radius: 100px;
    background: linear-gradient(135deg, #34d399 0%, #22c55e 100%);
    color: white;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(34,197,94,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.2s ease;
}
.next-btn:hover, .result-action-btn:hover { filter: brightness(1.1); }
.next-btn:active, .result-action-btn:active { transform: scale(0.97); }

.next-btn.hidden { display: none; }

.result-score {
    font-family: var(--font);
    font-weight: 900;
    font-size: 48px;
    color: #ff758c;
    font-variant-numeric: tabular-nums;
    margin-bottom: 16px;
}

.level-badge, .final-badge {
    background: rgba(255, 126, 179, 0.1);
    border: 1px solid rgba(255, 126, 179, 0.4);
    color: #ff758c;
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 24px;
}
.level-badge.hidden { display: none; }


/* GPU-ACCELERATED CSS CONFETTI */
#cssConfettiContainer {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    overflow: visible;
}
.css-confetti {
    position: absolute;
    width: 14px; height: 14px;
    opacity: 0;
    animation: cssBurst 2s cubic-bezier(0.25, 1, 0.4, 1) forwards;
}

.css-confetti.cannon-left {
    left: -10px; bottom: -10px;
}
.css-confetti.cannon-right {
    right: -10px; bottom: -10px;
}
.css-confetti.round { border-radius: 50%; }

@keyframes cssBurst {
    0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(0); opacity: 1; }
    8% { transform: translate3d(calc(var(--tx) * 0.1), calc(var(--ty) * 0.1), 0) rotate(0deg) scale(1.5); }
    100% { transform: translate3d(var(--tx), var(--ty), 0) rotate(var(--rot)) scale(0); opacity: 0; }
}


@keyframes pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.answer-card { animation: fadeSlideIn 0.35s ease both; }
.answer-card:nth-child(1) { animation-delay: 0.05s; }
.answer-card:nth-child(2) { animation-delay: 0.10s; }
.answer-card:nth-child(3) { animation-delay: 0.15s; }
.answer-card:nth-child(4) { animation-delay: 0.20s; }

/* ============================
   OFFLINE ZONE
   ============================ */
/* Title on the left, switch on the right; the explainer sits underneath.
   .offline-zone itself is a column flexbox from shared/components.css. */
.offline-zone__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.offline-zone__title {
    font-size: 15px;
    font-weight: 800;
    color: var(--pdg-fg);
}

/* components.css pins the toggle to the start of the column — inside this row
   it has to sit on the baseline of the title instead. */
.offline-zone__head .pdg-toggle { align-self: center; }

@media (max-width: 380px) {
    .offline-zone__head { gap: 10px; }
    .offline-zone__title { font-size: 14px; }
}

/* ============================
   SOUND LIBRARY (listen mode)
   ============================ */
/* The right-hand filler that balances the topbar: in the quiz that slot holds
   the score, here it keeps the category title centred. */
.library-spacer {
    width: 78px;
    flex-shrink: 0;
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    /* On top of .game-topbar's own 16px — the list needs more air from the
       header than the quiz's progress bar does. */
    margin-top: 14px;
}

.sound-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 10px 16px 10px 10px;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,1);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    font-family: 'Rubik', sans-serif;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}
.sound-row:hover {
    border-color: #ff7eb3;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 12px 32px rgba(255,126,179,0.15);
}
.sound-row:active { transform: scale(0.98); }

.sound-row__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,126,179,0.14);
    color: #ff758c;
    font-size: 16px;
    line-height: 1;
    padding-left: 2px;
    transition: all 0.2s ease;
}
/* The pause glyph is two bars — no optical offset needed. */
.sound-row.is-playing .sound-row__icon { padding-left: 0; }

.sound-row__name {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: #333;
}

.sound-row.is-playing {
    border-color: #ff7eb3;
    background: rgba(255,126,179,0.1);
    box-shadow: 0 8px 28px rgba(255,126,179,0.22);
}
.sound-row.is-playing .sound-row__icon {
    background: linear-gradient(135deg, #ff7eb3, #ff758c);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255,117,140,0.45);
}

@media (max-width: 380px) {
    .library-spacer { width: 0; }
    .sound-row { gap: 12px; padding: 8px 12px 8px 8px; }
    .sound-row__icon { width: 40px; height: 40px; }
    .sound-row__name { font-size: 14px; }
}

/* ============================
   DARK THEME OVERRIDES
   ============================ */
:root[data-theme="dark"] body {
    background: #0f0a1a;
    background-image:
      radial-gradient(ellipse at top left, rgba(255,126,179,0.18), transparent 55%),
      radial-gradient(ellipse at bottom right, rgba(130,100,220,0.22), transparent 55%);
    color: #f0ecf7;
}
:root[data-theme="dark"] .noise { opacity: 0.04; mix-blend-mode: overlay; }

:root[data-theme="dark"] .eyebrow { color: rgba(240,236,247,0.5); }
:root[data-theme="dark"] .home-subtitle { color: rgba(240,236,247,0.6); }

:root[data-theme="dark"] .category-card {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1);
    color: #f0ecf7;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
:root[data-theme="dark"] .category-card:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: #ff7eb3;
    box-shadow: 0 12px 40px rgba(255,126,179,0.2);
}
:root[data-theme="dark"] .cat-count { color: rgba(240,236,247,0.5); }




:root[data-theme="dark"] .category-label { color: #f0ecf7; }
:root[data-theme="dark"] .round-label { color: rgba(240,236,247,0.5); }

:root[data-theme="dark"] .progress-bar-bg { background: rgba(255,255,255,0.08); }
:root[data-theme="dark"] .progress-label { color: rgba(240,236,247,0.5); }

:root[data-theme="dark"] .answer-card {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
:root[data-theme="dark"] .answer-card:hover:not(.disabled) {
    background: rgba(255,255,255,0.1);
    border-color: #ff7eb3;
    box-shadow: 0 12px 32px rgba(255,126,179,0.2);
}
:root[data-theme="dark"] .answer-img,
:root[data-theme="dark"] .answer-img-placeholder {
    background: rgba(255,255,255,0.03);
    border-bottom-color: rgba(255,255,255,0.08);
}
:root[data-theme="dark"] .answer-name { color: #f0ecf7; }

:root[data-theme="dark"] .feedback-overlay,
:root[data-theme="dark"] #resultScreen,
:root[data-theme="dark"] #winScreen {
    background: #0f0a1a;
}
:root[data-theme="dark"] .feedback-box,
:root[data-theme="dark"] .result-box,
:root[data-theme="dark"] .win-box {
    background: #1a1330;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
    color: #f0ecf7;
}
:root[data-theme="dark"] .feedback-sub,
:root[data-theme="dark"] .result-sub,
:root[data-theme="dark"] .win-sub { color: rgba(240,236,247,0.6); }
:root[data-theme="dark"] .rays {
    background: repeating-conic-gradient(
        from 0deg,
        rgba(255, 126, 179, 0) 0deg 15deg,
        rgba(255, 126, 179, 0.28) 15deg 30deg
    );
}

:root[data-theme="dark"] .level-badge,
:root[data-theme="dark"] .final-badge {
    background: rgba(255,126,179,0.15);
    border-color: rgba(255,126,179,0.3);
}

:root[data-theme="dark"] .sound-row {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
:root[data-theme="dark"] .sound-row:hover {
    background: rgba(255,255,255,0.1);
    border-color: #ff7eb3;
    box-shadow: 0 12px 32px rgba(255,126,179,0.2);
}
:root[data-theme="dark"] .sound-row__name { color: #f0ecf7; }
:root[data-theme="dark"] .sound-row__icon {
    background: rgba(255,126,179,0.18);
    color: #ff9ec7;
}
:root[data-theme="dark"] .sound-row.is-playing {
    background: rgba(255,126,179,0.16);
    border-color: #ff7eb3;
}
:root[data-theme="dark"] .sound-row.is-playing .sound-row__icon {
    background: linear-gradient(135deg, #ff7eb3, #ff758c);
    color: #fff;
}

/* topbar overrides */
      .pdg-topbar {
        position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
        display: flex; justify-content: flex-end; align-items: center;
        padding: 14px 24px; pointer-events: none;
      }
      .pdg-topbar > * { pointer-events: auto; }

      body:not(.is-home) .pdg-topbar { display: none; }
      body:not(.is-home) { padding: 14px 24px 40px; }

