/* ==========================================================================
   UMOYA: The Unfinished Sky — fullscreen layout + HUD overlays
   Responsive strategy: mobile-first, Flexbox/Grid centering, FIT canvas,
   safe-area insets, and adaptive touch targets across desktop / tablet / phone.
   ========================================================================== */

:root {
    --gold: #f9a03f;
    --gold-bright: #ffd166;
    --ember: #e85d04;
    --ink: #120a04;
    --paper: #fff6e8;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
}

html,
body,
#root {
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, #2a1608 0%, #0b0502 70%);
    color: var(--paper);
    font-family: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ---- Centering shell (Flexbox + dynamic viewport height) ---------------- */

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    /* No flex centering here: Phaser's Scale.FIT + CENTER_BOTH already applies
       inline centering margins to the canvas. Flex centering ON TOP of those
       margins double-offsets the canvas to the right of center on desktop
       (observed in preview: the game strip sat right of the viewport center). */
}

#game-container canvas {
    display: block;
    box-shadow: 0 0 60px rgba(249, 160, 63, 0.18);
    border-radius: 2px;
    /* No max-width / max-height / margin overrides here: Phaser's Scale.FIT +
       CENTER_BOTH sets the canvas size and inline centering margins itself.
       CSS constraints fight the ScaleManager and drift the canvas off-center
       (the original "game sits on the right side" bug). */
}

/* ---- HUD layer ---------------------------------------------------------- */

#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
}

.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: calc(12px + var(--safe-top)) calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left));
    gap: 10px;
}

