/*
 * Highway's page. The canvas fills it. Words are set in Overpass, the open
 * face drawn from the highway sign alphabet; panels are motorway signs (sign
 * green, a white inset border, rounded corners); near misses and combos are
 * reflective yellow plates; a crash is brake-light red. Built for pal's
 * 720 by 390 panel and grows with a bigger one.
 */
@font-face { font-family: "Overpass"; src: url("./font/overpass.woff2") format("woff2"); font-weight: 100 900; }
:root {
  --sign: #0e5a3b; --sign-deep: #0a4630; --white: #f3f5f1; --dim: rgba(243, 245, 241, 0.62); --faint: rgba(243, 245, 241, 0.35);
  --yellow: #f4c430; --amber: #ff9f1c; --red: #e2372e; --asphalt: rgba(16, 18, 21, 0.72);
  --type: "Overpass", -apple-system, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #0d0f12; }
body { font: 500 13px/1.3 var(--type); color: var(--white); user-select: none; -webkit-user-select: none; font-variant-numeric: tabular-nums; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
kbd { display: inline-block; min-width: 18px; padding: 1px 5px 0; border-radius: 4px; font: 700 10px/15px var(--type); text-align: center; color: var(--white); background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35); }

/* a motorway sign: green, a white border inset from the edge */
.sign { position: relative; background: var(--sign); border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 3px var(--sign), inset 0 0 0 5px var(--white); }
.sign::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(160deg, rgba(255,255,255,0.09), transparent 40%); }
.plate { display: inline-block; background: var(--yellow); color: #1a1a14; border-radius: 6px; padding: 3px 9px 1px; box-shadow: inset 0 0 0 2px #1a1a14, inset 0 0 0 3px var(--yellow), 0 6px 18px rgba(0, 0, 0, 0.3); }

/* ---- loading ---- */
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 60%, #1b2a24, #0b0d10 70%); transition: opacity 500ms ease; }
#loading.gone { opacity: 0; pointer-events: none; }
#loading .sign { min-width: 220px; text-align: center; padding: 16px 22px 14px; }
#loading b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
#loading span { display: block; color: var(--dim); margin-top: 2px; }
#loading i { display: block; height: 3px; margin-top: 12px; border-radius: 2px; background: rgba(255,255,255,0.15); overflow: hidden; }
#loading em { display: block; height: 100%; width: 0; background: var(--white); transition: width 240ms ease; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
#score { position: absolute; left: 16px; top: 12px; }
#score b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
#rate { font-size: 11px; color: var(--dim); }
#combo { position: absolute; left: 14px; top: 64px; }
#combo b { display: block; font-size: 15px; font-weight: 800; color: #1a1a14; background: var(--yellow); border-radius: 6px 6px 0 0; padding: 3px 9px 1px; text-shadow: none; box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
#combo i { display: block; height: 4px; background: #1a1a14; border-radius: 0 0 6px 6px; overflow: hidden; }
#combo i::after { content: ""; display: block; height: 100%; width: calc(var(--left, 1) * 100%); background: var(--amber); }
#combo.bump b { animation: bump 260ms cubic-bezier(.2, 1.8, .4, 1); }
@keyframes bump { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
#trip { position: absolute; right: 16px; top: 14px; text-align: right; }
#trip span { display: block; }
#dist { font-size: 15px; font-weight: 700; }
#earn { font-size: 11px; color: var(--dim); }
#gauge { position: absolute; right: 18px; bottom: 12px; text-align: right; }
#gauge > div:first-child { display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; }
#speed { font-size: 48px; font-weight: 800; letter-spacing: -2px; line-height: 0.9; }
#gear { font-size: 13px; font-weight: 800; width: 22px; height: 22px; line-height: 23px; text-align: center; border-radius: 5px; background: rgba(255, 255, 255, 0.16); text-shadow: none; }
#unit { font-size: 11px; color: var(--dim); }
#rpm { width: 128px; height: 4px; margin: 5px 0 0 auto; border-radius: 2px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
#rpm i { display: block; height: 100%; width: calc(var(--rpm, 0) * 100%); background: linear-gradient(90deg, var(--white) 72%, var(--red)); }
/* under the score and the combo, so nothing covers the road ahead */
#pops { position: absolute; left: 14px; top: 100px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pop { font-size: 15px; transform-origin: left center; font-weight: 800; animation: pop 1.1s cubic-bezier(.2, 1.4, .4, 1) forwards; text-shadow: none; }
.pop small { font-size: 12px; font-weight: 700; margin-left: 6px; }
.pop.big { font-size: 18px; }
.pop.oncoming { background: var(--red); color: var(--white); box-shadow: inset 0 0 0 2px #2a0a08, inset 0 0 0 3px var(--red), 0 6px 18px rgba(0,0,0,0.3); }
@keyframes pop { 0% { opacity: 0; transform: translateY(8px) scale(0.7); } 18% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); color: var(--dim); font-size: 12px; white-space: nowrap; transition: opacity 600ms ease; }
#hint.gone { opacity: 0; }
.banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 46px; font-weight: 800; letter-spacing: -1.5px; animation: banner 900ms ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---- garage: a gantry sign on the left, the car on the road behind it ---- */
#garage { position: fixed; left: 12px; top: 12px; width: 262px; max-height: calc(100vh - 24px); }
#garage .sign { padding: 11px 13px 10px; }
.head { display: flex; justify-content: space-between; align-items: baseline; }
.head b { font-size: 18px; font-weight: 800; letter-spacing: -0.4px; }
.head span { font-weight: 700; color: var(--yellow); }
.rows { margin-top: 4px; }
.row { display: grid; grid-template-columns: 62px 1fr; align-items: center; min-height: 23px; padding: 0 6px; margin: 0 -6px; border-radius: 6px; cursor: default; font-size: 12.5px; }
.row > span { color: var(--dim); font-size: 11.5px; }
.row.on { background: rgba(255, 255, 255, 0.13); }
.row .val { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 700; }
.row .val em { flex: none; font-style: normal; font-size: 11px; font-weight: 600; color: var(--dim); }
.row .val em.can { color: var(--yellow); }
.row .val em.no { color: rgba(255, 140, 120, 0.85); }
.arrows::before { content: "‹"; margin-right: 6px; color: var(--faint); }
.arrows::after { content: "›"; margin-left: 6px; color: var(--faint); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 12px; height: 6px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); }
.pips i.f { background: var(--white); }
.swatches { display: flex; flex: 1 1 0; min-width: 0; gap: 3px; } /* they shrink to leave a price its room */
.swatches i { flex: 0 1 11px; min-width: 6px; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35); }
.swatches i.on { box-shadow: 0 0 0 2px var(--sign), 0 0 0 3.5px var(--white); }
.bars { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 1px 7px; margin: 2px 0 4px; font-size: 10.5px; color: var(--dim); }
.bars i { position: relative; align-self: center; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.bars i::after { content: ""; display: block; height: 100%; width: calc(var(--v) * 10%); background: var(--white); transition: width 220ms ease; }
/* another car than yours: the part it gains on yours in yellow, a mark where yours stands */
.bars i.up::after { background: linear-gradient(90deg, var(--white) calc(var(--w) / var(--v) * 100%), var(--yellow) 0); }
.bars i.up::before, .bars i.cmp::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--was) * 10% - 1px); width: 2px; background: var(--yellow); opacity: 0.9; z-index: 1; }
.drive { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.22); }
.drive .go { font-size: 16px; font-weight: 800; }
.keys { font-size: 10.5px; color: var(--dim); line-height: 1.7; white-space: nowrap; }
.best { font-size: 10.5px; color: var(--dim); line-height: 1.25; }

