/* 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;
}

* { 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); }

.crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 2px solid var(--neon-core);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon), inset 0 0 8px var(--neon);
    opacity: 0.85;
}
.crosshair::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    width: 4px; height: 4px;
    margin: -2px 0 0 -2px;
    background: var(--neon-core);
    border-radius: 50%;
}

.topbar {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    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;
}
.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: 58vh;
    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; }
#overlay-start.has-panel .help { display: none; }

/* 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;
}
@media (min-width: 560px) {
    .difficulty { grid-template-columns: repeat(4, auto); width: auto; }
}
.difficulty__opt {
    text-align: center;
    padding: 10px 14px;
    font: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    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: 8px; justify-content: center; max-width: 90vw; }
.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 { border-color: #ffe14a; border-style: dashed; box-shadow: 0 0 10px #ffe14a; }
.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__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; }

.tutorial {
    position: absolute;
    z-index: 6;
    top: max(66px, calc(env(safe-area-inset-top) + 58px));
    left: 50%;
    transform: translateX(-50%);
    width: min(580px, 92vw);
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    background: rgba(0, 0, 0, 0.66);
    border: 1px solid rgba(43, 140, 255, 0.65);
    border-radius: 6px;
    box-shadow: 0 0 18px rgba(43, 140, 255, 0.25);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.tutorial[hidden] { display: none; }
.tutorial.is-ok { border-color: #45ff8a; box-shadow: 0 0 22px rgba(69, 255, 138, 0.55); }
.tutorial__body { flex: 1; min-width: 0; }
.tutorial__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.75;
}
.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__text { margin: 6px 0 0; font-size: 0.95rem; line-height: 1.4; }
#tut-next { margin-top: 10px; }

/* Skipping must always be one obvious, easy-to-hit tap. */
.tutorial__skip {
    flex: none;
    align-self: center;
    min-height: 44px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.85rem;
    color: var(--neon-core);
    background: transparent;
    border: 1px solid var(--neon-core);
    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); }

.tutorial__actions { flex: none; align-self: center; display: flex; flex-direction: column; gap: 2px; }
.tutorial__actions .tutorial__skip { align-self: stretch; }
/* "Don't show again": quieter than Skip, but still a comfortable tap target. */
.tutorial__off {
    min-height: 38px;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.75rem;
    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); }

@media (max-width: 420px) {
    .tutorial { flex-direction: column; gap: 6px; }
    .tutorial__actions { align-self: stretch; }
}

/* 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 { transition: none; }
}

/* ---- 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__rand { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; }
.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);
    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, #level-end { 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, #level-end { min-height: 44px; }
}
