/* =====================================================================================
   Interface outside flight — "Telemetry" direction (docs/design/direcao-A.html).
   Language of the goggles' OSD: rulers with markings, brackets, big numbers in monospace, straight panels
   with a chamfered corner only on what is an action. Values only from styles/tokens.css. No blur or backdrop-filter:
   the 3D scene behind is darkened with a gradient (cheap on a Chromebook). The flight OSD is styles/osd.css.
   ===================================================================================== */

/* Captions that depend on the flight mode and the camera (used in the OSD and in the options) */
body.fly-assist .only-manual, body:not(.fly-assist) .only-assist, body:not(.cam-chase) .only-chase, body:not(.mouse-on) .only-mouse, body.keys-wasd .only-setas, body:not(.keys-wasd) .only-wasd, body:not(.in-battle) .only-battle, body.in-battle .only-race { display: none; }
body.mouse-aim .only-stickguide, body:not(.mouse-aim) .only-aimguide { display: none; }
body:not(.kbd-arcade) .only-arcade { display: none; }

/* Video capture (?captura=1): no cursor or interface over the scene */
body.capture, body.capture * { cursor: none !important; }
body.capture #menu, body.capture .overlay, body.capture #touch-sticks { display: none !important; }
body.capture.capture-clean #osd { display: none !important; }

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: var(--fs-body)/1.45 var(--f-num); }
/* Inside the iframe: no text selection, magnifier or long-press menu on tablets; no scrolling or gesture zoom */
body { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
input[type=text], textarea { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }
[hidden] { display: none !important; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#app canvas { touch-action: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: var(--rule-hi) solid var(--warn); outline-offset: 2px; }

/* Section label: spaced uppercase, like the OSD tags */
h3, h4 { margin: 0 0 var(--s2); font: 600 var(--fs-h3)/1.2 var(--f-title); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
h3 { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.hint { color: var(--dim); font-size: var(--fs-small); line-height: 1.45; margin: var(--s2) 0 0; }
kbd { font: 500 .82em var(--f-num); padding: 0 .4em; border: var(--rule) solid currentColor; margin: 0 1px; white-space: nowrap; }
.screen-title { display: block; margin: 0; font: 700 var(--fs-h1)/1 var(--f-title); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }

/* ---------------------------------------------------------------- controles */
/* Secondary button: straight, thin outline. (Also the OSD touch buttons.) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); min-width: 0; padding: var(--s2) var(--s3); font: 600 var(--fs-small) var(--f-title); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); background: var(--panel); border: var(--rule) solid var(--line-hi); cursor: pointer; white-space: nowrap; transition: background var(--dur), color var(--dur), border-color var(--dur); }
.btn:hover { background: var(--go); color: var(--on-go); border-color: var(--go); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--panel); color: var(--ink); border-color: var(--line-hi); }
.btn.primary { background: var(--go); color: var(--on-go); border-color: var(--go); }
.btn.warn { color: var(--hot); border-color: var(--hot); }
.btn.warn:hover { background: var(--hot); color: var(--bg); }
.btn.wide { width: 100%; }
.btn[data-armed] { white-space: normal; text-align: left; border-color: var(--hot); color: var(--hot); }

/* Dominant action of the screen: green plate with a chamfered corner. Focus stays INSIDE (the chamfer cuts what sticks out). */
.btn-big { display: block; width: 100%; padding: var(--s4) var(--s5); text-align: left; border: 0; cursor: pointer; color: var(--on-go); background: var(--go); font: 700 calc(var(--fs-hero) * .62)/1 var(--f-title); letter-spacing: .04em; text-transform: uppercase; clip-path: var(--chamfer); transition: transform var(--dur) var(--ease); }
.btn-big:hover { transform: translateX(4px); }
.btn-big:focus-visible, .quick:focus-visible, .btn-go:focus-visible { outline: none; box-shadow: inset 0 0 0 4px var(--warn); }

/* Secondary action in a list: row with a ruler and an arrow */
.row-list { border-top: var(--rule) solid var(--line); }
.row-btn { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; padding: var(--s3) var(--s1); text-align: left; background: none; border: 0; border-bottom: var(--rule) solid var(--line); color: var(--ink); cursor: pointer; font: 600 var(--fs-body) var(--f-title); letter-spacing: .08em; text-transform: uppercase; transition: background var(--dur); }
.row-btn::after { content: '▸'; color: var(--line-hi); font-family: var(--f-num); transition: color var(--dur); }
.row-btn:hover { background: linear-gradient(90deg, rgba(53, 255, 158, .1), transparent 75%); }
.row-btn:hover::after { color: var(--go); }
.row-btn:focus-visible { outline: none; background: linear-gradient(90deg, rgba(255, 181, 71, .16), transparent 75%); box-shadow: inset 3px 0 0 var(--warn); }
.row-btn.reward { color: var(--warn); }

.field { width: 100%; padding: var(--s2) var(--s3); font: 500 var(--fs-body) var(--f-num); color: var(--ink); background: var(--raise); border: var(--rule) solid var(--line-hi); border-radius: 0; }
.field.lang { width: auto; padding: var(--s2); background: var(--panel); border: 0; cursor: pointer; font-size: var(--fs-small); }
.field.lang option { background: var(--panel-solid); color: var(--ink); }
/* Language selector: the transparent <select> covers the whole label (opens the native list with the full names) */
.lang-pick { position: relative; display: inline-flex; align-items: center; gap: .45em; white-space: nowrap; }
.lang-pick::after { content: '▾'; color: var(--dim); }
.lang-sel { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; font-size: 16px; }
.lang-pick:focus-within { box-shadow: inset 0 0 0 2px var(--warn); }
.lc-short { display: none; }
.field.code { text-transform: uppercase; letter-spacing: .28em; text-align: center; width: 7em; flex: none; }
.row { display: flex; gap: var(--s2); margin-top: var(--s2); }

/* Segmented selector: the selected option turns amber (the "next gate" — what comes next is what you chose) */
.seg-label { color: var(--dim); margin: var(--s3) 0 var(--s1); font-size: var(--fs-small); }
.seg-label:first-child { margin-top: 0; }
[data-for] + [data-for]:not([hidden]) { margin-top: var(--s4); }
.seg { display: flex; border: var(--rule) solid var(--line-hi); }
.seg button { flex: 1; min-width: 0; padding: var(--s2) var(--s1); font: 500 var(--fs-small) var(--f-num); color: var(--ink); background: var(--panel); border: 0; border-left: var(--rule) solid var(--line); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background var(--dur), color var(--dur); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--raise); }
.seg button.on { background: var(--warn); color: var(--on-warn); font-weight: 700; }
.seg button:focus-visible { outline-offset: -3px; }

/* Checkbox: square with a solid mark, like an OSD indicator */
.check { display: flex; gap: var(--s2); align-items: center; padding: var(--s1) 0; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 1.15em; height: 1.15em; margin: 0; border: var(--rule) solid var(--go); background: transparent; cursor: pointer; }
.check input:checked { background: linear-gradient(var(--go), var(--go)) center / 55% 55% no-repeat; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s2); margin: var(--s2) 0; color: var(--dim); font-size: var(--fs-small); align-items: center; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--go); }
.slider output { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Number sheet: small label on top, number in monospace */
.stats { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0; }
.stats dt { color: var(--dim); font-size: var(--fs-small); }
.stats dd { margin: 0; font: 700 var(--fs-body) var(--f-num); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }

/* Track/arena plan (SVG from src/ui/trackPlan.js) */
.plan svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tp-bounds { fill: none; stroke: var(--line); stroke-dasharray: 2 2; }
.tp-line-under { fill: none; stroke: rgba(53, 255, 158, .12); stroke-linejoin: round; }
.tp-line { fill: none; stroke: var(--ink); stroke-linejoin: round; }
.tp-gate { fill: none; stroke: var(--warn); stroke-linecap: square; }
.tp-gate-start { stroke: var(--go); }
.tp-gate-dive { fill: rgba(255, 181, 71, .15); }
.tp-num { fill: var(--warn); font-family: var(--f-num); font-weight: 700; }
.tp-dir { fill: var(--go); }
.tp-obst { fill: rgba(226, 235, 231, .32); stroke: none; }
.tp-obst-high { fill: none; stroke: rgba(226, 235, 231, .45); }

/* ---------------------------------------------------------------- goggles frame (menu and loading) */
.deco-corners { position: absolute; inset: calc(var(--edge-y) * .45) calc(var(--edge-x) * .4); pointer-events: none; }
.deco-corners i { position: absolute; width: calc(var(--u) * 1.7); height: calc(var(--u) * 1.7); min-width: 12px; min-height: 12px; border: var(--rule-hi) solid var(--line-hi); }
.deco-corners i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.deco-corners i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.deco-corners i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.deco-corners i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.deco-ladder { position: absolute; right: calc(var(--edge-x) * .62); top: 24%; height: 50%; width: calc(var(--u) * 3.4); background: var(--ticks-y); -webkit-mask: linear-gradient(transparent, #000 20%, #000 80%, transparent); mask: linear-gradient(transparent, #000 20%, #000 80%, transparent); pointer-events: none; }
.deco-ladder::after { content: ''; position: absolute; left: -25%; right: -25%; top: 50%; height: 2px; background: var(--go); }

/* ---------------------------------------------------------------- carregamento */
#loading { position: fixed; inset: 0; z-index: 60; display: grid; align-items: center; padding: 0 var(--edge-x); background: var(--bg); transition: opacity var(--dur-slow); }
#loading.done { opacity: 0; pointer-events: none; }
.loading-box { width: min(100%, calc(var(--u) * 46)); }
.loading-title { font: 700 var(--fs-h1)/1 var(--f-title); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.loading-title b { color: var(--go); font-weight: 700; }
.loading-bar { position: relative; height: calc(var(--u) * .9); min-height: 8px; margin: var(--s5) 0 var(--s3); background: var(--ticks-x); }
.loading-bar i { position: absolute; inset: 0; background: var(--go); transform: scaleX(.03); transform-origin: left; transition: transform var(--dur-slow); }
#loading-text { color: var(--dim); font-size: var(--fs-small); }

/* ---------------------------------------------------------------- menu */
#menu { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; row-gap: var(--s5); padding: var(--edge-y) var(--edge-x); background: var(--scrim); }
/* A single row: the brand on the left and the menu on the right, centered in height. The menu shrinks with the screen (font and inset
   by --u); only in a window too narrow does it wrap to the line below, instead of cutting off. */
.menu-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); }
.brand { min-width: 0; }
.brand-name { font: 700 var(--fs-h1)/1 var(--f-title); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.brand-name b { color: var(--go); font-weight: 700; }
.menu-nav { display: flex; flex: none; margin-left: auto; border: var(--rule) solid var(--line); background: var(--panel); --nav-fs: clamp(11px, calc(var(--u) * 1.02), 19px); }
.menu-nav > * + * { border-left: var(--rule) solid var(--line); }
.menu-nav .btn { min-height: var(--touch); border: 0; background: none; padding: var(--s2) var(--s3); font-size: var(--nav-fs); letter-spacing: .07em; }
.menu-nav .field.lang { min-height: var(--touch); padding: var(--s2); font-size: var(--nav-fs); }
.menu-nav .btn:hover { background: var(--go); }

/* Screen 1: Quick Play + list on the left; the sheet of the track in the background at the bottom right */
.menu-body { min-height: 0; }
.menu-body.step-cat { display: grid; grid-template-columns: minmax(0, 46%) minmax(0, 1fr); align-items: start; }
.menu-body.step-cat > :not(#panel-cats):not(#scene-card), .menu-body.step-mode > #panel-cats, .menu-body.step-mode > #scene-card { display: none; }
#menu:has(.step-mode) .deco-ladder { display: none; }
#menu:has(.step-mode) { background: var(--scrim-full); } /* the plan needs a calm background behind it */
.menu-cats { display: flex; flex-direction: column; min-width: 0; }

.quick { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: var(--s1) var(--s4); padding: var(--s5) var(--s5) var(--s4); border: 0; text-align: left; cursor: pointer; color: var(--on-go); background: var(--go); clip-path: polygon(0 0, calc(100% - var(--cut) * 1.6) 0, 100% calc(var(--cut) * 1.6), 100% 100%, calc(var(--cut) * 1.6) 100%, 0 calc(100% - var(--cut) * 1.6)); transition: transform var(--dur) var(--ease); }
.quick:hover { transform: translateX(4px); }
.quick b { grid-column: 1 / -1; font: 700 var(--fs-hero)/.92 var(--f-title); letter-spacing: .02em; text-transform: uppercase; }
.quick-route { font: 500 var(--fs-small) var(--f-num); text-transform: uppercase; letter-spacing: .04em; }
.quick-best { text-align: right; font: 700 var(--fs-h2) var(--f-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.quick-best small { display: block; font: 500 calc(var(--fs-small) * .85) var(--f-num); letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.quick-best span:not(.has) { opacity: .55; }

.cat-head { margin: var(--s5) 0 var(--s1); }
.cat-list { border-top: var(--rule) solid var(--line); }
.cat { position: relative; display: grid; grid-template-columns: 3.2em minmax(0, 1fr) 1.2em; align-items: baseline; gap: 0 var(--s3); width: 100%; padding: var(--s3) var(--s1); text-align: left; background: none; border: 0; border-bottom: var(--rule) solid var(--line); color: var(--ink); cursor: pointer; transition: background var(--dur); }
.cat::before { content: ''; position: absolute; left: calc(var(--s3) * -1); top: 18%; bottom: 18%; width: 3px; background: transparent; }
.cat-n { color: var(--warn); font: 500 var(--fs-small) var(--f-num); }
.cat b { font: 700 var(--fs-h2)/1.05 var(--f-title); letter-spacing: .04em; text-transform: uppercase; }
.cat-desc { grid-column: 2; color: var(--dim); font-size: var(--fs-small); margin-top: 2px; }
.cat-go { grid-column: 3; grid-row: 1; color: var(--line-hi); font-family: var(--f-num); transition: color var(--dur); }
.cat:hover, .cat.last { background: linear-gradient(90deg, rgba(53, 255, 158, .09), transparent 70%); }
.cat.last::before { background: var(--go); }
.cat:hover .cat-go { color: var(--go); }
.cat:focus-visible { outline: none; background: linear-gradient(90deg, rgba(255, 181, 71, .16), transparent 75%); }
.cat:focus-visible::before { background: var(--warn); }
.cat-tut { margin-top: var(--s3); border-top: var(--rule) solid var(--line); }
.cat-tut .cat-n { color: var(--go); }

/* Guided training: card of the current step, at the top of the flight screen, below the timer */
.tut-card { position: absolute; left: 50%; top: calc(var(--edge-y) + var(--u) * 9); transform: translateX(-50%); width: min(calc(var(--u) * 46), calc(100% - var(--s5) * 2)); display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3) var(--s4); background: linear-gradient(90deg, rgba(8, 12, 11, .38), rgba(8, 12, 11, .12)); border-left: var(--rule-hi) solid var(--go); color: var(--ink); text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, .9); font: 500 var(--fs-body)/1.35 var(--f-num); animation: tut-in var(--dur) var(--ease); pointer-events: none; }
/* Nearly transparent background: the track ahead shows through the card; the text shadow ensures legibility */
.tut-card.ok { border-left-color: var(--warn); }
.tut-top { display: flex; justify-content: space-between; gap: var(--s3); color: var(--dim); font: 600 var(--fs-small) var(--f-title); letter-spacing: .12em; text-transform: uppercase; }
.tut-n { color: var(--go); }
.tut-title { font: 700 var(--fs-h2)/1.1 var(--f-title); letter-spacing: .03em; text-transform: uppercase; }
.tut-card.ok .tut-title { color: var(--warn); }
.tut-text { margin: 0; }
.tut-text kbd { color: var(--warn); }
.tut-meter { height: var(--s1); background: rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 var(--rule) var(--line); }
.tut-meter i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--go); transition: width var(--dur) var(--ease); }
@keyframes tut-in { from { opacity: 0; transform: translate(-50%, calc(var(--s2) * -1)); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .tut-card { animation: none; } .tut-meter i { transition: none; } }
.dlg-tut .dlg-box { max-width: calc(var(--u) * 46); }
.dlg-controls { width: min(680px, 96vw); }
.dlg-controls .hint { margin-top: var(--s2); }
.tut-offer { flex-wrap: wrap; align-items: center; gap: var(--s3); }
.tut-offer .btn-big { width: auto; flex: 1 1 auto; }
.tut-offer .row-btn { width: auto; border-bottom: 0; }

.scene-card { grid-column: 2; align-self: end; justify-self: end; width: clamp(180px, calc(var(--u) * 24), 460px); margin-right: calc(var(--u) * 5); padding: var(--s1) 0 var(--s1) var(--s4); border-left: var(--rule-hi) solid var(--warn); }
.scene-card .lvl, .track .lvl { display: block; color: var(--warn); font: 600 calc(var(--fs-small) * .9) var(--f-title); letter-spacing: .18em; text-transform: uppercase; }
.scene-card b { display: block; margin: 2px 0 var(--s2); font: 700 var(--fs-h2)/1 var(--f-title); text-transform: uppercase; letter-spacing: .03em; }
.scene-card .plan { height: calc(var(--u) * 9.5); margin-top: var(--s3); }

/* Screen 2: submode and scenarios on the left, plan in the middle, setup on the right */
.menu-body.step-mode { display: grid; grid-template-columns: minmax(0, 25%) minmax(0, 1fr) minmax(0, 27%); grid-template-rows: auto auto minmax(0, 1fr); gap: var(--s4) var(--s5); }
.menu-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.btn.back { background: none; }
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font: 600 var(--fs-body) var(--f-title); letter-spacing: .12em; text-transform: uppercase; }
.crumb .c-sep { color: var(--go); }
.menu-col { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
#panel-modes { grid-column: 1; grid-row: 2; overflow: visible; }
.menu-tracks { grid-column: 1; grid-row: 3; }
.menu-body.solo .menu-tracks { grid-row: 2 / 4; }
.menu-body.solo > #panel-modes { display: none; }
#panel-plan { grid-column: 2; grid-row: 2 / 4; }
#panel-options { grid-column: 3; grid-row: 2 / 4; padding: var(--s4); background: var(--panel); border-top: var(--rule-hi) solid var(--ink); }

.mode-list { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--rule) solid var(--line-hi); }
.mode { min-width: 0; padding: var(--s2) var(--s1); background: var(--panel); border: 0; border-left: var(--rule) solid var(--line); color: var(--ink); cursor: pointer; transition: background var(--dur), color var(--dur); }
.mode:first-child { border-left: 0; }
.mode b { display: block; font: 600 var(--fs-small) var(--f-title); letter-spacing: .08em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode span { display: none; }
.mode:hover { background: var(--raise); }
.mode.on { background: var(--ink); color: var(--bg); }
.mode:focus-visible { outline-offset: -3px; }
.mode-desc { margin-top: var(--s2); }

.track-list { display: flex; flex-direction: column; }
.track { position: relative; display: block; width: 100%; padding: var(--s3) var(--s3) var(--s3) var(--s4); text-align: left; background: var(--panel); border: var(--rule) solid transparent; border-bottom-color: var(--line); color: var(--ink); cursor: pointer; transition: border-color var(--dur), background var(--dur); }
.track:hover { background: var(--raise); }
.track.on { border-color: var(--go); }
.track.on::after { content: ''; position: absolute; right: -1px; top: -1px; border-top: calc(var(--u) * 1.1) solid var(--go); border-left: calc(var(--u) * 1.1) solid transparent; }
.track:focus-visible { outline-offset: -3px; }
.track b { display: block; font: 700 var(--fs-h2)/1.1 var(--f-title); text-transform: uppercase; letter-spacing: .02em; }
.track .rec { display: block; font: 500 var(--fs-small) var(--f-num); color: var(--dim); font-variant-numeric: tabular-nums; }
.track .rec.has { color: var(--go); }
.track .rec:empty { display: none; }

.panel-plan { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.plan-blurb { margin: 0 0 var(--s3); color: var(--dim); font-size: var(--fs-small); }
.panel-plan .plan { flex: 1; min-height: 0; }
.plan-ruler { height: 8px; margin: var(--s3) 0; background: var(--ticks-x); opacity: .8; }
.plan-stats { align-items: end; }
.plan-stats .best { margin-left: auto; text-align: right; }
.plan-stats .best dd { font-size: var(--fs-num-big); color: var(--dim); }
.plan-stats .best.has dd { color: var(--go); }

/* Championship in the setup panel: points bar under each pilot */
.champ-box { margin-top: var(--s3); padding-top: var(--s3); border-top: var(--rule) solid var(--line); }
.champ-status { margin: 0; font-size: var(--fs-small); }
.champ-table { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.champ-table:empty { display: none; }
.champ-table li { position: relative; display: grid; grid-template-columns: 1.6em 8px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: 3px 0 5px; }
.champ-table li::after { content: ''; position: absolute; left: calc(1.6em + 8px + var(--s2) * 2); right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, var(--line-hi) calc(var(--p, 0) * 100%), transparent 0); }
.champ-table li.me { color: var(--go); font-weight: 700; }
.champ-table li.me::after { background: linear-gradient(90deg, var(--go) calc(var(--p, 0) * 100%), transparent 0); }
.champ-table li.gone { opacity: .55; }
.champ-table .pos { color: var(--dim); }
.champ-table i { width: 8px; height: 8px; }
.champ-table .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-champ-reset { margin-top: var(--s3); }

/* Online room (only with online on) */
.lobby-code { display: flex; align-items: center; gap: var(--s3); }
.lobby-code span { color: var(--dim); font-size: var(--fs-small); letter-spacing: .12em; }
.lobby-code b { flex: 1; font: 700 var(--fs-h1) var(--f-num); letter-spacing: .16em; color: var(--warn); }
.lobby-track { color: var(--dim); font-size: var(--fs-small); margin: 2px 0 var(--s2); }
.lobby-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.lobby-players li { display: flex; gap: var(--s2); align-items: center; padding: var(--s1) var(--s2); background: var(--raise); }
.lobby-players i { width: 8px; height: 8px; flex: none; }
.lobby-players .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-players .tag { font-size: var(--fs-small); color: var(--dim); }
.lobby-players .tag.ok { color: var(--go); }
.net-msg { font-size: var(--fs-small); color: var(--warn); margin: var(--s2) 0 0; min-height: 1em; }
.net-msg.err { color: var(--hot); }

/* Footer: pilot readout on the left, FLY on the right */
.menu-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); min-height: 0; }
.foot-info { display: flex; flex-wrap: wrap; min-width: 0; color: var(--dim); font-size: var(--fs-small); }
.foot-info span { padding: 0 var(--s3); border-left: var(--rule) solid var(--line-hi); white-space: nowrap; }
.foot-info span:first-child { padding-left: 0; border-left: 0; color: var(--ink); }
/* Phone/tablet: on the start screen the summary (pilot, mode, camera, drone) leaves the footer; the Hangar stays at the top */
.touch-ui .menu-body.step-cat ~ .menu-foot .foot-info { display: none; }
.btn-go { flex: none; padding: var(--s3) var(--s6) var(--s3) var(--s5); font: 700 calc(var(--fs-hero) * .66)/1 var(--f-title); letter-spacing: .06em; text-transform: uppercase; color: var(--on-go); background: var(--go); border: 0; cursor: pointer; white-space: nowrap; clip-path: var(--chamfer); transition: transform var(--dur) var(--ease); }
.btn-go:hover { transform: translateX(4px); }
.btn-go:disabled { background: var(--raise); color: var(--dim); cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------- windows (Piloting and video, Records) */
.dlg { width: min(1180px, 96vw); max-width: none; max-height: 94vh; padding: 0; color: var(--ink); background: var(--panel-solid); border: var(--rule) solid var(--line-hi); border-top: var(--rule-hi) solid var(--go); scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
.dlg::backdrop { background: rgba(4, 6, 5, .72); }
.dlg-box { padding: var(--s4) var(--s5) var(--s5); }
/* Fixed header at the top of the window: Close stays at hand when scrolling (Piloting and video scrolls on a phone held sideways).
   The negative margins cover the box padding, so the content disappears underneath it instead of showing at the edges. */
.dlg-box > h3 { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: calc(var(--s4) * -1) calc(var(--s5) * -1) var(--s4); padding: var(--s4) var(--s5) var(--s3); background: var(--panel-solid); font: 700 var(--fs-h2) var(--f-title); letter-spacing: .06em; color: var(--ink); }
.dlg-box > h3 .btn { flex: none; }
/* Touch: finger-sized Close */
.touch-ui .dlg-box > h3 .btn { min-height: 48px; min-width: 48px; padding-inline: var(--s4); font-size: var(--fs-body); }
.set-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s6); }
.set-grid h4 { display: flex; align-items: center; gap: var(--s2); margin: var(--s5) 0 var(--s2); padding-top: var(--s2); border-top: var(--rule) solid var(--line); }
.set-grid > div > h4:first-child { margin-top: 0; }
.swatches { display: flex; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.swatches button { width: 1.6em; height: 1.6em; padding: 0; border: 0; cursor: pointer; }
.swatches button.on { outline: var(--rule-hi) solid var(--ink); outline-offset: 2px; }
.keys { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.keys th { text-align: left; color: var(--dim); font-weight: 500; padding: 3px 4px; }
.keys td { padding: 4px; border-top: var(--rule) solid var(--line); }
/* Columns: 2 keyboard, 3 mouse, 4 gamepad, 5 touch. With a touch screen (.touch-play, from input.js) touch replaces keyboard and mouse. */
html:not(.touch-play) .keys :is(th, td):nth-child(5), .touch-play .keys :is(th, td):is(:nth-child(2), :nth-child(3)) { display: none; }
.touch-play .no-touch { display: none; } /* keys that do not exist on the touch screen */
#seg-recscope { margin-bottom: var(--s2); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); margin: var(--s4) 0; }

/* Time tables: tabular monospace, record in green, difference in amber */
.board { width: 100%; border-collapse: collapse; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.board th { text-align: left; color: var(--dim); font: 600 calc(var(--fs-small) * .9) var(--f-title); letter-spacing: .12em; text-transform: uppercase; padding: var(--s1) var(--s2); }
.board td { padding: var(--s2); border-top: var(--rule) solid var(--line); }
.board .t { text-align: right; white-space: nowrap; }
.board .pos { width: 2.2em; color: var(--dim); }
.board .rmode, .board .rdrone { color: var(--dim); }
.board .gap { color: var(--warn); font-size: .92em; }
.board td small.gap { margin-left: var(--s2); }
.board tr.lead td.t:not(.gap) { color: var(--go); font-weight: 700; }
.board tr.me td { color: var(--go); font-weight: 700; }
.board tr.me { background: linear-gradient(90deg, rgba(53, 255, 158, .1), transparent); }
.board .empty { color: var(--dim); padding: var(--s4) var(--s2); text-align: center; }
.board .dot { display: inline-block; width: 8px; height: 8px; margin-right: var(--s2); vertical-align: 1px; }

/* ---------------------------------------------------------------- Hangar (src/ui/hangar.js): only variables from tokens.css */
.foot-info .foot-drone { display: inline-flex; align-items: flex-start; min-height: var(--touch); padding: 0 var(--s3); color: var(--go); background: none; border: 0; border-left: var(--rule) solid var(--line-hi); font: 600 var(--fs-small) var(--f-num); cursor: pointer; white-space: nowrap; }
.foot-info .foot-drone:hover { color: var(--on-go); background: var(--go); }
.foot-info .foot-drone .hg-ico { margin-left: var(--s1); }
.dlg-hangar .dlg-box { display: flex; flex-direction: column; gap: var(--s4); }
.dlg-hangar .dlg-box > h3 { margin-bottom: 0; }
.dlg-hangar .btn, .dlg-hangar .btn-big { min-height: var(--touch); }
.hg-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s5); align-items: end; padding-bottom: var(--s3); border-bottom: var(--rule) solid var(--line); }
.hg-level { display: flex; align-items: baseline; gap: var(--s3); }
.hg-level b { font: 700 var(--fs-num-big)/1 var(--f-title); letter-spacing: var(--ls-title); text-transform: uppercase; color: var(--go); }
.hg-level span { font: 600 var(--fs-h2)/1 var(--f-num); color: var(--ink); font-variant-numeric: tabular-nums; }
.hg-next { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; color: var(--dim); font-size: var(--fs-small); }
.hg-meter { position: relative; height: var(--s2); background: var(--raise); box-shadow: inset 0 0 0 var(--rule) var(--line); }
.hg-meter i { position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); background: var(--go); transition: width var(--dur-slow) var(--ease); }

.hg-body { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.hg-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s2); }
.hg-card { position: relative; display: flex; flex-direction: column; gap: var(--s1); min-width: 0; min-height: var(--touch); padding: var(--s2); text-align: left; color: var(--ink); background: var(--panel); border: var(--rule) solid var(--line); cursor: pointer; transition: border-color var(--dur), background var(--dur); }
.hg-card:hover { background: var(--raise); border-color: var(--line-hi); }
.hg-card.sel { background: var(--raise); border-color: var(--warn); }
.hg-card:focus-visible { outline: var(--rule-hi) solid var(--warn); outline-offset: var(--rule-hi); }
.hg-card.using { box-shadow: inset 0 calc(var(--rule-hi) * -2) 0 var(--go); }
.hg-thumb { display: block; aspect-ratio: var(--ratio-thumb); background: var(--bg); overflow: hidden; }
.hg-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.hg-card.locked .hg-thumb { background: var(--shade-locked); }
.hg-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 var(--fs-body)/1.2 var(--f-title); letter-spacing: var(--ls-title); text-transform: uppercase; }
.hg-card-tag { display: flex; align-items: center; gap: var(--s1); min-width: 0; overflow: hidden; white-space: nowrap; color: var(--dim); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.hg-card.locked .hg-card-name { color: var(--dim); }
.hg-card.using .hg-card-tag { color: var(--go); }
.hg-card.new .hg-card-tag { color: var(--warn); }
.hg-ico { flex: none; width: var(--icon); height: var(--icon); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.hg-detail { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; padding: var(--s3) var(--s4) var(--s4); background: var(--panel); border-top: var(--rule-hi) solid var(--warn); }
.hg-preview { display: block; width: 100%; aspect-ratio: var(--ratio-preview); background: var(--bg); }
.hg-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); min-width: 0; }
.hg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 var(--fs-h1)/1 var(--f-title); letter-spacing: var(--ls-title); text-transform: uppercase; }
.hg-tag { flex: none; color: var(--dim); font: 600 var(--fs-small) var(--f-title); letter-spacing: var(--ls-label); text-transform: uppercase; }
.hg-tag.using { color: var(--go); }
.hg-tag.locked { color: var(--warn); }
.hg-desc { margin: 0; color: var(--ink); font-size: var(--fs-body); line-height: 1.45; }
.hg-bars { display: grid; gap: var(--s2); margin: 0; }
.hg-bar-row { display: grid; grid-template-columns: minmax(0, var(--w-bar-label)) minmax(0, 1fr); gap: var(--s3); align-items: center; }
.hg-bar-row dt { color: var(--dim); font: 600 var(--fs-small) var(--f-title); letter-spacing: var(--ls-label); text-transform: uppercase; }
.hg-bar { position: relative; height: var(--s2); margin: 0; background: var(--raise); }
.hg-bar i { position: absolute; inset: 0 auto 0 0; width: calc(var(--v, 0) * 100%); background: var(--warn); transition: width var(--dur-slow) var(--ease); }
.hg-bar::after { content: ''; position: absolute; left: 50%; top: calc(var(--s1) * -1); bottom: calc(var(--s1) * -1); width: var(--rule-hi); background: var(--ink); }
.hg-ref { margin: 0; }
.hg-lock { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) var(--s3); color: var(--warn); background: var(--raise); }
.hg-lock p { margin: 0; font: 700 var(--fs-h3) var(--f-title); letter-spacing: var(--ls-label); text-transform: uppercase; }
.hg-lock .hg-meter i { background: var(--warn); }
.hg-use { padding: var(--s3) var(--s4); font: 700 var(--fs-h2)/1 var(--f-title); }
.hg-use:disabled { background: var(--raise); color: var(--dim); cursor: not-allowed; transform: none; }
.hg-why { margin: 0; }
.hg-why:empty { display: none; }
.hg-left { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.hg-note { margin: 0; }
@media (prefers-reduced-motion: reduce) { .hg-meter i, .hg-bar i { transition: none; } }
/* Narrow upright screen: the panel goes below the grid, 3 cards per row */
@media (max-aspect-ratio: 1/1) {
  .hg-top, .hg-body { grid-template-columns: minmax(0, 1fr); }
  .hg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Short landscape (phone held sideways): grid and panel side by side, shorter preview */
@media (max-height: 480px) and (min-aspect-ratio: 4/3) {
  .hg-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s1); }
  .hg-card { padding: var(--s1); }
  .hg-preview { aspect-ratio: auto; height: calc(var(--touch) * 2.6); }
}

