/* SUNRAIL — canyon anti-gravity racer. All selectors are scoped to #app, #hud, #ui. */

@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/BarlowCondensed-Regular.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/BarlowCondensed-Medium.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/BarlowCondensed-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/BarlowCondensed-Bold.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/BarlowCondensed-Italic.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 600; font-display: swap; src: url("../fonts/BarlowCondensed-SemiBoldItalic.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: italic; font-weight: 700; font-display: swap; src: url("../fonts/BarlowCondensed-BoldItalic.woff2") format("woff2"); }

:root {
  --ink: #f6efe3;
  --ink-dim: rgba(246, 239, 227, 0.7);
  --ink-faint: rgba(246, 239, 227, 0.42);
  --rail: #2fe6d6;
  --edge: #f0b27a;
  --ember: #e2572b;
  --danger: #ff5a3c;
  --good: #7ff6c8;
  --panel: rgba(22, 13, 16, 0.82);
  --panel-2: rgba(34, 20, 24, 0.72);
  --line: rgba(246, 239, 227, 0.16);
  --player-hull: #e2572b;
  --font: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --slant: 12px;
  --safe-br: 72px; /* keeps the bottom-right corner clear for the host's referral tab */
}

html, body {
  margin: 0;
  height: 100%;
  background: #1a1114;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#app::after {
  /* subtle edge falloff keeps the telemetry legible against bright rock */
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 140px rgba(10, 6, 10, 0.55);
}
.layer { position: absolute; inset: 0; pointer-events: none; }
.is-hidden { display: none !important; }

button { font-family: inherit; }

/* ---------------------------------------------------------------- panels */
#ui .panel, #hud .panel {
  position: relative;
  background: var(--panel);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  padding: 16px 26px;
  color: var(--ink);
}
#ui .panel-k, #hud .panel-k {
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--edge);
  margin-bottom: 10px; font-weight: 600;
}

/* ----------------------------------------------------------------- screens */
#ui { pointer-events: none; }
#ui .screen { position: absolute; inset: 0; pointer-events: none; }
#ui .screen > * { pointer-events: auto; }
#ui.overlay .screen { background: rgba(12, 7, 10, 0.58); }
#ui .screen-head { position: absolute; left: 40px; top: 28px; max-width: 760px; }
#ui h2 {
  margin: 0; font-size: 44px; line-height: 1; font-style: italic; font-weight: 700; letter-spacing: 0.01em;
  text-transform: uppercase; color: var(--ink); text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
#ui .screen-sub { margin: 8px 0 0; font-size: 17px; color: var(--ink-dim); font-weight: 500; letter-spacing: 0.02em; }
#ui .screen-sub b { color: var(--edge); font-weight: 600; }

/* menu items: angled panels */
#ui .menu { display: flex; flex-direction: column; gap: 6px; }
#ui .mi {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 14px;
  text-align: left; border: 0; cursor: pointer; color: var(--ink);
  background: rgba(22, 13, 16, 0.78);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  padding: 7px 26px 7px 22px; min-height: 44px;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}
#ui .mi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--edge);
  opacity: 0.9; transform: translateX(3px); transition: opacity 120ms ease;
}
#ui .mi-label { font-size: 23px; font-weight: 600; font-style: italic; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.1; }
#ui .mi-detail { grid-column: 1 / -1; font-size: 13px; color: var(--ink-dim); font-weight: 500; letter-spacing: 0.02em; margin-top: 2px; }
#ui .mi-sub { grid-column: 1 / -1; font-size: 14px; color: var(--ink-faint); }
#ui .mi-adjust { font-size: 16px; color: var(--edge); letter-spacing: 0.2em; }
#ui .mi:hover, #ui .mi.is-focus { background: var(--rail); color: #0b1a1c; }
#ui .mi:hover::before, #ui .mi.is-focus::before { background: #0b1a1c; }
#ui .mi:hover .mi-detail, #ui .mi.is-focus .mi-detail, #ui .mi:hover .mi-sub, #ui .mi.is-focus .mi-sub, #ui .mi:hover .mi-adjust, #ui .mi.is-focus .mi-adjust { color: rgba(11, 26, 28, 0.75); }
#ui .mi:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#ui .mi:disabled { opacity: 0.5; cursor: default; }
#ui .mi-danger.is-focus, #ui .mi-danger:hover { background: var(--danger); color: #1a0a08; }
#ui .mi-quiet .mi-label { font-size: 21px; font-weight: 500; color: var(--ink-dim); }
#ui .mi-quiet.is-focus .mi-label, #ui .mi-quiet:hover .mi-label { color: #0b1a1c; }
#ui .screen > .menu { position: absolute; left: 40px; bottom: 84px; width: 420px; }