.hud-distance {
    display: flex;
    align-items: baseline;
    gap: 6px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.hud-distance-value {
    font-size: clamp(34px, 8vw, 52px);
    font-weight: 900;
    color: var(--paper);
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

.hud-distance-unit {
    font-size: clamp(14px, 3vw, 18px);
    font-weight: 700;
    color: var(--gold-bright);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hud-zone-chip {
    margin-top: 10px;
    padding: 5px 12px;
    border: 2px solid var(--gold);
    border-radius: 999px;
    font-size: clamp(11px, 2.6vw, 14px);
    font-weight: 800;
    letter-spacing: 2px;
    background: rgba(10, 5, 2, 0.45);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.hud-best {
    position: absolute;
    top: calc(72px + var(--safe-top));
    left: calc(18px + var(--safe-left));
    font-size: clamp(12px, 2.8vw, 15px);
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255, 246, 232, 0.75);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.hud-controls {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.hud-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255, 246, 232, 0.35);
    background: rgba(10, 5, 2, 0.5);
    color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.12s ease, background 0.12s ease;
}

.hud-btn:active {
    transform: scale(0.9);
    background: rgba(249, 160, 63, 0.35);
}

/* ---- Zone banner -------------------------------------------------------- */

.zone-banner {
    position: absolute;
    top: 26%;
    left: 0;
    right: 0;
    text-align: center;
    animation: zoneBanner 2.6s ease forwards;
    opacity: 0;
}

.zone-banner-name {
    font-size: clamp(38px, 10vw, 64px);
    font-weight: 900;
    letter-spacing: clamp(6px, 2vw, 14px);
    text-shadow: 0 0 24px currentColor, 0 4px 14px rgba(0, 0, 0, 0.7);
}

.zone-banner-sub {
    margin-top: 6px;
    font-size: clamp(14px, 3.4vw, 20px);
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.85);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

@keyframes zoneBanner {
    0% {
        opacity: 0;
        transform: scale(1.35);
    }
    18% {
        opacity: 1;
        transform: scale(1);
    }
    78% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.96);
    }
}

/* ---- Weather banner (Living Weather, plan §4) --------------------------- */

.weather-banner {
    position: absolute;
    top: calc(118px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 22px;
    border-radius: 999px;
    border: 1px solid rgba(249, 160, 63, 0.45);
    background: rgba(10, 5, 2, 0.55);
    backdrop-filter: blur(4px);
    text-align: center;
    white-space: nowrap;
    animation: weatherIn 0.5s ease;
}

.weather-banner-name {
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold-bright);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.weather-banner-desc {
    font-size: clamp(10px, 2.6vw, 12px);
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255, 246, 232, 0.75);
}

@keyframes weatherIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ---- Overlays ----------------------------------------------------------- */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(24px + var(--safe-top)) calc(24px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(24px + var(--safe-left));
    pointer-events: auto;
    background: linear-gradient(
        180deg,
        rgba(8, 4, 1, 0.55) 0%,
        rgba(8, 4, 1, 0.78) 100%
    );
    backdrop-filter: blur(3px);
    animation: overlayIn 0.35s ease;
    overflow-y: auto;
}

@keyframes overlayIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.menu-card,
.pause-card,
.over-card {
    width: min(420px, 92vw);
    text-align: center;
    padding: clamp(22px, 5vw, 36px);
    border-radius: 22px;
    border: 1px solid rgba(249, 160, 63, 0.35);
    background: linear-gradient(165deg, rgba(34, 18, 6, 0.92), rgba(12, 6, 2, 0.95));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(249, 160, 63, 0.08) inset;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    margin: auto;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(26px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.menu-eyebrow,
.over-eyebrow {
    font-size: clamp(10px, 2.6vw, 13px);
    font-weight: 800;
    letter-spacing: 5px;
    color: var(--gold);
    text-transform: uppercase;
}

.menu-title {
    margin: 0;
    font-size: clamp(56px, 16vw, 92px);
    font-weight: 900;
    letter-spacing: clamp(4px, 2vw, 12px);
    line-height: 1;
    background: linear-gradient(180deg, #fff3c4 0%, var(--gold-bright) 45%, var(--ember) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 18px rgba(249, 160, 63, 0.4));
}

.menu-subtitle {
    font-size: clamp(16px, 4vw, 22px);
    font-weight: 600;
    letter-spacing: 3px;
    color: rgba(255, 246, 232, 0.9);
    text-transform: uppercase;
}

.menu-desc {
    margin: 0;
    font-size: clamp(13px, 3.2vw, 15px);
    line-height: 1.55;
    color: rgba(255, 246, 232, 0.7);
    max-width: 34ch;
}

.menu-hint {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: clamp(11px, 2.8vw, 13px);
    letter-spacing: 1px;
    color: rgba(255, 246, 232, 0.5);
}

.menu-best {
    margin-top: 4px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px dashed rgba(249, 160, 63, 0.45);
}

.menu-best-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.6);
}

.menu-best-value {
    font-size: 20px;
    font-weight: 900;
    color: var(--gold-bright);
}

/* ---- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 200px;
    min-height: 56px;
    padding: 14px 30px;
    border-radius: 999px;
    font-family: inherit;
    font-size: clamp(15px, 3.6vw, 18px);
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary {
    color: var(--ink);
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--ember) 100%);
    box-shadow: 0 8px 24px rgba(232, 93, 4, 0.45), 0 0 0 1px rgba(255, 243, 196, 0.5) inset;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(232, 93, 4, 0.6), 0 0 0 1px rgba(255, 243, 196, 0.7) inset;
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-ghost {
    color: rgba(255, 246, 232, 0.85);
    background: transparent;
    border: 1px solid rgba(255, 246, 232, 0.3);
}

.btn-ghost:hover {
    border-color: var(--gold);
    color: var(--gold-bright);
}

/* ---- Pause -------------------------------------------------------------- */

.pause-title {
    font-size: clamp(34px, 9vw, 48px);
    font-weight: 900;
    letter-spacing: 10px;
    color: var(--paper);
    text-shadow: 0 0 22px rgba(249, 160, 63, 0.45);
}

.pause-zone {
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.75);
}

/* ---- Game over ---------------------------------------------------------- */

.over-title {
    margin: 0;
    font-size: clamp(24px, 6vw, 34px);
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--paper);
}

.over-stats {
    display: flex;
    justify-content: center;
    gap: clamp(14px, 4vw, 26px);
    width: 100%;
}

.over-stat {
    flex: 1;
    max-width: 120px;
    padding: 12px 8px;
    border-radius: 14px;
    background: rgba(255, 246, 232, 0.06);
    border: 1px solid rgba(249, 160, 63, 0.25);
}

.over-stat-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.55);
}

.over-stat-value {
    margin-top: 4px;
    font-size: clamp(20px, 5vw, 26px);
    font-weight: 900;
    color: var(--gold-bright);
    font-variant-numeric: tabular-nums;
}

