/* Ghost Engine. The look is "Supercar on carbon" (Frederik's pick from the design lab, 18 Oct 2026, "A2c"), like a
   Ferrari / Lamborghini / Porsche digital cluster: near-black, sharp rectangles (no cut corners), thin white neon
   lines, red only for the revs, the redline, START and what's chosen, crisp dials without blur. Dark only.
   Background (#scene in index.html): carbon fibre that fades to black behind the dials, a slow light sheen, a red trim
   line and a red glow from below that follow the revs (--rev, set by fx.js). Motion: fx.js + the keyframes below.
   Written for the Tesla browser (older Chromium): no flex gap, no aspect-ratio, no :has(), no inset shorthand. */
:root {
  --font: 'Titillium Web', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bg: #040405;
  --panel: rgba(15, 16, 19, .78);
  --panel-2: rgba(24, 26, 30, .92);
  --panel-solid: #0b0c0e;
  --deep: #08090b;
  --sheet: rgba(9, 10, 12, .96);
  --line: rgba(255, 255, 255, .13);
  --steel: #a9afb8;
  --text: #e6e9ee;
  --text-hi: #ffffff;
  --dim: #616770;
  --on-glow: #050506;
  --ok-bg: rgba(40, 120, 70, .3);
  /* Neon lines and outlines (white), each with a halo (-soft) and an inner glow (-faint) */
  --neon: rgba(242, 245, 250, .85);
  --neon-dim: rgba(242, 245, 250, .22);
  --neon-soft: rgba(242, 245, 250, .28);
  --neon-faint: rgba(242, 245, 250, .06);
  /* Red: START, stop, the redline and what's chosen */
  --accent: #ff2a2a;
  --accent-text: #ff4b4b;
  --accent-soft: rgba(255, 42, 42, .55);
  --accent-faint: rgba(255, 42, 42, .14);
  --tick: #1b1e22;
  --tick-red: #3b1213;
  --tick-on: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 18px/1.35 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 0;
}

[hidden] {
  display: none !important;
}

.ico {
  width: 24px;
  height: 24px;
  display: block;
}

/* Background: behind everything, the content above it */
.scene {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene>div {
  position: absolute;
}

.scene-carbon {
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  opacity: .42;
  background:
    linear-gradient(27deg, #0d0d0e 5px, rgba(0, 0, 0, 0) 5px) 0 5px,
    linear-gradient(207deg, #0d0d0e 5px, rgba(0, 0, 0, 0) 5px) 10px 0,
    linear-gradient(27deg, #19191b 5px, rgba(0, 0, 0, 0) 5px) 0 10px,
    linear-gradient(207deg, #19191b 5px, rgba(0, 0, 0, 0) 5px) 10px 5px,
    linear-gradient(90deg, #121214 10px, rgba(0, 0, 0, 0) 10px),
    linear-gradient(#141416 25%, #101012 25%, #101012 50%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0) 75%, #1b1b1d 75%, #1b1b1d);
  background-color: #0b0b0c;
  background-size: 20px 20px;
  /* the weave only at the edges: plain black in the middle, behind the dials */
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at 50% 45%, rgba(0, 0, 0, 0) 35%, #000 90%);
  mask-image: radial-gradient(ellipse 62% 58% at 50% 45%, rgba(0, 0, 0, 0) 35%, #000 90%);
}

.scene-sheen {
  left: 0;
  top: -50%;
  width: 45vw;
  height: 200%;
  will-change: transform;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .03) 50%, rgba(255, 255, 255, 0));
  animation: scene-sheen 16s ease-in-out infinite;
}

@keyframes scene-sheen {
  0% {
    transform: translateX(-70vw) rotate(18deg);
  }

  65%,
  100% {
    transform: translateX(170vw) rotate(18deg);
  }
}

.scene-trim {
  left: 0;
  right: 0;
  bottom: 16%;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 42, 42, 0), #ff2a2a 20%, #ff2a2a 80%, rgba(255, 42, 42, 0));
  box-shadow: 0 0 12px 1px rgba(255, 42, 42, .3);
  opacity: calc(.12 + var(--rev, 0) * .5);
}

.scene-floor {
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%;
  background: radial-gradient(ellipse 70% 100% at 50% 100%, rgba(255, 25, 25, .32), rgba(255, 25, 25, 0) 70%);
  opacity: calc(.06 + var(--rev, 0) * .4);
}

.scene-vignette {
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, .85));
}

html.moving .scene-sheen {
  opacity: .5;
}

/* calmer while driving (fx.js also slows it down) */

/* Top bar: no line under it (Frederik, 18 Oct), a softly glowing logo */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  z-index: 3;
}

.logo {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--text-hi);
  text-shadow: 0 0 14px var(--neon-soft);
}

.logo .mark {
  width: 34px;
  height: 34px;
  margin-right: 12px;
  filter: drop-shadow(0 0 6px var(--neon-soft));
}

.logo .word {
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 6px;
  white-space: nowrap;
}

.bar-right {
  display: flex;
  align-items: center;
}

/* Language picker in the top bar */
.lang-dropdown {
  position: relative;
  margin-left: 10px;
}

.lang-curr-btn {
  height: 48px;
  min-width: 60px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-hi);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid var(--line);
  background-color: var(--panel);
  cursor: pointer;
  transition: border-color .25s, box-shadow .25s, background-color .25s, color .25s;
}