/* main menu */
#ui .screen-menu::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 54%; background: linear-gradient(90deg, rgba(12, 7, 10, 0.66), rgba(12, 7, 10, 0.25) 60%, rgba(12, 7, 10, 0)); pointer-events: none; }
#ui .screen-menu .brand { position: absolute; left: 40px; top: 30px; width: 520px; }
#ui .brand-title {
  margin: 0; font-size: 104px; line-height: 0.86; font-style: italic; font-weight: 700; letter-spacing: -0.015em;
  color: var(--ink); text-shadow: 0 4px 30px rgba(0, 0, 0, 0.55);
}
#ui .brand-title::after { content: ""; display: block; width: 140px; height: 6px; margin-top: 14px; background: var(--rail); transform: skewX(-30deg); }
#ui .brand-sub { margin: 14px 0 0; font-size: 18px; line-height: 1.3; color: var(--ink-dim); max-width: 440px; font-weight: 500; text-shadow: 0 1px 10px rgba(0,0,0,0.6); }
#ui .screen-menu .menu-main { left: 40px; top: 278px; bottom: auto; width: 430px; }
#ui .screen-menu .menu-footer { position: absolute; left: 40px; bottom: 20px; display: flex; gap: 18px; font-size: 14px; color: var(--ink-dim); letter-spacing: 0.03em; }
#ui .menu-footer b { display: inline-block; min-width: 20px; padding: 1px 6px; margin-right: 4px; border: 1px solid var(--ink-faint); border-radius: 3px; font-weight: 600; color: var(--ink); text-align: center; }
#ui .side-card { position: absolute; right: 40px; bottom: calc(var(--safe-br) + 20px); width: 330px; padding: 18px 26px 18px 30px; }
#ui .side-card-k { font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--edge); font-weight: 600; }
#ui .side-card-title { font-size: 34px; font-style: italic; font-weight: 700; text-transform: uppercase; line-height: 1; margin: 4px 0 8px; }
#ui .circuit-map { width: 100%; height: 130px; display: block; }
#ui .cm-shadow { fill: none; stroke: rgba(0, 0, 0, 0.5); stroke-width: 9; stroke-linejoin: round; }
#ui .cm-road { fill: none; stroke: var(--rail); stroke-width: 4; stroke-linejoin: round; }
#ui .side-card-facts { margin: 10px 0 0; display: grid; gap: 6px; }
#ui .side-card-facts > div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; font-size: 15px; }
#ui .side-card-facts dt { color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; padding-top: 3px; }
#ui .side-card-facts dd { margin: 0; color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