.over-stat-zone {
    font-size: clamp(12px, 3vw, 14px);
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1.2;
    padding-top: 6px;
}

.over-record {
    padding: 6px 18px;
    border-radius: 999px;
    font-size: clamp(12px, 3vw, 14px);
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--ink);
    background: linear-gradient(90deg, var(--gold-bright), var(--ember));
    animation: recordPulse 1.1s ease-in-out infinite;
}

@keyframes recordPulse {
    0%,
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.06);
        filter: brightness(1.25);
    }
}

.over-fact {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border-left: 3px solid var(--gold);
    background: rgba(249, 160, 63, 0.08);
    text-align: left;
}

.over-fact-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 4px;
}

.over-fact-text {
    font-size: clamp(12px, 3vw, 14px);
    line-height: 1.5;
    color: rgba(255, 246, 232, 0.85);
}

.over-quote {
    font-size: clamp(11px, 2.8vw, 13px);
    letter-spacing: 1px;
    color: rgba(255, 246, 232, 0.5);
}

/* ---- Story comic overlay (STORY phase, plan §2/§3) ---------------------- */

.story-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
    background: radial-gradient(ellipse at 50% 25%, #241207 0%, #0b0502 72%);
    cursor: pointer;
    overflow: hidden;
    animation: overlayIn 0.35s ease;
}

.story-skip {
    position: absolute;
    top: calc(14px + var(--safe-top));
    left: calc(14px + var(--safe-left));
    min-width: 84px;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid rgba(249, 160, 63, 0.5);
    background: rgba(10, 5, 2, 0.6);
    color: var(--paper);
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 3px;
    cursor: pointer;
    z-index: 2;
}

.story-skip:hover {
    border-color: var(--gold-bright);
    color: var(--gold-bright);
}

.story-progress {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: calc(14px + var(--safe-right));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: default;
    z-index: 2;
}

.story-progress-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    color: rgba(255, 246, 232, 0.75);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.story-panel {
    width: min(560px, 94vw);
    max-height: 78dvh;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(249, 160, 63, 0.35);
    background: #0d0704;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 40px rgba(249, 160, 63, 0.08);
}

.story-art {
    display: block;
    width: 100%;
    height: auto;
}

.story-caption-card {
    margin: 14px 16px 18px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid rgba(249, 160, 63, 0.45);
    background: rgba(18, 9, 5, 0.92);
    text-align: center;
}

.story-caption-line {
    font-size: clamp(14px, 3.4vw, 17px);
    line-height: 1.7;
    color: var(--paper);
}

.story-hint {
    font-size: clamp(11px, 2.8vw, 13px);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.55);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   STORY COMIC OVERLAY (StoryComic.tsx) — opaque full-screen cutscene layer
   that fully covers the Phaser canvas so story text never visually overlaps
   active gameplay.
   ========================================================================== */

.story-container {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    background:
        radial-gradient(ellipse at 50% 18%, rgba(233, 196, 106, 0.16), transparent 55%),
        linear-gradient(180deg, #1a0f08 0%, #2b1810 45%, #120a06 100%);
    font-family: inherit;
    color: var(--paper, #fff6e8);
    overflow: hidden;
}

.story-top-bar {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 16px;
    z-index: 2;
}

.story-dots {
    display: flex;
    gap: 8px;
}

.story-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 246, 232, 0.25);
    border: 1px solid rgba(233, 196, 106, 0.5);
    transition: background 0.2s ease, transform 0.2s ease;
}