.lang-curr-btn:hover {
  border-color: var(--neon);
  box-shadow: 0 0 12px var(--neon-faint);
}

.lang-curr-btn[aria-expanded="true"] {
  border-color: var(--accent);
  background-color: var(--panel-2);
  box-shadow: 0 0 14px var(--accent-faint);
}

.lang-chevron {
  width: 14px;
  height: 14px;
  margin-left: 6px;
  color: var(--steel);
  transition: transform .2s ease;
}

.lang-curr-btn[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  background: var(--sheet);
  border: 1px solid var(--neon-dim);
  box-shadow: 0 0 24px var(--neon-faint), 0 12px 36px rgba(0, 0, 0, .85);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.lang-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--steel);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .5px;
  text-align: left;
  cursor: pointer;
  transition: all .2s;
  box-sizing: border-box;
}

.lang-opt:hover {
  background: var(--panel-2);
  color: var(--text-hi);
  border-color: var(--line);
}

.lang-opt.active,
.lang-opt[aria-selected="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255, 42, 42, .08);
  box-shadow: 0 0 12px var(--accent-faint);
}

.lang {
  display: flex;
  margin-left: 10px;
}

.lang-btn {
  width: 52px;
  height: 48px;
  margin-left: 4px;
  color: var(--dim);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Neon boxes: a thin line around every control; red and glowing when chosen or pressed */
.lang-btn,
.icon-btn,
.seg,
.test,
.row,
.row-btn,
.engine-tile,
.engine-btn,
.stop-btn,
.gas {
  border: 1px solid var(--line);
  background-color: var(--panel);
  transition: border-color .25s, box-shadow .25s, background-color .25s, color .25s;
}

.lang-btn[aria-checked="true"],
.seg[aria-checked="true"],
.engine-tile[aria-checked="true"] {
  border-color: var(--accent);
  background-color: var(--panel-2);
  color: var(--text-hi);
  box-shadow: 0 0 16px var(--accent-soft), inset 0 0 18px var(--accent-faint);
}

.lang-btn:active,
.icon-btn:active,
.seg:active,
.engine-tile:active,
.engine-btn:active,
.test:active {
  border-color: var(--accent);
  box-shadow: 0 0 22px var(--accent-soft), inset 0 0 22px var(--accent-soft);
}

@media (hover: hover) {

  .engine-tile:hover,
  .seg:hover,
  .icon-btn:hover,
  .lang-btn:hover,
  .engine-btn:hover {
    border-color: var(--neon);
    box-shadow: 0 0 12px var(--neon-faint);
  }
}

/* The instrument cluster: crisp, no blur (Frederik, 18 Oct) */
.cluster {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px 96px;
  /* bottom set by fitCluster() */
  transition: opacity 1.4s ease;
}

.cluster-svg {
  width: 100%;
  height: 100%;
  max-width: 1180px;
  font-family: var(--font);
}

/* scales to fit both ways */
.cluster text {
  text-anchor: middle;
  fill: var(--text-hi);
  font-family: var(--font);
}

.cluster .tick {
  fill: var(--tick);
}

.cluster .tick.red {
  fill: var(--tick-red);
}

.cluster .tick.on {
  fill: var(--tick-on);
}

.cluster .tick.on.red {
  fill: var(--accent);
}

.cluster .scale {
  fill: var(--dim);
  font-size: 22px;
  font-weight: 600;
}

.cluster .big {
  font-size: 64px;
  font-weight: 600;
}

.cluster .xl {
  font-size: 92px;
}

.cluster .xxl {
  font-size: 150px;
  font-weight: 600;
  letter-spacing: -2px;
}

.cluster .mid {
  font-size: 40px;
  font-weight: 600;
}

.cluster .unit {
  fill: var(--steel);
  font-size: 18px;
  letter-spacing: 5px;
}

.cluster .label {
  fill: var(--dim);
  font-size: 14px;
  letter-spacing: 4px;
}

.cluster .gear {
  font-size: 60px;
  font-weight: 700;
}

.cluster .badge {
  fill: var(--panel-solid);
  stroke: var(--neon);
  stroke-width: 2;
}

.cluster .engine-pick {
  cursor: pointer;
}

.cluster .engine-pick text {
  fill: var(--steel);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.cluster .engine-pick path {
  stroke: var(--accent);
}

.cluster .engine-pick:active text {
  fill: var(--text-hi);
}

.cluster .note {
  fill: var(--dim);
  font-size: 17px;
  letter-spacing: 1px;
  transition: opacity .8s;
}

.cluster .note.waiting {
  opacity: 0;
}

/* hidden while the volume toast says the same */
body.on .cluster .note {
  display: none !important;
}

/* Radio track info inside the cluster */
.cluster .cluster-radio {
  font-size: 15px;
  font-weight: 600;
  text-anchor: middle;
  fill: var(--text-hi);
  transition: opacity .3s, fill .3s;
  opacity: .95;
}

.cluster .cluster-radio.has-info {
  font-size: 14.5px;
  font-weight: 700;
  fill: var(--text-hi);
  letter-spacing: 0.2px;
}

/* Smooth ping-pong marquee for long song titles in cluster */
.cluster .cluster-radio.marquee {
  animation: cluster-radio-marquee var(--marquee-duration, 16s) ease-in-out infinite;
  will-change: transform;
}

@keyframes cluster-radio-marquee {

  0%,
  22% {
    transform: translateX(var(--marquee-shift, 0px));
  }

  50%,
  72% {
    transform: translateX(calc(-1 * var(--marquee-shift, 0px)));
  }

  100% {
    transform: translateX(var(--marquee-shift, 0px));
  }
}

.cluster .cluster-radio.off {
  fill: var(--dim);
  opacity: .7;
  letter-spacing: 1px;
}

.cluster .cluster-radio-g:hover .cluster-radio.off {
  fill: var(--text);
  opacity: 1;
}

.cluster .cluster-radio-sub {
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  fill: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  transition: opacity .3s, fill .3s;
  opacity: .85;
}

.cluster .cluster-radio-g:hover .cluster-radio-sub {
  fill: var(--steel);
  opacity: 1;
}

/* Radio station navigation arrows (desktop & touch) */
.cluster .cluster-radio-nav {
  color: var(--neon-soft);
  opacity: .55;
  cursor: pointer;
  transition: color .2s ease, opacity .2s ease;
}

.cluster .cluster-radio-g:hover .cluster-radio-nav {
  opacity: .85;
  color: var(--text);
}

.cluster .cluster-radio-nav:hover {
  color: var(--accent) !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 6px var(--accent-soft));
}

.cluster .cluster-radio-nav:active path {
  stroke-width: 3.2;
}

/* A gear change: the gear box flashes red (fx.js adds .shift) */
.cluster.shift .badge {
  animation: shift-flash .42s ease-out;
}

.cluster.shift .gear {
  animation: shift-text .42s ease-out;
}

@keyframes shift-flash {
  from {
    fill: var(--accent);
  }

  to {
    fill: var(--panel-solid);
  }
}

@keyframes shift-text {
  from {
    fill: var(--on-glow);
  }

  to {
    fill: var(--text-hi);
  }
}

/* At the limiter the red ticks strobe (fx.js adds html.limit) */
html.limit .cluster .tick.on.red {
  animation: limit-strobe .14s steps(2, end) infinite;
}

@keyframes limit-strobe {
  50% {
    opacity: .2;
  }
}

/* START: the dials power up from dark; an engine switch dims them for a moment (fx.js) */
html.fx-start .cluster-svg {
  animation: dials-power .9s ease-out;
}

@keyframes dials-power {
  from {
    opacity: .15;
  }

  to {
    opacity: 1;
  }
}

html.fx-switch .cluster-svg {
  animation: dials-dip .9s ease-in-out;
}

@keyframes dials-dip {

  0%,
  100% {
    opacity: 1;
  }

  35% {
    opacity: .25;
  }
}

/* Engine list: a grid of tiles (switch-engine panel) */
.engine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 12px;
  width: 100%;
  max-width: 1000px;
  padding: 0 24px;
}

