/* The arcade's pixel font (Press Start 2P, SIL OFL 1.1: flight/static/flight/fonts/OFL.txt), served from
   this site (the page's CSP allows fonts from 'self' only). Used in ARCADE. */
@font-face {
    font-family: "Press Start 2P"; font-display: swap;
    src: url("../fonts/press-start-2p-latin.5c7e04d0202b.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Press Start 2P"; font-display: swap;
    src: url("../fonts/press-start-2p-latin-ext.d1de284c0403.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* The transmission before the launch (.tx) is set in Audiowide (SIL Open Font License, fonts/OFL-audiowide.txt): wide, rounded and sci-fi, with the
   Polish and Spanish letters (Orbitron, the first choice, has none of the Polish ones). Self-hosted for the same reason as above. */
@font-face {
    font-family: "Audiowide"; font-weight: 400; font-display: swap;
    src: url("../fonts/audiowide-latin.fa3af39df234.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Audiowide"; font-weight: 400; font-display: swap;
    src: url("../fonts/audiowide-latin-ext.783f59ac4281.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Standalone full-screen page for the FLIGHT game. Deliberately does not use
   the site stylesheet: the game is always dark/neon whatever theme is chosen. */

:root {
    --neon: #2b8cff;
    --neon-core: #bfe8ff;
    --danger: #ff7a1a;
    /* Held upright, the top bar sits right under the iPhone status bar, whose fade dims its upper edge:
       everything that hangs off the bar moves down by this much (landscape has no such overlap). */
    --bar-drop: 0px;
    --px: "Press Start 2P", ui-monospace, Menlo, Consolas, monospace;
}
@media (orientation: portrait) { :root { --bar-drop: 10px; } }
/* Installed on the home screen (no Safari bars, translucent status bar): the system fade over the top
   reaches further down than in the browser, so the bar sits lower there. Landscape is not affected. */
@media (orientation: portrait) and (display-mode: standalone), (orientation: portrait) and (display-mode: fullscreen) { :root { --bar-drop: 32px; } }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #000;
    color: var(--neon-core);
    font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
}

#game {
    position: fixed;
    inset: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}

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

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud[hidden] { display: none; }

.hud__score,
.hud__shield {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--neon);
}
.hud__score { left: max(16px, env(safe-area-inset-left)); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.hud__shield { right: max(16px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 10px; }
.hud__label { opacity: 0.7; font-size: 0.7rem; }
.hud__bar {
    display: block;
    width: min(200px, 30vw);
    height: 10px;
    border: 1px solid var(--neon-core);
    box-shadow: 0 0 10px var(--neon), inset 0 0 6px rgba(43, 140, 255, 0.5);
}
.hud__bar > span {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--neon-core);
    box-shadow: 0 0 10px var(--neon);
    transform-origin: left;
    transition: transform 0.15s;
}
.hud__shield.is-low .hud__bar > span { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

/* Four short diagonal strokes (an X) that do not touch: nothing in the middle, so a far-away
   obstacle stays visible right where the guns converge. */
.crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    opacity: 0.9;
    filter: drop-shadow(0 0 3px var(--neon));
}
.crosshair svg { display: block; width: 100%; height: 100%; overflow: visible; }
.crosshair path { fill: none; stroke: var(--neon-core); stroke-width: 1.5; stroke-linecap: round; }

.topbar {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + var(--bar-drop));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    z-index: 5;
    /* The bar spans the whole width, but only its buttons are to be touched: in a phone held sideways
       "Fly again" sits right under it and the empty bar used to swallow the taps. */
    pointer-events: none;
}
.topbar a,
.topbar button { pointer-events: auto; }
.topbar__link,
.topbar__btn {
    color: var(--neon-core);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(43, 140, 255, 0.6);
    border-radius: 4px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
}
.topbar__link:hover, .topbar__btn:hover,
.topbar__link:focus-visible, .topbar__btn:focus-visible { border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); outline: none; }

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

.overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: rgba(0, 0, 0, 0.55);
    transition: opacity 0.4s;
}
/* The start screen sits low so the 3D FLIGHT sign above the horizon stays
   visible, like on the cover. */
#overlay-start {
    /* Content starts below the horizon and grows downwards (and scrolls if it
       must), so opening a panel never pushes it up over the sign. */
    justify-content: flex-start;
    padding-top: var(--menu-pad, 61vh); /* (the script raises it a little where the buttons would not fit: layoutMenu) */
    padding-bottom: max(24px, 4vh);
    gap: 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.6) 32%, rgba(0, 0, 0, 0) 50%);
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.overlay--hidden { opacity: 0; pointer-events: none; visibility: hidden; }
.overlay h1, .overlay h2, .overlay p { margin: 0; }
.overlay__lead { font-size: 1.1rem; letter-spacing: 0.08em; }
.overlay__note { font-size: 0.85rem; opacity: 0.7; }
.overlay__tagline { margin-top: -6px; font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.75; }
.overlay__note[hidden] { display: none; }

.neon {
    font-size: clamp(3rem, 14vw, 8rem);
    font-weight: 900;
    letter-spacing: 0.06em;
    color: transparent;
    -webkit-text-stroke: 2px var(--neon-core);
    text-shadow: 0 0 12px var(--neon), 0 0 32px var(--neon), 0 0 64px var(--neon);
}
.neon--small { font-size: clamp(2rem, 8vw, 4rem); }

.btn {
    margin-top: 8px;
    padding: 14px 34px;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--neon-core);
    /* A dark base under the tint: the 3D sign behind must not show through. */
    background: linear-gradient(rgba(43, 140, 255, 0.12), rgba(43, 140, 255, 0.12)), rgba(2, 8, 22, 0.85);
    border: 2px solid var(--neon-core);
    border-radius: 4px;
    box-shadow: 0 0 14px var(--neon), inset 0 0 14px rgba(43, 140, 255, 0.4);
    cursor: pointer;
}
.btn:hover, .btn:focus-visible { background: linear-gradient(rgba(43, 140, 255, 0.3), rgba(43, 140, 255, 0.3)), rgba(2, 8, 22, 0.85); outline: none; }

.help {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.7;
    opacity: 0.75;
}

.noscript, #overlay-nogl { font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
    .overlay { transition: none; }
    .hud__bar > span { transition: none; }
}

/* ---- Difficulty, leaderboard, score form, sharing --------------------- */

/* A tall overlay (game over with form + board + share) must scroll on a small
   screen instead of clipping; margin:auto on the children keeps it centred
   when it does fit. */
.overlay { overflow-y: auto; justify-content: flex-start; }
/* A tall overlay scrolls; its items must keep their height instead of
   squeezing (and overlapping) to fit. */
.overlay > * { flex-shrink: 0; }
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
#overlay-start > :first-child { margin-top: 0; }

/* Four choices: a 2x2 grid on phones (a single row of four is wider than the
   screen and clipped the outer buttons), one row from tablet width up. */
.difficulty {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: min(340px, 90vw);
    margin-top: 6px;
}
.difficulty { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(380px, 94vw); gap: 6px; }
@media (min-width: 560px) {
    .difficulty { grid-template-columns: repeat(4, auto); width: auto; }
}
.difficulty__opt {
    text-align: center;
    padding: 9px 4px;
    font: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--neon-core);
    background: rgba(2, 8, 22, 0.85);
    border: 1px solid rgba(43, 140, 255, 0.55);
    border-radius: 4px;
    cursor: pointer;
}
.difficulty__opt[aria-checked="true"] {
    background: linear-gradient(rgba(43, 140, 255, 0.35), rgba(43, 140, 255, 0.35)), rgba(2, 8, 22, 0.9);
    border-color: var(--neon-core);
    box-shadow: 0 0 10px var(--neon);
}
.difficulty__opt:focus-visible { outline: 2px solid var(--neon-core); outline-offset: 2px; }

.linkrow { display: flex; gap: 10px; }
.linkrow__btn, .share__btn {
    padding: 6px 12px;
    font: inherit;
    font-size: 0.8rem;
    color: var(--neon-core);
    background: rgba(2, 8, 22, 0.85);
    border: 1px solid rgba(43, 140, 255, 0.45);
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
.linkrow__btn[aria-expanded="true"] { border-color: var(--neon-core); box-shadow: 0 0 8px var(--neon); }
.linkrow__btn:hover, .share__btn:hover,
.linkrow__btn:focus-visible, .share__btn:focus-visible { border-color: var(--neon-core); outline: none; }

.panel[hidden], .board[hidden], .share[hidden], .submit[hidden] { display: none; }
.panel { min-height: 0; }

.board {
    width: min(340px, 90vw);
    font-size: 0.9rem;
    text-align: left;
}
.board__title { margin: 0 0 6px; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; text-align: center; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 3px 8px;
    border-bottom: 1px solid rgba(43, 140, 255, 0.2);
    font-variant-numeric: tabular-nums;
}
.board li.is-me { color: #fff; background: rgba(43, 140, 255, 0.22); }
.board__pos { width: 1.8em; opacity: 0.6; }
/* Nicknames can be 25 characters: wrap them instead of cutting the joke off. */
.board__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.board__msg { text-align: center; opacity: 0.7; margin: 4px 0 10px; }

.submit { width: min(340px, 90vw); }
.submit__label { display: block; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; margin-bottom: 4px; }
.submit__row { display: flex; gap: 8px; }
.submit input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font: inherit;
    font-size: 1rem; /* 16px+ stops iOS zooming into the field */
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--neon-core);
    border-radius: 4px;
}
.submit input:focus-visible { outline: 2px solid var(--neon); outline-offset: 1px; }
/* `.overlay p { margin: 0 }` is more specific than a lone class, so the hint
   needs the parent in the selector for its gap to apply. */
