:root {
  --bg: #0b0e13;
  --bg-elev: #121722;
  --bg-card: #161c28;
  --line: #243045;
  --text: #e8edf7;
  --muted: #8b97ad;
  --accent: #ff6a3d;
  --accent-2: #ffb347;
  --good: #3dd68c;
  --warn: #f5c542;
  --danger: #ff5d6c;
  --rpm: #ff6a3d;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2438 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 1100px; margin: 0 auto; padding: 18px 18px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, #243149, #151b28);
  border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--accent);
  box-shadow: var(--shadow);
}
.brand-text h1 {
  margin: 0; font-size: 1.35rem; letter-spacing: .02em; font-weight: 700;
}
.tagline { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.unit-toggle {
  display: inline-flex; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px;
}
.unit-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-weight: 600;
}
.unit-btn.active { background: var(--accent); color: #111; }

.dash {
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 16px;
  margin-bottom: 18px;
}
.gauge, .main-controls, .engines, .testdrive, .more, .privacy-card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%), var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.gauge { padding: 22px 22px 16px; }
.speed-readout {
  display: flex; align-items: baseline; gap: 10px;
  justify-content: center; margin-bottom: 12px;
}
.speed-value {
  font-size: clamp(4rem, 12vw, 6.5rem);
  font-weight: 800; letter-spacing: -.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.speed-unit { color: var(--muted); font-size: 1.2rem; font-weight: 600; text-transform: uppercase; }

.rpm-wrap { margin-top: 4px; }
.rpm-bar {
  height: 14px; border-radius: 999px; background: #0a0f18;
  border: 1px solid var(--line); overflow: hidden;
}
.rpm-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #3dd68c, var(--accent-2), var(--accent), #ff3b30);
  transition: width .12s linear;
}
.rpm-meta {
  display: flex; justify-content: space-between; margin-top: 8px;
  color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums;
}
#gearValue {
  color: var(--accent-2); background: rgba(255,179,71,.1);
  padding: 2px 10px; border-radius: 999px; border: 1px solid rgba(255,179,71,.25);
}
.gps-status {
  margin-top: 14px; text-align: center; color: var(--muted);
  font-size: .9rem; min-height: 1.3em;
}
.gps-status.ok { color: var(--good); }
.gps-status.warn { color: var(--warn); }
.gps-status.err { color: var(--danger); }

.main-controls {
  padding: 22px; display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.start-btn {
  appearance: none; border: 0;
  background: linear-gradient(180deg, #ff8a5c, var(--accent));
  color: #140b07; font-weight: 800; font-size: 1.35rem;
  padding: 22px 18px; border-radius: 18px;
  box-shadow: 0 10px 30px rgba(255,106,61,.35), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .08s ease, filter .15s ease;
}
.start-btn:active { transform: scale(.98); }
.start-btn.running {
  background: linear-gradient(180deg, #ff7a88, var(--danger));
  box-shadow: 0 10px 30px rgba(255,93,108,.3), inset 0 1px 0 rgba(255,255,255,.25);
  color: #1a0608;
}
.volume-row {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 12px;
}
.vol-label, .vol-value { color: var(--muted); font-weight: 600; }
.vol-value { min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 999px;
  background: #0a0f18; border: 1px solid var(--line); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff2;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff2; cursor: pointer;
}

.section-label {
  margin: 0 0 12px; font-size: .95rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); font-weight: 700;
}
.hint-inline { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .8; }

.engines, .testdrive, .more, .privacy { margin-bottom: 16px; }
.engines, .testdrive { padding: 18px; }

.engine-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.engine-btn {
  border: 1px solid var(--line); background: #101623;
  border-radius: 14px; padding: 14px 10px; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s, background .15s, transform .08s;
}
.engine-btn:active { transform: scale(.98); }
.engine-btn.active {
  border-color: rgba(255,106,61,.7);
  background: linear-gradient(180deg, rgba(255,106,61,.18), rgba(255,106,61,.05));
  box-shadow: inset 0 0 0 1px rgba(255,106,61,.25);
}
.eng-name { font-weight: 800; font-size: 1.05rem; }
.eng-sub { color: var(--muted); font-size: .8rem; }

.pedals {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 14px; align-items: end;
}
.pedal {
  background: #0d121c; border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 10px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 180px;
}
.pedal-slider {
  writing-mode: bt-lr; /* legacy */
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  width: 36px; height: 140px;
}
.pedal-label { font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-size: .8rem; }
.pedal .gas::-webkit-slider-thumb { background: var(--good); }
.pedal .brake::-webkit-slider-thumb { background: var(--danger); }

.td-buttons { display: flex; flex-direction: column; gap: 10px; height: 100%; justify-content: center; }
.action-btn {
  border: 1px solid var(--line); background: #101623;
  border-radius: 14px; padding: 18px 14px; font-weight: 700; font-size: 1.05rem;
}
.action-btn:active, .action-btn.held {
  background: rgba(255,106,61,.18); border-color: rgba(255,106,61,.6);
}
.action-btn.demoing {
  background: rgba(61,214,140,.15); border-color: rgba(61,214,140,.55); color: var(--good);
}
.td-note { margin: 12px 0 0; color: var(--muted); font-size: .88rem; }

.more-toggle {
  width: 100%; text-align: left; padding: 16px 18px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); font-weight: 700; color: var(--text);
  box-shadow: var(--shadow);
}
.more-panel {
  margin-top: 10px; padding: 16px 18px 8px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.setting { margin-bottom: 16px; }
.setting label {
  display: flex; justify-content: space-between; gap: 12px;
  margin-bottom: 8px; font-weight: 600;
}
.setting-hint { color: var(--muted); font-weight: 500; font-size: .85rem; }
.setting-toggle {
  display: flex; align-items: center; justify-content: space-between;
}
.setting-toggle label { margin: 0; }
.setting-toggle input[type="checkbox"] {
  width: 22px; height: 22px; accent-color: var(--accent);
}

.privacy-card { padding: 18px; }
.privacy-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.privacy-card p { margin: 0 0 10px; color: var(--muted); line-height: 1.45; }
.privacy-card details summary {
  cursor: pointer; color: var(--accent-2); font-weight: 700; margin-bottom: 8px;
}
.privacy-card ol { margin: 0; padding-left: 1.2rem; color: var(--muted); line-height: 1.55; }
.privacy-card li { margin-bottom: 6px; }

.footer {
  text-align: center; color: #667388; font-size: .8rem; margin-top: 8px; line-height: 1.4;
}

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .engine-grid { grid-template-columns: repeat(2, 1fr); }
  .engine-grid .engine-btn:last-child { grid-column: 1 / -1; }
  .pedals { grid-template-columns: 1fr 1fr; }
  .td-buttons { grid-column: 1 / -1; flex-direction: row; }
  .action-btn { flex: 1; }
}
@media (max-width: 480px) {
  #app { padding: 12px 12px 32px; }
  .start-btn { font-size: 1.2rem; padding: 18px 14px; }
  .pedal { min-height: 160px; }
  .pedal-slider { height: 120px; }
}
