:root {
  --paper: #f5f5f4;
  --ink: #111214;
  --muted: #6b6e74;
  --line: #e2e2df;
  --blue: #1f5eff;
  --orange: #ff6a13;
  --hud: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fb4c6; font-family: Archivo, system-ui, sans-serif; color: var(--ink); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; color: var(--hud); text-shadow: 0 1px 2px rgba(0,0,0,.45); }
#hud .label { font-family: 'Archivo Narrow', sans-serif; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .78; }
.timing { position: absolute; top: 20px; left: 24px; min-width: 210px; }
.timing .big { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.timing .rows div { display: flex; justify-content: space-between; gap: 18px; font-variant-numeric: tabular-nums; font-size: 15px; line-height: 1.6; }
.tag { background: var(--orange); color: #fff; padding: 1px 6px; border-radius: 3px; margin-left: 6px; text-shadow: none; opacity: 1 !important; }
#delta.pos { color: #ff8a7a; } #delta.neg { color: #7dffa8; }
#map { position: absolute; top: 18px; right: 22px; width: 220px; height: 160px; }
.perf { position: absolute; top: 184px; right: 22px; font-variant-numeric: tabular-nums; }
/* Cockpit view: speed and gear above the dash, where the dial behind the wheel cannot be read. */
.chud { position: absolute; left: 50%; top: 52%; transform: translateX(-50%); display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
#cSpeed { font-size: 30px; font-weight: 600; min-width: 2.2ch; text-align: right; } #cGear { font-size: 22px; font-weight: 600; margin-left: 10px; }
.assists { position: absolute; left: 24px; bottom: 24px; display: flex; gap: 6px; align-items: center; }
#hud .chip { pointer-events: auto; cursor: pointer; user-select: none; -webkit-user-select: none; }
.chip { font-family: 'Archivo Narrow', sans-serif; font-size: 12px; letter-spacing: .08em; padding: 3px 7px; border: 1px solid rgba(255,255,255,.55); border-radius: 4px; opacity: .45; }
.chip.on { opacity: 1; background: rgba(255,255,255,.14); }
.chip.drs.on { background: var(--blue); border-color: var(--blue); }
.tyres { display: grid; grid-template-columns: 30px 14px 14px 30px; gap: 3px 6px; align-items: center; margin-left: 8px; }
.tyres b { font: 600 11px 'Archivo Narrow', sans-serif; font-variant-numeric: tabular-nums; }
.tyres b:nth-of-type(odd) { text-align: right; }
.tyres span { width: 14px; height: 20px; border-radius: 3px; background: #4a90e2; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dash { position: absolute; right: 28px; bottom: 22px; width: 300px; text-align: right; }
.lights { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 8px; }
.lights i { width: 14px; height: 6px; border-radius: 2px; background: rgba(255,255,255,.18); }
.lights i.g { background: #36d97b; } .lights i.o { background: #ffa21f; } .lights i.r { background: #ff3b30; }
.lights.flash i { background: #4aa3ff; }
.dashrow { display: flex; justify-content: flex-end; align-items: flex-end; gap: 22px; }
.gear { font-size: 58px; font-weight: 700; line-height: 1; }
.speed { font-size: 64px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.rpmbar { height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin-top: 10px; overflow: hidden; }
#rpmFill { height: 100%; width: 0; background: #fff; }
.rpmtext { margin-top: 4px; font-variant-numeric: tabular-nums; }
.toast { position: absolute; top: 28%; left: 50%; transform: translate(-50%, 0); font-size: 18px; font-weight: 600; letter-spacing: .02em; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

/* Menus: light paper panel over a dimmed scene */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(12,14,18,.28); padding: 16px; }
.panel { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: 14px; padding: 30px 32px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.eyebrow { font-family: 'Archivo Narrow', sans-serif; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--orange); }
h1 { margin: 6px 0 2px; font-size: 32px; font-weight: 600; letter-spacing: -.01em; }
.sub { margin: 0 0 18px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { background: none; border: 0; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-color: var(--ink); }
.note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.setting select { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions button { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 8px; }
.actions button.primary { background: var(--blue); border-color: var(--blue); color: #fff; padding: 10px 26px; font-weight: 600; }
.binds { display: grid; grid-template-columns: 1fr repeat(3, 92px); gap: 6px 6px; align-items: center; font-size: 14px; }
.binds .slot { position: relative; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 13px; color: var(--ink); padding: 0 20px 0 8px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.binds .slot.empty { color: #b5b7bb; }
.binds .slot.wait { border-color: var(--blue); color: var(--blue); }
.binds .slot .x { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: #a0a2a6; font-size: 14px; padding: 0 3px; }
.setting { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.setting input[type=range] { width: 200px; accent-color: var(--blue); }
.paints { display: flex; gap: 8px; }
.paints button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.paints button.active { box-shadow: 0 0 0 2px var(--ink); }
.switch { position: relative; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #d4d5d2; border-radius: 11px; transition: background .2s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(18px); }
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--paper); color: var(--muted); font-size: 15px; }

@media (max-width: 640px) {
  .dash { width: 220px; right: 16px; } .speed { font-size: 46px; } .gear { font-size: 42px; }
  #map { width: 150px; height: 109px; right: 16px; } .timing { left: 16px; } .perf { top: 132px; right: 16px; }
  .binds { grid-template-columns: 1fr repeat(2, 80px); } .binds .slot:nth-child(4n) { display: none; }
  .setting input[type=range] { width: 130px; }
}
@media (prefers-reduced-motion: reduce) { .toast, .switch i, .switch i::after { transition: none; } }

/* Photo mode: the frame stays clean, one paper bar at the bottom */
.photo { position: fixed; left: 0; right: 0; bottom: 20px; display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.photobar { pointer-events: auto; display: flex; align-items: center; gap: 28px; background: var(--paper); border-radius: 12px; padding: 12px 14px 12px 20px; box-shadow: 0 12px 36px rgba(0,0,0,.22); max-width: 100%; }
.photostatus { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; min-width: 250px; }
.photoactions { display: flex; gap: 8px; }
.photoactions button { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 8px; white-space: nowrap; }
.photoactions button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.photoactions button:disabled { opacity: .45; cursor: default; }
@media (max-width: 640px) { .photobar { flex-direction: column; align-items: stretch; gap: 10px; } .photostatus { min-width: 0; } }
