:root {
  --ink: #f3f1f6; --dim: rgba(243, 241, 246, .62); --pink: #ff2d78; --cyan: #25d9ff; --amber: #ffb054;
  --panel: rgba(8, 7, 14, .62); --line: rgba(255, 255, 255, .14);
  --sans: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-touch-callout: none; background: #05050a; color: var(--ink); font-family: var(--sans); -webkit-user-select: none; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button, .overlay, #hud, #touch, #steer { touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { display: inline-block; min-width: 1.5em; padding: .05em .4em; margin: 0 .15em; border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .08); font: 600 .82em var(--sans); text-align: center; }

#loading { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #05050a; z-index: 9; }
#loading .jp { font-style: normal; font-size: 13px; letter-spacing: .6em; color: var(--pink); margin-right: -.6em; }
#loading b { font-size: clamp(34px, 8vw, 84px); font-weight: 900; font-style: italic; letter-spacing: .04em; line-height: 1; background: linear-gradient(180deg, #fff 35%, #ffcf9a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(255, 90, 40, .45)); }
#loading b i { background: linear-gradient(180deg, #ff9a3c 20%, #ff2d78 100%); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: .12em; }
#loading u { display: block; width: min(320px, 60vw); height: 2px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: loadsweep 1.1s linear infinite; opacity: .9; }
@keyframes loadsweep { from { background-position: -100% 0; } to { background-position: 300% 0; } }
#loading span { color: var(--dim); letter-spacing: .25em; text-transform: uppercase; font-size: 13px; }
.state-loading #loading { display: flex; }

.overlay { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; z-index: 5; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); text-align: center; }
.state-select #select, .state-results #results { display: flex; }

/* ---- opening screen: the wordmark over the car in the garage ---- */
#select { justify-content: space-between; align-items: stretch; text-align: left; padding-left: max(clamp(18px, 4vw, 56px), env(safe-area-inset-left)); padding-right: max(clamp(18px, 4vw, 56px), env(safe-area-inset-right));
  background: radial-gradient(120% 90% at 62% 55%, rgba(5, 5, 10, 0) 38%, rgba(5, 5, 10, .55) 100%), linear-gradient(180deg, rgba(5, 5, 10, .82) 0%, rgba(5, 5, 10, 0) 34%, rgba(5, 5, 10, 0) 52%, rgba(5, 5, 10, .9) 100%); }
