/* Arus UI: quiet liquid glass over the water. One set of tokens; Barlow Condensed italic for
   numbers and titles, Inter for everything you read. State never rides on colour alone. */
:root {
  --ink: #f4f7f8;
  --ink-2: rgba(244, 247, 248, 0.7);
  --ink-3: rgba(244, 247, 248, 0.46);
  --glass: rgba(12, 24, 32, 0.38);
  --glass-2: rgba(12, 24, 32, 0.56);
  --glass-3: rgba(12, 24, 32, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --line-2: rgba(255, 255, 255, 0.26);
  --hi: rgba(255, 255, 255, 0.92);
  --dark: #06121a;
  --accent: #ffb341;        /* orange: warnings, penalties */
  --cool: #6cc4ff;          /* blue: boost, the player */
  --r: 18px;
  --blur: blur(22px) saturate(1.35);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --num: 'Barlow Condensed', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--dark); color: var(--ink); font-family: Inter, system-ui, sans-serif; -webkit-user-select: none; user-select: none; -webkit-font-smoothing: antialiased; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; }
button:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }

/* ------------------------------------------------------------------ shared pieces */
.glass { background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
h1 { font: italic 800 64px/0.88 var(--num); margin: 0; letter-spacing: 0.03em; }
h2 { font: italic 800 38px/1 var(--num); margin: 0 0 14px; letter-spacing: 0.01em; }
h3 { font: 600 11px Inter, sans-serif; margin: 0 0 8px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 7px 0; }
.row label { font-size: 13px; color: var(--ink-2); }
.seg { display: flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); }
.seg button { border: 0; background: none; color: var(--ink-2); font: 600 12.5px Inter, sans-serif; padding: 6px 13px; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--hi); color: var(--dark); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18); }
.seg-wide { width: 100%; }
.seg-wide button { flex: 1; padding: 8px 10px; font-size: 13px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-2); color: var(--ink); cursor: pointer; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.icon-btn:hover { background: var(--glass-3); }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; margin-right: 3px; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.08); font: 600 11px Inter, sans-serif; color: var(--ink); text-align: center; }
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, rgba(4, 14, 20, 0.2), rgba(4, 14, 20, 0.6)); }
.card { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; scrollbar-width: thin; padding: 26px 26px 22px; border-radius: 24px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }
.card.small { width: min(300px, 100%); text-align: center; }
.card > button { display: block; width: 100%; margin-top: 10px; padding: 13px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); color: var(--ink); font: 600 15px Inter, sans-serif; cursor: pointer; transition: background 0.15s; }
.card > button:hover { background: rgba(255, 255, 255, 0.14); }
.card > button.primary, .go { margin-top: 18px; background: var(--hi); color: var(--dark); border-color: transparent; font-weight: 700; }
.card > button.primary:hover, .go:hover { background: #fff; }
.loading { position: fixed; inset: 0; display: grid; place-items: end start; padding: 0 0 max(48px, 8vh) max(28px, 5vw); background: var(--dark) center / cover no-repeat; color: var(--ink-2); z-index: 5; }
.loading::before { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(4, 12, 18, 0.92), rgba(4, 12, 18, 0.35) 60%, rgba(4, 12, 18, 0.55)); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#loadText { position: relative; display: grid; gap: 6px; font-size: 13px; }
#loadText b { font: italic 800 54px/0.9 var(--num); color: var(--ink); letter-spacing: 0.02em; }
.load-bar { display: block; width: 220px; height: 3px; margin-top: 12px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; position: relative; }
.load-bar::after { content: ''; position: absolute; inset: 0; width: 40%; background: var(--hi); border-radius: 2px; animation: load 1.1s ease-in-out infinite; }
.load-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.load-row .load-bar { margin-top: 0; }
#loadPct { font: italic 700 18px/1 var(--num); color: var(--ink); min-width: 3.2em; }
.load-bar.fill::after { display: none; }
.load-bar.fill > i { position: absolute; inset: 0 auto 0 0; width: 4%; background: var(--hi); border-radius: 2px; transition: width 0.3s ease-out; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* ------------------------------------------------------------------ main menu */
.screen.menu { display: block; padding: 0; background: linear-gradient(90deg, rgba(4, 14, 20, 0.55), rgba(4, 14, 20, 0) 46%), linear-gradient(0deg, rgba(4, 14, 20, 0.35), rgba(4, 14, 20, 0) 30%); }
.m-panel { position: absolute; top: 20px; bottom: 20px; left: max(20px, 3vw); width: min(430px, calc(100% - 40px)); padding: 24px 22px; border-radius: 26px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: 16px; }
.m-panel::-webkit-scrollbar { display: none; }
.m-brand h1 { font-size: 68px; }
.m-group { padding: 14px 14px 10px; border-radius: var(--r); background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); }
.venues { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.venue { position: relative; aspect-ratio: 16 / 10.5; text-align: left; padding: 0; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; cursor: pointer; color: var(--ink); background: #0b1a22 center / cover no-repeat; font: 500 11px Inter, sans-serif; transition: transform 0.15s, border-color 0.15s; }
.venue:hover { transform: translateY(-2px); border-color: var(--line-2); }
.venue::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(4, 12, 18, 0.88) 0%, rgba(4, 12, 18, 0.25) 55%, rgba(4, 12, 18, 0) 75%); }
.venue .v-t { position: absolute; left: 10px; right: 10px; bottom: 9px; z-index: 1; }
.venue b { display: block; font: italic 800 19px/1 var(--num); letter-spacing: 0.01em; }
.venue .v-t > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; color: var(--ink-2); line-height: 1.3; }
.venue small { position: absolute; top: 8px; right: 8px; z-index: 1; padding: 3px 8px; border-radius: 999px; background: rgba(4, 12, 18, 0.55); font: 600 10.5px Inter, sans-serif; font-variant-numeric: tabular-nums; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.venue small:empty { display: none; }
/* chosen: a white frame and a check mark, not only a colour change */
.venue.on { border: 2px solid var(--hi); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.14); }
.venue.on .v-t b::after { content: '\2713'; margin-left: 6px; font: 700 14px Inter, sans-serif; }
.venue:disabled { cursor: default; filter: grayscale(0.7) brightness(0.6); transform: none; }
.m-settings { position: absolute; top: 22px; right: max(22px, 3vw); }
.m-craft { position: absolute; right: max(22px, 3vw); bottom: 22px; width: min(320px, calc(100% - 44px)); padding: 16px; border-radius: 24px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }
.m-craft .m-group { background: none; border: 0; padding: 0; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; margin: 12px 0 10px; font-size: 12px; color: var(--ink-2); }
.bar { display: flex; gap: 3px; justify-content: flex-end; }
.bar i { width: 22px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
.bar i.f { background: var(--hi); }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.22); cursor: pointer; padding: 0; transition: transform 0.12s; }
.swatch:hover { transform: scale(1.08); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3); transform: scale(1.12); }
.menu-best { margin: 12px 2px 0; font-size: 12px; color: var(--ink-2); min-height: 1em; font-variant-numeric: tabular-nums; }
.go { display: block; width: 100%; padding: 15px; border-radius: 999px; font: italic 800 24px/1 var(--num); letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; transition: background 0.15s, transform 0.1s; }
.go:active { transform: scale(0.985); }
.go-hint { margin: 8px 0 0; text-align: center; font-size: 11px; color: var(--ink-3); }
.s-h { margin-top: 18px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; font-size: 12.5px; color: var(--ink-2); }
.tricklist { columns: 2; margin: 12px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.7; color: var(--ink-2); }
.controls { margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.controls summary { cursor: pointer; }
.credits { margin: 10px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }

/* ------------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--num); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3); }
.chip { display: inline-block; padding: 6px 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.k { display: block; font: 600 10px Inter, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); text-shadow: none; }
.hud-tl { position: absolute; top: max(18px, env(safe-area-inset-top)); left: 22px; display: grid; gap: 8px; justify-items: start; }
.pos { line-height: 0.82; }
.pos b { font-size: 78px; font-weight: 800; font-style: italic; }
.pos .of { font-size: 30px; font-weight: 700; color: var(--ink-2); margin-left: 2px; }
.lap { font-size: 24px; font-weight: 700; }
.lap .k { display: inline; margin-right: 4px; }
.lap span:last-child { color: var(--ink-2); }
.hud-tr { position: absolute; top: max(18px, env(safe-area-inset-top)); right: 22px; text-align: right; display: grid; gap: 6px; justify-items: end; }
.time { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.best, .pen { font-size: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pen { color: var(--accent); font-weight: 700; }
.pen:not(:empty)::before { content: '\25B2  '; font-size: 12px; }   /* a shape as well as the colour */
#map { position: absolute; left: 18px; bottom: 18px; width: 172px; height: 172px; border-radius: 28px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); }
.gauge { position: absolute; right: 18px; bottom: 8px; width: 230px; height: 196px; }
.gauge svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gauge path { fill: none; stroke-linecap: round; }
.g-track { stroke: rgba(255, 255, 255, 0.14); stroke-width: 9; }
.g-speed { stroke: var(--hi); stroke-width: 9; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset 0.08s linear; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35)); }
.g-btrack { stroke: rgba(108, 196, 255, 0.16); stroke-width: 5; }
.g-boost { stroke: var(--cool); stroke-width: 5; stroke-dasharray: 100; stroke-dashoffset: 70; transition: stroke-dashoffset 0.08s linear; }
.gauge.on .g-boost { stroke: #fff; filter: drop-shadow(0 0 8px rgba(108, 196, 255, 0.9)); }
.g-read { position: absolute; left: 0; right: 0; top: 62px; text-align: center; line-height: 0.85; }
.g-read b { display: block; font-size: 76px; font-weight: 800; font-style: italic; font-variant-numeric: tabular-nums; }
.g-read span { font: 600 11px Inter, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.g-label { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font: 600 10px Inter, sans-serif; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); text-shadow: none; }
.gauge.on .g-label { color: var(--ink); }
.gauge.on .g-label::before { content: '\25B6\25B6  '; }   /* boosting: arrows, not only a glow */
.msg { position: absolute; top: 25%; left: 0; right: 0; text-align: center; font-size: 48px; font-weight: 800; font-style: italic; letter-spacing: 0.03em; opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.msg.show { opacity: 1; transform: none; }
.msg.warn { color: var(--accent); }
.msg.warn::before { content: '\25B2  '; font-size: 30px; vertical-align: 6px; }
.feed { position: absolute; top: 36%; left: 0; right: 0; text-align: center; font-size: 30px; font-weight: 800; font-style: italic; }
.feed div { animation: rise 1.4s ease-out forwards; }
.feed small { display: block; font: 600 13px Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); font-style: normal; }
@keyframes rise { 0% { opacity: 0; transform: translateY(14px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }
.count { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-size: 160px; font-weight: 800; font-style: italic; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.35); }
.score b { font-size: 66px; font-weight: 800; font-style: italic; line-height: 0.9; font-variant-numeric: tabular-nums; }
.mult { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; }
.chain { width: 120px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.chain div { height: 100%; width: 0; background: var(--hi); }

/* ------------------------------------------------------------------ results */
.res { list-style: none; padding: 0; margin: 0 0 4px; counter-reset: r; display: grid; gap: 4px; }
.res li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-variant-numeric: tabular-nums; counter-increment: r; background: rgba(255, 255, 255, 0.035); }
.res li::before { content: counter(r); display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); font: italic 800 17px var(--num); color: var(--ink-2); }
/* the podium: filled discs (a shape change, not only a colour) */
.res li:nth-child(-n+3)::before { background: var(--hi); color: var(--dark); border-color: transparent; }
.res li span:first-of-type { flex: 1; font-weight: 600; }
.res li span:last-of-type { color: var(--ink-2); }
.res li.me { background: rgba(255, 255, 255, 0.14); box-shadow: inset 3px 0 0 var(--cool); }
.res li.me span { color: var(--ink); font-weight: 700; }
.res li em { display: block; font: 500 11px Inter, sans-serif; color: var(--accent); font-style: normal; }
.cup-rounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: cr; }
.cup-rounds li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); counter-increment: cr; }
.cup-rounds li::before { content: counter(cr); display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); font: italic 800 15px var(--num); color: var(--ink-2); }
.cup-rounds li b { flex: 1; font-weight: 600; }
.cup-rounds li span { color: var(--ink-3); font-size: 12px; }
.cup-rounds li.done { opacity: 0.55; }
.cup-rounds li.now { background: rgba(255, 255, 255, 0.13); box-shadow: inset 3px 0 0 var(--cool); }
.cup-h { margin: 14px 0 8px; font: 600 12px Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.res-sub { margin: -8px 0 16px; font-size: 12px; color: var(--ink-3); letter-spacing: 0.02em; }
.res.plain li::before { content: none; }
.res li.note { counter-increment: none; background: none; color: var(--ink-2); justify-content: center; font-size: 13px; }
.res li.note::before { content: none; }

/* ------------------------------------------------------------------ touch */
.touch { position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 0 14px max(14px, env(safe-area-inset-bottom)); pointer-events: none; }
.touch > div { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.touch button { width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: 700 22px Inter, sans-serif; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: none; }
.touch button.t-small { width: 64px; height: 64px; font-size: 12px; }
.touch button.down { background: rgba(255, 255, 255, 0.35); }

/* ------------------------------------------------------------------ replay bar and photo panel */
.replay { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100% - 32px)); padding: 12px 14px; border-radius: 22px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.rp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.replay .seg { flex-wrap: wrap; border-radius: 18px; max-width: 100%; }
.replay .seg button { white-space: nowrap; }
.rp-row input[type=range] { flex: 1; min-width: 120px; accent-color: #fff; }
.rp-btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); color: var(--ink); font: 600 13px Inter, sans-serif; padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.rp-btn:hover { background: rgba(255, 255, 255, 0.14); }
.rp-clock { font: 600 13px Inter, sans-serif; color: var(--ink-2); min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.rp-who { font: italic 800 18px var(--num); min-width: 90px; text-align: center; }
.rp-gap { flex: 1; }
.photo { position: fixed; right: 16px; top: 16px; width: min(290px, calc(100% - 32px)); padding: 18px; border-radius: 22px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); display: grid; gap: 12px; }
.photo h3 { margin: 0; }
.photo label { display: grid; gap: 6px; font: 600 12px Inter, sans-serif; color: var(--ink-2); }
.photo label span { float: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.photo input[type=range] { width: 100%; accent-color: #fff; }
.ph-hint { margin: 0; font: 500 12px Inter, sans-serif; color: var(--ink-3); line-height: 1.45; }
.photo button { padding: 11px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); color: var(--ink); font: 600 14px Inter, sans-serif; cursor: pointer; }
.photo button.primary { background: var(--hi); color: var(--dark); border-color: transparent; font-weight: 700; }

/* ------------------------------------------------------------------ small screens and touch */
@media (pointer: coarse) {
  /* phones: the map goes under the clock, the gauge tucks into the corner above the buttons */
  #map { width: 104px; height: 104px; top: max(64px, calc(env(safe-area-inset-top) + 52px)); bottom: auto; left: auto; right: 14px; border-radius: 20px; }
  /* and what sits under the clock (best, penalty, split, ghost gap) moves left of the map */
  .hud-tr > :not(.time) { margin-right: 114px; }
  .gauge { right: 6px; bottom: 96px; width: 150px; height: 128px; }
  .g-read { top: 40px; }
  .g-read b { font-size: 46px; }
  .g-label { bottom: 6px; }
  .touch { padding: 0 10px max(12px, env(safe-area-inset-bottom)); }
  .touch > div { gap: 8px; }
  .touch button { width: 64px; height: 64px; }
  .touch button.t-small { width: 54px; height: 54px; font-size: 11px; }
  /* no frosted blur over the live 3D view on phones: it re-blurs the scene under every button each frame */
  .touch button { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(10, 22, 30, 0.45); }
  .touch button.down { background: rgba(255, 255, 255, 0.35); }
  /* same for everything that sits over the race: the menus keep their glass */
  #hud, #hud *, #map, .nametag, .icon-btn { backdrop-filter: none; -webkit-backdrop-filter: none; }
  #hud .chip, #map { background: rgba(6, 18, 26, 0.55); }
  /* the settings button lives in the menu panel's header on phones: in the corner, the jet ski card covered it */
  .m-brand { position: relative; }
  .m-brand .m-settings { position: absolute; top: 0; right: 0; }
  /* and the jet ski card scrolls instead of running off the top of a landscape phone */
  .m-craft { max-height: calc(100% - 44px); overflow-y: auto; scrollbar-width: none; }
  .m-craft::-webkit-scrollbar { display: none; }
}
@media (max-width: 760px) {
  .screen.menu { background: linear-gradient(0deg, rgba(4, 14, 20, 0.6), rgba(4, 14, 20, 0) 70%); }
  .m-panel { top: auto; bottom: 0; left: 0; width: 100%; max-height: 64dvh; border-radius: 26px 26px 0 0; padding: 18px 16px calc(150px + env(safe-area-inset-bottom)); gap: 12px; }
  .m-brand h1 { font-size: 46px; }
  .m-brand .sub { display: none; }
  .m-craft { left: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; padding: 10px 16px max(12px, env(safe-area-inset-bottom)); background: var(--glass-3); box-shadow: none; border-width: 1px 0 0; }
  .m-craft .stats, .m-craft h3, .menu-best, .go-hint { display: none; }
  .m-craft .seg { margin-bottom: 8px; }
  .swatches { justify-content: center; }
  .go { margin-top: 10px; padding: 13px; font-size: 21px; }
  .m-settings { top: max(14px, env(safe-area-inset-top)); right: 14px; }
  .pos b { font-size: 56px; }
  .time { font-size: 26px; }
  .keys { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .photo { top: auto; bottom: 16px; max-height: calc(100% - 32px); overflow-y: auto; }
  .replay { bottom: 10px; padding: 10px; gap: 8px; }
  .rp-gap { display: none; }
  .rp-btn { padding: 7px 11px; }
}

/* ------------------------------------------------------------------ race moments */
.count { display: grid; justify-items: center; gap: 10px; }
.count b { font-size: 150px; line-height: 0.85; }
.lights { display: flex; gap: 14px; padding: 12px 16px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.lights i { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line-2); transition: background 0.12s, box-shadow 0.12s; }
.lights i.on { background: var(--accent); border-color: transparent; box-shadow: 0 0 16px rgba(255, 179, 65, 0.8); }
.lights.go i { background: var(--hi); box-shadow: 0 0 18px rgba(255, 255, 255, 0.9); }
.pdelta { display: inline-block; margin-left: 8px; font: 800 22px var(--num); vertical-align: 26px; opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.pdelta.show { opacity: 1; transform: none; }
.pdelta.up { color: var(--cool); }
.pdelta.down { color: var(--accent); }
.split { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; animation: rise-in 0.3s ease-out; }
.split .k { display: inline; margin-right: 4px; }
.split em { font-style: normal; margin-left: 6px; }
.split em.up { color: var(--cool); }
.split em.down { color: var(--accent); }
.split.gap { animation: none; }
@keyframes rise-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pause-info { display: grid; gap: 2px; margin: -4px 0 8px; padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.pause-info span { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.pause-info b { font: italic 800 46px/1 var(--num); }
.pause-info b i { font-size: 24px; color: var(--ink-2); }
.pause-info small { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.touch button svg { display: block; margin: auto; }
/* the menu settles in: panels rise and fade when it opens */
.screen.menu .m-panel { animation: panel-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.screen.menu .m-craft { animation: panel-in 0.45s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.card { animation: card-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen.menu .m-panel, .screen.menu .m-craft, .card, .split { animation: none; } }

/* ------------------------------------------------------------------ film: letterbox and titles */
.bars { position: fixed; inset: 0; pointer-events: none; }
.bars i { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.9s cubic-bezier(0.65, 0, 0.35, 1); }
.bars i:first-child { top: 0; }
.bars i:last-child { bottom: 0; }
.bars.on i { height: 10.5vh; }
body.cine #hud, body.cine #touch { opacity: 0; transition: opacity 0.4s; }
#hud, #touch { transition: opacity 0.6s; }
.cine-title { position: fixed; left: max(28px, 6vw); bottom: calc(10.5vh + max(28px, 4vh)); pointer-events: none; display: grid; gap: 6px; opacity: 0; transform: translateY(10px); transition: opacity 0.9s, transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1); text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45); }
.cine-title.on { opacity: 1; transform: none; }
.cine-title small { font: 600 12px Inter, sans-serif; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2); }
.cine-title b { font: italic 800 clamp(48px, 9vw, 104px)/0.86 var(--num); letter-spacing: 0.01em; }
.cine-title span { font: 500 15px Inter, sans-serif; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .bars i, .cine-title { transition: none; } }

/* ------------------------------------------------------------------ online room */
.online { display: grid; gap: 10px; }
.on-idle { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.on-join { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.online input { min-width: 0; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--ink); font: 600 14px Inter, sans-serif; outline: none; }
.online input:focus { border-color: var(--hi); }
#onCode { text-transform: uppercase; letter-spacing: 0.3em; font-family: var(--num); font-size: 18px; }
.pill { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass-2, rgba(255,255,255,0.08)); color: var(--ink); font: 600 13px Inter, sans-serif; cursor: pointer; white-space: nowrap; }
.pill:hover { border-color: var(--hi); }
.on-head { display: flex; align-items: center; gap: 8px; }
.on-head span { flex: 1; color: var(--ink-2); font: 600 13px Inter, sans-serif; }
.on-head b { font: italic 800 26px/1 var(--num); letter-spacing: 0.12em; color: var(--ink); margin-left: 4px; }
.on-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.on-players li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); font: 600 14px Inter, sans-serif; }
.on-players li em { font-style: normal; color: var(--ink-2); font-weight: 500; }
.on-players li.ready em { color: var(--ink); }
.on-note { margin: 0; color: var(--ink-2); font: 500 12.5px/1.4 Inter, sans-serif; }
.on-note:empty { display: none; }
.m-panel.guest .venues, .m-panel.guest .m-group { pointer-events: none; opacity: 0.55; }
.go:disabled { opacity: 0.45; cursor: default; }
.nametag { position: fixed; transform: translate(-50%, -100%); pointer-events: none; padding: 3px 9px; border-radius: 999px; background: rgba(4, 12, 18, 0.6); border: 1px solid var(--line); color: var(--ink); font: 700 12px Inter, sans-serif; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
body.cine .nametag { opacity: 0; }
@media (max-width: 560px) { #segMode button { padding: 6px 8px; font-size: 12px; white-space: nowrap; } }