.engine-tile {
  min-height: 104px;
  padding: 14px 18px;
  text-align: left;
  color: var(--text);
}

.engine-tile .spec {
  display: block;
  color: var(--steel);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.engine-tile .name {
  display: block;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 2px 0 2px;
  color: var(--text-hi);
}

.engine-tile[aria-checked="true"] .name {
  text-shadow: 0 0 12px var(--accent-soft);
}

.engine-tile .desc {
  display: block;
  color: var(--steel);
  font-size: 14px;
  line-height: 1.3;
}

.engine-tile .cars {
  display: block;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.3;
  margin-top: 5px;
}

/* Bottom dock: stop engine above hold-to-rev, same size. Hold-to-rev keeps its slot while driving (invisible),
   and the toast floats above the dock, so nothing else moves when either comes or goes. */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 20px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.dock>* {
  pointer-events: auto;
}

.stop-btn {
  width: 360px;
  height: 64px;
  margin-top: 10px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--accent);
  color: var(--accent-text);
  text-shadow: 0 0 10px var(--accent-soft);
  box-shadow: 0 0 14px var(--accent-faint), inset 0 0 14px var(--accent-faint);
  transition: transform .6s cubic-bezier(.2, .8, .2, 1), opacity .6s ease, background-color .2s ease, border-color .2s ease;
  transform-origin: center bottom;
}