.story-dot.active {
    background: var(--gold-bright, #e9c46a);
    transform: scale(1.25);
    box-shadow: 0 0 8px rgba(233, 196, 106, 0.8);
}

.story-skip-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    min-height: 44px;
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(233, 196, 106, 0.55);
    border-radius: 8px;
    color: var(--gold-bright, #e9c46a);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.story-skip-btn:hover {
    background: rgba(233, 196, 106, 0.18);
    border-color: var(--gold-bright, #e9c46a);
}

.story-art-viewport {
    width: min(620px, 94vw);
    max-height: 46vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-art-viewport svg {
    width: 100%;
    height: auto;
    max-height: 46vh;
    display: block;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
}

.story-bottom-gradient {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 34vh;
    background: linear-gradient(180deg, transparent, rgba(10, 5, 2, 0.85) 60%);
    pointer-events: none;
}

.story-caption-box {
    position: relative;
    z-index: 2;
    width: min(640px, 94vw);
    padding: 18px 22px;
    background: rgba(18, 10, 6, 0.92);
    border: 1px solid rgba(233, 196, 106, 0.45);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    text-align: center;
}

.story-slide-title {
    margin: 0 0 10px;
    font-size: clamp(18px, 4.4vw, 26px);
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold-bright, #e9c46a);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.story-narration-text {
    margin: 0;
    font-size: clamp(14px, 3.4vw, 17px);
    line-height: 1.7;
    color: var(--paper, #fff6e8);
    min-height: 3.4em;
}

.story-cursor {
    display: inline-block;
    width: 9px;
    margin-left: 3px;
    color: var(--gold-bright, #e9c46a);
    animation: story-cursor-blink 0.8s steps(1) infinite;
}

@keyframes story-cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.story-action-row {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.story-keyboard-hint {
    font-size: clamp(11px, 2.8vw, 13px);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 246, 232, 0.55);
}

.story-next-btn {
    min-width: 180px;
    min-height: 52px;
    padding: 12px 26px;
    background: linear-gradient(180deg, #e9c46a, #bc8800);
    border: 1px solid #ffe8a8;
    border-radius: 10px;
    color: #1e1008;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(233, 196, 106, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.story-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(233, 196, 106, 0.55);
}

.story-next-btn:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    .story-art-viewport,
    .story-art-viewport svg {
        max-height: 34vh;
    }

    .story-keyboard-hint {
        display: none;
    }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS — mobile-first, adaptive touch targets + centering
   ========================================================================== */

/* ---- Mobile (<= 600px): one-handed thumb zone, hide decorative text ------ */

@media (max-width: 600px) {
    .menu-card,
    .pause-card,
    .over-card {
        width: min(440px, 94vw);
        gap: 12px;
    }

    /* Hide non-essential flavor text to prevent vertical overflow/scroll. */
    .menu-desc,
    .over-quote,
    .over-fact {
        display: none;
    }

    .btn {
        min-width: 220px;
        min-height: 60px;
        width: 100%;
        max-width: 320px;
    }

    .hud-btn {
        width: 52px;
        height: 52px;
    }
}

/* ---- Short viewports (<= 700px height, landscape phones): compact cards -- */

@media (max-height: 700px) {
    .menu-card,
    .pause-card,
    .over-card {
        gap: 8px;
        padding: 16px;
    }
    .menu-desc,
    .over-quote {
        display: none;
    }
    .menu-title {
        font-size: clamp(44px, 12vh, 64px);
    }
    .zone-banner {
        top: 14%;
    }
    .btn {
        min-height: 52px;
        padding: 12px 26px;
    }
}

/* ---- Touch devices (no hover, coarse pointer): enlarge hit areas --------- */

@media (hover: none) and (pointer: coarse) {
    .hud-btn {
        width: 56px;
        height: 56px;
    }
    .btn {
        min-height: 60px;
    }
    .btn-primary:hover {
        transform: none;
    }
}

/* ---- Tablet (601px - 1024px): scale touch targets, rebalance padding ----- */

@media (min-width: 601px) and (max-width: 1024px) {
    .hud-btn {
        width: 52px;
        height: 52px;
    }
    .menu-card,
    .pause-card,
    .over-card {
        width: min(460px, 80vw);
        padding: clamp(26px, 4vw, 40px);
    }
    .btn {
        min-height: 56px;
    }
}

/* ---- Desktop (> 1024px): ambient backdrop, hover states, roomier cards --- */

@media (min-width: 1025px) {
    #app {
        background:
            radial-gradient(ellipse at 50% 30%, rgba(249, 160, 63, 0.10) 0%, rgba(0, 0, 0, 0) 55%),
            radial-gradient(ellipse at 50% 0%, #2a1608 0%, #0b0502 70%);
    }
    #game-container canvas {
        box-shadow: 0 0 90px rgba(249, 160, 63, 0.28), 0 0 0 1px rgba(249, 160, 63, 0.12);
    }
    .menu-card,
    .pause-card,
    .over-card {
        width: min(460px, 40vw);
        padding: 40px;
        gap: 18px;
    }
    .btn {
        min-height: 56px;
        transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    }
    .btn-ghost:hover {
        transform: translateY(-1px);
    }
    .hud-btn:hover {
        background: rgba(249, 160, 63, 0.28);
        transform: scale(1.05);
    }
}

/* ==========================================================================
   3-2-1 FLIGHT COUNTDOWN OVERLAY
   ========================================================================== */

.overlay-countdown {
    background: radial-gradient(circle at 50% 45%, rgba(20, 10, 4, 0.72) 0%, rgba(11, 5, 2, 0.88) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
}

.countdown-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 36px;
    border-radius: 28px;
    background: rgba(18, 10, 6, 0.85);
    border: 1px solid rgba(249, 160, 63, 0.35);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 40px rgba(249, 160, 63, 0.25);
    animation: countdownPop 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes countdownPop {
    0% {
        transform: scale(0.6);
        opacity: 0;
    }
    40% {
        transform: scale(1.12);
        opacity: 1;
    }
    70% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.countdown-eyebrow {
    font-size: clamp(10px, 2.5vw, 13px);
    font-weight: 800;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.countdown-number {
    font-size: clamp(72px, 18vw, 120px);
    font-weight: 900;
    line-height: 1;
    color: var(--gold-bright);
    text-shadow:
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 50px rgba(249, 160, 63, 0.6),
        0 4px 12px rgba(0, 0, 0, 0.8);
    font-family: inherit;
    margin: 4px 0 12px;
}

.countdown-number.countdown-fly {
    color: #ffd700;
    letter-spacing: 4px;
    font-size: clamp(60px, 16vw, 100px);
    animation: flyFlash 0.6s ease-out infinite alternate;
}

@keyframes flyFlash {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.9));
    }
    100% {
        transform: scale(1.08);
        filter: drop-shadow(0 0 45px rgba(249, 160, 63, 1));
    }
}

.countdown-subtitle {
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 600;
    color: var(--sand);
    max-width: 320px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.countdown-hint {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    background: rgba(249, 160, 63, 0.14);
    border: 1px solid rgba(249, 160, 63, 0.35);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--gold-bright);
}

/* ==========================================================================
   STORY COMIC OVERLAYS & CONTROLS
   ========================================================================== */

.comic-overlay {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #000;
    user-select: none;
    overflow: hidden;
}

.comic-skip-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 100;
    padding: 8px 16px;
    background: rgba(18, 10, 6, 0.7);
    border: 1px solid rgba(249, 160, 63, 0.5);
    border-radius: 20px;
    color: var(--gold-bright);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.comic-skip-btn:hover {
    background: rgba(249, 160, 63, 0.3);
    border-color: var(--gold-bright);
    transform: scale(1.04);
}

.comic-narrator-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(18, 10, 6, 0.75);
    border: 1px solid rgba(249, 160, 63, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.narrator-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffd700, #c05c10);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.narrator-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--sand);
    text-transform: uppercase;
}

.comic-narration-box {
    position: absolute;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 100;
    background: rgba(16, 8, 4, 0.88);
    border: 1px solid rgba(249, 160, 63, 0.4);
    border-radius: 18px;
    padding: 16px 20px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.comic-narration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comic-slide-counter {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--gold);
    text-transform: uppercase;
}

.comic-slide-title {
    font-size: 16px;
    font-weight: 800;
    color: #fff6e8;
    letter-spacing: 0.5px;
}

.comic-narration-text {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
    color: #f7ebdb;
    min-height: 48px;
    margin: 0;
}

.comic-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
}

.comic-indicators {
    display: flex;
    gap: 8px;
}

.comic-dot {
    width: 24px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.25s ease;
}

.comic-dot.active {
    background: var(--gold-bright);
    width: 38px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.comic-next-btn {
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--gold-bright), var(--ember));
    border: none;
    border-radius: 24px;
    color: #120a06;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(249, 160, 63, 0.4);
    transition: all 0.2s ease;
}

.comic-next-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 22px rgba(255, 215, 0, 0.6);
}

.comic-next-btn.begin-btn {
    background: linear-gradient(135deg, #ffd700, #ff4500);
    box-shadow: 0 0 24px rgba(255, 140, 0, 0.7);
    animation: beginPulse 1.2s infinite alternate;
}

@keyframes beginPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.06); filter: brightness(1.2); }
}