/* f1kart — SNES-stijl. HUD, lampen en touchknoppen uit wft-kart-gp; menu's opnieuw in donkerblauw. */
:root {
  --navy: #0b1433;
  --navy2: #13204d;
  --navy3: #1c2d66;
  --yellow: #ffd23f;
  --red: #e63946;
  --panel: rgba(11, 20, 51, 0.94);
  --px: 'Press Start 2P', ui-monospace, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: #fff;
  font-family: var(--px); user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none;
}
#view {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  image-rendering: pixelated; image-rendering: crisp-edges; display: block;
}
[hidden] { display: none !important; }
button { font-family: var(--px); color: #fff; cursor: pointer; }
button:disabled { cursor: default; }
#hud, #flash, #wrongWay { text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-size: clamp(10px, 2.4vmin, 18px); }
#hud .icon { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); }
#hud .tl { position: absolute; left: calc(max(12px, env(safe-area-inset-left)) + 52px); top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; }
#hudLap { color: var(--yellow); }
#hudBest { font-size: 0.7em; color: #cfe; }
#hud .tc { position: absolute; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); text-align: center; }
#hudTime { font-size: 1.15em; }
#hudOffs { margin-top: 6px; font-size: 0.7em; color: #ffb0b5; }
#hud .tr { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); }
.icon { pointer-events: auto; width: 40px; height: 40px; border: 3px solid #fff; background: rgba(0,0,0,.55);
  font-size: 12px; box-shadow: 3px 3px 0 #000; }
#battery { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.55); border: 3px solid #fff; padding: 5px 8px; box-shadow: 3px 3px 0 #000; }
#battMode { font-size: 8px; color: #9fa; }
#battFill { display: flex; gap: 2px; padding: 2px; border: 2px solid #fff; position: relative; }
#battFill::after { content: ''; position: absolute; right: -6px; top: 30%; width: 4px; height: 40%; background: #fff; }
#battFill i { display: block; width: clamp(7px, 1.6vmin, 12px); height: clamp(12px, 2.8vmin, 20px); background: #222; }
#battFill i.g { background: #3ee05a; } #battFill i.y { background: #f4d020; } #battFill i.r { background: #f03020; }
#battery.low { border-color: #f03020; animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

#lights { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); display: flex; gap: 10px;
  background: #111; padding: 10px 14px; border: 4px solid #fff; box-shadow: 4px 4px 0 #000; }
#lights i { width: clamp(22px, 6vmin, 44px); aspect-ratio: 1; background: #3a0000; border: 3px solid #000; }
#lights i.on { background: #ff1a1a; box-shadow: 0 0 14px #f00; }
#flash { position: fixed; top: 42%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(22px, 8vmin, 64px);
  color: var(--yellow); pointer-events: none; white-space: nowrap; animation: pop .25s steps(3); }
#flash.long { font-size: clamp(12px, 4vmin, 32px); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(2.2); } }
#wrongWay { position: fixed; top: 58%; left: 50%; transform: translateX(-50%); font-size: clamp(12px, 3.6vmin, 28px);
  color: #fff; background: var(--red); border: 3px solid #fff; padding: 8px 12px; box-shadow: 4px 4px 0 #000;
  pointer-events: none; white-space: nowrap; animation: blink .5s steps(2) infinite; }

/* ---------- touch pad ---------- */
#touch { position: fixed; inset: auto 0 0 0; height: 46vh; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); touch-action: none; }
#touch button { touch-action: none; width: clamp(64px, 17vmin, 120px); aspect-ratio: 1; border: 4px solid rgba(255,255,255,.85);
  background: rgba(0,0,0,.35); font-size: clamp(16px, 4vmin, 28px); box-shadow: 4px 4px 0 rgba(0,0,0,.5); border-radius: 0; }
#touch button.down { background: rgba(255,255,255,.35); transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(0,0,0,.5); }
#touch .steer, #touch .pedals { display: flex; gap: clamp(10px, 3vmin, 24px); align-items: flex-end; }
#touch .gas { width: clamp(80px, 22vmin, 150px); background: rgba(40,180,60,.45); font-size: clamp(13px, 3vmin, 22px); }
#touch .brake { background: rgba(230,57,70,.5); font-size: clamp(11px, 2.4vmin, 18px); }
/* Kantelsturen: geen stuurknoppen, REM onder de linkerduim, GAS onder de rechter. */
#touch.tilt .steer { display: none; }
#touch.tilt .pedals { width: 100%; justify-content: space-between; }
#touch.tilt .brake { width: clamp(80px, 22vmin, 150px); }