.stop-btn.scaled {
  transform: scale(0.65);
  opacity: .75;
}

.stop-btn.scaled:hover {
  opacity: 1;
  transform: scale(0.72);
}

.stop-btn.start-mode {
  border: 2px solid var(--accent);
  color: var(--text-hi);
  background: rgba(255, 42, 42, .08);
  box-shadow: 0 0 24px var(--accent-soft), inset 0 0 20px var(--accent-faint);
  text-shadow: 0 0 16px var(--accent-soft);
  letter-spacing: 7px;
}

.stop-btn.start-mode:active {
  background: var(--accent-faint);
  box-shadow: 0 0 32px var(--accent-soft), inset 0 0 26px var(--accent-soft);
}

.stop-btn,
.gas {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 5px;
  text-transform: uppercase;
}

.gas {
  width: 360px;
  height: 64px;
  margin-top: 10px;
  color: var(--steel);
  touch-action: none;
  -webkit-touch-callout: none;
}

.gas.held {
  border-color: var(--accent);
  background-color: var(--accent);
  color: var(--on-glow);
  box-shadow: 0 0 30px var(--accent-soft);
}

.gas.off {
  visibility: hidden;
  pointer-events: none;
}

/* Volume toast after start: floats above the dock */
.toast {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 640px;
  margin: 0 0 4px -320px;
  transition: opacity .8s, transform .8s;
}

.toast-inner {
  display: flex;
  align-items: center;
  padding: 16px 22px;
  text-align: left;
  border: 1px solid var(--neon);
  background: var(--panel-solid);
  box-shadow: 0 0 22px var(--neon-soft), inset 0 0 18px var(--neon-faint);
}

.toast .ico {
  width: 34px;
  height: 34px;
  flex: none;
  margin-right: 16px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-soft));
}

.toast strong {
  display: block;
  font-size: 20px;
  letter-spacing: .5px;
  color: var(--text-hi);
}

.toast span {
  display: block;
  color: var(--steel);
  font-size: 15px;
}

.toast.fade {
  opacity: 0;
  transform: translateY(12px);
}