/* ---------------------------------------------------------------- pause, result, podium */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; }
/* Pause: panel on the left; the frozen event stays visible beside it */
.pause { align-items: center; justify-items: start; padding: var(--edge-y) var(--edge-x); background: var(--scrim); }
.side-box { width: clamp(240px, calc(var(--u) * 34), 620px); display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); background: var(--panel-solid); border-top: var(--rule-hi) solid var(--ink); }
.side-box .hint { margin: 0; }
.side-box .btn-big { margin-top: var(--s3); }

.results, .podium { place-items: center; padding: var(--edge-y) var(--edge-x); background: var(--scrim-full); }
.res-box { position: relative; width: clamp(300px, calc(var(--u) * 68), 1200px); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); background: var(--panel-solid); border-top: var(--rule-hi) solid var(--go); scrollbar-width: thin; }
.res-top { display: flex; align-items: center; gap: var(--s5); }
.res-pos { flex: none; display: flex; align-items: baseline; color: var(--go); }
.res-pos b { font: 700 calc(var(--fs-hero) * 1.7)/.85 var(--f-title); }
.res-pos small { font: 600 var(--fs-h2) var(--f-num); color: var(--dim); }
.res-sum { min-width: 0; }
.res-head { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s3); }
.res-head div { display: flex; flex-direction: column; }
.res-head small { color: var(--dim); font-size: var(--fs-small); }
.res-head b { font: 700 var(--fs-num-big) var(--f-num); font-variant-numeric: tabular-nums; }
.res-head .rec b { color: var(--go); }
.res-table td:nth-child(2) { font-weight: 500; }
.res-table .pos { font: 700 var(--fs-body) var(--f-title); }
.pbar { display: inline-block; position: relative; width: calc(var(--u) * 9); min-width: 40px; height: 6px; margin-right: var(--s3); vertical-align: middle; background: var(--line); }
.pbar::after { content: ''; position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); background: var(--warn); }
tr.me .pbar::after { background: var(--go); }
.res-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s5); }

