/* ═══════════════════════════════════════════════════════════════════
   Grammar Gauntlet — rapid-fire Chinese grammar drill
   Hero: slate → cyan (#0f172a → #0e7490 → #06b6d4). Deliberately distinct
   from Look-Alike's teal, Tone Pair Arcade's rose and Character Builder's
   indigo — every game hero on this site reads as its own place.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Hero ────────────────────────────────────────────────────────── */
.gg-hero {
    background: linear-gradient(135deg, #0f172a 0%, #0e7490 55%, #06b6d4 100%);
    border-radius: 0.5rem;
}

/* ── HUD row above the stage ─────────────────────────────────────── */
.gg-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.gg-hud-item {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
    white-space: nowrap;
}

.gg-hud-item small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
}

.gg-heart {
    color: #ef4444;
    font-size: 1.15rem;
    transition: transform 0.15s, color 0.15s;
}

.gg-heart.lost {
    color: #cbd5e1;
    transform: scale(0.85);
}

.gg-combo-badge {
    display: inline-block;
    min-width: 2.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #0e7490;
    color: #fff;
    font-size: 0.95rem;
}

/* Round progress */
.gg-progress {
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.3);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.gg-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #0e7490, #06b6d4);
    transition: width 0.3s ease;
}

/* ── The stage ───────────────────────────────────────────────────── */
.gg-stage {
    position: relative;
    min-height: 440px;
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #f0f9ff 0%, #ecfeff 100%);
    border: 1px solid rgba(14, 116, 144, 0.15);
    padding: 1rem;
    overflow: hidden;
}

/* ── Prompt ──────────────────────────────────────────────────────── */
.gg-prompt {
    text-align: center;
    min-height: 8.5rem;
    padding: 0.25rem 0 0.75rem;
}

.gg-prompt-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.gg-chip {
    border-radius: 999px;
    padding: 0.05rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    background: #64748b;
}

