/* Time Attack Suomi brand (tas-brand-kit): dark first, Barlow and Barlow Condensed served from assets/fonts (no Google Fonts). */
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('assets/fonts/barlow-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('assets/fonts/barlow-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('assets/fonts/barlow-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('assets/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Barlow Condensed'; font-style: italic; font-weight: 800; font-display: swap; src: url('assets/fonts/barlow-condensed-latin-800-italic.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  color-scheme: dark;
  --color-bg: #0A0E17; --color-surface: #121A2B; --color-surface-2: #1A2440; --color-border: #2A3552;
  --color-text: #F2F4F8; --color-text-muted: #A9B4C8; --color-primary: #0040A0; --color-primary-hover: #0052CC;
  --color-electric: #0060F0; --color-link: #6FA8FF; --color-silver: #C9D1DE;
  --font-heading: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', system-ui, sans-serif;
  --radius: 6px; --touch-min: 48px;
  --panel-bg: rgba(18, 26, 43, 0.94); /* surface, as the kit's notice box */
  --scrim: rgba(10, 14, 23, 0.6); /* dark backing for text over the 3D view */
  --hud-shadow: 0 1px 3px rgba(10, 14, 23, 0.85);
  --color-podium-1: #F2C94C; --color-podium-2: #D5DBE5; --color-podium-3: #E0A36B; /* places 1–3 only */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--color-bg); color: var(--color-text); font: 400 16px/1.5 var(--font-body); overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; }

.hud { position: absolute; inset: 0; pointer-events: none; color: var(--color-text); text-shadow: var(--hud-shadow); }
.hud[hidden] { display: none; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 6px 16px 5px; background: var(--scrim); border-radius: var(--radius); text-align: center; }
.hud-time { font: 700 38px/1 var(--font-heading); font-variant-numeric: tabular-nums; }
.hud-sectors { margin-top: 2px; display: flex; gap: 12px; justify-content: center; font: 700 17px/1.2 var(--font-heading); font-variant-numeric: tabular-nums; }
.hud-delta { min-height: 22px; font: 700 20px/1.1 var(--font-heading); font-variant-numeric: tabular-nums; }
.hud-delta.ahead { color: var(--color-link); }
.hud-map { position: absolute; top: 10px; right: max(10px, env(safe-area-inset-right)); width: 120px; height: 120px; background: var(--scrim); border: 1px solid var(--color-border); border-radius: var(--radius); }
.hud-bottom { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 6px 12px 6px 16px; background: var(--scrim); border-radius: var(--radius); font: 700 36px/1 var(--font-heading); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-unit { font: 600 15px var(--font-body); color: var(--color-text-muted); }
.hud-gear { display: inline-block; min-width: 1.5em; margin-left: 10px; padding: 1px 6px; text-align: center; border: 2px solid var(--color-link); border-radius: var(--radius); }
.hud-flash { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); font: italic 800 52px/1 var(--font-heading); text-transform: uppercase; text-shadow: 0 2px 12px rgba(10, 14, 23, 0.9); opacity: 0; }
.hud-flash.on { animation: flash 1.1s ease-out forwards; }
.hud-ready { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); font: italic 800 64px/1.05 var(--font-heading); text-transform: uppercase; text-shadow: 0 2px 16px rgba(10, 14, 23, 0.9); }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, 8px); } 15% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; } 100% { opacity: 0; } }