.submit .submit__hint { margin: 12px 0 0; font-size: 0.75rem; line-height: 1.4; opacity: 0.8; min-height: 1.2em; text-shadow: 0 0 3px #000, 0 0 8px #000; }
.submit .submit__hint.is-error { color: var(--danger); opacity: 1; }
.btn--small { margin-top: 0; padding: 8px 14px; font-size: 0.85rem; }

.share { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 90vw; }
/* icon-only buttons: all the same size, whatever the platform */
.share__btn { width: 48px; height: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; }
.share__btn svg { width: 22px; height: 22px; display: block; }
.share__prompt { margin: 0; font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--neon-core); text-shadow: 0 0 8px var(--neon); }
.share__prompt:empty { display: none; }

/* A short glow on the share buttons right after a run, to show they exist. */
@keyframes share-nudge {
    0%, 100% { border-color: rgba(43, 140, 255, 0.45); box-shadow: 0 0 0 rgba(43, 140, 255, 0); transform: scale(1); }
    50% { border-color: var(--neon-core); box-shadow: 0 0 14px var(--neon), inset 0 0 8px rgba(43, 140, 255, 0.4); transform: scale(1.06); }
}
.share.is-nudging .share__btn { animation: share-nudge 1.1s ease-in-out var(--nudge-count, 3); }
@media (prefers-reduced-motion: reduce) {
    .share.is-nudging .share__btn { animation: none; border-color: var(--neon-core); box-shadow: 0 0 8px var(--neon); }
}

/* Overlays can scroll on a phone; #game blocks browser panning for the flight. */
.overlay { touch-action: pan-y; }

/* ---- Obstacle kinds, status effects, repair cells ---------------------- */