/* Menu and the switch-engine panel */
.sheet {
  position: fixed;
  top: 76px;
  right: 24px;
  width: 440px;
  max-height: calc(100% - 100px);
  overflow-y: auto;
  z-index: 6;
  background: var(--sheet);
  padding: 18px 22px 22px;
  border: 1px solid var(--neon-dim);
  box-shadow: 0 0 40px var(--neon-faint), 0 20px 60px rgba(0, 0, 0, .6);
}

/* The engine dialog: centred on the screen over everything, with the rest dimmed behind it */
.sheet.wide {
  left: 50%;
  top: 50%;
  right: auto;
  width: 1040px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  transform: translate(-50%, -50%);
}

.backdrop {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background: rgba(0, 0, 0, .72);
}

.sheet.wide .engine-grid {
  padding: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-hi);
  text-shadow: 0 0 12px var(--neon-soft);
}

.row,
.row-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 64px;
  margin: 8px 0;
  padding: 10px 16px;
  text-align: left;
}

.row.col {
  flex-direction: column;
  align-items: stretch;
}

.row small {
  display: block;
  color: var(--dim);
  font-size: 13px;
}

.row input[type=checkbox] {
  width: 28px;
  height: 28px;
  accent-color: var(--accent);
}

.row-value {
  color: var(--steel);
  font-size: 15px;
}

.row-btn .row-value {
  display: flex;
  align-items: center;
}

.row-btn .row-value .ico {
  width: 18px;
  height: 18px;
  margin-left: 8px;
}

/* Menu Volume Controls */
.vol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  min-height: 56px;
  box-sizing: border-box;
}

.vol-mute-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  margin: 0 10px 0 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--steel);
  border: 1px solid var(--line);
  background-color: var(--panel);
  cursor: pointer;
  transition: border-color .25s, box-shadow .25s, background-color .25s, color .25s;
  flex-shrink: 0;
}

.vol-mute-btn:hover {
  border-color: var(--neon);
  box-shadow: 0 0 12px var(--neon-faint);
  color: var(--text-hi);
}

.vol-mute-btn.muted {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--panel-2);
  box-shadow: 0 0 14px var(--accent-faint);
}

.vol-mute-btn .ico {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.vol-info {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 80px;
  margin-right: 12px;
}

.vol-info span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.vol-info .vol-num {
  font-size: 12px;
  color: var(--steel);
  font-weight: 400;
  margin-top: 1px;
}

.vol-range {
  flex: 0 1 140px;
  width: 140px;
  max-width: 150px;
  min-width: 70px;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
  outline: none;
}

.seg-group {
  display: flex;
  margin: 10px -4px 2px;
}

.seg {
  flex: 1;
  min-height: 48px;
  margin: 0 4px;
  color: var(--steel);
  font-size: 15px;
  font-weight: 600;
}

.seg[aria-checked="true"] {
  text-shadow: 0 0 10px var(--accent-soft);
}

#soundCheck {
  margin-top: 10px;
  color: var(--steel);
  font-size: 15px;
}

#soundCheck summary {
  cursor: pointer;
  padding: 10px 0;
}

.tests {
  display: flex;
  flex-wrap: wrap;
  margin: 8px -4px;
}

.test {
  flex: 1 1 180px;
  min-height: 52px;
  margin: 4px;
  font-size: 15px;
}

.test.done {
  border-color: var(--neon);
  background-color: var(--ok-bg);
}

.diag,
.debug {
  font: 13px/1.5 Menlo, Consolas, monospace;
  color: var(--dim);
  margin-top: 8px;
  white-space: pre-wrap;
}


/* Menu: slides in from the right (Frederik's pick). See app.js openPanel/closePanel */
.sheet,
.backdrop {
  animation-duration: .38s;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}

.sheet.wide {
  --tx: -50%;
}

.backdrop.enter {
  animation-name: fade-in;
}

.backdrop.leave {
  animation-name: fade-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

#menu.enter {
  animation-name: slide-in;
}

#menu.leave {
  animation-name: slide-out;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slide-out {
  from {
    opacity: 1;
    transform: none;
  }

  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* Engine dialog: a red line of light flashes across the middle as it opens with a short scale and fade, then the
   tiles drop in one by one */
.sheet.wide.enter {
  animation-name: panel-in;
  animation-duration: .5s;
}

.sheet.wide.leave {
  animation-name: panel-out;
  animation-duration: .28s;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translate(var(--tx), -50%) scale(.96);
  }

  to {
    opacity: 1;
    transform: translate(var(--tx), -50%);
  }
}