/* ---- cards: pause and the run's end ---- */
#card { position: fixed; inset: 0; display: grid; place-items: center; }
#card .sign { width: min(400px, calc(100vw - 32px)); padding: 16px 20px 14px; animation: rise 360ms cubic-bezier(.2, 1, .3, 1); }
@keyframes rise { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: none; } }
#card h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
#card .why { color: var(--dim); margin-top: 1px; }
#card .crash { color: #ffd2cc; }
#card dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 16px; margin: 12px 0 10px; }
#card dt { color: var(--dim); }
#card dd { margin: 0; text-align: right; font-weight: 700; }
#card dt.total, #card dd.total { color: var(--yellow); font-weight: 800; font-size: 15px; }
#card .keys { display: flex; gap: 14px; margin-top: 4px; }

/* key hints you can also click */
button[data-key] { font: inherit; color: inherit; background: none; border: 0; padding: 2px 4px; margin: -2px -4px; border-radius: 6px; cursor: pointer; }
button[data-key]:hover { background: rgba(255, 255, 255, 0.12); }
.row { cursor: pointer; }

/* ---- the driver's level and missions, right of the garage sign ---- */
#side { position: fixed; right: 12px; top: 12px; width: 220px; display: flex; flex-direction: column; gap: 8px; }
.driver, .missions { background: var(--asphalt); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 10px; padding: 9px 11px; }
.driver b { font-size: 15px; font-weight: 800; margin-right: 6px; }
.driver span { font-size: 11px; color: var(--dim); }
.driver i { display: block; height: 4px; margin: 5px 0 3px; border-radius: 2px; background: rgba(255,255,255,0.18); overflow: hidden; }
.driver i::after { content: ""; display: block; height: 100%; width: calc(var(--v) * 100%); background: var(--yellow); transition: width 400ms ease; }
.driver small { display: block; font-size: 10.5px; color: var(--yellow); }
.missions > div { padding: 3px 0; font-size: 11.5px; line-height: 1.25; }
.missions > div + div { border-top: 1px solid rgba(255,255,255,0.1); }
.missions em { display: block; font-style: normal; font-size: 10.5px; color: var(--dim); }
.missions i { display: block; height: 3px; margin: 3px 0 2px; border-radius: 2px; background: rgba(255,255,255,0.15); overflow: hidden; }
.missions i::after { content: ""; display: block; height: 100%; width: calc(var(--v) * 100%); background: var(--white); }
.missions .done em { color: var(--yellow); font-weight: 700; }
.missions .done i::after { background: var(--yellow); }
.row .val em.lock { color: rgba(255,255,255,0.5); font-weight: 600; }