.hud__status {
    position: absolute;
    left: 50%;
    bottom: max(56px, calc(env(safe-area-inset-bottom) + 40px));
    transform: translateX(-50%);
    display: flex;
    gap: 14px;
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
}
.status--jam { color: #ffe14a; text-shadow: 0 0 8px #ffe14a; animation: blink 0.5s steps(2) infinite; }
.status--poison { color: #d24dff; text-shadow: 0 0 8px #d24dff; }
@keyframes blink { 50% { opacity: 0.35; } }

.crosshair.is-jammed { filter: drop-shadow(0 0 4px #ffe14a); }
.crosshair.is-jammed path { stroke: #ffe14a; stroke-dasharray: 2 3; }
.hud__shield.is-poisoned .hud__bar > span { background: #d24dff; box-shadow: 0 0 10px #d24dff; }

.pop {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: 800;
    text-shadow: 0 0 14px currentColor;
    animation: pop 1s ease-out forwards;
}
@keyframes pop { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -50px); } }

.legend { list-style: none; margin: 0; padding: 0; width: min(380px, 90vw); text-align: left; font-size: 0.85rem; }
.legend[hidden] { display: none; }
.legend li { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
/* Colour and shape both carry the meaning. */
.swatch { flex: none; width: 22px; height: 22px; border: 2px solid currentColor; display: inline-block; }
.swatch--cube    { color: #ff7a1a; background: #5a2106; }
.swatch--pillar  { color: #ff3040; background: #560a12; width: 14px; height: 24px; margin: 0 4px; }
.swatch--crystal { color: #ffe14a; background: #544806; transform: rotate(45deg) scale(0.8); }
.swatch--toxin   { color: #d24dff; background: #3d1356; border-radius: 50%; }
.swatch--wall    { color: #f2f6ff; background: linear-gradient(#45ff8a, #45ff8a) center / 8px 8px no-repeat, #1a2233; }
.swatch--cell    { color: #45ff8a; border-radius: 50%; background: transparent; box-shadow: 0 0 8px #45ff8a; }

@media (prefers-reduced-motion: reduce) {
    .status--jam { animation: none; }
    .pop { animation-duration: 0.01s; }
}

/* ---- Levels: HUD, banner, board column ------------------------------- */

.hud__level {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(230px, 40vw);
    text-align: center;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--neon);
    font-variant-numeric: tabular-nums;
}
.hud__levelrow { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.hud__goal { margin: 4px 0 3px; opacity: 0.85; }
.hud__bar--goal { width: 100%; height: 6px; }
.hud__bar--goal.is-met > span { background: #45ff8a; box-shadow: 0 0 10px #45ff8a; }
.hud__bar--goal > span { transform: scaleX(0); }

/* "LEVEL 2 / Sunset Drive / Destroy 64 of 85 obstacles" fading in and out. */
.banner {
    position: absolute;
    left: 0; right: 0;
    top: 30%;
    text-align: center;
    pointer-events: none;
}
.banner[hidden] { display: none; }
.banner--show { animation: banner 4.6s ease-out forwards; }
.banner--show.banner--short { animation-duration: 1.8s; } /* the goals follow as captions (see .goalcap) */
.banner__level {
    font-size: clamp(2rem, 8vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: transparent;
    -webkit-text-stroke: 2px var(--neon-core);
    text-shadow: 0 0 14px var(--neon), 0 0 40px var(--neon);
}
.banner__name { font-size: clamp(1rem, 3.5vw, 1.6rem); letter-spacing: 0.2em; text-transform: uppercase; margin-top: 4px; }
.banner__goal { font-size: 0.9rem; opacity: 0.75; margin-top: 8px; }
.banner--show .banner__goal { animation: banner-goal 0.7s ease-out 2.3s both; }
@keyframes banner-goal { from { opacity: 0; } to { opacity: 0.75; } }

/* Decoding titles: each character is its real letter (kept invisible while
   alien, so it holds its width) with an alien glyph laid over it. */
.dec { position: relative; display: inline-block; }
.dec__real { opacity: 0; }
.dec .alien {
    position: absolute;
    left: 50%; top: 50%;
    width: 0.62em; height: 0.88em;
    transform: translate(-50%, -52%);
    fill: none;
    stroke: #7dffd4;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 4px #1fd5a0);
    opacity: 0.85;
}
/* The banner's big "LEVEL n" is outlined text; a settled letter must show. */
.dec--flash { animation: dec-flash 0.45s ease-out; }
@keyframes dec-flash {
    from { color: #fff; text-shadow: 0 0 18px #fff, 0 0 34px var(--neon-core); -webkit-text-stroke-color: #fff; }
}
@keyframes banner {
    0% { opacity: 0; transform: scale(1.1); }
    6% { opacity: 1; transform: scale(1); }
    84% { opacity: 1; }
    100% { opacity: 0; }
}

.board__lvl { width: 2.6em; text-align: center; opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
    .banner--show { animation-duration: 2.5s; }
    .banner--show .banner__goal, .dec--flash { animation: none; }
}

/* ---- Combo, floating labels, first-run hint, listen button ------------- */

.hud__combo {
    position: absolute;
    left: max(16px, env(safe-area-inset-left));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 40px);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--neon);
    font-variant-numeric: tabular-nums;
}
.hud__combo[hidden] { display: none; }
.hud__combo.is-hot { color: #ffe14a; text-shadow: 0 0 10px #ffb000; }
.hud__combobar { display: block; width: 120px; height: 4px; margin-top: 4px; background: rgba(43, 140, 255, 0.25); }
.hud__combobar > span { display: block; height: 100%; background: currentColor; transform-origin: left; }

/* A label that appears where something happened and drifts up. */
.pop--at {
    left: 50%; top: 50%;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    animation: popat 0.9s ease-out forwards;
}
.pop--graze { color: #9fe8ff; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em; }
.pop--hot { color: #ffe14a; font-size: 1.25rem; }
@keyframes popat {
    from { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
    15% { transform: translate(-50%, -60%) scale(1.1); }
    to { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}

.hint {
    position: absolute;
    left: 50%;
    bottom: 22%;
    transform: translateX(-50%);
    max-width: min(420px, 88vw);
    padding: 10px 16px;
    text-align: center;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(43, 140, 255, 0.6);
    border-radius: 4px;
    animation: hint 7s ease-in-out forwards;
}
.hint[hidden] { display: none; }
@keyframes hint { 0%, 100% { opacity: 0; } 8%, 85% { opacity: 1; } }

.difficulty__hint { margin: 0; min-height: 2.4em; max-width: min(380px, 88vw); font-size: 0.8rem; opacity: 0.75; }

.btn--ghost { text-decoration: none; background: transparent; box-shadow: none; display: inline-block; }
.btn--ghost:hover, .btn--ghost:focus-visible { background: rgba(43, 140, 255, 0.2); }
#listen { margin-top: 0; padding: 10px 22px; font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
    .pop--at { animation-duration: 0.01s; }
    .hint { animation: none; }
}

/* ---- Tutorial ---------------------------------------------------------- */

/* The training flight has no score, combo or level to show. */
.hud.is-tutorial .hud__level,
.hud.is-tutorial .hud__score,
.hud.is-tutorial .hud__combo { display: none; }

/* The lessons are captions, not a panel: big pixel letters just above the middle of the screen, one
   line at a time, typed out in the colour of the thing they talk about ([y] yellow, [p] purple, [g]
   green, [r] red). The layer itself ignores the pointer, so steering and shooting go straight through. */
.tutorial {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
}
.tutorial[hidden] { display: none; }
.tutorial__stage {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translateX(-50%);
    width: min(92vw, 900px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    transition: opacity 0.15s;
}
.tutorial__text {
    margin: 0;
    text-align: center;
    font-family: var(--px);
    font-size: clamp(14px, min(3.6vw, 6vh), 36px);
    line-height: 1.6;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #eaf8ff;
    text-shadow: 0 0 6px var(--neon), 0 0 22px var(--neon), 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000;
    transition: opacity 0.2s;
}
/* The part not typed yet stays in the layout (so the line does not shift as it grows), just unseen. */
.tutorial__rest { visibility: hidden; }
.tutorial__text.is-out { opacity: 0; }
.tutorial__text.is-y { color: #ffd23f; text-shadow: 0 0 6px #ff9a00, 0 0 22px #ff9a00, 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000; }
.tutorial__text.is-p { color: #d9a3ff; text-shadow: 0 0 6px #a238ff, 0 0 22px #a238ff, 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000; }
.tutorial__text.is-g { color: #7dffa8; text-shadow: 0 0 6px #17c15a, 0 0 22px #17c15a, 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000; }
.tutorial__text.is-o { color: #ffb066; text-shadow: 0 0 6px #ff7a00, 0 0 22px #ff7a00, 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000; }
.tutorial__text.is-r { color: #ff8a8a; text-shadow: 0 0 6px #ff2d2d, 0 0 22px #ff2d2d, 0 3px 0 rgba(0, 0, 0, 0.85), 0 0 3px #000; }
/* A lesson the player has not managed for a while: the instruction breathes. */
.tutorial__text.is-nudge { animation: tut-nudge 1.4s ease-in-out infinite; }
@keyframes tut-nudge { 50% { opacity: 0.55; } }

#tut-next { pointer-events: auto; margin-top: 0; }
.tutorial__foot #tut-next { padding: 8px 14px; min-height: 44px; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: none; white-space: nowrap; }
/* Steps about the column of buttons at the right edge: the caption leaves room for it. The pause screen
   takes over the middle, so the captions step aside while it is up. */
.tutorial.has-side .tutorial__stage { width: calc(100vw - 150px); }
.tutorial.is-paused .tutorial__stage, .tutorial.is-paused .tutorial__ok { opacity: 0; }
/* The button a step is about: a yellow ring that pulses. */
.is-spot { border-color: #ffd23f !important; animation: tut-spot 1.1s ease-in-out infinite; }
@keyframes tut-spot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.9), 0 0 14px #ffd23f; }
    50% { box-shadow: 0 0 0 10px rgba(255, 210, 63, 0), 0 0 24px #ffd23f; }
}

/* Done: a big green word in the middle. */
.tutorial__ok {
    position: absolute;
    left: 50%;
    top: 38%;
    margin: 0;
    transform: translate(-50%, -50%) scale(0.6);
    font-family: var(--px);
    font-size: clamp(28px, min(9vw, 14vh), 84px);
    text-transform: uppercase;
    white-space: nowrap;
    color: #45ff8a;
    text-shadow: 0 0 10px #17c15a, 0 0 36px #17c15a, 0 4px 0 rgba(0, 0, 0, 0.85);
    opacity: 0;
}
.tutorial.is-ok .tutorial__stage { opacity: 0; }
.tutorial.is-ok .tutorial__ok { animation: tut-ok 1s ease-out forwards; }
@keyframes tut-ok {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    22% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
    40%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* Progress and the ways out: small and low, but always there (skipping stays one easy tap). */
.tutorial__foot {
    position: absolute;
    left: 50%;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 34px); /* above the shield bar in the corner */
    transform: translateX(-50%);
    width: min(94vw, 640px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2px 14px;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.tutorial__step { opacity: 0.7; }
.tutorial__dots { display: inline-flex; gap: 5px; }
.tutorial__dots span { width: 7px; height: 7px; border: 1px solid var(--neon-core); border-radius: 50%; }
.tutorial__dots .is-done { background: #45ff8a; border-color: #45ff8a; }
.tutorial__dots .is-now { background: var(--neon-core); }
.tutorial__skip {
    pointer-events: auto;
    min-height: 44px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: none;
    color: var(--neon-core);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(191, 232, 255, 0.55);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.tutorial__skip:hover, .tutorial__skip:focus-visible { background: rgba(43, 140, 255, 0.3); outline: none; box-shadow: 0 0 10px var(--neon); }
/* "Don't show again": quieter than Skip, but still a comfortable tap target. */
.tutorial__off {
    pointer-events: auto;
    min-height: 38px;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: none;
    color: var(--neon-core);
    opacity: 0.8;
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(191, 232, 255, 0.45);
    text-underline-offset: 3px;
}
.tutorial__off:hover, .tutorial__off:focus-visible { opacity: 1; outline: none; text-decoration-color: var(--neon-core); }

/* The goals at the start of a level: captions like the tutorial's, a little below the banner's title. */
.goalcap { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); width: min(92%, 900px); text-align: center; pointer-events: none; }
.goalcap__text { font-size: clamp(13px, min(3.1vw, 5vh), 30px); }

/* The opening cutscene (launch from the base): captions as in the goals, and a small "skip" line at the bottom. */
.launch { position: absolute; inset: 0; pointer-events: none; }
.launch[hidden] { display: none; }
/* The transmission before the launch: a black screen, a blinking cursor, lines typed one by one, then one blinking word: START.
   It keeps clear of the top bar (exit, pause, sound) and of the notch and rounded corners (safe areas), and is set smaller than the
   captions: five paragraphs have to fit on a phone held either way. */
.tx { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; overflow-y: auto; box-sizing: border-box; background: #000;
    padding: calc(max(12px, env(safe-area-inset-top)) + var(--bar-drop, 0px) + 64px) max(28px, calc(env(safe-area-inset-right) + 20px)) max(24px, calc(env(safe-area-inset-bottom) + 16px)) max(28px, calc(env(safe-area-inset-left) + 20px)); }
.tx[hidden] { display: none; }
.tx__screen { flex: none; width: min(100%, 760px); font-family: "Audiowide", ui-monospace, Menlo, Consolas, monospace; font-weight: 400; font-size: clamp(12px, min(2.1vw, 3.5vh), 19px); line-height: 1.6; letter-spacing: 0.02em; color: #bfe9ff; text-shadow: 0 0 6px var(--neon), 0 0 16px rgba(43, 140, 255, 0.55); }
.tx__line { margin: 0 0 0.8em; min-height: 1.6em; }
.tx__line.is-head { color: #eaf8ff; letter-spacing: 0.14em; }
.tx__rest { color: transparent; text-shadow: none; } /* the part not typed yet keeps its place, so the line does not jump */
.tx__cursor { display: inline-block; width: 0.6em; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; background: #bfe9ff; box-shadow: 0 0 8px var(--neon); animation: tx-blink 1.1s steps(1) infinite; }
.tx__cursor.is-typing { animation: none; }
@keyframes tx-blink { 50% { opacity: 0; } }
/* START: one word, no frame; it breathes slowly (about 0.8 times a second, between full and a quarter of its brightness, never a flash). */
.tx .tx__go { flex: none; margin: 10px 0 0; padding: 12px 30px; min-height: 44px; font-family: "Audiowide", ui-monospace, Menlo, Consolas, monospace; font-weight: 400; text-transform: none; box-shadow: none; font-size: clamp(18px, min(4vw, 5.5vh), 28px); letter-spacing: 0.32em; text-indent: 0.32em; color: #eaf8ff; text-shadow: 0 0 8px var(--neon), 0 0 22px var(--neon); background: none; border: 0; cursor: pointer; animation: tx-start 1.25s ease-in-out infinite; }
.tx .tx__go[hidden] { display: none; }
.tx .tx__go:hover, .tx .tx__go:focus-visible { background: none; box-shadow: none; outline: none; } /* (the blinking word is the focus mark) */
@keyframes tx-start { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.tx__skip { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); padding: 8px 12px; min-height: 44px; font: inherit; font-size: 0.8rem; letter-spacing: 0.08em; color: #bfe9ff; background: none; border: 0; opacity: 0.6; cursor: pointer; }
.tx__skip:hover, .tx__skip:focus-visible { opacity: 1; }
@media (max-height: 520px) { .tx { padding-top: calc(max(12px, env(safe-area-inset-top)) + var(--bar-drop, 0px) + 52px); } .tx__line { margin-bottom: 0.5em; } .tx .tx__go { margin-top: 2px; padding: 6px 24px; min-height: 40px; } }
@media (prefers-reduced-motion: reduce) { .tx__cursor, .tx .tx__go { animation: none; } }
.launch__skip { position: absolute; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 0.8rem; letter-spacing: 0.08em; opacity: 0.6; }

/* With a panel open the start screen slides up (revealStartPanel()); what slides under the bar at the top fades out
   instead of showing through between its buttons. */
#overlay-start.has-panel {
    -webkit-mask-image: linear-gradient(to bottom, transparent calc(var(--bar-drop, 0px) + 58px), #000 calc(var(--bar-drop, 0px) + 86px));
    mask-image: linear-gradient(to bottom, transparent calc(var(--bar-drop, 0px) + 58px), #000 calc(var(--bar-drop, 0px) + 86px));
}

/* "How to play": a window of its own, over the start screen. */
#overlay-howto { z-index: 8; background: rgba(0, 0, 0, 0.78); }
.howto-win {
    width: min(34rem, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 14px; padding: 20px;
    text-align: left; background: rgba(4, 10, 28, 0.94); border: 1px solid rgba(43, 140, 255, 0.6); border-radius: 10px;
    box-shadow: 0 0 24px rgba(43, 140, 255, 0.3);
}
.howto-win__title { font-size: 1.3rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--neon-core); text-shadow: 0 0 10px var(--neon); }
.howto-win__scroll { position: relative; min-height: 0; display: flex; flex-direction: column; }
.howto-win__body { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
/* Chevrons at the bottom and at the top of the text while there is more to scroll to in that direction (howtoMore()
   toggles .has-more and .has-less). A slow bob, about 0.6 times a second, well under the flashing limit; still with
   reduced motion. */
.howto-win__more {
    position: absolute; z-index: 1; left: 50%; bottom: 6px; margin-left: -14px;
    fill: none; stroke: var(--neon-core); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
    filter: drop-shadow(0 0 4px var(--neon));
    pointer-events: none; opacity: 0; transition: opacity 0.25s;
}
.howto-win__more--up { bottom: auto; top: 6px; }
/* The strips under the chevrons: the first and last lines of the text fade out into the window's background. */
.howto-win__scroll::before, .howto-win__scroll::after {
    content: ""; position: absolute; left: 0; right: 0; height: 40px; pointer-events: none;
    opacity: 0; transition: opacity 0.25s;
}
.howto-win__scroll::after { bottom: 0; background: linear-gradient(to bottom, rgba(4, 10, 28, 0), rgba(4, 10, 28, 0.94) 70%); }
.howto-win__scroll::before { top: 0; z-index: 1; background: linear-gradient(to top, rgba(4, 10, 28, 0), rgba(4, 10, 28, 0.94) 70%); }
.howto-win__scroll.has-more::after, .howto-win__scroll.has-less::before { opacity: 1; }
.howto-win__scroll.has-more .howto-win__more:not(.howto-win__more--up) { opacity: 0.9; animation: howto-more-bob 1.6s ease-in-out infinite; }
.howto-win__scroll.has-less .howto-win__more--up { opacity: 0.9; animation: howto-less-bob 1.6s ease-in-out infinite; }
@keyframes howto-more-bob { 50% { transform: translateY(4px); } }
@keyframes howto-less-bob { 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .howto-win__scroll .howto-win__more { animation: none !important; } }
.howto-win h3 { margin: 0 0 4px; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--neon-core); opacity: 0.85; }
.howto-win p, .howto-win li { font-size: 0.9rem; line-height: 1.5; }
.howto-win .help { margin: 0; opacity: 0.95; font-size: 0.9rem; line-height: 1.5; }
.howto-win .help li + li { margin-top: 4px; }
.howto-win__tip { opacity: 0.8; }
.howto-win__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.howto-win__actions .btn { margin-top: 0; min-height: 44px; padding: 12px 22px; font-size: 0.95rem; }
.howto-win .tutline { text-align: center; max-width: none; }
.howto-win .tutline[hidden] { display: none; }
/* Portrait phone: the top bar (and the Dynamic Island / status bar above it) sits over the top of the window and fades
   its title out. The window starts just below the bar and keeps only a small gap at the bottom, so it is as tall as the
   free space allows (the text scrolls only if it must) and is centred in that space on any phone. */
@media (orientation: portrait) {
    #overlay-howto {
        padding-top: calc(max(12px, env(safe-area-inset-top)) + var(--bar-drop, 0px) + 56px);
        padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + 24px);
    }
}

/* The card the game waits on before the first lesson. */
#overlay-tut { z-index: 7; background: rgba(0, 0, 0, 0.72); }
#overlay-tut .overlay__lead { max-width: 34em; line-height: 1.5; }
#overlay-tut .btn { min-height: 44px; }
.tutcard__never { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 4px 8px; font-size: 1rem; cursor: pointer; }
.tutcard__never input { width: 24px; height: 24px; margin: 0; accent-color: var(--neon-core); cursor: pointer; }

/* The start screen's "skip / replay" line. */
.tutline { margin: 0; text-align: center; min-height: 1.4em; font-size: 0.8rem; opacity: 0.8; max-width: 92vw; line-height: 1.9; }
/* The note on its own line, the links centred on the next. */
#tut-note { display: block; }
.tutline .linkbtn[hidden] { display: none; }
.tutline .linkbtn { margin: 0 6px; }
.linkbtn {
    padding: 4px 2px;
    font: inherit;
    color: var(--neon-core);
    background: none;
    border: 0;
    border-bottom: 1px solid rgba(191, 232, 255, 0.5);
    cursor: pointer;
}
.linkbtn:hover, .linkbtn:focus-visible { border-bottom-color: var(--neon-core); outline: none; text-shadow: 0 0 8px var(--neon); }

@media (prefers-reduced-motion: reduce) {
    .tutorial__stage, .tutorial__text { transition: none; }
    .tutorial__text.is-nudge { animation: none; }
    .is-spot { animation: none; box-shadow: 0 0 0 3px #ffd23f, 0 0 16px #ffd23f; }
    .tutorial.is-ok .tutorial__ok { animation: none; opacity: 1; transform: translate(-50%, -50%); }
}

/* ---- The limits of the field -------------------------------------------- */
/* Where the ship cannot go any further the edge of the screen pulses orange, softly. */
.edges i { position: absolute; opacity: 0; pointer-events: none; transition: opacity 0.4s; }
.edges i.is-on { opacity: 1; animation: edge-pulse 1.4s ease-in-out infinite; }
.edges [data-edge="l"] { left: 0; top: 0; bottom: 0; width: clamp(36px, 9vw, 110px); background: linear-gradient(to right, rgba(255, 140, 40, 0.6), rgba(255, 140, 40, 0)); }
.edges [data-edge="r"] { right: 0; top: 0; bottom: 0; width: clamp(36px, 9vw, 110px); background: linear-gradient(to left, rgba(255, 140, 40, 0.6), rgba(255, 140, 40, 0)); }
.edges [data-edge="t"] { left: 0; right: 0; top: 0; height: clamp(36px, 9vh, 90px); background: linear-gradient(to bottom, rgba(255, 140, 40, 0.6), rgba(255, 140, 40, 0)); }
.edges [data-edge="b"] { left: 0; right: 0; bottom: 0; height: clamp(36px, 9vh, 90px); background: linear-gradient(to top, rgba(255, 140, 40, 0.6), rgba(255, 140, 40, 0)); }
@keyframes edge-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { .edges i.is-on { animation: none; opacity: 0.6; } }

/* ---- Terrain warning, terrain legend swatch ----------------------------- */

.terrain-warn {
    position: absolute;
    left: 50%;
    top: 26%;
    transform: translateX(-50%);
    padding: 6px 16px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #ff7a1a;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid #ff7a1a;
    border-radius: 4px;
    text-shadow: 0 0 10px #ff5a00;
    animation: terrain-blink 0.5s steps(2) infinite;
}
.terrain-warn[hidden] { display: none; }
@keyframes terrain-blink { 50% { opacity: 0.35; } }
.swatch--ground {
    border: 0;
    background: linear-gradient(to top, #2b8cff, #bfe8ff);
    clip-path: polygon(50% 4%, 100% 100%, 0 100%);
}
@media (prefers-reduced-motion: reduce) {
    .terrain-warn { animation: none; }
}

/* A between-screen button that ignores input for a moment (see lockScreen). */
.btn[data-locked] { opacity: 0.4; pointer-events: none; transition: opacity 0.3s; }
.btn:not([data-locked]) { transition: opacity 0.3s; }

/* ---- Last-seconds countdown -------------------------------------------- */

.countdown {
    position: absolute;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%);
    font-size: clamp(7rem, 30vmin, 18rem);
    font-weight: 900;
    line-height: 1;
    color: var(--neon-core);
    text-shadow: 0 0 24px var(--neon), 0 0 60px var(--neon);
    opacity: 0;
    pointer-events: none;
    user-select: none;
    font-variant-numeric: tabular-nums;
}
.countdown.is-low { color: #ff9a4a; text-shadow: 0 0 24px #ff5a00, 0 0 60px #ff5a00; }
.countdown.is-on { animation: countdown-blink 1s ease-out both; }
/* Two flashes per second; never fully opaque, so the course stays visible. */
@keyframes countdown-blink {
    0%   { opacity: 0.55; transform: translate(-50%, -50%) scale(1.3); }
    30%  { opacity: 0.16; transform: translate(-50%, -50%) scale(1); }
    50%  { opacity: 0.45; }
    80%, 100% { opacity: 0.14; transform: translate(-50%, -50%) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
    .countdown.is-on { animation: none; opacity: 0.32; }
}

/* ---- Legibility over the 3D sign ---------------------------------------- */

/* On a tall phone the start screen can scroll up over the FLIGHT sign. Every
   control has a dark base (above); loose text gets a dark halo, and the
   leaderboard a dark panel, so nothing depends on what the scene shows. */
#overlay-start .overlay__lead,
#overlay-start .overlay__note,
#overlay-start .overlay__tagline,
#overlay-start .difficulty__hint,
#overlay-start .tutline,
#overlay-start .help,
#overlay-start .legend,
#overlay-start .board__title {
    text-shadow: 0 0 3px #000, 0 0 8px #000, 0 1px 12px #000;
}
#overlay-start .board,
#overlay-start .legend {
    background: rgba(2, 8, 22, 0.8);
    border-radius: 6px;
    padding: 8px;
}

/* ---- Start-level picker (practice from an unlocked level) --------------- */

.levelpick { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; max-width: min(380px, 92vw); }
.levelpick[hidden] { display: none; }
.levelpick__label { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.8; }
.levelpick__btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    font: inherit;
    font-size: 1.1rem;
    color: var(--neon-core);
    background: rgba(2, 8, 22, 0.85);
    border: 1px solid rgba(43, 140, 255, 0.55);
    border-radius: 4px;
    cursor: pointer;
}
.levelpick__btn:hover:not(:disabled), .levelpick__btn:focus-visible { border-color: var(--neon-core); box-shadow: 0 0 8px var(--neon); outline: none; }
.levelpick__btn:disabled { opacity: 0.35; cursor: default; }
.levelpick__value { min-width: 2ch; font-size: 1.3rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.levelpick__note { flex-basis: 100%; margin: 0; font-size: 0.8rem; opacity: 0.8; text-align: center; }
.levelpick__note[hidden] { display: none; }
#overlay-start .levelpick__label, #overlay-start .levelpick__note, #overlay-start .levelpick__value {
    text-shadow: 0 0 3px #000, 0 0 8px #000, 0 1px 12px #000;
}

/* ---- Boss fight --------------------------------------------------------- */

/* A boss level has no kill goal (it is passed by destroying the boss). */
.hud__level.is-boss .hud__goal, .hud__level.is-boss .hud__bar--goal { display: none; }

.bossbar {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 40px + var(--bar-drop));
    left: 50%;
    transform: translateX(-50%);
    width: min(420px, 78vw);
    text-align: center;
}
.bossbar[hidden] { display: none; }
.bossbar__name { display: block; margin-bottom: 4px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.3em; text-transform: uppercase; color: #ff7a9a; text-shadow: 0 0 10px #ff2f6d; }
.bossbar__track {
    position: relative;
    display: block;
    height: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 47, 109, 0.7);
    border-radius: 2px;
    overflow: hidden;
}
.bossbar__track > span { display: block; height: 100%; background: #ff2f6d; box-shadow: 0 0 12px #ff2f6d; transform-origin: left center; transition: transform 0.15s linear; }
/* three segments of life */
.bossbar__track::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent calc(33.33% - 1px), rgba(0, 0, 0, 0.9) calc(33.33% - 1px) 33.33%, transparent 33.33% calc(66.66% - 1px), rgba(0, 0, 0, 0.9) calc(66.66% - 1px) 66.66%, transparent 66.66%);
}
/* the core is open: shoot it now */
.bossbar.is-open .bossbar__track { border-color: #ffe14a; box-shadow: 0 0 14px #ffe14a; }
.bossbar.is-open .bossbar__track > span { background: #ffe14a; box-shadow: 0 0 14px #ffe14a; }

/* A red pulse at the screen's edges for as long as the boss is there. */
.alert {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 20, 50, 0.5) 100%);
    transition: opacity 0.6s;
}
.alert--on { opacity: 1; animation: alert-pulse 1.4s ease-in-out infinite; }
@keyframes alert-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
    .alert--on { animation: none; opacity: 0.7; }
    .bossbar__track > span { transition: none; }
}

/* Language choice on the start screen: the same game under another language prefix. */
.langpick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.langpick__opt {
    font: inherit; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none;
    color: inherit; padding: 6px 12px; min-height: 32px; display: inline-flex; align-items: center;
    background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(43, 140, 255, 0.45); border-radius: 6px;
}
a.langpick__opt:hover, a.langpick__opt:focus-visible { border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); outline: none; }
.langpick__opt--current { border-color: var(--neon-core); box-shadow: 0 0 8px var(--neon); }

/* Pause and mute sit together at the right of the top bar; on a narrow phone they may wrap. */
.topbar__right { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar__btn[hidden] { display: none; }
#pause-end, #pause-menu, #level-end, #over-menu { margin-top: 4px; padding: 10px 22px; font-size: 0.9rem; }
.btn[hidden] { display: none; }

/* Touch screens: tap targets of at least 44 px (Apple HIG / Material), with room between them. */
@media (pointer: coarse) {
    .topbar__link, .topbar__btn { min-height: 44px; padding: 10px 14px; display: inline-flex; align-items: center; }
    .topbar__right { gap: 10px; }
    .topbar { gap: 10px; }
    #pause-end, #pause-menu, #level-end, #over-menu { min-height: 44px; }
}

/* On a phone the top bar (back link, pause, mute) spans the whole width and would cover the level
   and timer block and the boss bar, so they move down below it (the symbols keep it to one row). */
@media (max-width: 640px) {
    .hud__level { top: calc(max(12px, env(safe-area-inset-top)) + 56px + var(--bar-drop)); }
    .bossbar { top: calc(max(12px, env(safe-area-inset-top)) + 56px + 40px + var(--bar-drop)); }
}

/* Top bar symbols (back arrow, pause/play, sound): square buttons, 44 px for fingers. */
.topbar__icon { width: 44px; height: 44px; min-height: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.topbar__icon svg { width: 22px; height: 22px; display: block; }
/* A stop square in front of "End game" (it hides while the button asks for the second tap). */
#pause-end:not([data-armed])::before, #level-end:not([data-armed])::before { content: "\25A0\00a0"; }
a.topbar__icon svg { width: 26px; height: 26px; } /* the door is a narrow symbol: a little larger */

/* ---- Start screen: the info sits above the sign, the share icons open a row under the top bar ---- */
.intro { position: absolute; left: 0; right: 0; top: var(--intro-top, 24vh); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 12px; text-align: center; pointer-events: none; }
.topbar .langpick { gap: 4px; flex-wrap: nowrap; }
.topbar .langpick__opt { padding: 4px 9px; min-height: 32px; font-size: 0.72rem; }
.topbar__right { flex-wrap: nowrap; align-items: center; }
.topbar__btn[hidden] { display: none; }
.share--bar {
    position: absolute; z-index: 6;
    top: calc(max(12px, env(safe-area-inset-top)) + 52px + var(--bar-drop));
    right: max(12px, env(safe-area-inset-right));
    gap: 6px; flex-wrap: nowrap; max-width: none;
    padding: 6px; background: rgba(0, 0, 0, 0.7); border: 1px solid rgba(43, 140, 255, 0.45); border-radius: 12px;
}
.share--bar[hidden] { display: none; }
#share-toggle[aria-expanded="true"] { border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); }
@media (max-width: 480px) {
    .overlay__tagline { letter-spacing: 0.1em; font-size: 0.75rem; }
    .intro { top: 31vh; }
}
@media (min-width: 560px) {
    .difficulty__opt { padding: 10px 14px; font-size: 0.85rem; letter-spacing: 0.1em; }
}
@media (max-width: 340px) {
    .difficulty__opt { font-size: 0.66rem; letter-spacing: 0.02em; }
}
/* Language chips: short codes (PL EN ES) on narrow screens, full names on wide ones. */
.langpick__full { display: none; }
@media (min-width: 600px) {
    .langpick__short { display: none; }
    .langpick__full { display: inline; }
}

/* Difficulty: a small label and three numbered tiles; the hint below names the chosen one. */
.difficulty__label { line-height: 1; margin: 4px 0 -4px; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.8; }
#overlay-start .difficulty__label { text-shadow: 0 0 3px #000, 0 0 8px #000; }
.difficulty { grid-template-columns: repeat(4, 56px); justify-content: center; width: auto; gap: 10px; }
.difficulty__opt, .difficulty__opt { font-size: 1.15rem; font-weight: 700; letter-spacing: 0; padding: 8px 0; }
@media (min-width: 560px) { .difficulty { grid-template-columns: repeat(4, 64px); } .difficulty__opt { font-size: 1.15rem; padding: 8px 0; letter-spacing: 0; } }
.langpick[hidden] { display: none; }

/* ---- Tilt steering: buttons at the right edge in the upper half, shown only while no finger is down ---- */
.gyro-side { position: absolute; z-index: 6; top: 22%; display: flex; flex-direction: column; gap: 10px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.gyro-side.is-visible { opacity: 1; pointer-events: auto; }
.gyro-side--right { right: max(8px, env(safe-area-inset-right)); }
.gyro-btn { width: 48px; height: 48px; min-height: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation; }
.gyro-btn svg { width: 24px; height: 24px; display: block; }
.gyro-btn[hidden] { display: none; }
/* Phone held sideways: the right column is taller than the screen and its last button (crosshair)
   fell below the edge. That button moves out to the left side, in line with the exit button above it
   (the same left offset as the top bar, so it clears the notch); it still fades in and out together
   with the column. */
@media (orientation: landscape) and (max-height: 520px) {
    .gyro-side .crosshair-btn { position: fixed; top: 22%; left: max(12px, env(safe-area-inset-left)); }
}
/* The gyro buttons show their state with the background: clear when off, a translucent blue fill when on. */
.gyro-toggle, #gyro-menu { background: transparent; }
.gyro-toggle[aria-pressed="true"], #gyro-menu[aria-pressed="true"] { background: rgba(43, 140, 255, 0.4); border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); }
#gyro-menu[hidden] { display: none; }
.gyro-msg { position: absolute; z-index: 6; top: 64px; left: 50%; transform: translateX(-50%); max-width: 90vw; margin: 0; padding: 8px 12px; text-align: center; font-size: 0.8rem; background: rgba(0, 0, 0, 0.78); border: 1px solid rgba(43, 140, 255, 0.55); border-radius: 8px; }
.gyro-msg[hidden] { display: none; }
@media (max-width: 340px) {
    .topbar__icon { width: 38px; height: 38px; }
    .topbar, .topbar__right { gap: 6px; }
}

/* ---- Phone held sideways (short, wide screen) ---------------------------
   Only ~360-430 px of height: everything gets tighter, the start screen puts
   the difficulty and the start level side by side, and the game-over screen
   uses two columns, so the main buttons stay visible without scrolling. */
.start-options { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.diffgroup { display: flex; flex-direction: column; align-items: center; gap: 10px; }
@media (orientation: landscape) and (max-height: 520px) {
    .neon { font-size: clamp(1.8rem, 12vh, 3.2rem); }
    .neon--small { font-size: clamp(1.6rem, 9vh, 2.6rem); }
    .overlay { gap: 6px; padding: 10px 16px; }
    .overlay__lead { font-size: 0.95rem; }
    .overlay__note { font-size: 0.78rem; }
    .btn { padding: 8px 22px; font-size: 1rem; }
    #overlay-start { padding-top: 52vh; padding-bottom: 10px; gap: 6px; }
    /* the two lines under the title stand at the height of the top buttons (between the language chips and the
       buttons on the right): the room under the bar goes to the picture and the menu, which rise with it */
    .intro { top: calc(max(12px, env(safe-area-inset-top)) + var(--bar-drop, 0px)); min-height: 44px; justify-content: center; gap: 2px; }
    .intro .overlay__lead { font-size: 0.9rem; }
    .intro .overlay__tagline { font-size: 0.72rem; }
    /* a row that centres itself: difficulty, and next to it the start level when it is shown;
       the hint goes under both (a grid left an empty column behind a hidden start level) */
    .start-options { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-end; column-gap: 28px; row-gap: 4px; width: min(100%, 640px); } /* a definite width, so the hint's 100% wraps under the row even when the hint is long */
    .diffgroup { order: 1; gap: 4px; }
    .start-options .levelpick { order: 2; }
    .start-options .difficulty__hint { order: 3; flex-basis: 100%; max-width: none; min-height: 0; text-align: center; } /* the base max-width (380px) would let a short hint sit beside the tiles */
    .diffgroup .difficulty { grid-template-columns: repeat(4, 48px); gap: 8px; }
    .difficulty__opt { padding: 5px 0; font-size: 1rem; }
    .difficulty__label { margin: 0; }
    .linkrow { gap: 8px; }
    .linkrow__btn { padding: 6px 12px; }
    /* language chips: two-letter codes (PL EN ES) right beside the exit button, the other buttons stay on the right */
    .topbar { justify-content: flex-start; }
    .topbar__right { margin-left: auto; }
    .langpick__short { display: inline; }
    .langpick__full { display: none; }

    /* game over: result on the left, the actions and the board on the right */
    #overlay-over { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: row dense; align-content: start; justify-items: center; column-gap: 20px; row-gap: 2px; padding-block: 6px; overflow-y: auto; }
    #overlay-over .neon--small { font-size: clamp(1.4rem, 8vh, 2.2rem); }
    #overlay-over #restart-hint { display: none; } /* a keyboard hint */
    #overlay-over .submit__hint { font-size: 0.68rem; }
    #overlay-over > * { grid-column: 1; }
    #overlay-over #restart { grid-column: 2; grid-row: 1; }
    #overlay-over #over-menu { grid-column: 2; grid-row: 2; margin-top: 0; }
    #overlay-over .levelpick { grid-column: 2; grid-row: 3; }
    #overlay-over .board { grid-column: 2; grid-row: 4 / span 6; width: 100%; max-width: 340px; font-size: 0.78rem; }
    #overlay-over .board li { padding-block: 1px; }
    #overlay-over .submit { grid-column: 1; }
    #overlay-over .share__prompt { font-size: 0.7rem; }
    #overlay-over .share__btn { width: 36px; height: 36px; }
    #overlay-over #listen { padding: 6px 16px; font-size: 0.85rem; }
}

/* ---- Full screen button and the home-screen hint --------------------------- */
#fullscreen { display: none; }
#fullscreen[hidden] { display: none !important; }
/* only offered when the phone is held sideways (where the browser bars cost the most) */
@media (orientation: landscape) and (max-height: 520px) { #fullscreen { display: inline-flex; } }
.howto__install { margin: 8px 0 0; font-size: 0.8rem; opacity: 0.85; max-width: 34rem; }
.howto__install[hidden] { display: none; }
/* a notch or rounded corners when the game fills the whole screen */
.overlay { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
@media (orientation: landscape) and (max-height: 520px) {
    .overlay { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* ---- Tilt: the up/down invert button and the ?gyrodebug readout ---------- */
.gyro-invert[aria-pressed="true"] { border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); }
/* Autofire on: the whole button is lit like the tilt button is (same fill, border and glow as .gyro-toggle[aria-pressed="true"]). */
.autofire-btn[aria-pressed="true"], #autofire-top[aria-pressed="true"] { background: rgba(43, 140, 255, 0.4); border-color: var(--neon-core); box-shadow: 0 0 10px var(--neon); }
#gyro-debug { position: fixed; z-index: 9; left: 8px; bottom: 8px; margin: 0; padding: 6px 8px; max-width: calc(100vw - 16px); overflow: hidden; pointer-events: none;
    font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #bfffbf; background: rgba(0, 0, 0, 0.75); border: 1px solid #3f9; border-radius: 4px; white-space: pre; }

/* Resilience (#63): resume / unsent-score notices on the start screen, offline pill and toast in the flight. */
.notice { width: min(92vw, 460px); margin: 0 auto 10px; padding: 10px 12px; text-align: center; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 209, 102, 0.6); border-radius: 10px; }
.notice[hidden] { display: none; }
.notice__text { margin: 0 0 8px; font-size: 0.9rem; }
.notice__row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.notice__row input { min-width: 0; flex: 1 1 140px; max-width: 220px; padding: 8px 10px; font: inherit; color: inherit; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 8px; }
.notice__msg { margin: 6px 0 0; min-height: 0; font-size: 0.8rem; opacity: 0.85; }
.notice__msg:empty { display: none; }
.overlay__note.is-warn { color: #ffd166; opacity: 1; }
.net-pill, .net-toast { position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); max-width: 90vw; margin: 0; padding: 6px 12px; text-align: center; font-size: 0.78rem; background: rgba(0, 0, 0, 0.78); border-radius: 8px; pointer-events: none; }
.net-pill { top: 40px; border: 1px solid rgba(255, 209, 102, 0.7); }
.net-toast { bottom: 18px; border: 1px solid rgba(69, 255, 138, 0.6); }
.net-pill[hidden], .net-toast[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
    /* No room for it in the column: a slim one-line bar along the bottom edge instead. */
    .notice { position: absolute; z-index: 5; left: 50%; bottom: 2px; transform: translateX(-50%); display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; width: max-content; max-width: 96vw; margin: 0; padding: 2px 8px; line-height: 1.2; }
    .notice__text { margin: 0; font-size: 0.74rem; text-align: left; }
    .notice__row { flex-wrap: nowrap; gap: 6px; }
    .notice__row input { flex: 0 1 120px; padding: 2px 8px; font-size: 0.8rem; }
    .notice .btn--small { padding: 3px 8px; font-size: 0.68rem; white-space: nowrap; }
    .notice__msg { position: absolute; bottom: 100%; left: 0; right: 0; margin: 0 0 2px; text-align: center; font-size: 0.72rem; }
}

.difficulty__icon { display: block; margin: 0 auto; }

/* Touch screens: no visible scroll bar on the menus (it showed at the right edge of the start screen in the
   home-screen app once the leaderboard made it taller than the screen). Scrolling by finger still works;
   desktop keeps its scroll bar, which mouse users need. */
@media (pointer: coarse) {
    .overlay { scrollbar-width: none; -ms-overflow-style: none; }
    .overlay::-webkit-scrollbar { display: none; width: 0; height: 0; background: transparent; }
}

/* ---- ARCADE ---------------------------------------------------------------
   The picture (canvas, HUD, flashes) is never wider than 3:4: on a phone held upright it fills the
   screen, on a wide one it stands in the middle and the sides become the cabinet's side art.
   --field-w is set by resize() in flight-game.js (the same width the renderer uses). */
#game.is-arcade #scene,
#game.is-arcade .hud,
#game.is-arcade .flash,
#game.is-arcade .alert {
    left: calc((100% - var(--field-w, 100%)) / 2);
    right: auto;
    width: var(--field-w, 100%);
}
#game.is-arcade::before,
#game.is-arcade::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: calc((100% - var(--field-w, 100%)) / 2);
    z-index: -1; /* under everything else in #game (the top bar sits over the side art) */
    pointer-events: none; /* a touch here reaches #game itself, which steers and fires */
    background:
        repeating-linear-gradient(135deg, rgba(43, 140, 255, 0.07) 0 2px, transparent 2px 26px),
        linear-gradient(to bottom, #050816, #0a0420 55%, #12021c);
}
#game.is-arcade::before { left: 0; border-right: 2px solid rgba(191, 232, 255, 0.55); box-shadow: inset -12px 0 24px -12px var(--neon); }
#game.is-arcade::after { right: 0; border-left: 2px solid rgba(191, 232, 255, 0.55); box-shadow: inset 12px 0 24px -12px var(--neon); }

/* HUD as on a cabinet, in the arcade's pixel font: along the top 1UP / HI-SCORE / WAVE (red labels,
   white numbers), along the bottom the ships in reserve and the shield. Sizes follow the picture's
   own width (cqw), not the window's: on a phone held sideways the picture is only ~340 px wide. */
.hud__hi[hidden], .hud__ships[hidden] { display: none; }
.hud__ships { display: inline-flex; gap: 6px; color: #fff; filter: drop-shadow(0 0 5px var(--neon)); }
.hud__ships svg { width: clamp(16px, 4.6cqw, 26px); height: clamp(16px, 4.6cqw, 26px); display: block; }
#game.is-arcade { --hud-top: 14px; }
@media (orientation: portrait) { #game.is-arcade { --hud-top: calc(max(12px, env(safe-area-inset-top)) + 58px + var(--bar-drop)); } }
.hud.is-arcade { container-type: inline-size; font-family: var(--px); }
.hud.is-arcade .hud__label { opacity: 1; font-size: clamp(8px, 2.7cqw, 17px); letter-spacing: 0.04em; color: #ff3b4f; text-shadow: 0 0 6px rgba(255, 45, 85, 0.8); }
.hud.is-arcade .hud__score,
.hud.is-arcade .hud__hi,
.hud.is-arcade .hud__level {
    position: absolute; top: var(--hud-top); bottom: auto;
    display: flex; flex-direction: column; gap: 7px;
    font-size: clamp(11px, 4.1cqw, 26px); letter-spacing: 0; text-transform: uppercase;
    color: #fff; text-shadow: 0 0 6px rgba(191, 232, 255, 0.7);
}
.hud.is-arcade .hud__score { left: 12px; align-items: flex-start; }
.hud.is-arcade .hud__hi { left: 50%; transform: translateX(-50%); align-items: center; }
.hud.is-arcade .hud__level { left: auto; right: 12px; transform: none; width: auto; align-items: flex-end; }
.hud.is-arcade .hud__levelrow { flex-direction: column; align-items: flex-end; gap: 7px; font-weight: 400; }
.hud.is-arcade #level-label { font-size: clamp(8px, 2.7cqw, 17px); color: #ffd166; text-shadow: 0 0 6px rgba(255, 209, 102, 0.7); }
.hud.is-arcade #score-label { animation: blink 1.1s steps(1, end) infinite; }
.hud.is-arcade .hud__goal,
.hud.is-arcade .hud__bar--goal { display: none; }
/* bottom row: ships on the left, the shield (a bar of blocks) on the right */
.hud.is-arcade .hud__shield { left: 12px; right: 12px; justify-content: space-between; gap: 8px; text-shadow: none; }
.hud.is-arcade .hud__shield .hud__label { margin-left: auto; color: var(--neon-core); text-shadow: 0 0 6px var(--neon); }
.hud.is-arcade .hud__bar:not(.hud__bar--goal) { width: clamp(70px, 34cqw, 160px); height: 12px; border-width: 2px; }
.hud.is-arcade .hud__bar:not(.hud__bar--goal) > span { background: repeating-linear-gradient(90deg, var(--neon-core) 0 8px, transparent 8px 11px); }
.hud.is-arcade .hud__shield.is-low .hud__bar > span { background: repeating-linear-gradient(90deg, var(--danger) 0 8px, transparent 8px 11px); }
@container (max-width: 360px) { .hud.is-arcade .hud__shield .hud__label { display: none; } }
/* wave titles, pop-ups and the combo in the pixel font too */
.hud.is-arcade .banner__level {
    font-family: var(--px); font-size: clamp(18px, 9cqw, 46px); letter-spacing: 0.04em; line-height: 1.3;
    color: #fff; -webkit-text-stroke: 0; text-shadow: 0 0 12px var(--neon), 3px 3px 0 #ff2d55;
}
.hud.is-arcade .banner__name { font-size: clamp(9px, 3.7cqw, 17px); letter-spacing: 0.04em; line-height: 1.7; color: #ffd166; margin-top: 10px; padding: 0 10px; }
.hud.is-arcade .banner__goal { font-size: clamp(8px, 2.8cqw, 12px); line-height: 1.7; padding: 0 12px; }
.hud.is-arcade .pop { font-size: clamp(11px, 3.6cqw, 16px); font-weight: 400; }
.hud.is-arcade .pop--hot { font-size: clamp(13px, 4.4cqw, 20px); }
.hud.is-arcade .hud__combo { left: 12px; font-size: clamp(8px, 2.8cqw, 12px); font-weight: 400; letter-spacing: 0; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 34px); }
/* A fresh ship blinks while nothing can hurt it. */
.hud.is-invuln .crosshair,
.hud.is-invuln .hud__shield { animation: blink 0.25s steps(1, end) infinite; }

/* Start screen: ARCADE is the big button; the campaign (with its difficulties) comes under it. */
.arcade-start { display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* ARCADE: just the lettering, no frame -- the title, and a blinking PRESS START as wide as it
   (its size is fitted in flight-game.js, fitArcadeBlink). */
.btn--arcade {
    display: inline-flex; flex-direction: column; align-items: center; gap: 0;
    margin-top: 0; padding: 6px 10px;
    border: 0; background: none; box-shadow: none; border-radius: 4px;
}
.btn--arcade:hover, .btn--arcade:focus-visible { background: none; }
.btn--arcade:hover .btn--arcade__title, .btn--arcade:focus-visible .btn--arcade__title { text-shadow: 3px 3px 0 #ff2d55, 0 0 22px #ff2d55, 0 0 40px #ff2d55; }
.btn--arcade:focus-visible { outline: 2px dashed rgba(255, 209, 102, 0.7); outline-offset: 4px; }
.btn--arcade__title { font-family: var(--px); font-size: clamp(2rem, 9vw, 2.6rem); font-weight: 400; letter-spacing: 0.06em; line-height: 1.2; color: #fff; text-shadow: 3px 3px 0 #ff2d55, 0 0 14px #ff2d55; }
.btn--arcade__blink { margin-top: 10px; font-family: var(--px); font-size: 1rem; letter-spacing: 0; line-height: 1.2; white-space: nowrap; color: #ffd166; text-shadow: 0 0 10px rgba(255, 209, 102, 0.7); animation: blink 1s steps(1, end) infinite; }
.arcade-start__sub { margin: 0; font-size: 0.78rem; opacity: 0.8; text-shadow: 0 0 3px #000, 0 0 8px #000; }
.arcade-start__hi { margin: 2px 0 0; font: 0.62rem/1.5 var(--px); color: #ff5a6e; text-shadow: 0 0 3px #000, 0 0 8px #000; }
.arcade-start__hi[hidden] { display: none; }
.board__part { margin-top: 14px; }
.modes, .campaign { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.modes { gap: 12px; }
/* ---- OR ---- between ARCADE and the campaign (a vertical rule when they stand side by side) */
.modes__or { display: flex; align-items: center; gap: 12px; width: min(300px, 80vw); margin: 2px 0; }
.modes__or::before, .modes__or::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(191, 232, 255, 0.6), transparent); }
.modes__or span { font: 0.62rem/1 var(--px); letter-spacing: 0.1em; text-transform: uppercase; color: var(--neon-core); text-shadow: 0 0 3px #000, 0 0 8px #000, 0 0 10px var(--neon); }
/* Upright phones: the extra ARCADE block starts a little higher (still under the sign), so the
   campaign's difficulty tiles stay on the first screen. */
/* Upright phones: the 3D picture is raised (applyMenuView() in flight-game.js), so the horizon and the sign stand
   higher and the menu under them, down to the row of buttons, is on the first screen. The script measures the menu
   and sets --menu-pad (where it starts) and --intro-top (the tagline above the sign) in px; the values here are for
   the moment before it has run. */
@media (orientation: portrait) {
    #overlay-start { padding-top: var(--menu-pad, 45vh); gap: 6px; }
    #overlay-start .difficulty__hint { min-height: 0; } /* (no room reserved for a second line) */
    .intro { top: var(--intro-top, 21vh); }
}
@media (orientation: portrait) and (max-height: 720px) { .intro .overlay__tagline { display: none; } } /* (room for the menu) */

/* CONTINUE? with a big neon countdown. */
.continue__count {
    font-family: var(--px); font-size: clamp(4rem, 24vw, 8rem); font-weight: 400; line-height: 1;
    color: #ffd166;
    text-shadow: 4px 4px 0 #ff2d55, 0 0 30px #ff2d55;
    font-variant-numeric: tabular-nums;
}
.continue__count.is-tick { animation: continue-tick 0.5s ease-out; }
@keyframes continue-tick { from { transform: scale(1.25); } to { transform: scale(1); } }
#continue-yes { border-color: #ff5a6e; box-shadow: 0 0 16px #ff2d55, inset 0 0 14px rgba(255, 45, 85, 0.45); }

@media (orientation: landscape) and (max-height: 520px) {
    .btn--arcade { padding: 2px 8px; }
    .btn--arcade__title { font-size: 1.6rem; }
    .btn--arcade__blink { margin-top: 6px; }
    .continue__count { font-size: clamp(3rem, 22vh, 6rem); }
    /* ARCADE and the campaign side by side under the sign */
    .modes { flex-direction: row; align-items: center; justify-content: center; column-gap: 32px; flex-wrap: wrap; }
    .campaign { gap: 4px; }
    .arcade-start__sub { max-width: 260px; }
    .modes__or { flex-direction: column; width: auto; align-self: stretch; margin: 0; }
    .modes__or::before, .modes__or::after { width: 1px; height: auto; min-height: 24px; background: linear-gradient(180deg, transparent, rgba(191, 232, 255, 0.6), transparent); }
    .modes .start-options { width: 340px; max-width: 100%; } /* narrow enough to stand beside ARCADE (a fixed width: a % one counts as the text width when the row is laid out) */
    /* The menu stands 13vh higher than it used to (56vh -> 43vh), and flight-game.js raises the picture (grid, horizon,
       sign) by the same amount (layoutMenu: the scene stands unraised at 56vh), so everything moves up together. */
    #overlay-start { padding-top: 43vh; }
}
/* the narrowest phones held sideways (667 px and less): the two lines must stay clear of the buttons on both sides */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 720px) {
    .intro .overlay__lead { font-size: 0.76rem; }
    .intro .overlay__tagline { font-size: 0.62rem; letter-spacing: 0.1em; }
}
/* A laptop (a wide window of not much height): ARCADE and the campaign side by side under the sign, as on a phone on its
   side, so that the whole menu, down to the row of buttons, fits (layoutMenu() then needs to raise the picture less). */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 521px) and (max-height: 860px) {
    .modes { flex-direction: row; align-items: center; justify-content: center; column-gap: 40px; flex-wrap: wrap; }
    .campaign { gap: 6px; }
    .modes__or { flex-direction: column; width: auto; align-self: stretch; margin: 0; }
    .modes__or::before, .modes__or::after { width: 1px; height: auto; min-height: 24px; background: linear-gradient(180deg, transparent, rgba(191, 232, 255, 0.6), transparent); }
    .modes .start-options { width: 340px; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .btn--arcade__blink, .hud.is-arcade #score-label, .hud.is-invuln .crosshair, .hud.is-invuln .hud__shield { animation: none; }
    .continue__count.is-tick { animation: none; }
}

/* ARCADE screens (CONTINUE?, game over) in the pixel font. */
#game.is-arcade #overlay-continue h2,
#game.is-arcade #overlay-over h2,
#game.is-arcade #overlay-pause h2 {
    font-family: var(--px); font-weight: 400; font-size: clamp(18px, 6.5vw, 40px); line-height: 1.4; letter-spacing: 0.02em;
    color: #fff; -webkit-text-stroke: 0; text-shadow: 3px 3px 0 #ff2d55, 0 0 14px #ff2d55; text-transform: uppercase;
}
#game.is-arcade #overlay-continue .btn,
#game.is-arcade #overlay-over > .btn, #game.is-arcade #overlay-over #submit-btn { font-family: var(--px); font-weight: 400; font-size: 0.78rem; letter-spacing: 0.02em; line-height: 1.6; }
#game.is-arcade #overlay-continue .overlay__note,
#game.is-arcade #final-score { font-family: var(--px); font-size: 0.72rem; line-height: 1.8; text-transform: uppercase; }

/* "Take me back to the 80s": a switch with a lamp. */
.retro-toggle {
    position: relative; margin-top: 4px; padding: 8px 12px 8px 32px;
    font: 0.62rem/1.5 var(--px); letter-spacing: 0.02em; color: #ffd166; text-align: left; text-transform: uppercase;
    background: none; border: 0; border-radius: 4px; cursor: pointer;
    text-shadow: 0 0 3px #000, 0 0 8px #000; /* no frame: the lettering alone, readable over the scene */
}
/* a classic tick box: a square, with a green tick when the look is on */
.retro-toggle::before {
    content: ""; position: absolute; left: 6px; top: 50%; width: 14px; height: 14px; margin-top: -9px;
    border: 2px solid #ffd166; border-radius: 2px; background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 6px rgba(255, 209, 102, 0.45);
}
.retro-toggle[aria-pressed="true"]::after {
    content: ""; position: absolute; left: 12px; top: 50%; width: 6px; height: 13px; margin-top: -13px;
    border: solid #45ff8a; border-width: 0 4px 4px 0; transform: rotate(40deg);
    filter: drop-shadow(0 0 4px #45ff8a);
}
.retro-toggle:hover { color: #ffe39a; }
.retro-toggle:focus-visible { outline: 2px dashed rgba(255, 209, 102, 0.7); outline-offset: 2px; }

/* The CRT: scanlines, a vignette, rounded glass and a faint reflection, over the picture (the HUD
   included, as on a real tube). Phosphor trails are drawn in WebGL (PhosphorPass). */
.crt { position: absolute; inset: 0; z-index: 3; pointer-events: none; display: none; border-radius: 22px; }
#game.is-arcade .crt { left: calc((100% - var(--field-w, 100%)) / 2); right: auto; width: var(--field-w, 100%); }
#game.is-retro .crt {
    display: block;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.07), transparent 32%),
        radial-gradient(ellipse at center, transparent 65%, rgba(0, 0, 0, 0.4) 100%),
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0 1px, transparent 1px 3px);
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.9), inset 0 0 50px rgba(0, 0, 0, 0.65), inset 0 0 140px rgba(40, 90, 255, 0.1);
}
#game.is-retro #scene { border-radius: 22px; }

/* The cabinet, on screens wide enough to show it beside the picture: the marquee down the left side,
   the coin door on the right. Decoration only (aria-hidden); touches go through to #game. */
.cabinet { display: none; }
#game.is-arcade.has-cabinet .cabinet { display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.cabinet__side {
    position: absolute; top: 0; bottom: 0; width: calc((100% - var(--field-w, 100%)) / 2);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
    font-family: var(--px); text-transform: uppercase;
}
.cabinet__side--left { left: 0; }
.cabinet__side--right { right: 0; }
.cabinet__marquee {
    writing-mode: vertical-rl; text-orientation: upright; font-size: clamp(26px, 6.5vh, 64px); letter-spacing: 0.08em;
    color: #fff; text-shadow: 0 0 10px var(--neon), 0 0 30px var(--neon), 4px 4px 0 #ff2d55;
}
.cabinet__players { font-size: 11px; color: #ffd166; text-shadow: 0 0 6px rgba(255, 209, 102, 0.7); }
.cabinet__coin {
    display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 20px;
    background: linear-gradient(#1c2232, #0b0e17); border: 2px solid #3d465e; border-radius: 6px; box-shadow: inset 0 0 12px #000;
}
.cabinet__slot { width: 6px; height: 36px; background: #000; border-radius: 3px; box-shadow: 0 0 10px #ff2d55, inset 0 0 3px #ff2d55; }
.cabinet__price { font-size: 10px; color: #ff5a6e; }
.cabinet__insert { font-size: 12px; line-height: 1.7; text-align: center; color: #ffd166; animation: blink 1s steps(1, end) infinite; }
@media (prefers-reduced-motion: reduce) { .cabinet__insert { animation: none; } }

/* ?arcadeaudio: the sliders for tuning the ARCADE sound by ear. */
.audio-panel {
    position: fixed; z-index: 9; left: 8px; bottom: 8px; display: grid; gap: 2px; padding: 8px 10px;
    font: 11px/1.3 ui-monospace, Menlo, Consolas, monospace; color: #ffd166;
    background: rgba(0, 0, 0, 0.82); border: 1px solid rgba(255, 209, 102, 0.6); border-radius: 6px;
}
.audio-panel label { display: grid; grid-template-columns: 70px 110px 44px; align-items: center; gap: 6px; }
.audio-panel.is-folded label { display: none; }
.audio-panel output { text-align: right; }
.audio-panel div { display: flex; gap: 6px; margin-top: 4px; }
.audio-panel button { font: inherit; color: inherit; background: #222; border: 1px solid #665; border-radius: 4px; padding: 4px 8px; }

/* ---- ARCADE: power-up self-test (after the coin, once a visit) ---- */
.boot { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: #000; cursor: pointer; }
.boot[hidden] { display: none; }
.boot::after { /* scanlines over the test screen */
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px);
}
.boot__screen { width: min(360px, 86vw); font: clamp(10px, 3.2vw, 14px)/1.9 var(--px); color: #c8ffd2; text-shadow: 0 0 6px rgba(80, 255, 140, 0.6); text-transform: uppercase; }
.boot__line { margin: 0; white-space: pre; }
.boot__line--title { font-size: 1.5em; color: #fff; text-shadow: 3px 3px 0 #ff2d55, 0 0 12px #ff2d55; }
.boot__line--dim { opacity: 0.6; }
.boot__line--credit { margin-top: 10px; color: #ffd166; text-shadow: 0 0 8px rgba(255, 209, 102, 0.8); animation: blink 0.5s steps(1, end) infinite; }
.boot__line--bars { display: grid; grid-template-columns: repeat(7, 1fr); height: 28px; margin: 10px 0 4px; }
.boot__line--bars span:nth-child(1) { background: #c0c0c0; }
.boot__line--bars span:nth-child(2) { background: #c0c000; }
.boot__line--bars span:nth-child(3) { background: #00c0c0; }
.boot__line--bars span:nth-child(4) { background: #00c000; }
.boot__line--bars span:nth-child(5) { background: #c000c0; }
.boot__line--bars span:nth-child(6) { background: #c00000; }
.boot__line--bars span:nth-child(7) { background: #0000c0; }

/* ---- ARCADE: attract mode (DEMO / PRESS START, and the HI-SCORE table) over the self-playing game ---- */
.attract {
    position: absolute; z-index: 5; top: 0; bottom: 0; pointer-events: none;
    left: calc((100% - var(--field-w, 100%)) / 2); width: var(--field-w, 100%);
    display: flex; align-items: center; justify-content: center; text-align: center;
    font-family: var(--px); text-transform: uppercase;
}
.attract[hidden], .attract__demo[hidden], .attract__board[hidden] { display: none; }
.attract__title { margin: 0 0 18px; font-size: clamp(22px, 9vw, 44px); color: #fff; text-shadow: 3px 3px 0 #ff2d55, 0 0 14px #ff2d55; }
.attract__blink { margin: 18px 0 0; font-size: clamp(12px, 4.4vw, 20px); color: #ffd166; text-shadow: 0 0 10px rgba(255, 209, 102, 0.7); animation: blink 1s steps(1, end) infinite; }
.attract__coin { margin: 12px 0 0; font-size: clamp(9px, 3vw, 13px); color: #ff5a6e; }
.attract__board { padding: 18px 16px; background: rgba(0, 0, 0, 0.78); border-radius: 8px; }
.attract__rows { list-style: none; margin: 0; padding: 0; font-size: clamp(10px, 3.4vw, 15px); line-height: 2; }
.attract__rows li { display: grid; grid-template-columns: 3.6em 6.5em 7em; gap: 10px; text-align: left; }
.attract__rows li:nth-child(1) { color: #ffd166; }
.attract__rows li:nth-child(2), .attract__rows li:nth-child(3) { color: #fff; }
.attract__rows li:nth-child(n + 4) { color: var(--neon-core); }
.attract__score { text-align: right; }
@media (prefers-reduced-motion: reduce) { .attract__blink, .boot__line--credit { animation: none; } }

/* ---- ARCADE: initials for the leaderboard, three slots with up/down arrows ---- */
.initials { display: flex; justify-content: center; gap: 14px; margin: 6px 0 2px; }
.initials[hidden] { display: none; }
.initials__slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.initials__btn {
    width: 44px; height: 34px; padding: 0; font: 14px/1 var(--px); color: #ffd166; cursor: pointer;
    background: rgba(0, 0, 0, 0.55); border: 2px solid rgba(255, 209, 102, 0.6); border-radius: 6px; touch-action: manipulation;
}
.initials__btn:hover, .initials__btn:focus-visible { border-color: #ffd166; outline: none; box-shadow: 0 0 10px rgba(255, 209, 102, 0.5); }
#game .initials__char { /* (#game: stronger than the form's own input style) */
    width: 44px; height: 52px; padding: 0; text-align: center; font: 30px/1 var(--px); color: #fff; caret-color: transparent;
    background: #000; border: 2px solid #ff5a6e; border-radius: 6px; text-shadow: 3px 3px 0 #ff2d55;
}
#game .initials__char:focus { outline: none; border-color: #ffd166; box-shadow: 0 0 12px rgba(255, 209, 102, 0.6); }
.submit.is-initials #nickname { display: none; }
.submit.is-initials .submit__row { justify-content: center; }
#game.is-arcade .submit__label { font-family: var(--px); font-size: 0.75rem; text-transform: uppercase; color: #ffd166; }