@keyframes panel-out {
  to {
    opacity: 0;
    transform: translate(var(--tx), -50%) scale(.97);
  }
}

.sheet.wide::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--accent);
  box-shadow: 0 0 16px 4px var(--accent-soft);
  opacity: 0;
  pointer-events: none;
}

.sheet.wide.enter::after {
  animation: panel-line .5s ease-out both;
}

.sheet.wide.leave::after {
  animation: panel-line .32s ease-in reverse both;
}

.sheet.wide.enter .engine-tile {
  animation: tile-drop .38s cubic-bezier(.2, .8, .2, 1) .18s both;
}

.sheet.wide.enter .engine-tile:nth-child(2) {
  animation-delay: .23s;
}

.sheet.wide.enter .engine-tile:nth-child(3) {
  animation-delay: .28s;
}

.sheet.wide.enter .engine-tile:nth-child(4) {
  animation-delay: .33s;
}

.sheet.wide.enter .engine-tile:nth-child(5) {
  animation-delay: .38s;
}

.sheet.wide.enter .engine-tile:nth-child(6) {
  animation-delay: .43s;
}

.sheet.wide.enter .engine-tile:nth-child(7) {
  animation-delay: .48s;
}

.sheet.wide.enter .engine-tile:nth-child(8) {
  animation-delay: .53s;
}

.sheet.wide.enter .engine-tile:nth-child(9) {
  animation-delay: .58s;
}

.sheet.wide.enter .engine-tile:nth-child(10) {
  animation-delay: .63s;
}

.sheet.wide.enter .engine-tile:nth-child(11) {
  animation-delay: .68s;
}

.sheet.wide.enter .engine-tile:nth-child(12) {
  animation-delay: .73s;
}

@keyframes tile-drop {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  .bar {
    padding: 10px 14px;
  }

  .logo .word {
    font-size: 17px;
    letter-spacing: 4px;
  }

  .lang-btn {
    width: 44px;
    height: 44px;
    font-size: 13px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .engine-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 8px;
    padding: 0 12px;
  }

  .engine-tile {
    min-height: 84px;
    padding: 10px 12px;
  }

  .engine-tile .name {
    font-size: 18px;
  }

  .engine-tile .desc {
    display: none;
  }

  .start-btn {
    width: 280px;
    height: 80px;
  }

  .gas,
  .stop-btn {
    width: 300px;
  }

  .toast {
    width: 340px;
    margin-left: -170px;
  }

  .toast-inner {
    padding: 12px 14px;
  }

  .toast strong {
    font-size: 17px;
  }

  .sheet {
    left: 12px;
    right: 12px;
    width: auto;
    top: 64px;
  }

  .sheet.wide {
    left: 12px;
    right: 12px;
    top: 50%;
    width: auto;
    max-width: none;
    transform: translateY(-50%);
    --tx: 0;
  }

  .intro-word {
    font-size: 20px;
    letter-spacing: 7px;
    padding-left: 7px;
    animation-name: intro-word-sm;
  }

  .logo .word {
    font-size: 15px;
    letter-spacing: 3px;
  }

  .logo .mark {
    width: 28px;
    height: 28px;
    margin-right: 8px;
  }

  .engine-tile .cars {
    font-size: 11px;
  }
}