/* season / standings / calendar */
#ui .calendar { position: absolute; left: 40px; top: 120px; width: 520px; }
#ui .cal-row { display: grid; grid-template-columns: 28px 170px 1fr 70px; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 16px; }
#ui .cal-row.is-next { background: rgba(47, 230, 214, 0.08); }
#ui .cal-n { color: var(--edge); font-weight: 700; font-style: italic; }
#ui .cal-name { font-weight: 600; font-size: 19px; text-transform: uppercase; font-style: italic; }
#ui .cal-mood { color: var(--ink-dim); font-size: 14px; }
#ui .cal-res { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
#ui .tag-next { font-size: 12px; letter-spacing: 0.14em; background: var(--rail); color: #0b1a1c; padding: 2px 8px; font-weight: 700; }
#ui .standings-panel { position: absolute; right: 40px; top: 120px; width: 480px; }
#ui .tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
#ui .tbl th { text-align: left; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--line); }
#ui .tbl td { padding: 6px 8px; border-bottom: 1px solid rgba(246, 239, 227, 0.08); }
#ui .tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
#ui .tbl tr.me td { background: rgba(47, 230, 214, 0.1); color: var(--ink); font-weight: 600; }
#ui .st-c { display: inline-block; width: 10px; height: 10px; margin-right: 10px; transform: skewX(-20deg); vertical-align: middle; }
#ui .muted { color: var(--ink-faint); }
#ui .mv { font-size: 11px; margin-left: 6px; }
#ui .mv.up { color: var(--good); }
#ui .mv.down { color: var(--danger); }
#ui .screen-season .menu { width: 420px; }
#ui .fl { display: inline-block; margin-left: 8px; font-size: 11px; letter-spacing: 0.1em; background: var(--edge); color: #1a1114; padding: 1px 6px; font-weight: 700; vertical-align: middle; }

/* circuit select */
#ui .circuit-row { position: absolute; left: 40px; right: 40px; top: 124px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
#ui .circuit-card { border: 0; cursor: pointer; text-align: left; color: var(--ink); display: grid; gap: 4px; padding: 14px 20px 14px 24px; transition: background-color 120ms ease; }
#ui .circuit-card .circuit-map { height: 150px; }
#ui .circuit-card.is-on { background: rgba(47, 230, 214, 0.14); box-shadow: inset 0 0 0 2px var(--rail); }
#ui .circuit-card:hover { background: rgba(47, 230, 214, 0.1); }
#ui .circuit-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#ui .cc-name { font-size: 26px; font-style: italic; font-weight: 700; text-transform: uppercase; line-height: 1; }
#ui .cc-len { font-size: 14px; color: var(--ink-dim); }
#ui .cc-rec { font-size: 14px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#ui .circuit-detail { position: absolute; left: 40px; bottom: 84px; width: 520px; }
#ui .cd-title { font-size: 30px; font-style: italic; font-weight: 700; text-transform: uppercase; line-height: 1; }
#ui .cd-tag { color: var(--edge); font-size: 17px; font-weight: 600; margin-top: 2px; }
#ui .cd-mood { color: var(--ink-dim); font-size: 15px; margin-top: 6px; }
#ui .cd-feats { color: var(--ink); font-size: 15px; margin-top: 8px; letter-spacing: 0.03em; }
#ui .cd-rules { color: var(--ink-faint); font-size: 14px; margin-top: 6px; }
#ui .screen-circuits .menu { left: auto; right: 40px; width: 360px; }

/* pre-race */
#ui .entrylist { position: absolute; left: 40px; top: 120px; width: 460px; }
#ui .grid-row { display: grid; grid-template-columns: 30px 24px 1fr 120px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: 16px; }
#ui .grid-row.me { background: rgba(47, 230, 214, 0.1); font-weight: 600; }
#ui .g-pos { font-style: italic; font-weight: 700; color: var(--edge); }
#ui .g-tag { text-align: right; color: var(--ink-faint); font-size: 14px; }
#ui .panel-info { position: absolute; left: 520px; top: 120px; width: 380px; }
#ui .screen-prerace .menu { width: 460px; }
#ui .screen-qual .menu { width: 460px; }
#ui .qual-result { position: absolute; left: 40px; top: 130px; width: 520px; }
#ui .qr-pos { font-size: 22px; color: var(--edge); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
#ui .qr-time { font-size: 84px; font-style: italic; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; margin: 6px 0; }
#ui .qr-delta { color: var(--ink-dim); font-size: 16px; font-variant-numeric: tabular-nums; }