.gg-chip-beginner { background: #16a34a; }
.gg-chip-intermediate { background: #d97706; }
.gg-chip-advanced { background: #be123c; }

.gg-prompt-cat {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
}

.gg-prompt-kind {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0e7490;
    margin-bottom: 0.35rem;
}

.gg-prompt-kind-fix {
    color: #be123c;
}

/* The sentence with its gap */
.gg-sentence {
    font-size: clamp(1.5rem, 5.5vw, 2.25rem);
    font-weight: 600;
    line-height: 1.5;
    color: #0f172a;
    word-break: break-word;
}

.gg-gap {
    display: inline-block;
    min-width: 2.2em;
    margin: 0 0.12em;
    border-bottom: 3px solid #0e7490;
    color: #0e7490;
    opacity: 0.65;
}

.gg-prompt-question {
    font-size: clamp(1.15rem, 4vw, 1.5rem);
    font-weight: 600;
    color: #0f172a;
}

.gg-prompt-en {
    font-size: 1rem;
    color: var(--bs-secondary-color);
    margin-top: 0.35rem;
}

.gg-prompt-pattern {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    background: rgba(14, 116, 144, 0.1);
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    color: #0e7490;
}

/* Countdown bar */
.gg-timer {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
    margin-bottom: 1rem;
}

.gg-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #06b6d4, #0e7490);
}

.gg-timer-fill.urgent {
    background: linear-gradient(90deg, #f97316, #ef4444);
    animation: gg-pulse 0.6s ease-in-out infinite;
}

@keyframes gg-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ── Options ─────────────────────────────────────────────────────── */
.gg-options {
    display: grid;
    gap: 0.75rem;
}

/* Four short words → a 2x2 that opens out to a row on tablet and up. */
.gg-options-gap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 576px) {
    .gg-options-gap { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Two full sentences → always stacked; they are far too long to sit side by side. */
.gg-options-fix {
    grid-template-columns: minmax(0, 1fr);
}

.gg-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(14, 116, 144, 0.25);
    border-radius: 0.75rem;
    background: #fff;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
    padding: 0.75rem 0.75rem 0.75rem 1.6rem;
    text-align: center;
}

.gg-option:hover:not(:disabled) {
    border-color: #0e7490;
    transform: translateY(-2px);
}

.gg-option:disabled {
    cursor: default;
}

.gg-option-gap {
    min-height: 5rem;
}

.gg-option-gap .gg-option-body {
    font-size: clamp(1.5rem, 6vw, 2.1rem);
    line-height: 1.2;
    color: #0f172a;
}

.gg-option-fix {
    min-height: 3.6rem;
}

.gg-option-fix .gg-option-body {
    font-size: clamp(1rem, 3.6vw, 1.3rem);
    line-height: 1.6;
    color: #0f172a;
}

/* The authored pair marks the difference with <u>; make that legible rather than
   a hairline, without turning it into a giveaway (both options carry one). */
.gg-option-fix u {
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.gg-option-key {
    position: absolute;
    top: 0.35rem;
    left: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    opacity: 0.65;
}

.gg-option.correct {
    border-color: #16a34a;
    background: #dcfce7;
    animation: gg-pop 0.35s ease;
}

.gg-option.wrong {
    border-color: #dc2626;
    background: #fee2e2;
    animation: gg-shake 0.35s ease;
}

.gg-option.faded {
    opacity: 0.4;
}

@keyframes gg-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes gg-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ── Reveal panel ────────────────────────────────────────────────── */
.gg-reveal {
    margin-top: 0.9rem;
    /* Reserved so the stage does not jump when the explanation appears. Raised from 9rem
       when the reveal gained its own Next button — the row is always there now, so the
       reserve has to cover it or every answer nudges the board down. */
    min-height: 11.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gg-reveal.shown {
    opacity: 1;
}

.gg-reveal-head {
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.gg-reveal-head.ok { color: #15803d; }
.gg-reveal-head.bad { color: #b91c1c; }

.gg-reveal-answer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.gg-reveal-sentence {
    font-size: 1.35rem;
    line-height: 1.5;
}

.gg-reveal-blank {
    background: rgba(6, 182, 212, 0.28);
    border-radius: 0.2rem;
    padding: 0 0.1em;
    color: inherit;
}

.gg-reveal-pinyin {
    font-size: 0.95rem;
    color: #0e7490;
}

.gg-reveal-en {
    font-size: 0.9rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.5rem;
}

.gg-reveal-pair {
    display: grid;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

.gg-reveal-wrong,
.gg-reveal-right {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
}

.gg-mark {
    font-weight: 800;
    flex: 0 0 auto;
}

.gg-reveal-wrong { color: #b91c1c; }
.gg-reveal-wrong .gg-mark { color: #dc2626; }
.gg-reveal-right { color: #15803d; }
.gg-reveal-right .gg-mark { color: #16a34a; }

.gg-reveal-why {
    font-size: 0.875rem;
    background: rgba(6, 182, 212, 0.1);
    border-left: 3px solid #06b6d4;
    border-radius: 0.25rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.5rem;
}

/* Every reveal offers the rule behind the question — the whole point of the game
   is that a miss lands the reader on the grammar page that explains it. */
.gg-reveal-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: #0e7490;
    background: rgba(14, 116, 144, 0.09);
    border-radius: 0.5rem;
    padding: 0.35rem 0.7rem;
}

.gg-reveal-link:hover {
    background: rgba(14, 116, 144, 0.18);
    color: #0e7490;
}

/* The reveal is dismissed by hand, so the way out of it has to be the most obvious
   thing on the panel — nothing else here is a filled button. */
.gg-next-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.gg-next {
    padding: 0.5rem 1.4rem;
}

.gg-next-hint {
    font-size: 0.78rem;
    color: var(--bs-secondary-color);
}

@media (max-width: 575.98px) {
    .gg-next {
        flex: 1 1 100%;
    }

    .gg-next-hint {
        display: none;
    }
}

.gg-speaker {
    border: none;
    background: transparent;
    color: #0e7490;
    padding: 0.1rem 0.3rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.gg-speaker:hover {
    background: rgba(14, 116, 144, 0.12);
}

.gg-speaker.gg-speaker-loading {
    opacity: 0.45;
    cursor: progress;
}

/* Floating score */
.gg-float {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 1.5rem;
    color: #15803d;
    pointer-events: none;
    animation: gg-float-up 0.9s ease-out forwards;
}

@keyframes gg-float-up {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -60px); }
}

/* ── Overlays ────────────────────────────────────────────────────── */
.gg-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    text-align: center;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(2px);
    z-index: 5;
    overflow-y: auto;
}

.gg-big-icon {
    font-size: 2.5rem;
    color: #0e7490;
}

.gg-btn-primary {
    background: linear-gradient(135deg, #0e7490, #06b6d4);
    border: none;
    color: #fff;
    font-weight: 600;
}

.gg-btn-primary:hover {
    background: linear-gradient(135deg, #155e75, #0e7490);
    color: #fff;
}

.gg-btn-primary:disabled {
    opacity: 0.55;
}

/* Level and mode pickers on the start screen */
.gg-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.gg-picker-label {
    width: 100%;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-bottom: -0.2rem;
}

.gg-pick-btn {
    border: 2px solid rgba(14, 116, 144, 0.3);
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.12s;
}

.gg-pick-btn:hover {
    border-color: #0e7490;
}

.gg-pick-btn.active {
    background: linear-gradient(135deg, #0e7490, #06b6d4);
    border-color: #0e7490;
    color: #fff;
}

.gg-final-score {
    font-size: 2.75rem;
    font-weight: 800;
    color: #0e7490;
    line-height: 1;
}

.gg-final-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.1rem;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
}

.gg-final-missed {
    width: 100%;
    max-width: 24rem;
    max-height: 11rem;
    overflow-y: auto;
}

.gg-final-missed-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
}

/* Screen-reader-only live region for answer feedback. */
.gg-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ── Dark mode ───────────────────────────────────────────────────── */
[data-bs-theme="dark"] .gg-stage {
    background: linear-gradient(180deg, #0f172a 0%, #164e63 100%);
    border-color: rgba(6, 182, 212, 0.25);
}

[data-bs-theme="dark"] .gg-sentence,
[data-bs-theme="dark"] .gg-prompt-question {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .gg-prompt-kind { color: #22d3ee; }
[data-bs-theme="dark"] .gg-prompt-kind-fix { color: #fb7185; }

[data-bs-theme="dark"] .gg-prompt-pattern {
    background: rgba(6, 182, 212, 0.18);
    color: #67e8f9;
}

[data-bs-theme="dark"] .gg-gap {
    border-bottom-color: #22d3ee;
    color: #22d3ee;
}

[data-bs-theme="dark"] .gg-option {
    background: #1e293b;
    border-color: rgba(6, 182, 212, 0.3);
}

[data-bs-theme="dark"] .gg-option-gap .gg-option-body,
[data-bs-theme="dark"] .gg-option-fix .gg-option-body {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .gg-option.correct {
    background: #14532d;
    border-color: #16a34a;
}

[data-bs-theme="dark"] .gg-option.wrong {
    background: #7f1d1d;
    border-color: #dc2626;
}

[data-bs-theme="dark"] .gg-overlay {
    background: rgba(15, 23, 42, 0.95);
}

[data-bs-theme="dark"] .gg-pick-btn {
    background: #1e293b;
    color: #e2e8f0;
    border-color: rgba(6, 182, 212, 0.35);
}

[data-bs-theme="dark"] .gg-reveal-head.ok { color: #4ade80; }
[data-bs-theme="dark"] .gg-reveal-head.bad { color: #f87171; }
[data-bs-theme="dark"] .gg-reveal-wrong { color: #fca5a5; }
[data-bs-theme="dark"] .gg-reveal-right { color: #86efac; }
[data-bs-theme="dark"] .gg-reveal-pinyin { color: #67e8f9; }

[data-bs-theme="dark"] .gg-reveal-why {
    background: rgba(6, 182, 212, 0.14);
}

[data-bs-theme="dark"] .gg-reveal-link {
    background: rgba(6, 182, 212, 0.16);
    color: #67e8f9;
}

[data-bs-theme="dark"] .gg-reveal-link:hover {
    background: rgba(6, 182, 212, 0.28);
    color: #a5f3fc;
}

[data-bs-theme="dark"] .gg-float { color: #4ade80; }
[data-bs-theme="dark"] .gg-heart.lost { color: #475569; }
[data-bs-theme="dark"] .gg-final-score { color: #22d3ee; }
[data-bs-theme="dark"] .gg-big-icon { color: #22d3ee; }
