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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a0f;
    font-family: 'Courier New', monospace;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Fullscreen Canvas ─────────────────────────────────────── */

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    image-rendering: auto;
}

/* ── Screen Rotation Prompt ────────────────────────────────── */

#rotatePrompt {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0f;
    z-index: 200;
}

.rotate-text {
    color: #555;
    font-size: clamp(14px, 2.5vw, 20px);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

@media screen and (orientation: landscape) {
    #rotatePrompt { display: none !important; }
}

/* ── Overlays (menu, game over) ───────────────────────────── */

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: auto;
}

.overlay.hidden {
    display: none;
    pointer-events: none;
}

.overlay.active {
    background: rgba(5, 5, 12, 0.92);
}

.menu-overlay {
    gap: clamp(10px, 2.4vh, 18px);
    background:
        linear-gradient(180deg, rgba(4, 7, 14, 0.72), rgba(4, 7, 14, 0.28) 45%, rgba(4, 7, 14, 0.76)),
        linear-gradient(90deg, rgba(4, 7, 14, 0.88), rgba(4, 7, 14, 0.18) 38%, rgba(4, 7, 14, 0.64));
}

.menu-overlay.active {
    background:
        linear-gradient(180deg, rgba(4, 7, 14, 0.72), rgba(4, 7, 14, 0.28) 45%, rgba(4, 7, 14, 0.76)),
        linear-gradient(90deg, rgba(4, 7, 14, 0.88), rgba(4, 7, 14, 0.18) 38%, rgba(4, 7, 14, 0.64));
}

.title {
    color: #c8f7ff;
    font-size: clamp(32px, 7vw, 64px);
    letter-spacing: 0.15em;
    text-transform: lowercase;
    margin-bottom: 0.6em;
}

.subtitle-tap {
    color: #556;
    font-size: clamp(12px, 2vw, 18px);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
}

.menu-overlay .title {
    margin-bottom: 0;
    text-shadow:
        0 0 14px rgba(155, 231, 255, 0.52),
        0 0 34px rgba(155, 231, 255, 0.18);
}

.menu-stats,
.menu-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: clamp(14px, 4vw, 34px);
    max-width: min(560px, calc(100vw - 32px));
    color: #9fb4bd;
    font-size: clamp(11px, 1.7vw, 15px);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(4, 7, 14, 0.8);
}

.menu-stats strong {
    color: #e8fbff;
}

.menu-controls {
    color: #d7f9ff;
}

.menu-controls span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.menu-controls strong {
    display: inline-grid;
    place-items: center;
    width: clamp(20px, 3.8vw, 24px);
    height: clamp(20px, 3.8vw, 24px);
    border: 1px solid rgba(200, 247, 255, 0.42);
    border-radius: 4px;
    color: #f7feff;
    background: rgba(3, 10, 18, 0.46);
    box-shadow: 0 0 12px rgba(155, 231, 255, 0.16);
}

.menu-sound {
    color: #9be7ff;
    font-size: clamp(10px, 1.5vw, 13px);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.84;
    text-shadow: 0 0 10px rgba(155, 231, 255, 0.28);
}

.menu-sound.muted {
    color: #ff9aa9;
    text-shadow: 0 0 10px rgba(255, 90, 130, 0.32);
}

/* ── Stats (game over) ─────────────────────────────────────── */

.stats {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    margin-bottom: 0.8em;
}

.stat-line {
    color: #aab;
    font-size: clamp(14px, 2.5vw, 22px);
    letter-spacing: 0.1em;
}

.stat-line strong {
    color: #c8f7ff;
}

.stat-line.best {
    margin-top: 0.3em;
    padding-top: 0.3em;
    border-top: 1px solid #222;
}

.stat-line.new-best {
    color: #ffe86b;
    font-weight: bold;
    text-align: center;
    text-shadow:
        0 0 10px rgba(255, 232, 107, 0.7),
        0 0 24px rgba(255, 232, 107, 0.28);
    animation: best-pop 0.8s ease-out both, pulse 1.8s ease-in-out 0.8s infinite;
}

.stat-line.new-best.hidden {
    display: none;
}

.overlay.gameover-pop .title {
    animation: gameover-pop 0.42s ease-out both;
}