.touch-layer { position: absolute; inset: 0; touch-action: none; }
.touch-layer[hidden] { display: none; }
.pad { position: absolute; pointer-events: none; border-radius: 12px; background-color: rgba(0, 64, 160, 0.22); border: 2px solid rgba(111, 168, 255, 0.45); }
.pad.on { border-color: #6FA8FF; box-shadow: 0 0 0 1px #6FA8FF; } /* pressed: only the border lights up, the view stays clear */
.pad::before, .pad::after { position: absolute; display: grid; place-items: center; font: italic 800 20px var(--font-heading); letter-spacing: 0.04em; color: rgba(242, 244, 248, 0.85); text-shadow: var(--hud-shadow); }
.pad::after { content: attr(data-label); inset: 0; }
.pad-restart::after { font-size: 15px; padding-left: env(safe-area-inset-left, 0px); }
/* Steering and pedal: the centre line is neutral, a label on each side of it. */
.pad-steer { background-image: linear-gradient(to right, transparent calc(50% - 1px), rgba(242, 244, 248, 0.6) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); }
.pad-steer::before { content: attr(data-left); inset: 0 50% 0 0; }
.pad-steer::after { content: attr(data-right); inset: 0 0 0 50%; }
.pad-pedal { background-image: linear-gradient(to bottom, transparent calc(50% - 1px), rgba(242, 244, 248, 0.6) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); }
.pad-pedal::before { content: attr(data-up); inset: 0 0 50% 0; }
.pad-pedal::after { content: attr(data-down); inset: 50% 0 0 0; }
/* Strength bars: a thin track beside the thumb, filled from the centre line. */
.level { position: absolute; border-radius: 3px; background: rgba(242, 244, 248, 0.18); pointer-events: none; }
.level > span { position: absolute; border-radius: 3px; }
.pad-steer .level { top: 8px; left: 10px; right: 10px; height: 6px; }
.level-left { top: 0; bottom: 0; right: 50%; width: calc(var(--left, 0) * 50%); background: #6FA8FF; }
.level-right { top: 0; bottom: 0; left: 50%; width: calc(var(--right, 0) * 50%); background: #6FA8FF; }
.pad-pedal .level { left: 8px; top: 10px; bottom: 10px; width: 6px; }
.level-gas { left: 0; right: 0; bottom: 50%; height: calc(var(--gas, 0) * 50%); background: #6FA8FF; }
.level-brake { left: 0; right: 0; top: 50%; height: calc(var(--brake, 0) * 50%); background: #F2F4F8; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(10, 14, 23, 0.45); overflow-y: auto; }
.overlay[hidden] { display: none; }
.panel { width: min(820px, 100%); padding: 22px 26px; background: var(--panel-bg); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5); }
.eyebrow { margin: 0 0 6px; font: 700 15px/1.3 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-link); }
.display { margin: 0; font: italic 800 clamp(28px, 2.4vw + 14px, 46px)/1.05 var(--font-heading); text-transform: uppercase; letter-spacing: -0.01em; }
.lead { margin: 8px 0 0; font-size: 17px; line-height: 1.5; color: var(--color-text-muted); }
.brand { display: flex; align-items: center; gap: 26px; }
.brand .logo { flex: none; width: 104px; height: auto; margin: 8px 0; } /* kit: clear space >= 1/4 of the logo width */
.cars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 12px; }
.car { display: grid; gap: 2px; padding: 8px 8px 10px; border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary); border-radius: var(--radius); background: var(--color-surface-2); color: var(--color-text); font: inherit; line-height: 1.3; text-align: left; cursor: pointer; }
.car:hover { border-color: var(--color-electric); box-shadow: 0 0 18px rgba(0, 96, 240, 0.35); }
.car:focus-visible, .btn:focus-visible { outline: 3px solid var(--color-electric); outline-offset: 2px; }
.car img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; margin-bottom: 6px; }
.car .class { font: 700 15px/1.3 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-link); }
.car .name { font-size: 16px; font-weight: 600; }
.car .target { font-size: 15px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.notes { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 18px; }
.help, .credit { margin: 0; font-size: 15px; line-height: 1.5; color: var(--color-text-muted); text-align: center; }
.results { text-align: center; }
.laptime { margin: 4px 0; font: italic 800 clamp(48px, 7vw + 12px, 80px)/1 var(--font-heading); font-variant-numeric: tabular-nums; }
.delta { margin: 6px 0 0; font: 700 21px/1.3 var(--font-heading); font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.delta.good { color: var(--color-link); }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.btn { min-height: var(--touch-min); padding: 12px 28px; border: 2px solid transparent; border-radius: var(--radius); font: italic 800 18px/1 var(--font-heading); letter-spacing: 0.02em; text-transform: uppercase; cursor: pointer; }
.btn.primary { background: var(--color-primary); color: #fff; }
.btn.primary:hover { background: var(--color-primary-hover); }
.btn.ghost { background: transparent; color: var(--color-text); border-color: var(--color-silver); }
.btn.ghost:hover { border-color: var(--color-electric); background: rgba(0, 96, 240, 0.12); }
.brand { flex-wrap: wrap; }
.menu { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
/* Results: nickname and submit */
.submit { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 10px 12px; margin-top: 14px; }
.field { display: grid; gap: 4px; text-align: left; font: 700 15px/1.3 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-link); }
.field input { min-height: var(--touch-min); width: min(280px, 70vw); padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface-2); color: var(--color-text); font: 600 17px var(--font-body); letter-spacing: normal; text-transform: none; -webkit-user-select: text; user-select: text; }
.field input:focus-visible { outline: 3px solid var(--color-electric); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.status { flex-basis: 100%; margin: 0; font-size: 15px; color: var(--color-text-muted); }
.status.done { color: var(--color-link); }
/* Leaderboards and settings */
.tabs, .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { margin: 8px 0 12px; }
.tab, .opt { min-height: var(--touch-min); padding: 10px 16px; border: 2px solid var(--color-silver); border-radius: var(--radius); background: transparent; color: var(--color-text); font: 700 16px var(--font-body); cursor: pointer; }
.tab[aria-pressed="true"], .opt[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tab:focus-visible, .opt:focus-visible { outline: 3px solid var(--color-electric); outline-offset: 2px; }
.board-wrap { max-height: 52vh; overflow-y: auto; }
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th { padding: 6px 8px; border-bottom: 1px solid var(--color-border); text-align: left; font: 700 15px/1.3 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-link); }
.board td { padding: 8px; border-bottom: 1px solid var(--color-border); font-size: 16px; }
.board th:last-child, .board td:last-child { text-align: right; }
.board .p1 td:first-child { color: var(--color-podium-1); font-weight: 700; }
.board .p2 td:first-child { color: var(--color-podium-2); font-weight: 700; }
.board .p3 td:first-child { color: var(--color-podium-3); font-weight: 700; }
.board .me td { background: rgba(0, 64, 160, 0.4); }
.setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.setting-label { font-weight: 600; }

.rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate { position: fixed; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 32px; padding: 32px; background: var(--color-bg); color: var(--color-text); text-align: center; }
  .rotate img { width: 128px; height: auto; }
  .rotate p { margin: 0; font: italic 800 28px/1.05 var(--font-heading); text-transform: uppercase; }
}
@media (pointer: coarse) { /* phones: the bottom centre belongs to the steering thumb, speed and gear move to the left */
  .hud-bottom { top: 30%; bottom: auto; left: max(12px, env(safe-area-inset-left)); transform: none; }
}
@media (max-width: 767px) { .actions { display: grid; grid-template-columns: 1fr 1fr; } } /* brand: full-width buttons on phones */
@media (max-width: 560px) { .cars { grid-template-columns: 1fr; } }
@media (max-height: 480px) { /* landscape phones */
  .overlay { padding: 8px; }
  .panel { padding: 12px 16px; }
  .brand { gap: 18px; }
  .brand .logo { width: 64px; margin: 6px 0; } /* the kit's minimum size for the full badge */
  .display { font-size: 26px; }
  .lead { margin-top: 4px; font-size: 15px; }
  .cars { gap: 10px; margin: 10px 0 6px; }
  .car img { aspect-ratio: 5 / 2; }
  .laptime { font-size: 54px; }
}
@media (max-height: 340px) { /* landscape phones with the browser bars showing */
  .start .lead { display: none; }
  .cars { margin-bottom: 4px; }
  .car img { aspect-ratio: 7 / 2; }
}