/* ---------- schermen ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(11, 20, 51, .45); }
.screen.solid { background: var(--navy); z-index: 5; }
.panel { background: var(--panel); border: 4px solid #fff; box-shadow: 6px 6px 0 #000, inset 0 0 0 4px var(--red);
  padding: 18px 16px; width: min(440px, 100%); max-height: 100%; overflow: auto; touch-action: pan-y; text-align: center;
  display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.panel.small { width: min(360px, 100%); }
.panel h1 { font-size: clamp(16px, 5vw, 24px); color: var(--yellow); text-shadow: 3px 3px 0 var(--red); margin: 4px 0; }
.panel h2 { font-size: 10px; margin: 6px 0 0; color: var(--yellow); }
.panel p { font-size: 9px; line-height: 1.8; margin: 0; }
.logo h1 { font-size: clamp(28px, 10vw, 44px); margin: 4px 0 8px; text-shadow: 4px 4px 0 var(--red), 7px 7px 0 #000; letter-spacing: 2px; }
.logo p { color: #9fd; }
.muted { color: #9aa6c8; }

.big { background: var(--red); border: 3px solid #fff; padding: 14px 18px; font-size: 13px; box-shadow: 4px 4px 0 #000; }
.big:active:not(:disabled) { transform: translate(2px,2px); box-shadow: 2px 2px 0 #000; }
.big.alt { background: var(--navy3); }
.big:disabled { background: #3a4260; color: #8a90a8; border-color: #8a90a8; }
.link { background: none; border: none; color: #fff; font-size: 10px; padding: 10px; text-decoration: underline; text-underline-offset: 4px; }
.row { display: flex; justify-content: center; align-items: center; gap: 4px; }
.row .dot { font-size: 10px; }

/* [1] coureurs */
#driverGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card { display: flex; align-items: center; gap: 10px; background: var(--navy2); border: 3px solid #3a4a80; padding: 12px 10px;
  font-size: 10px; text-align: left; box-shadow: 3px 3px 0 #000; }
.card .sw, .sw { display: inline-block; width: 14px; height: 14px; flex: none; background: var(--c); border: 2px solid #000; }
.card[aria-selected="true"] { border-color: var(--yellow); background: var(--navy3); }
.card[aria-selected="true"]::after { content: '◀'; margin-left: auto; color: var(--yellow); }

/* [2] klaar */
.who { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; color: var(--yellow); }
.who .link { font-size: 8px; padding: 6px; }
table.best, table.laps { width: 100%; border-collapse: collapse; font-size: 11px; }
table.best td, table.laps td { padding: 6px 4px; text-align: left; border-bottom: 1px solid #26346a; }
table.best td:last-child, table.laps td:last-child { text-align: right; }
.help { font-size: 8px; line-height: 2; color: #cdd6f0; list-style: none; padding: 0; margin: 0; }
.touchOnly { display: none; }
body.touch .touchOnly { display: block; }
body.touch .keysOnly { display: none; }
.pending { font-size: 8px; line-height: 1.6; color: var(--yellow); border: 2px dashed var(--yellow); padding: 6px; }
.pending .link { font-size: 8px; padding: 4px 6px; color: var(--yellow); }

/* [3] draaien */
.phones { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0; }
.ph { display: inline-block; border: 3px solid #fff; background: var(--navy3); }
.ph.p { width: 22px; height: 38px; }
.ph.l { width: 38px; height: 22px; border-color: var(--yellow); }
.arrow { font-size: 24px; color: var(--yellow); font-family: sans-serif; }

/* [5] finish */
.record { color: var(--yellow) !important; animation: blink .6s steps(2) infinite; }
.bigtime { font-size: clamp(22px, 8vw, 34px); color: #fff; text-shadow: 3px 3px 0 #000; }
table.laps tr.best td { color: var(--yellow); }
.save { font-size: 9px; line-height: 1.8; }
.save.ok { color: #7ae582; } .save.bad { color: #ffb0b5; } .save.busy { color: #cdd6f0; }
.save .link { display: block; margin: 4px auto 0; font-size: 9px; color: #fff; }

/* [6] ranglijst */
.bar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; }
.bar .link { font-size: 14px; padding: 6px; text-decoration: none; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tabs button { background: var(--navy2); border: 3px solid #3a4a80; padding: 10px 4px; font-size: 9px; }
.tabs button[aria-selected="true"] { border-color: var(--yellow); color: var(--yellow); background: var(--navy3); }
#boardTable { width: 100%; border-collapse: collapse; font-size: 9px; }
#boardTable th { font-size: 7px; color: #9aa6c8; font-weight: normal; padding: 4px; text-align: left; }
#boardTable td { padding: 7px 4px; text-align: left; border-bottom: 1px solid #26346a; white-space: nowrap; }
#boardTable td.n, #boardTable th.n { text-align: right; }
#boardTable td.pl { width: 2.4em; color: #9aa6c8; }
#boardTable td .sw { width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
#boardTable tr.me td { color: var(--yellow); background: rgba(255, 210, 63, .1); border-top: 2px solid var(--yellow); border-bottom: 2px solid var(--yellow); }
#boardTable tr.me td:first-child { border-left: 2px solid var(--yellow); }
#boardTable tr.me td:last-child { border-right: 2px solid var(--yellow); }
#boardNotYet { font-size: 8px; }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--navy); font-size: 14px; color: var(--yellow); z-index: 10; }
