/* Sizes are in rem, and rem follows the short side of the screen, so the
   same screen fits 1920x1080 landscape and 1080x1920 portrait. */
:root {
  --bg: #05070a; --card: #0f131a; --line: #222b37; --text: #eef3f8; --muted: #8391a1;
  --ice: #2f95ff; --ice-d: #154a85; --amber: #ffc233; --green: #5fdc8a; --red: #ff4545;
  --accent: var(--ice);
}
body.sport { --accent: var(--amber); }
body.eco { --accent: var(--green); }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 1.62vmin; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Helvetica Neue", Roboto, "Noto Sans", sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- The screen: dot field + speed ---------- */
#dots { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: block; }
#hud { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.hud-in { text-align: center; }
body:not(.running) .hud-in { visibility: hidden; }
.gear { font-size: 2.6rem; font-weight: 700; color: var(--accent); letter-spacing: .08em; height: 3.2rem; }
.gear.hot { color: var(--red); }
.speed { font-size: 14rem; line-height: 1; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.unit { font-size: 2.1rem; color: #c5ced8; letter-spacing: .06em; margin-top: .2rem; }
.meta { font-size: 1.35rem; color: var(--muted); letter-spacing: .1em; margin-top: 1.1rem; font-variant-numeric: tabular-nums; }
.meta i { display: inline-block; width: .35rem; height: .35rem; border-radius: 50%; background: var(--muted); margin: 0 .9rem; vertical-align: middle; }

/* ---------- Demo layer ---------- */
body.car .chrome, body.car .pedals, body.car .holdbar, body.car .start, body.car .demo-only { display: none !important; }
body:not(.car) .car-only { display: none; }
.demo-only, .car-only { flex: none; }
.info { font-size: 1.15rem; color: var(--muted); line-height: 1.4; margin-top: .7rem; }

.chrome { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 1.6rem 2.2rem; }
.brand { font-size: 1.4rem; letter-spacing: .34em; color: var(--muted); display: flex; align-items: center; }
.brand b { color: var(--text); font-weight: 700; margin-left: .5em; }
.mark { width: 2.4rem; height: .35rem; border-radius: 1rem; background: var(--accent); margin-right: 1.1rem; box-shadow: 0 0 1rem var(--accent); }
.chip { font-size: 1.05rem; letter-spacing: .16em; color: var(--muted); border: 1px solid var(--line); border-radius: 10rem; padding: .45rem 1.1rem; margin-left: 1.6rem; background: rgba(5, 7, 10, .6); }
.top-right { display: flex; align-items: center; }
.tbtn { height: 4.2rem; min-width: 4.2rem; border-radius: 10rem; border: 1px solid var(--line); background: rgba(12, 16, 22, .82); color: var(--muted);
  display: flex; align-items: center; justify-content: center; margin-left: 1rem; }
.tbtn svg { width: 2.1rem; height: 2.1rem; }
.modeseg { display: flex; height: 4.2rem; border-radius: 10rem; border: 1px solid var(--line); background: rgba(12, 16, 22, .82); padding: .35rem; }
.modeseg button { padding: 0 1.4rem; border-radius: 10rem; font-size: 1.15rem; font-weight: 700; letter-spacing: .2em; color: var(--muted); }
.modeseg button.active { background: var(--accent); color: #06080b; }
.running #power { color: var(--accent); }

.start { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.running .start { display: none; }
.start button { pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 21rem; height: 21rem; border-radius: 50%;
  border: 2px solid var(--accent); color: var(--accent); background: rgba(8, 12, 17, .9); box-shadow: 0 0 4rem rgba(143, 200, 238, .25); }
.start svg { width: 5.6rem; height: 5.6rem; margin-bottom: 1.3rem; }
.start span { font-size: 1.4rem; letter-spacing: .28em; font-weight: 600; }
.start button:active { transform: scale(.97); }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 1.4rem; padding: .4rem; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; margin-top: 1rem; }
.seg button { font-size: 1.5rem; padding: 1.05rem .6rem; border-radius: 1.05rem; color: var(--muted); }
.seg button.active { background: #1e2a39; color: var(--text); font-weight: 600; }
.seg [data-mode].active { background: var(--accent); color: #06080b; }

.pedals { position: fixed; left: 50%; bottom: 1.8rem; transform: translateX(-50%); width: 46rem; max-width: calc(100% - 3rem); height: 8.4rem;
  display: grid; grid-template-columns: 7rem 1fr 1.5fr; grid-gap: .9rem; }
body.live .pedals, body.live .holdbar { display: none; }
.holdbar { position: fixed; left: 50%; bottom: 11.1rem; transform: translateX(-50%); width: 46rem; max-width: calc(100% - 3rem); height: 4.2rem;
  display: flex; align-items: center; border-radius: 10rem; border: 1px solid var(--line); background: rgba(12, 16, 22, .86); padding: .35rem; }
.holdlabel { font-size: 1.05rem; font-weight: 700; letter-spacing: .22em; color: var(--muted); padding: 0 1.2rem 0 1rem; }
.holdbar button { flex: 1; height: 100%; border-radius: 10rem; font-size: 1.4rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.holdbar button[data-hold="off"] { font-size: 1.05rem; letter-spacing: .14em; }
.holdbar button.active { background: var(--accent); color: #06080b; }
.seg.mode { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; background: rgba(12, 16, 22, .86); }
.seg.mode button { font-size: 1.6rem; font-weight: 700; padding: 0; }
.pedal { border-radius: 1.4rem; border: 1px solid var(--line); background: rgba(12, 16, 22, .86); font-size: 1.6rem; font-weight: 700; letter-spacing: .2em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
.pedal small { font-size: 1rem; font-weight: 500; letter-spacing: .12em; color: var(--muted); margin-top: .4rem; }
.pedal.gas { color: var(--accent); }
.pedal.gas.down { background: var(--accent); color: var(--bg); }
.pedal.gas.down small { color: var(--bg); }
.pedal.brake.down { background: #3a1216; border-color: var(--red); color: var(--red); }

/* ---------- Settings drawer (lean) ---------- */
.scrim { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .35); visibility: hidden; opacity: 0; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 33rem; max-width: 100%; background: #080b10; border-left: 1px solid var(--line);
  padding: 1.2rem 1.6rem 1.6rem; display: flex; flex-direction: column; visibility: hidden; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; flex: none; margin-bottom: .6rem; }
.drawer h2 { font-size: 1.1rem; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.drawer-head .tbtn { height: 3.2rem; min-width: 3.2rem; border: 0; background: none; margin: 0 -.6rem 0 0; }
.drawer-head .tbtn svg { width: 1.7rem; height: 1.7rem; }
.drawer > .row, .drawer > .seg, .demo-only, .car-only { flex: none; margin-top: .8rem; }

.engines { flex: 1 1 auto; min-height: 12rem; overflow-y: auto; margin: 0 -.6rem; padding-right: .2rem; -webkit-overflow-scrolling: touch; }
.engines::-webkit-scrollbar { width: .3rem; }
.engines::-webkit-scrollbar-thumb { background: #263140; border-radius: 1rem; }
.engine { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; padding: 0 .9rem; height: 3.7rem; border-radius: .9rem; }
.engine b { font-size: 1.45rem; font-weight: 500; color: #c3ccd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.engine .cyl { font-size: 1.1rem; color: var(--muted); letter-spacing: .06em; flex: none; margin-left: 1rem; font-variant-numeric: tabular-nums; }
.engine.active { background: #141d28; }
.engine.active b { color: var(--text); font-weight: 600; }
.engine.active .cyl { color: var(--accent); }

.row { display: flex; align-items: center; }
.ico { width: 2rem; height: 2rem; color: var(--muted); flex: none; margin-right: 1rem; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 3rem; background: transparent; margin-right: 1.2rem; }
input[type=range]::-webkit-slider-runnable-track { height: .35rem; border-radius: 1rem; background: #263140; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); margin-top: -.83rem; }
.pill { font-size: 1.2rem; padding: .6rem 1.2rem; border-radius: 10rem; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.active { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.drawer .seg { border-radius: 1rem; padding: .3rem; }
.drawer .seg.three { margin-top: .8rem; }
.drawer .seg button { font-size: 1.25rem; padding: .7rem .4rem; border-radius: .75rem; }

@media (orientation: portrait) {
  html { font-size: 1.72vmin; }
  .speed { font-size: 15rem; }
  .pedals { bottom: 2.4rem; height: 9.5rem; }
  .holdbar { bottom: 12.9rem; height: 4.6rem; }
  .engines { display: grid; grid-template-columns: 1fr 1fr; grid-column-gap: 1rem; align-content: start; }
  .drawer { top: auto; left: 0; width: 100%; height: 56%; border-left: 0; border-top: 1px solid var(--line); border-radius: 2.4rem 2.4rem 0 0; }
}
/* Small or short windows (e.g. a narrow preview pane): let the drawer scroll as a whole. */
@media (max-height: 520px), (max-width: 520px) {
  .drawer { overflow-y: auto; display: block; }
  .engines { max-height: 20rem; }
}