/* Pilot Points of the event: statement on the left, total and next-drone bar on the right; unlocked ones below */
.res-pp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3) var(--s5); padding: var(--s3) var(--s4); background: var(--raise); border-left: var(--rule-hi) solid var(--warn); }
.pp-items { margin: 0; padding: 0; list-style: none; font: 500 var(--fs-small) var(--f-num); }
.pp-items li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; border-bottom: var(--rule) solid var(--line); }
.pp-items li b { color: var(--go); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-items li.neg b { color: var(--dim); }
.pp-items li.empty { color: var(--dim); }
.pp-sum { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.pp-sum small { color: var(--dim); font: 600 var(--fs-h3) var(--f-title); letter-spacing: .16em; text-transform: uppercase; }
.pp-total { font: 700 var(--fs-num-big)/1 var(--f-num); color: var(--warn); }
.pp-level { font: 600 var(--fs-body) var(--f-title); letter-spacing: .06em; text-transform: uppercase; }
.pp-level span { margin-left: var(--s2); color: var(--dim); font-family: var(--f-num); text-transform: none; letter-spacing: 0; }
.pp-next { color: var(--dim); font-size: var(--fs-small); }
.pp-up { color: var(--go); font: 600 var(--fs-body) var(--f-title); text-transform: uppercase; letter-spacing: .06em; }
.pp-unlocks { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--s2); }
.pp-unlock { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s4); padding: var(--s2) var(--s3); border: var(--rule) solid var(--go); background: var(--panel); }
.pp-unlock b { color: var(--go); font: 700 var(--fs-body) var(--f-title); text-transform: uppercase; letter-spacing: .04em; }
.pp-unlock .btn { min-height: var(--touch); }

