@font-face { font-family: "Barlow"; font-weight: 400; src: url(../fonts/Barlow-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 500; src: url(../fonts/Barlow-500.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 600; src: url(../fonts/Barlow-600.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; src: url(../fonts/BarlowCondensed-500.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; src: url(../fonts/BarlowCondensed-600.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: italic; src: url(../fonts/BarlowCondensed-600i.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: italic; src: url(../fonts/BarlowCondensed-700i.woff2) format("woff2"); font-display: swap; }

:root {
  --ink: #0d0e10;
  --panel: #131418;
  --panel2: #1a1b20;
  --line: #2a2c32;
  --text: #ece9e2;
  --muted: #8d8e94;
  --amber: #f2a51e;
  --red: #e2483a;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --sans: "Barlow", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font: 15px/1.4 var(--sans); overflow: hidden; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button, .btn {
  font: 500 15px var(--sans); color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 3px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: #44474f; }
button.primary { background: var(--amber); border-color: var(--amber); color: #15120a; font-weight: 600; }
button.primary:hover { background: #ffb630; }
button.ghost { background: transparent; }
h2 { font: 600 13px var(--sans); color: var(--muted); margin: 0 0 8px; letter-spacing: 0.02em; }
.wordmark { font: italic 700 46px/1 var(--cond); letter-spacing: 0.01em; }
.mono { font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

/* loading */
.screen { position: fixed; inset: 0; }
#loading, #nogl { background: var(--ink); display: flex; align-items: flex-end; padding: 0 0 12vh 8vw; z-index: 20; }
.load-inner { width: min(460px, 84vw); }
.load-bar { height: 2px; background: var(--line); margin: 22px 0 10px; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .2s; }
.load-text { color: var(--muted); font-size: 14px; }

/* menu */
#menu { pointer-events: none; z-index: 5; }
#menu .panel {
  pointer-events: auto; position: absolute; left: 0; top: 0; bottom: 0; width: min(400px, 100vw);
  background: rgba(15, 16, 19, 0.94); border-right: 1px solid var(--line);
  padding: 28px 28px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px;
}
.brand .tag { color: var(--muted); margin: 10px 0 0; max-width: 30ch; }
.car-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.car-list li { padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.car-list li:hover { background: var(--panel2); }
.car-list li.on { background: var(--panel2); }
.car-list li.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--amber); }
.car-list .name { font: italic 600 22px/1.1 var(--cond); }
.car-list .spec { color: var(--muted); font-size: 13px; margin-top: 2px; }
.car-list .blurb { font-size: 13px; margin-top: 4px; color: #c8c5be; }
.paints { display: flex; flex-wrap: wrap; gap: 6px; }
.paints button { width: 30px; height: 30px; padding: 0; border-radius: 2px; border: 2px solid transparent; }
.paints button.on { border-color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 8px 12px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--text); color: var(--ink); }
.seg.small button { padding: 6px 10px; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.right { justify-content: flex-end; margin-top: 18px; }
#menu .actions .primary { flex: 1 0 100%; padding: 13px; font: italic 700 22px var(--cond); letter-spacing: 0.02em; }
.keys { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; padding-top: 12px; border-top: 1px solid var(--line); }
.keys b { color: var(--text); font-weight: 600; }

/* modal sheets */
.modal { position: fixed; inset: 0; background: rgba(6, 7, 8, 0.55); display: flex; align-items: center; justify-content: center; z-index: 15; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 22px 24px; width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; }
.sheet.narrow { width: min(320px, 92vw); }
.sheet h2 { font: italic 700 28px var(--cond); color: var(--text); margin-bottom: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row > span:first-child { color: #d6d3cc; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack button { text-align: left; }
input[type=range] { width: 180px; accent-color: var(--amber); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--amber); }

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; font-family: var(--cond); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.score { position: absolute; left: 24px; top: 18px; font-size: 20px; }
.score b { font: italic 700 30px var(--cond); }
.score .lbl { color: #cfccc4; font-weight: 500; }
.score .muted { color: #b8b5ad; font-size: 17px; }
.combo { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); text-align: center; min-width: 220px; transition: opacity .25s; }
.combo.off { opacity: 0; }
.combo-top { display: flex; align-items: baseline; justify-content: center; gap: 12px; }
.combo .mult { font: italic 700 30px var(--cond); color: var(--amber); }
.combo .pts { font: italic 700 44px var(--cond); }
.chain { height: 3px; background: rgba(255,255,255,0.18); margin: 2px auto 0; width: 200px; }
.chain i { display: block; height: 100%; background: var(--text); width: 0; }
.live { font: 600 20px var(--cond); color: #e6e2d9; margin-top: 4px; min-height: 24px; }
.feed { position: absolute; left: 50%; top: 122px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.feed div { font: italic 600 26px var(--cond); animation: pop 2.2s forwards; white-space: nowrap; }
.feed div em { font-style: normal; color: var(--amber); margin-left: 8px; }
.feed div.bad { color: var(--red); }
.feed div.part { color: #d9b38a; font-size: 21px; }
@keyframes pop { 0% { opacity: 0; transform: translateY(8px); } 8% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.dash { position: absolute; right: 28px; bottom: 24px; display: grid; grid-template-columns: auto auto; grid-template-areas: "rpm rpm" "spd gear" "bars bars"; align-items: end; column-gap: 14px; }
.rpm { grid-area: rpm; height: 6px; background: rgba(255,255,255,0.16); position: relative; margin-bottom: 4px; }
.rpm i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text); width: 0; }
.rpm s { position: absolute; top: 0; bottom: 0; right: 0; background: var(--red); opacity: 0.7; width: 12%; }
.spd { grid-area: spd; text-align: right; }
.spd b { font: italic 700 84px/0.9 var(--cond); font-variant-numeric: tabular-nums; display: inline-block; min-width: 3ch; }
.spd span { font: 600 20px var(--cond); color: #cfccc4; margin-left: 4px; }
.gear { grid-area: gear; font: italic 700 40px/1 var(--cond); border: 2px solid var(--text); width: 46px; height: 52px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.bars { grid-area: bars; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.bar { font: 500 14px var(--cond); color: #cfccc4; }
.bar i { display: block; height: 4px; background: var(--text); margin-top: 3px; width: 100%; transform-origin: left; }
.bar.nitro i { background: #6fb7ff; }
.bar.hp i { background: #9fd36a; }
.bar.hp.low i { background: var(--red); }
#minimap { position: absolute; left: 22px; bottom: 22px; width: 180px; height: 180px; border-radius: 50%; border: 2px solid rgba(236,233,226,0.75); background: rgba(12,13,15,0.5); }
.hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #d2cfc7; font: 500 16px var(--cond); transition: opacity 1s; }
.respawn { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font: italic 600 30px var(--cond); background: rgba(13,14,16,0.85); padding: 10px 18px; border-left: 3px solid var(--red); }
.toast { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; font: 500 15px var(--sans); opacity: 0; transition: opacity .3s; text-shadow: none; }
.toast.on { opacity: 1; }
.touch { position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: none; }
.touch .tl, .touch .tr { position: absolute; bottom: 20px; display: flex; gap: 10px; pointer-events: auto; }
.touch .tl { left: 16px; } .touch .tr { right: 16px; }
.touch button { width: 74px; height: 74px; font: 600 18px var(--cond); background: rgba(20,21,25,0.55); border: 1px solid rgba(236,233,226,0.35); border-radius: 50%; touch-action: none; }
.touch button.on { background: rgba(242,165,30,0.6); }

/* replay */
#replay { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.r-head { position: absolute; left: 22px; top: 18px; display: flex; gap: 14px; align-items: baseline; font: 600 22px var(--cond); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.r-head .rec { font-style: italic; font-weight: 700; font-size: 30px; }
.r-bar { pointer-events: auto; position: absolute; left: 0; right: 0; bottom: 0; background: rgba(13,14,16,0.92); border-top: 1px solid var(--line); padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.r-row { display: flex; align-items: center; gap: 12px; }
.r-row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
button.icon { width: 42px; height: 36px; padding: 0; font-size: 15px; }
.r-track { flex: 1; height: 26px; position: relative; cursor: pointer; }
.r-track::before { content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 2px; background: var(--line); }
.r-range { position: absolute; top: 11px; height: 4px; background: rgba(242,165,30,0.55); }
.r-headline { position: absolute; top: 3px; width: 2px; height: 20px; background: var(--text); margin-left: -1px; }
.r-handle { position: absolute; top: 4px; width: 10px; height: 18px; margin-left: -5px; background: var(--amber); cursor: ew-resize; }