/* results */
#ui .screen-results { overflow: hidden; }
#ui .res-hero { position: absolute; left: 40px; top: 28px; width: 620px; }
#ui .res-k { font-size: 14px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--edge); font-weight: 600; }
#ui .res-pos { font-size: 112px; line-height: 0.9; font-style: italic; font-weight: 700; letter-spacing: -0.01em; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
#ui .res-line { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
#ui .res-table { position: absolute; left: 40px; top: 236px; width: 620px; padding: 10px 26px 12px 30px; max-height: calc(100vh - 330px); overflow: hidden; background: rgba(22, 13, 16, 0.9); }
#ui .res-stats { position: absolute; right: 40px; top: 28px; width: 440px; background: rgba(22, 13, 16, 0.9); }
#ui .res-stats dl { margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
#ui .res-stats dl > div { display: flex; justify-content: space-between; font-size: 15px; border-top: 1px solid var(--line); padding-top: 4px; }
#ui .res-stats dt { color: var(--ink-faint); }
#ui .res-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
#ui .res-credits > div { display: flex; justify-content: space-between; font-size: 15px; padding: 3px 0; }
#ui .res-credits .res-total { border-top: 1px solid var(--ink); font-weight: 700; font-size: 17px; margin-top: 4px; padding-top: 6px; }
#ui .res-record b { color: var(--rail); }
#ui .res-standings { position: absolute; right: 40px; top: 300px; width: 440px; max-height: calc(100vh - 440px); overflow: hidden; }
#ui .res-quote { position: absolute; left: 40px; bottom: 96px; margin: 0; max-width: 620px; font-style: italic; font-size: 19px; color: var(--ink-dim); border-left: 4px solid var(--edge); padding: 4px 0 4px 16px; }
#ui .screen-results .menu { left: auto; right: 40px; width: 360px; }
#ui .screen-results[data-mode="timetrial"] .res-pos { font-size: 72px; }

/* pause / help / confirm */
#ui .screen-pause .menu { left: 40px; top: 120px; bottom: auto; width: 420px; }
#ui .pause-hint { position: absolute; left: 40px; top: 520px; color: var(--ink-dim); font-size: 14px; }
#ui .help-grid { position: absolute; left: 40px; right: 40px; top: 124px; display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
#ui .keys td { font-size: 15px; padding: 5px 8px; }
#ui .keys td:first-child { white-space: nowrap; }
#ui .keys b { display: inline-block; min-width: 26px; padding: 1px 7px; margin-right: 4px; border: 1px solid var(--ink-faint); border-radius: 3px; font-weight: 600; text-align: center; }
#ui .help-rules ul { margin: 0; padding-left: 18px; font-size: 15px; line-height: 1.35; color: var(--ink-dim); }
#ui .help-rules li { margin-bottom: 8px; }
#ui .help-rules b { color: var(--ink); }
#ui .screen-help .menu { left: 40px; bottom: 84px; width: 300px; }
#ui .confirm-box { position: absolute; left: 40px; top: 160px; width: 520px; }
#ui .confirm-text { font-size: 22px; line-height: 1.3; }
#ui .screen-confirm .menu { left: 40px; top: 280px; bottom: auto; width: 420px; }

/* garage */
#ui .screen-garage .screen-head { left: 40px; }
#ui .credits-big { color: var(--rail); font-weight: 700; font-variant-numeric: tabular-nums; }
#ui .garage-upgrades { position: absolute; left: 40px; top: 112px; width: 520px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#ui .upg { padding: 10px 20px 10px 24px; }
#ui .upg-head { display: flex; justify-content: space-between; align-items: center; }
#ui .upg-name { font-size: 21px; font-style: italic; font-weight: 700; text-transform: uppercase; }
#ui .pips { display: flex; gap: 4px; }
#ui .pips i { width: 26px; height: 8px; background: rgba(246, 239, 227, 0.2); transform: skewX(-30deg); }
#ui .pips i.on { background: var(--rail); }
#ui .upg-blurb { margin: 2px 0 6px; color: var(--ink-dim); font-size: 13px; }
#ui .upg-next { display: flex; flex-direction: column; justify-content: space-between; font-size: 13px; gap: 4px; }
#ui .upg-cost { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--edge); }
#ui .upg-max { color: var(--good); font-weight: 600; }
#ui .btn { border: 0; cursor: pointer; font-family: inherit; font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 20px; color: #0b1a1c; background: var(--rail); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
#ui .btn:disabled { background: rgba(246, 239, 227, 0.18); color: var(--ink-faint); cursor: default; }
#ui .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#ui .upg-buy { margin-top: 8px; padding: 6px 16px; font-size: 14px; }
#ui .garage-livery { position: absolute; left: 40px; top: 372px; width: 520px; }
#ui .swatches { display: flex; gap: 8px; flex-wrap: wrap; }
#ui .swatch { border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--ink-dim); cursor: pointer; padding: 6px 10px; display: flex; align-items: center; gap: 8px; font-family: inherit; font-size: 14px; letter-spacing: 0.04em; clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
#ui .swatch i { width: 18px; height: 18px; background: var(--sw); transform: skewX(-20deg); display: inline-block; }
#ui .swatch.is-on { border-color: var(--rail); color: var(--ink); background: rgba(47, 230, 214, 0.12); }
#ui .screen-garage .menu { left: 40px; bottom: 84px; width: 420px; }