.tap-again {
    animation: pulse 2s ease-in-out infinite;
    animation-delay: 0.5s;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

@keyframes gameover-pop {
    0%   { transform: scale(0.92); opacity: 0; }
    70%  { transform: scale(1.04); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes best-pop {
    0%   { transform: translateY(8px) scale(0.9); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ── HUD ───────────────────────────────────────────────────── */

.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 32px);
    z-index: 50;
    pointer-events: none;
}

.hud.hidden { display: none; }

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.biome-progress {
    position: absolute;
    top: clamp(10px, 2vh, 18px);
    left: 50%;
    width: min(240px, 34vw);
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.biome-name {
    color: #e8fbff;
    font-size: clamp(10px, 1.6vw, 14px);
    font-weight: bold;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(155, 231, 255, 0.42);
}

.biome-track {
    width: 100%;
    height: 5px;
    margin-top: 6px;
    border: 1px solid rgba(200, 247, 255, 0.24);
    border-radius: 2px;
    overflow: hidden;
    background: rgba(2, 5, 12, 0.56);
}

.biome-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #9be7ff, #ffe66d);
    box-shadow: 0 0 10px rgba(155, 231, 255, 0.58);
}

.biome-infinity {
    margin-top: 0;
    color: #e8fbff;
    font-size: clamp(18px, 3vw, 28px);
    line-height: 0.9;
    text-shadow: 0 0 12px rgba(155, 231, 255, 0.55);
}

.biome-infinity.hidden,
.biome-track.hidden {
    display: none;
}

/* Score */

.score-display {
    color: #c8f7ff;
    font-size: clamp(24px, 5vw, 42px);
    font-weight: bold;
    letter-spacing: 0.1em;
    text-shadow: 0 0 12px rgba(200, 247, 255, 0.3);
}

/* Coins */

.coin-display {
    color: #fd3;
    font-size: clamp(14px, 2.5vw, 22px);
    letter-spacing: 0.08em;
    text-shadow: 0 0 8px rgba(255, 220, 60, 0.3);
}

.life-display {
    color: #ff7795;
    font-size: clamp(14px, 2.5vw, 22px);
    letter-spacing: 0.08em;
    text-shadow: 0 0 8px rgba(255, 90, 130, 0.35);
}

.wing-status {
    color: #9be7ff;
    font-size: clamp(11px, 1.8vw, 15px);
    letter-spacing: 0.14em;
    text-align: right;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(120, 230, 255, 0.25);
}

.audio-status {
    color: #c8f7ff;
    font-size: clamp(10px, 1.5vw, 13px);
    letter-spacing: 0.12em;
    text-align: right;
    text-transform: uppercase;
    opacity: 0.82;
    text-shadow: 0 0 8px rgba(200, 247, 255, 0.22);
}

.audio-status.muted {
    color: #ff9aa9;
    text-shadow: 0 0 10px rgba(255, 90, 130, 0.35);
}

/* Stamina bar */

.stamina-bar-container {
    width: clamp(100px, 20vw, 180px);
    height: clamp(8px, 1.5vh, 14px);
    border: 1px solid #335;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
}

.stamina-bar {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #4a8, #6c4);
    transition: width 0.05s linear;
}

.stamina-bar.locked {
    background: linear-gradient(90deg, #445, #667);
}

/* ── Touch Feedback ────────────────────────────────────────── */

.touch-feedback {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    pointer-events: none;
}

.touch-feedback.hidden {
    display: none;
}

.touch-zone {
    width: 50%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.08s ease-out;
}

.touch-zone.active {
    opacity: 1;
}

.sprint-zone {
    background:
        linear-gradient(90deg, rgba(118, 255, 168, 0.18), rgba(118, 255, 168, 0)),
        radial-gradient(circle at 24% 70%, rgba(214, 246, 109, 0.22), rgba(214, 246, 109, 0) 34%);
}

.jump-zone {
    background:
        linear-gradient(270deg, rgba(155, 231, 255, 0.2), rgba(155, 231, 255, 0)),
        radial-gradient(circle at 76% 58%, rgba(180, 245, 255, 0.26), rgba(180, 245, 255, 0) 34%);
}

/* ── Debug Overlay ─────────────────────────────────────────── */

.debug-overlay {
    position: fixed;
    left: clamp(12px, 2vw, 24px);
    bottom: clamp(12px, 2vh, 24px);
    z-index: 60;
    min-width: 220px;
    max-width: min(340px, calc(100vw - 24px));
    padding: 8px 10px;
    border: 1px solid rgba(155, 231, 255, 0.28);
    border-radius: 4px;
    background: rgba(2, 5, 12, 0.78);
    color: #bff6ff;
    font-size: 10px;
    line-height: 1.35;
    letter-spacing: 0;
    pointer-events: none;
    text-shadow: 0 0 8px rgba(120, 230, 255, 0.25);
}

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

.debug-title {
    margin-bottom: 3px;
    color: #fff;
    font-weight: bold;
    text-transform: uppercase;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    white-space: nowrap;
}

.debug-row span:first-child {
    color: #6f9da8;
}

/* ── Theme Stinger ─────────────────────────────────────────── */

.theme-stinger {
    position: fixed;
    top: 23%;
    left: 50%;
    z-index: 55;
    transform: translateX(-50%);
    color: #e8fbff;
    font-size: clamp(14px, 2.6vw, 24px);
    font-weight: bold;
    letter-spacing: 0.18em;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
    text-shadow:
        0 0 10px rgba(155, 231, 255, 0.75),
        0 0 24px rgba(155, 231, 255, 0.35);
    transition: opacity 0.12s linear, transform 0.12s linear;
}

.theme-stinger.hidden {
    display: none;
}