/* Until app.js has put the loading screen up, show nothing (the top bar's left-aligned name flashed first) */
html.booting .bar,
html.booting #cluster,
html.booting .dock {
  visibility: hidden;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Safe areas (viewport-fit=cover): the notch on top/sides, the home bar at the bottom */
.bar {
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}

.dock {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 760px) {
  .bar {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }

  /* Engine dialog as a one-column list with the descriptions back */
  .sheet.wide {
    max-height: calc(100% - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .sheet.wide .engine-grid {
    grid-template-columns: 1fr;
    grid-gap: 8px;
  }

  .sheet.wide .engine-tile {
    min-height: 0;
    padding: 12px 14px;
  }

  .sheet.wide .engine-tile .desc {
    display: block;
    font-size: 13px;
  }

  .sheet.wide .engine-tile .cars {
    font-size: 12px;
  }

  .cluster {
    padding-left: 12px;
    padding-right: 12px;
  }

  .gas,
  .stop-btn {
    width: calc(100% - 32px);
    max-width: 360px;
  }

  .toast {
    width: auto;
    left: 16px;
    right: 16px;
    margin: 0 0 4px;
  }

  .toast span {
    font-size: 14px;
  }
}

/* A short, wide screen like the car's (its browser is shorter than the screen) */
@media (min-width: 761px) and (max-height: 760px) {
  .engine-grid {
    grid-gap: 10px;
  }

  .engine-tile {
    min-height: 0;
    padding: 10px 16px;
  }

  .engine-tile .name {
    font-size: 21px;
  }

  .engine-tile .desc {
    font-size: 13px;
    line-height: 1.25;
  }

  .engine-tile .cars {
    font-size: 12px;
    margin-top: 3px;
  }
}

/* A phone held sideways: short and wide, like a small car screen */
@media (max-height: 500px) {
  .bar {
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
  }

  .lang-btn,
  .icon-btn {
    width: 44px;
    height: 44px;
  }

  /* Stop and hold-to-rev side by side so the dials keep their height */
  .dock {
    flex-direction: row;
    justify-content: center;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .stop-btn,
  .gas {
    width: 220px;
    height: 52px;
    margin: 0 6px;
  }

  .toast {
    width: 460px;
    left: 50%;
    right: auto;
    margin: 0 0 6px -230px;
  }

  .toast-inner {
    padding: 10px 16px;
  }

  .toast span {
    display: none;
  }

  /* title only, so it covers less of the dials */
  .cluster {
    padding-top: 0;
  }

  .sheet {
    top: 8px;
    max-height: calc(100% - 16px);
  }

  .sheet.wide .engine-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Narrow phones (iPhone mini/SE to standard): the name wrapped in Safari */
@media (max-width: 400px) {
  .logo .word {
    font-size: 14px;
    letter-spacing: 2px;
  }

  .logo .mark {
    width: 26px;
    height: 26px;
    margin-right: 7px;
  }

  .lang-btn {
    margin-left: 2px;
  }

  /* keep the 44 px touch size, tighten the gaps instead */
  .icon-btn {
    margin-left: 6px;
  }
}

/* Radio Stations Sheet & Grid */
.radio-sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
  flex-wrap: wrap;
}

.radio-sheet-top .seg-group {
  margin: 0;
  flex: 1 1 auto;
  min-width: 240px;
}

.radio-sheet-ctrl {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-wrap input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  position: relative;
  transition: all .25s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--dim);
  transition: all .2s;
}

.toggle-wrap input:checked+.toggle-slider {
  border-color: var(--accent);
  background: var(--panel-2);
  box-shadow: 0 0 10px var(--accent-faint);
}

.toggle-wrap input:checked+.toggle-slider::after {
  left: 18px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}

.toggle-text {
  font-size: 13px;
  color: var(--steel);
  white-space: nowrap;
}

.vol-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.vol-wrap input[type=range] {
  width: 90px;
  accent-color: var(--accent);
  cursor: pointer;
}

.stations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 6px 0 4px;
  max-height: 52vh;
  overflow-y: auto;
}

.station-card {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--steel);
  text-align: left;
  cursor: pointer;
  transition: all .25s;
}

.station-card:hover {
  border-color: var(--neon);
  box-shadow: 0 0 12px var(--neon-faint);
  color: var(--text-hi);
  transform: translateY(-2px);
}

.station-card.active {
  border-color: var(--accent);
  background-color: var(--panel-2);
  color: var(--text-hi);
  box-shadow: 0 0 16px var(--accent-soft), inset 0 0 16px var(--accent-faint);
}

.station-card span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.station-card b {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-card small {
  font-size: 11px;
  min-height: 15px;
  color: var(--dim);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-card.active small {
  color: #3dffa8;
}

@media (max-width: 760px) {
  #radioSheet {
    padding: 14px 16px 18px;
    max-height: 85vh;
  }

  .radio-sheet-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 8px 0;
  }

  .radio-sheet-top .seg-group {
    width: 100%;
    margin: 0;
  }

  .radio-sheet-ctrl {
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .stations-grid {
    grid-template-columns: 1fr;
    max-height: 48vh;
    gap: 8px;
  }
}

/* Too slow for the effects (fx.js measures; ?lite forces it): no background motion */
html.fx-lite .scene * {
  animation: none !important;
}