/* Track medals: each one's own color (tokens), in the track list and on the sheet */
.medal-bronze { --medal: var(--medal-bronze); }
.medal-prata { --medal: var(--medal-prata); }
.medal-ouro { --medal: var(--medal-ouro); }
.track .md { display: block; margin-top: var(--s1); color: var(--medal); font: 600 calc(var(--fs-small) * .9) var(--f-title); letter-spacing: .16em; text-transform: uppercase; }
.track .md::before { content: ''; display: inline-block; width: .7em; height: .7em; margin-right: var(--s1); border-radius: 50%; background: var(--medal); vertical-align: -.05em; }
.plan-stats .medals { flex-basis: 100%; }
.plan-stats .medals dd { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.plan-stats .medals dd span { color: var(--medal); font-weight: 500; }
.plan-stats .medals dd span.got { font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.res-actions .btn-big { width: auto; flex: none; padding-right: var(--s6); }
.res-actions .row-btn { width: auto; border-bottom: 0; padding: var(--s2) var(--s1); }

.podium { z-index: 35; }
.podium-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.podium-kicker { color: var(--warn); font: 600 var(--fs-h3) var(--f-title); letter-spacing: .2em; text-transform: uppercase; }
/* Podium: chamfered steps, height = position; 1st green, 2nd amber, 3rd neutral. Each pilot's color is the step's trim */
.podium-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: var(--s3); margin: var(--s3) 0; }
.podium-step { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.podium-step .nm { font: 700 var(--fs-h2) var(--f-title); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-step .pts { color: var(--dim); font: 500 var(--fs-small) var(--f-num); }
.podium-step .block { display: flex; align-items: flex-end; padding: var(--s2) var(--s3); margin-top: var(--s2); font: 700 var(--fs-hero)/1 var(--f-title); color: var(--dim); background: var(--raise); border-top: 4px solid var(--c); clip-path: var(--chamfer-sm); transform-origin: bottom; animation: podium-rise var(--dur-slow) var(--ease) both; }
.podium-step.p1 .block { height: calc(var(--u) * 11); color: var(--on-go); background: var(--go); animation-delay: 120ms; }
.podium-step.p2 .block { height: calc(var(--u) * 7.5); color: var(--warn); animation-delay: 60ms; }
.podium-step.p3 .block { height: calc(var(--u) * 5); }
.podium-step.p1 .nm { color: var(--go); }
@keyframes podium-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
#podium-table td:nth-child(n+3), #podium-table th:nth-child(n+3) { text-align: right; }

/* ---------------------------------------------------------------- short iframe in landscape (640×360 up to ~1020×480) */
@media (max-height: 480px) and (min-aspect-ratio: 4/3) {
  #menu { row-gap: var(--s3); }
  .deco-ladder, .cat-head, .plan-blurb, .plan-ruler, .mode-desc { display: none; }
  .quick { padding: var(--s3) var(--s4); }
  .cat { padding: var(--s2) var(--s1); }
  .cat-desc { display: none; }
  .scene-card .plan { height: calc(var(--u) * 12); }
  .menu-body.step-mode { gap: var(--s2) var(--s3); grid-template-columns: minmax(0, 27%) minmax(0, 1fr) minmax(0, 30%); }
  .track { padding: var(--s2) var(--s3); }
  .track .lvl { display: none; }
  #panel-options { padding: var(--s3); }
  .set-grid { gap: var(--s4); }
  .side-box { gap: var(--s2); }
  .res-box { gap: var(--s2); padding: var(--s3) var(--s4); }
  .board td { padding: 3px var(--s2); }
}

/* ---------------------------------------------------------------- narrow upright screen (phone): a single column that scrolls */
@media (max-aspect-ratio: 1/1) {
  #menu { overflow-y: auto; grid-template-rows: auto 1fr auto; } /* spare height goes to the body, it does not space out the header */
  .menu-head { flex-direction: column; }
  /* With the Hangar the top bar has 4 items: upright, it wraps onto lines instead of exceeding the width */
  /* 2×2 grid of equal columns, plus a narrow column for the icons (sound, fullscreen): the dividers are the background
     showing through the 1px gap */
  .menu-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--rule); width: 100%; margin-left: 0; background: var(--line); --nav-fs: clamp(14px, 3.8vw, 20px); }
  .menu-nav > * + * { border-left: 0; }
  .menu-nav .btn, .menu-nav .field.lang { width: 100%; min-height: 52px; padding: var(--s2) var(--s3); background: var(--panel-solid); text-align: center; text-align-last: center; }
  .menu-nav .btn { white-space: normal; line-height: 1.15; }
  /* "Português (Brasil)" has 18 monospace characters (0.6em each): the font shrinks with the width to fit in half a column */
  .menu-nav .field.lang { padding-inline: var(--s2); font-size: max(11px, min(var(--nav-fs), calc((100vw - 160px) / 22))); }
  #lang-pick { order: 1; justify-content: center; } #btn-hangar { order: 2; } #btn-sound { order: 3; } #btn-records { order: 4; } #btn-settings { order: 5; } #btn-fullscreen { order: 6; }
  .menu-nav .qb { width: 56px; padding: var(--s2); }
  .brand-name { white-space: normal; }
  .deco-ladder, .scene-card { display: none; }
  .menu-body.step-cat { grid-template-columns: minmax(0, 1fr); }
  .menu-body.step-mode, .menu-body.step-mode.solo { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  /* Each panel takes the height it needs and the whole menu scrolls: without this the track list, the plan and the Setup
     were squeezed into the screen height and the Setup ended up over the map */
  .menu-body, .menu-col, .panel-plan, .menu-foot { min-height: auto; }
  .menu-col { overflow: visible; }
  #panel-modes, .menu-tracks, .menu-body.solo .menu-tracks, #panel-plan, #panel-options { grid-column: 1; grid-row: auto; }
  #panel-plan .plan { height: 50vw; flex: none; }
  .menu-foot { position: sticky; bottom: 0; flex-direction: column; align-items: stretch; gap: var(--s2); }
  .btn-go { width: 100%; }
  .set-grid, .rec-grid, .res-pp { grid-template-columns: 1fr; }
  .side-box { width: 100%; }
}
/* ---------------------------------------------------------------- rotate screen: only on an upright phone */
[data-rotate], .rotate-tip { display: none; }
/* .touch-ui comes from JS (rotate.js): touch screen OR a browser that identifies as phone/tablet
   (phone simulators usually only change the identification, keeping the mouse) */
@media (max-aspect-ratio: 1/1) {
  .touch-ui .rotate-btn { display: flex; width: 100%; padding: var(--s3); color: var(--go); background: var(--panel); border-color: var(--go); }
  .touch-ui .rotate-row { display: flex; }
  .touch-ui .rotate-tip:not(.closed) { display: grid; }
  .touch-ui .rotate-tip [data-rotate] { display: inline-flex; }
  /* With the hint open on the start screen, the header button would be redundant */
  .touch-ui #menu:has(.step-cat .rotate-tip:not(.closed)) .rotate-btn { display: none; }
}
/* Landscape hint on the start screen: a drawn phone that turns sideways and back, in a loop */
.rotate-tip { position: relative; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s3); align-items: center; margin-top: var(--s5); padding: var(--s3) var(--s5) var(--s3) var(--s3); background: var(--panel); border-left: var(--rule-hi) solid var(--go); animation: rt-in var(--dur-slow) var(--ease) .4s both; }
.rotate-tip.closed { display: none; }
.rt-anim { width: 64px; height: 64px; overflow: visible; }
.rt-phone { transform-box: fill-box; transform-origin: center; animation: rt-turn 3.2s var(--ease) infinite; }
.rt-phone rect { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.rt-phone line { stroke: var(--go); stroke-width: 2.5; stroke-linecap: round; }
.rt-arrow, .rt-arrow-head { fill: none; stroke: var(--go); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; animation: rt-arrow 3.2s var(--ease) infinite; }
.rt-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.rt-text b { font: 700 var(--fs-body) var(--f-title); letter-spacing: .06em; text-transform: uppercase; color: var(--go); }
.rt-text span { color: var(--dim); font-size: var(--fs-small); }
.rt-go { margin-top: var(--s2); color: var(--go); border-color: var(--go); }
.rt-close { position: absolute; right: 0; top: 0; width: 36px; height: 36px; padding: 0; border: 0; background: none; color: var(--dim); font-size: 14px; cursor: pointer; }
.rt-close:hover { color: var(--ink); }
@keyframes rt-turn { 0%, 22% { transform: rotate(0deg); } 45%, 75% { transform: rotate(90deg); } 95%, 100% { transform: rotate(0deg); } }
@keyframes rt-arrow { 0%, 12% { opacity: 0; } 25%, 45% { opacity: 1; } 55%, 100% { opacity: 0; } }
@keyframes rt-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .rotate-tip, .rt-arrow, .rt-arrow-head { animation: none; }
  .rt-phone { animation: none; transform: rotate(90deg); }
}
.rotate-msg { position: fixed; left: 50%; bottom: calc(var(--edge-y) + 64px); z-index: 70; width: max-content; max-width: calc(100vw - 32px); margin: 0; padding: var(--s3) var(--s4); transform: translateX(-50%); color: var(--ink); background: var(--panel-solid); border-top: var(--rule-hi) solid var(--warn); font-size: var(--fs-small); text-align: center; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .podium-step .block { animation: none; }
}
@media (max-height: 480px) and (min-aspect-ratio: 4/3) { .seg button { white-space: normal; overflow: visible; line-height: 1.15; padding: 3px 2px; } }

/* ---------------------------------------------------------------- quick buttons: sound and fullscreen (src/ui/screenButtons.js) */
.qb { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); }
.qb-ico { width: 1.35em; height: 1.35em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.qb-spk { fill: currentColor; }
.menu-nav .qb { min-width: var(--touch); }
.qb-off, .is-off .qb-on, .qb-exit, .is-on .qb-enter { display: none; }
.is-off .qb-off, .is-on .qb-exit { display: inline; }
[data-sound].is-off { color: var(--warn); }
.qb-row { justify-content: flex-start; }
.qb-row::after { margin-left: auto; }

/* ---------------------------------------------------------------- phone/tablet upright: game only in landscape */
.rotate-lock { display: none; }
@media (max-aspect-ratio: 1/1) {
  .touch-ui .rotate-lock { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); padding: var(--s5); text-align: center; background: var(--panel-solid, #0b0f0d); }
  .touch-ui .rotate-lock [data-rotate] { display: inline-flex; }
  .touch-ui body { overflow: hidden; }
}
.rl-anim { width: 120px; height: 120px; overflow: visible; }
.rotate-lock b { font: 700 clamp(22px, 6vw, 32px) var(--f-title); letter-spacing: .06em; text-transform: uppercase; color: var(--go); }
.rotate-lock span { max-width: 32ch; color: var(--ink); font-size: clamp(15px, 4.2vw, 19px); line-height: 1.4; }
.rl-go { margin-top: var(--s3); min-height: var(--touch); padding-inline: var(--s5); color: var(--go); border-color: var(--go); }

/* ---------------------------------------------------------------- narrow landscape (small phone, 640×360 iframe):
   the header stays on a single row. The brand goes onto two lines (fits the button height) and the language becomes an abbreviation. */
@media (max-width: 820px) and (min-aspect-ratio: 1/1) {
  .brand-name b { display: block; }
  .lc-full { display: none; }
  .lc-short { display: inline; }
}
@media (max-width: 600px) and (min-aspect-ratio: 1/1) {
  .menu-nav .btn { padding-inline: var(--s1); letter-spacing: .03em; }
  .menu-nav .qb { min-width: 40px; }
}
/* Laptop (medium height): the category list ends above the footer summary, without overlapping */
@media (max-height: 900px) and (min-aspect-ratio: 4/3) {
  .cat-head { display: none; }
  .cat { padding-block: var(--s2); }
}