#select .bars { position: absolute; inset: 0; pointer-events: none; border-top: clamp(0px, 2.2vh, 22px) solid #000; border-bottom: clamp(0px, 2.2vh, 22px) solid #000; background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px); }
#select .jpside { position: absolute; right: max(18px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: clamp(16px, 2.6vw, 30px); font-weight: 800; letter-spacing: .5em; color: rgba(255, 255, 255, .16); text-shadow: 0 0 18px rgba(255, 45, 120, .5); pointer-events: none; }
#select header { position: relative; margin-top: clamp(6px, 3vh, 34px); animation: titlein .9s cubic-bezier(.2, .8, .2, 1) both; }
#select .kicker { display: inline-flex; align-items: center; gap: .8em; font-size: clamp(10px, 1.3vw, 14px); font-weight: 700; letter-spacing: .42em; color: var(--dim); }
#select .kicker b { padding: .25em .5em .2em .7em; letter-spacing: .3em; color: #fff; background: var(--pink); border-radius: 2px; transform: skewX(-10deg); }
#select h1 { margin-top: .12em; font-size: clamp(46px, 11vw, 148px); font-weight: 900; font-style: italic; letter-spacing: .01em; line-height: .86; text-transform: uppercase; transform: skewX(-4deg); transform-origin: 0 100%;
  background: linear-gradient(180deg, #ffffff 30%, #ffd9b0 78%, #ffab6b 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .55)) drop-shadow(0 0 34px rgba(255, 96, 32, .5)); }
#select h1 i { display: block; padding-right: .1em; background: linear-gradient(180deg, #ffb347 8%, #ff5a1f 55%, #ff2d78 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#select .streak { display: block; margin-top: clamp(8px, 1.4vh, 16px); width: min(46vw, 560px); height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--cyan), rgba(37, 217, 255, 0)); box-shadow: 0 0 14px var(--cyan), 0 0 40px rgba(37, 217, 255, .5); transform-origin: 0 50%; animation: streakin 1.2s .25s cubic-bezier(.2, .8, .2, 1) both; }
#select header p { margin-top: 12px; max-width: 34em; color: rgba(243, 241, 246, .82); text-shadow: 0 1px 6px #000, 0 0 2px #000; letter-spacing: .14em; text-transform: uppercase; font-size: clamp(10px, 1.35vw, 14px); line-height: 1.5; }
@keyframes titlein { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes streakin { from { transform: scaleX(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drivepulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 31, .55), 0 10px 40px rgba(255, 45, 120, .35); } 50% { box-shadow: 0 0 0 12px rgba(255, 90, 31, 0), 0 10px 54px rgba(255, 45, 120, .6); } }
#cards { display: flex; gap: 14px; width: min(980px, 100%); margin-top: auto; }
/* a single car on offer: one compact card to one side, so it does not cover the car */
body.solo #cards { width: min(340px, 100%); margin-right: auto; }
body.solo .hint .pick { display: none; }
.card { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color .15s, box-shadow .15s, transform .15s; }
.card .name { font-size: clamp(20px, 3.4vw, 32px); font-weight: 800; font-style: italic; letter-spacing: .05em; }
.card .tag { color: var(--dim); font-size: clamp(11px, 1.5vw, 14px); min-height: 2.5em; line-height: 1.25; }
.card .stat { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .16em; }
.card .stat em { width: 4.2em; font-style: normal; color: var(--dim); }
.card .stat i { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.card .stat b { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: 0 50%; }
.card.sel { transform: translateY(-4px); }
.card.sel[data-car="0"] { border-color: var(--cyan); box-shadow: 0 0 26px rgba(37, 217, 255, .4); }
.card.sel[data-car="0"] .stat b { background: var(--cyan); }
.card.sel[data-car="1"] { border-color: #d24bff; box-shadow: 0 0 26px rgba(210, 75, 255, .45); }
.card.sel[data-car="1"] .stat b { background: #d24bff; }
.card.sel[data-car="2"] { border-color: #ff8a1f; box-shadow: 0 0 26px rgba(255, 138, 31, .45); }
.card.sel[data-car="2"] .stat b { background: #ff8a1f; }
#drive, .btns button { margin-top: 14px; padding: 12px 54px; font-size: clamp(18px, 2.6vw, 26px); font-weight: 800; font-style: italic; letter-spacing: .18em; color: #0a0610; background: var(--ink); border-radius: 6px; box-shadow: 0 0 30px rgba(255, 255, 255, .25); }
#drive:active, .btns button:active { transform: scale(.97); }
#drive { align-self: flex-start; margin-top: 16px; padding: 14px 64px 13px; color: #fff; background: linear-gradient(100deg, #ff7a1f 0%, #ff2d78 100%); border-radius: 4px; transform: skewX(-8deg); animation: drivepulse 1.8s ease-in-out infinite; text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
#drive span { display: inline-block; transform: skewX(8deg); }
#drive span::after { content: ' ▸'; }
#drive:active { transform: skewX(-8deg) scale(.97); }
#select .hint { align-self: flex-start; }
#select #cards { margin-right: auto; }
.hint { margin-top: 10px; color: var(--dim); font-size: 13px; letter-spacing: .08em; }
.touch .key-only { display: none; }

#hud { position: fixed; inset: 0; display: none; pointer-events: none; z-index: 3; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); }
.state-drive #hud, .state-count #hud { display: block; }
#hud .l { display: block; font-size: 11px; letter-spacing: .28em; color: var(--dim); }
#lapbox, #scorebox { position: absolute; top: max(12px, env(safe-area-inset-top)); }
#lapbox { left: max(16px, env(safe-area-inset-left)); }
#scorebox { right: max(16px, env(safe-area-inset-right)); text-align: right; }
#lapbox b, #scorebox b { display: block; font-size: clamp(24px, 4vw, 40px); font-weight: 800; font-style: italic; line-height: 1.05; }
#pos { display: block; margin-top: 4px; font-style: italic; font-weight: 800; font-size: clamp(20px, 3vw, 30px); color: var(--cyan); }
#time, #best { font-size: 14px; color: var(--dim); font-variant-numeric: tabular-nums; }
#chain { position: absolute; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px; opacity: 0; transition: opacity .25s; white-space: nowrap; }
#chain.on { opacity: 1; }
#chainpts { font-size: clamp(34px, 7vw, 68px); font-weight: 800; font-style: italic; color: var(--amber); text-shadow: 0 0 22px rgba(255, 150, 40, .7); font-variant-numeric: tabular-nums; }
#mult { font-size: clamp(18px, 3vw, 30px); font-weight: 800; color: var(--pink); }
#angle { font-size: clamp(14px, 2vw, 20px); color: var(--dim); min-width: 2.4em; text-align: left; }
#toast { position: absolute; left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + clamp(52px, 9vw, 92px)); transform: translateX(-50%); font-size: clamp(16px, 2.6vw, 26px); font-weight: 800; font-style: italic; letter-spacing: .14em; opacity: 0; transition: opacity .4s; white-space: nowrap; }
#toast.on { opacity: 1; transition: none; }
#toast.bad { color: var(--pink); }
#toast.good { color: var(--cyan); }
/* tachometer: generated bezel and face (assets/hud), scale drawn per car by src/hud.js. --d is the dial's diameter, --u a hundredth of its radius */
#tach { --d: clamp(150px, 29vmin, 330px); --u: calc(var(--d) / 200); --glow: 37, 217, 255; position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: var(--d); height: var(--d); text-shadow: none; }
#tach .dial { position: absolute; inset: 0; border-radius: 50%; background: #07070b url(./assets/hud/dial.webp) center / 100% 100% no-repeat; box-shadow: 0 calc(var(--u) * 5) calc(var(--u) * 22) rgba(0, 0, 0, .75), 0 0 calc(var(--u) * 30) rgba(var(--glow), .22); }
#tach svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#tach .scale path { fill: none; stroke: #f6f4fa; stroke-linecap: butt; }
#tach .scale .major { stroke-width: 2.6; }
#tach .scale .minor { stroke-width: 1.5; opacity: .9; }
#tach .scale .micro { stroke-width: .8; opacity: .55; }
#tach .scale .hot { stroke: #ff3140; opacity: 1; }
#tach .scale .zone { stroke: #ff1f33; opacity: .5; }
#tach .scale .glow { stroke: rgb(var(--glow)); stroke-width: 1.3; opacity: .9; filter: drop-shadow(0 0 2.5px rgb(var(--glow))) drop-shadow(0 0 6px rgba(var(--glow), .8)); }
#tach .scale text { font-family: var(--sans); font-weight: 800; font-style: italic; fill: #fff; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 1.6px; }
#tach .scale text.hot { fill: #ff4452; }
#tach .scale text.unit { font-weight: 600; font-style: normal; letter-spacing: .12em; fill: rgba(243, 241, 246, .6); stroke: none; }
#tach .needle { transform: rotate(180deg); transform-origin: 50% 50%; will-change: transform; }
#tach .needle .sh { fill: rgba(0, 0, 0, .45); }
#tach .needle .body { fill: #ff3a24; }
#tach .needle .hi { fill: #ffb9a6; }
#tach .hub { position: absolute; left: 50%; top: 50%; width: calc(var(--u) * 27); height: calc(var(--u) * 27); margin: calc(var(--u) * -13.5) 0 0 calc(var(--u) * -13.5); border-radius: 50%; background: url(./assets/hud/hub.webp) center / 100% 100%; box-shadow: 0 calc(var(--u) * 1.5) calc(var(--u) * 5) rgba(0, 0, 0, .8); }
#tach .glass { position: absolute; inset: 8%; border-radius: 50%; background: linear-gradient(140deg, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, .03) 30%, rgba(255, 255, 255, 0) 46%); }
/* digital module in the dial's free quarter: shift LEDs, gear, speed */
#tach .digi { position: absolute; left: 55%; top: 58.5%; right: -3%; bottom: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--u) * 5) calc(var(--u) * 7) calc(var(--u) * 4); background: linear-gradient(180deg, rgba(22, 22, 30, .96), rgba(6, 6, 10, .96)); border: 1px solid rgba(var(--glow), .55); border-radius: calc(var(--u) * 5); clip-path: polygon(calc(var(--u) * 12) 0, 100% 0, 100% 100%, 0 100%, 0 calc(var(--u) * 12)); box-shadow: inset 0 0 calc(var(--u) * 12) rgba(var(--glow), .16); }
#tach .digi::before { content: ""; position: absolute; left: 0; top: 0; width: calc(var(--u) * 17); height: 1px; background: rgba(var(--glow), .7); transform-origin: 0 0; transform: translateY(calc(var(--u) * 12)) rotate(-45deg); }
#tach .leds { display: flex; gap: calc(var(--u) * 2.2); padding-left: calc(var(--u) * 9); }
#tach .leds i { flex: 1 1 0; height: calc(var(--u) * 6.5); border-radius: calc(var(--u) * 1.6); background: rgba(255, 255, 255, .11); }
#tach .leds i.on { background: #37f08a; box-shadow: 0 0 calc(var(--u) * 6) #37f08a; }
#tach .leds i.on:nth-child(n+5) { background: #ffc233; box-shadow: 0 0 calc(var(--u) * 6) #ffc233; }
#tach .leds i.on:nth-child(n+8) { background: #ff3140; box-shadow: 0 0 calc(var(--u) * 6) #ff3140; }
#tach.shift .leds i, #tach.shift .leds i.on:nth-child(n) { background: #ff3140; box-shadow: 0 0 calc(var(--u) * 8) #ff3140; animation: shiftflash .1s steps(1) infinite; }
@keyframes shiftflash { 0% { opacity: 1; } 50% { opacity: .12; } }
#tach .row { display: flex; align-items: flex-end; justify-content: space-between; gap: calc(var(--u) * 4); }
#setBtn { font-size: calc(var(--u) * 50); font-weight: 800; font-style: italic; line-height: .86; color: rgb(var(--glow)); text-shadow: 0 0 calc(var(--u) * 12) rgba(var(--glow), .7); min-width: .62em; text-align: center; }
#tach.shift #setBtn { color: #ff4452; text-shadow: 0 0 calc(var(--u) * 12) rgba(255, 49, 64, .8); }
#tach .spd { text-align: right; }
#speed { display: block; font-size: calc(var(--u) * 33); font-weight: 800; font-style: italic; line-height: .9; font-variant-numeric: tabular-nums; color: #fff; }
#tach .spd span { display: block; margin-top: calc(var(--u) * 1.5); font-size: calc(var(--u) * 8.5); letter-spacing: .24em; color: var(--dim); }
#help { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.75; color: var(--dim); text-shadow: none; }
#tip { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); max-width: 92vw; padding: 8px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; font-size: clamp(13px, 1.9vw, 17px); letter-spacing: .06em; opacity: 0; transition: opacity .5s; text-shadow: none; text-align: center; }
#tip.on { opacity: 1; }

#count { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 4; pointer-events: none; font-size: clamp(90px, 22vw, 220px); font-weight: 800; font-style: italic; text-shadow: 0 0 60px rgba(255, 45, 120, .8); }
.state-count #count { display: flex; }

#rpm { position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); width: min(400px, 86vw); display: none; z-index: 4; pointer-events: none; text-align: center; }
.state-count #rpm { display: block; }
#rpm em { display: block; margin-bottom: 5px; font-style: italic; font-weight: 800; font-size: 13px; letter-spacing: .34em; color: var(--ink); text-shadow: 0 1px 4px #000; }
#rpm .bar { position: relative; height: 18px; border-radius: 4px; background: linear-gradient(180deg, rgba(22, 22, 30, .92), rgba(6, 6, 10, .92)); border: 1px solid rgba(255, 255, 255, .3); box-shadow: 0 4px 18px rgba(0, 0, 0, .6); overflow: hidden; }
#rpm i { position: absolute; top: 0; bottom: 0; background: rgba(46, 220, 110, .34); border-left: 2px solid #2edc6e; border-right: 2px solid #2edc6e; }
#rpm b { position: absolute; inset: 3px; border-radius: 2px; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); opacity: .92; }
#rpm u { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 2px), rgba(6, 6, 10, .9) calc(5% - 2px) 5%); }
#rpm.green b { background: #2edc6e; box-shadow: 0 0 12px #2edc6e; }
#rpm.green .bar { border-color: #2edc6e; }
#rpm span { display: block; margin-top: 6px; white-space: nowrap; font-size: 11px; letter-spacing: .14em; color: var(--dim); text-shadow: 0 1px 4px #000; }
.touch #rpm { bottom: 48%; }
#touch { display: none; }
.touch.state-drive #touch, .touch.state-count #touch { display: block; }
/* Touch controls: the left thumb slides on a wide pad to steer, the right thumb has DRIFT and BRAKE; the gas is automatic
   (AUTO GAS, on by default) unless it is switched off, which brings back GAS and KICK. */
#touch button { position: fixed; z-index: 6; border-radius: 50%; background: rgba(12, 10, 20, .5); border: 1.5px solid rgba(255, 255, 255, .28); font-size: 13px; font-weight: 800; letter-spacing: .08em; touch-action: none; color: var(--ink); }
#touch button.down { background: rgba(255, 255, 255, .28); }
.touch { --tb: max(20px, env(safe-area-inset-bottom)); --tl: max(16px, env(safe-area-inset-left)); --tr: max(16px, env(safe-area-inset-right)); --big: clamp(92px, 24vmin, 124px); }
#steer { position: fixed; z-index: 6; left: var(--tl); bottom: var(--tb); width: min(44vw, 320px); height: clamp(84px, 22vmin, 112px); border-radius: 999px; background: rgba(12, 10, 20, .42); border: 1.5px solid rgba(255, 255, 255, .22); touch-action: none; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; box-sizing: border-box; }
#steer b { font-size: 22px; opacity: .55; }
#steer span { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 9px; letter-spacing: .18em; text-transform: uppercase; opacity: .45; pointer-events: none; }
#steer.used span { display: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: rgba(255, 255, 255, .2); border: 1.5px solid rgba(255, 255, 255, .6); will-change: transform; pointer-events: none; }
#steer.down #knob { background: rgba(255, 255, 255, .42); }
#th { right: var(--tr); bottom: var(--tb); width: var(--big); height: var(--big); border-color: var(--pink) !important; font-size: 16px !important; }
#tb { right: calc(var(--tr) + var(--big) + 14px); bottom: var(--tb); width: calc(var(--big) * .74); height: calc(var(--big) * .74); }
#tg { right: var(--tr); bottom: calc(var(--tb) + var(--big) + 14px); width: calc(var(--big) * .8); height: calc(var(--big) * .8); border-color: var(--cyan) !important; display: none; }
#tk { right: calc(var(--tr) + var(--big) * .8 + 14px); bottom: calc(var(--tb) + var(--big) + 20px); width: calc(var(--big) * .56); height: calc(var(--big) * .56); font-size: 10px !important; display: none; }
.manual-gas #tg, .manual-gas #tk { display: block; }
#tauto { right: calc(var(--tr) + 54px); top: calc(max(12px, env(safe-area-inset-top)) + 74px); width: auto !important; height: 44px; padding: 0 14px; border-radius: 22px !important; font-size: 10px !important; border-color: var(--cyan) !important; }
#tauto::after { content: ' ON'; color: var(--cyan); }
.manual-gas #tauto { border-color: rgba(255, 255, 255, .28) !important; }
.manual-gas #tauto::after { content: ' OFF'; color: inherit; opacity: .6; }
#tre { right: var(--tr); top: calc(max(12px, env(safe-area-inset-top)) + 74px); width: 44px; height: 44px; font-size: 20px !important; }
/* touch: the lower corners hold the buttons, so the tachometer sits under the lap box */
.touch { --td: clamp(92px, min(32vmin, 100vh - 240px), 180px); }
.touch #tach { --d: var(--td); right: auto; bottom: auto; left: max(14px, env(safe-area-inset-left)); top: calc(max(12px, env(safe-area-inset-top)) + 118px); }
.touch #tip { bottom: 62%; }
@media (orientation: portrait) { .touch #tip { left: calc(max(14px, env(safe-area-inset-left)) + var(--td) + 14px); right: 10px; transform: none; max-width: none; } }   /* beside the tachometer */

#results { justify-content: center; gap: 14px; background: rgba(5, 5, 10, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#results h2 { font-size: clamp(20px, 3.4vw, 34px); font-style: italic; letter-spacing: .3em; color: var(--dim); }
#results .big b { display: block; font-size: clamp(64px, 15vw, 150px); font-weight: 800; font-style: italic; line-height: 1; color: var(--amber); text-shadow: 0 0 40px rgba(255, 150, 40, .6); }
#results .big span { letter-spacing: .4em; font-size: 13px; color: var(--dim); }
#results .row { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; font-size: clamp(15px, 2.2vw, 20px); letter-spacing: .1em; }
#rrank { color: var(--pink); font-weight: 800; }
.btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.btns #change { background: none; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }

@media (max-width: 560px) {
  #cards { gap: 6px; }
  .card { padding: 8px; }
  .card .name { font-size: 15px; letter-spacing: .02em; }
  .card .tag { display: none; }
  .card .stat { gap: 4px; font-size: 9px; letter-spacing: .06em; }
  .card .stat em { width: 3.6em; }
  #drive { padding: 12px 40px; }
}
@media (max-height: 460px) {
  #select header p { display: none; }
  #select h1 { font-size: 15vh; } #select h1 i { display: inline; }
  #select header { margin-top: 0; } #select .streak { margin-top: 5px; }
  body.solo #cards { width: min(250px, 42vw); } .card { padding: 8px 12px; gap: 4px; } .card .name { font-size: 16px; }
  #drive { position: absolute; right: max(64px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); margin: 0; padding: 12px 46px; }
  #select .jpside { display: none; }
  .card .tag { display: none; }
  #help { font-size: 11px; line-height: 1.5; }
}

/* ---- settings screen (src/settings.js): categories on the left, the picked one's settings on the right ---- */
#setBtn { position: fixed; z-index: 7; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 40px; height: 40px; padding: 8px; border-radius: 50%; border: 1px solid var(--line); background: rgba(8, 7, 14, .5); color: var(--ink); cursor: pointer; opacity: .7; touch-action: manipulation; }
#setBtn:hover { opacity: 1; } #setBtn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.state-loading #setBtn { display: none; }
#settings { --row: rgba(255, 255, 255, .055); --g1: rgba(243, 241, 246, .6); position: fixed; inset: 0; z-index: 20; display: none; place-items: center; background: rgba(4, 3, 9, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.settings-open #settings { display: grid; }
#settings .setcard { display: grid; grid-template-columns: 216px 1fr; width: min(900px, 94vw); height: min(600px, 90vh); overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: rgba(14, 12, 22, .94); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); text-shadow: none; }
#settings button, #settings input { font-family: var(--sans); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#settings button:focus-visible, #settings input:focus-visible { outline: 2px solid rgba(255, 255, 255, .85); outline-offset: 2px; }
#setSide { display: flex; flex-direction: column; gap: 2px; padding: 18px 12px 14px; background: rgba(255, 255, 255, .025); border-right: 1px solid var(--line); min-height: 0; }
#setSide h2 { margin: 2px 12px 14px; font-size: 20px; font-weight: 800; font-style: italic; letter-spacing: .02em; }
#setSide h2 small { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; font-style: normal; letter-spacing: .24em; text-transform: uppercase; color: var(--pink); }
#setSide .tab { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: rgba(243, 241, 246, .8); font-size: 15px; font-weight: 600; cursor: pointer; text-align: left; }
#setSide .tab svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#setSide .tab:hover { background: rgba(255, 255, 255, .05); }
#setSide .tab[aria-selected="true"] { background: rgba(255, 255, 255, .13); color: #fff; }
#setSide .grow { flex: 1 1 auto; min-height: 8px; }
#setClose { padding: 11px 12px; border: 0; border-radius: 10px; background: linear-gradient(100deg, #ff7a2f, var(--pink)); color: #fff; font-size: 14px; font-weight: 800; font-style: italic; letter-spacing: .14em; cursor: pointer; }
#setPane { overflow-y: auto; min-height: 0; padding: 20px 30px 28px; overscroll-behavior: contain; touch-action: pan-y; }
#setPane > h2 { font-size: 24px; font-weight: 800; font-style: italic; margin-bottom: 4px; }
#settings .sec { display: none; } #settings .sec.on { display: block; }
#settings h3 { margin: 20px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--g1); }
#settings .note { margin: 6px 2px 0; font-size: 13px; line-height: 1.45; color: var(--g1); }
#settings .row { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 54px; padding: 10px 14px; margin: 0 0 6px; border: 0; border-radius: 12px; background: var(--row); color: var(--ink); text-align: left; }
#settings button.row { cursor: pointer; } #settings button.row:hover { background: rgba(255, 255, 255, .085); }
#settings .row .t { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; }
#settings .row small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; line-height: 1.4; color: var(--g1); }
#settings .row .v { flex: none; min-width: 44px; text-align: right; font-size: 14px; color: var(--g1); }
#settings .row.stack { flex-wrap: wrap; gap: 8px 16px; } #settings .row.stack > div:last-child { flex: 1 1 100%; }
#settings .row input[type=range] { flex: 0 1 240px; accent-color: var(--pink); touch-action: pan-x; }
#settings .sw b { position: relative; flex: none; width: 46px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, .2); transition: background .15s; }
#settings .sw b::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: transform .15s; }
#settings .sw[aria-pressed="true"] b { background: var(--pink); } #settings .sw[aria-pressed="true"] b::after { transform: translateX(18px); }
#settings .seg { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .07); }
#settings .seg button { flex: 1 1 0; min-width: 0; padding: 8px 4px; border: 0; border-radius: 8px; background: none; color: rgba(243, 241, 246, .7); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; line-height: 1.2; }
#settings .seg button:hover { color: #fff; }
#settings .seg button small { margin-top: 2px; font-size: 11px; color: rgba(243, 241, 246, .45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#settings .seg button[aria-checked="true"] { background: rgba(255, 255, 255, .17); color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
#settings .seg button[aria-checked="true"] small { color: rgba(243, 241, 246, .75); }
#settings .ask { display: none; margin: 2px 0 6px; padding: 12px 14px; align-items: center; gap: 10px; flex-wrap: wrap; border-radius: 12px; background: rgba(255, 255, 255, .09); font-size: 13px; }
#settings .ask.on { display: flex; } #settings .ask span { flex: 1 1 200px; }
#settings .ask button { padding: 8px 14px; border: 0; border-radius: 9px; background: #f3f1f6; color: #101214; font-size: 13px; font-weight: 700; cursor: pointer; }
#settings .keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; padding: 14px; border-radius: 12px; background: var(--row); font-size: 14px; }
#settings .keys i { font-style: normal; color: var(--g1); }
#settings kbd { display: inline-block; min-width: 26px; margin-right: 4px; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); font: 600 12px var(--sans); text-align: center; }
.touch #settings .deskOnly, .touch #settings #setCarNote { display: none; }
@media (max-width: 640px), (max-height: 460px) {
  #settings .setcard { grid-template-columns: 1fr; grid-template-rows: auto 1fr; width: 96vw; height: 94vh; }
  #setSide { flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  #setSide h2, #setSide .grow { display: none; }
  #setSide .tab { width: auto; padding: 8px 10px; gap: 7px; font-size: 13.5px; white-space: nowrap; } #setSide .tab svg { width: 17px; height: 17px; }
  #setClose { margin-left: auto; padding: 9px 12px; font-size: 12px; }
  #setPane { padding: 10px 14px 20px; } #setPane > h2 { display: none; } #settings h3 { margin-top: 12px; }
}