/* ---- nitro and the modes' clocks in the HUD ---- */
#nitro { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim); }
#nitro i { width: 110px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.16); overflow: hidden; }
#nitro i::after { content: ""; display: block; height: 100%; width: calc(var(--v, 0) * 100%); background: linear-gradient(90deg, #4fb3ff, #a8e1ff); transition: width 120ms linear; }
#nitro kbd { opacity: 0; transition: opacity 200ms; }
#nitro.ready kbd { opacity: 1; }
#nitro.ready span { color: var(--white); }
#nitro.lit i::after { background: linear-gradient(90deg, #ff9f1c, #fff1a8); box-shadow: 0 0 10px rgba(255, 180, 60, 0.8); }
#modebox { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); text-align: center; }
#modebox b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
#modebox b.low { color: #ff8a7a; }
#modebox span { font-size: 11px; color: var(--dim); }
.pop.mission { background: var(--white); color: var(--sign); }
.pop.mission small { display: block; margin: 0; font-weight: 600; }

/* ---- the end of a run: the pay counting up on the left, the level and missions on the right ---- */
#card .sign:has(.result) { width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 24px); display: flex; flex-direction: column; padding-top: 13px; padding-bottom: 11px; }
.result { display: grid; grid-template-columns: 1fr 210px; gap: 16px; min-height: 0; }
.result .left { display: flex; flex-direction: column; min-height: 0; }
.result .headline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result .standing { font-size: 12px; font-weight: 600; color: var(--dim); }
.result .standing a { color: var(--white); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.result dl { margin: 8px 0 6px; gap: 1px 16px; overflow-y: auto; min-height: 0; scrollbar-width: none; }
.result .right { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.result .driver, .result .missions { background: rgba(0, 0, 0, 0.18); }