/* toast */
#toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%) translateY(-20px); background: var(--panel); color: var(--ink); padding: 8px 22px; font-size: 15px; letter-spacing: 0.04em; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); opacity: 0; transition: opacity 200ms ease, transform 200ms ease; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------------------------------------------------------- HUD */
#hud { font-variant-numeric: tabular-nums; }
#hud .hud-tl { position: absolute; left: 28px; top: 22px; width: 230px; }
#hud .hud-pos { display: flex; align-items: baseline; gap: 6px; line-height: 1; }
#hud .hud-pos-n { font-size: 58px; font-weight: 700; font-style: italic; letter-spacing: -0.01em; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.6); }
#hud .hud-pos-t { font-size: 22px; font-weight: 600; color: var(--ink-dim); }
#hud .hud-lap { font-size: 20px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--edge); margin-top: -2px; }
#hud .hud-times { margin-top: 8px; display: grid; gap: 2px; }
#hud .hud-time-row { display: grid; grid-template-columns: 54px 1fr; font-size: 18px; line-height: 1.15; }
#hud .hud-time-row .k { font-size: 12px; letter-spacing: 0.16em; color: var(--ink-faint); padding-top: 4px; font-weight: 600; }
#hud .hud-time-row .v { font-weight: 600; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7); }
#hud .hud-delta .v { color: var(--edge); }
#hud .hud-delta .v.neg { color: var(--good); }
#hud .hud-standings { position: absolute; left: 28px; top: 50%; transform: translateY(-50%); display: grid; gap: 1px; font-size: 14px; }
#hud .st-row { display: grid; grid-template-columns: 18px 14px 40px 1fr; align-items: center; gap: 6px; padding: 2px 10px 2px 6px; background: rgba(10, 6, 10, 0.35); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); min-width: 118px; }
#hud .st-row.me { background: rgba(47, 230, 214, 0.22); font-weight: 700; }
#hud .st-row.out { opacity: 0.45; }
#hud .st-p { font-weight: 700; font-style: italic; }
#hud .st-c { width: 10px; height: 10px; transform: skewX(-20deg); }
#hud .st-g { text-align: right; color: var(--ink-dim); font-size: 13px; }
#hud .st-row.me .st-g { color: var(--ink); }
#hud .hud-tr { position: absolute; right: 28px; top: 22px; width: 150px; }
#hud .hud-map { width: 150px; height: 150px; display: block; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)); }
#hud .hud-gap { display: grid; gap: 2px; font-size: 14px; color: var(--ink-dim); margin-top: 4px; text-align: right; font-weight: 600; letter-spacing: 0.04em; }
#hud .hud-gap span:first-child { color: var(--ink); }
#hud .hud-radio { position: absolute; left: 50%; top: 24px; transform: translateX(-50%); max-width: 640px; display: grid; gap: 2px; padding: 8px 26px 8px 30px; background: rgba(10, 6, 10, 0.55); clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); opacity: 0; transition: opacity 220ms ease; }
#hud .hud-radio.show { opacity: 1; }
#hud .hud-radio-sp { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--edge); font-weight: 700; }
#hud .hud-radio[data-tone="rival"] .hud-radio-sp { color: var(--rail); }
#hud .hud-radio-tx { font-size: 17px; line-height: 1.2; font-weight: 500; }
#hud .hud-msg { position: absolute; left: 50%; top: 34%; transform: translateX(-50%); text-align: center; opacity: 0; pointer-events: none; }
#hud .hud-msg.show { animation: sr-msg 1.6s ease-out forwards; }
#hud .hud-msg-main { font-size: 44px; font-weight: 700; font-style: italic; text-transform: uppercase; line-height: 1; letter-spacing: 0.02em; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6); }
#hud .hud-msg[data-kind="good"] .hud-msg-main { color: var(--good); }
#hud .hud-msg[data-kind="warn"] .hud-msg-main { color: var(--danger); font-size: 38px; }
#hud .hud-msg[data-kind="big"] .hud-msg-main { font-size: 76px; color: var(--ink); }
#hud .hud-msg-sub { font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--edge); margin-top: 6px; font-weight: 600; }
@keyframes sr-msg { 0% { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.96); } 10% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-6px); } }
#hud .hud-count { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-size: 150px; font-weight: 700; font-style: italic; line-height: 1; color: var(--ink); text-shadow: 0 6px 40px rgba(0, 0, 0, 0.6); opacity: 0; }
#hud .hud-count.pop { animation: sr-count 0.9s ease-out forwards; }
@keyframes sr-count { 0% { opacity: 0; transform: translateX(-50%) scale(1.3); } 15% { opacity: 1; transform: translateX(-50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scale(0.9); } }
#hud .hud-bl { position: absolute; left: 28px; bottom: 26px; width: 230px; }
#hud .hud-speed { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
#hud .hud-speed-n { font-size: 76px; font-weight: 700; font-style: italic; letter-spacing: -0.01em; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.65); }
#hud .hud-speed-u { font-size: 16px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
#hud .hud-bar { position: relative; height: 14px; margin-top: 8px; background: rgba(10, 6, 10, 0.55); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); overflow: hidden; }
#hud .hud-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--edge); transition: width 120ms linear; }
#hud .hud-shield.low .hud-bar-fill { background: var(--danger); }
#hud .hud-bar-k { position: absolute; left: 10px; top: 0; font-size: 10px; letter-spacing: 0.16em; line-height: 14px; color: #1a1114; font-weight: 700; }
#hud .hud-shield.low .hud-bar-k { color: var(--ink); }
#hud .hud-bc { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); width: 380px; text-align: center; }
#hud .hud-chips { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
#hud .chip { font-size: 11px; letter-spacing: 0.16em; font-weight: 700; padding: 3px 12px; color: var(--ink-faint); background: rgba(10, 6, 10, 0.4); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); transition: color 120ms ease, background-color 120ms ease; }
#hud .chip.on { background: var(--rail); color: #0b1a1c; }
#hud .hud-boost { position: relative; display: flex; align-items: center; gap: 10px; justify-content: center; }
#hud .hud-boost-segs { display: flex; gap: 3px; flex: 1; }
#hud .hud-boost-segs i { flex: 1; height: 16px; background: rgba(10, 6, 10, 0.55); transform: skewX(-24deg); border-top: 1px solid rgba(246, 239, 227, 0.12); }
#hud .hud-boost-segs i.on { background: var(--rail); box-shadow: 0 0 10px rgba(47, 230, 214, 0.5); }
#hud .hud-boost-k { font-size: 14px; letter-spacing: 0.2em; font-weight: 700; color: var(--ink-dim); min-width: 58px; text-align: left; }
#hud .hud-boost-k.ready { color: var(--rail); }
#hud .hud-boost-k.active { color: var(--ink); }
#hud .hud-boost-hint { font-size: 12px; letter-spacing: 0.14em; color: var(--ink); border: 1px solid var(--rail); padding: 1px 8px; opacity: 0; transition: opacity 160ms ease; }
#hud .hud-boost-hint.show { opacity: 1; }
#hud .hud-hints { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); display: flex; gap: 14px; font-size: 12px; color: var(--ink-faint); letter-spacing: 0.04em; white-space: nowrap; }
#hud .hud-hints b { color: var(--ink-dim); border: 1px solid var(--line); padding: 0 5px; margin-right: 3px; border-radius: 2px; font-weight: 600; }
#hud[data-mode="timetrial"] .hud-standings, #hud[data-mode="qualifying"] .hud-standings { display: none; }

/* touch controls: only on coarse pointers, and clear of the host tab */
.touch { display: none; position: absolute; inset: 0; pointer-events: none; }
.touch button { pointer-events: auto; position: absolute; width: 64px; height: 64px; border: 1px solid rgba(246, 239, 227, 0.35); background: rgba(10, 6, 10, 0.4); color: var(--ink); font-family: var(--font); font-size: 22px; font-weight: 700; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); touch-action: none; user-select: none; -webkit-user-select: none; }
.touch button:active, .touch button.on { background: rgba(47, 230, 214, 0.6); color: #0b1a1c; }
@media (pointer: coarse) {
  .touch.show { display: block; }
  #hud .hud-hints { display: none; }
  #hud .hud-bc { left: 100px; right: 200px; width: auto; transform: none; bottom: 16px; }
}
.touch .t-left { left: 14px; bottom: 92px; }
.touch .t-right { left: 86px; bottom: 92px; }
.touch .t-throttle { right: 14px; bottom: 160px; }
.touch .t-brake { right: 14px; bottom: 88px; }
.touch .t-boost { right: 86px; bottom: 88px; width: 64px; font-size: 13px; letter-spacing: 0.08em; }
.touch .t-pause { left: 50%; top: 16px; transform: translateX(-50%); width: 56px; height: 36px; font-size: 13px; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  #ui .brand-title { font-size: 84px; }
  #ui .screen-menu .brand { width: 440px; }
  #ui .side-card { width: 280px; right: 24px; }
  #ui .circuit-row { grid-template-columns: repeat(2, 1fr); top: 110px; }
  #ui .circuit-card .circuit-map { height: 110px; }
  #ui .help-grid { grid-template-columns: 1fr 1fr; }
  #ui .help-rules { grid-column: 1 / -1; }
  #ui .res-table { width: 56%; }
  #ui .res-stats, #ui .res-standings { width: 36%; }
}
@media (max-width: 720px), (max-height: 520px) {
  #ui .screen-head { left: 16px; top: 14px; right: 16px; }
  #ui h2 { font-size: 30px; }
  #ui .screen-sub { font-size: 14px; }
  #ui .screen > .menu { left: 16px !important; right: 16px !important; width: auto !important; bottom: 16px; }
  #ui .screen-circuits .menu, #ui .screen-results .menu { right: 16px !important; left: auto !important; width: 260px !important; }
  #ui .mi { min-height: 44px; padding: 8px 20px 8px 18px; }
  #ui .mi-label { font-size: 21px; }
  #ui .screen-menu .brand { left: 16px; top: 14px; width: calc(100% - 32px); }
  #ui .brand-title { font-size: 64px; }
  #ui .brand-title::after { height: 4px; width: 90px; margin-top: 8px; }
  #ui .brand-sub { font-size: 14px; margin-top: 10px; max-width: 420px; }
  #ui .screen-menu .menu-main { left: 16px; top: 150px; width: min(360px, calc(100% - 32px)); }
  #ui .side-card { display: none; }
  #ui .screen-menu .menu-footer { display: none; }
  #ui .calendar, #ui .standings-panel, #ui .entrylist, #ui .panel-info, #ui .qual-result, #ui .confirm-box, #ui .garage-upgrades, #ui .garage-livery { left: 16px; right: 16px; width: auto; top: 78px; }
  #ui .garage-upgrades { grid-template-columns: 1fr; }
  #ui .standings-panel { top: 200px; }
  #ui .garage-livery { top: 330px; }
  #ui .circuit-row { left: 16px; right: 16px; top: 78px; gap: 8px; }
  #ui .circuit-card .circuit-map { height: 80px; }
  #ui .cc-name { font-size: 19px; }
  #ui .circuit-detail { display: none; }
  #ui .help-grid { left: 16px; right: 16px; top: 78px; grid-template-columns: 1fr; }
  #ui .help-grid .panel { padding: 10px 18px; }
  #ui .res-hero { left: 16px; top: 14px; width: calc(100% - 32px); }
  #ui .res-pos { font-size: 64px; }
  #ui .res-table { left: 16px; top: 150px; width: calc(100% - 32px); }
  #ui .res-stats { left: 16px; right: 16px; top: 330px; width: auto; }
  #ui .res-standings { display: none; }
  #ui .res-quote { display: none; }
  #hud .hud-tl { left: 12px; top: 10px; width: 170px; }
  #hud .hud-pos-n { font-size: 40px; }
  #hud .hud-time-row { font-size: 14px; grid-template-columns: 40px 1fr; }
  #hud .hud-standings { display: none; }
  #hud .hud-tr { right: 12px; top: 10px; width: 96px; }
  #hud .hud-map { width: 96px; height: 96px; }
  #hud .hud-gap { font-size: 11px; }
  #hud .hud-radio { top: 112px; max-width: 70%; padding: 6px 18px; }
  #hud .hud-radio-tx { font-size: 14px; }
  #hud .hud-speed-n { font-size: 48px; }
  #hud .hud-bl { width: 170px; left: 12px; bottom: 14px; }
  #hud .hud-bc { width: 220px; bottom: 14px; }
  #hud .hud-msg-main { font-size: 40px; }
  #hud .hud-msg[data-kind="big"] .hud-msg-main { font-size: 56px; }
  #hud .hud-count { font-size: 90px; }
}

/* peek: a compact title over the live scene, no menus competing for the small frame */
.peek #ui .screen-menu .menu-main { display: none; }
.peek #ui .brand-title { font-size: 72px; }
.peek #ui .screen-menu .brand { width: 70%; }
.peek #ui .side-card, .peek #ui .menu-footer { display: none; }
.peek #hud .hud-hints, .peek #hud .hud-standings { display: none; }

/* reduced motion: no decorative animation, the scene itself stays live */
.reduced-motion #hud .hud-msg.show, .reduced-motion #hud .hud-count.pop { animation-duration: 0.01ms; }
.reduced-motion #ui .mi, .reduced-motion #hud .hud-bar-fill { transition: none; }

/* narrow phones: stack the boost bar above the speed readout, move the radio below the timing block */
@media (max-width: 720px) {
  #hud .hud-hints { display: none; }
  #hud .hud-radio { top: 118px; left: 12px; right: 12px; transform: none; max-width: none; }
  #hud .hud-bc { left: 12px; right: 12px; width: auto; transform: none; bottom: 70px; }
  #hud .hud-chips { flex-wrap: nowrap; gap: 4px; }
  #hud .chip { font-size: 10px; padding: 2px 8px; white-space: nowrap; letter-spacing: 0.1em; }
  #hud .hud-msg { top: 42%; }
}
/* short viewports (landscape phones): compact brand and menu, no details */
@media (max-height: 520px) {
  #ui .screen-menu .brand { top: 10px; left: 16px; }
  #ui .brand-title { font-size: 56px; }
  #ui .brand-title::after { height: 3px; width: 80px; margin-top: 6px; }
  #ui .brand-sub { display: none; }
  #ui .screen-menu .menu-main { top: 96px; left: 16px; width: 340px; gap: 4px; }
  #ui .mi { min-height: 40px; padding: 5px 20px 5px 18px; }
  #ui .mi-label { font-size: 19px; }
  #ui .mi-detail, #ui .mi-sub { display: none; }
  #ui .screen > .menu { bottom: 12px; }
  #ui h2 { font-size: 26px; }
  #ui .screen-sub { display: none; }
  #ui .screen-head { top: 10px; }
  #hud .hud-hints { display: none; }
  #hud .hud-radio { top: 8px; }
  #hud .hud-chips { display: none; }
  #hud .hud-msg { top: 40%; }
  #hud .hud-standings { display: none; }
}
