/* K-Tunes Remap Simulator — styles
   One visual world: a dark dyno cell with a single orange accent. */
:root {
  /* layout idea: instrument cluster on the left, ECU workbench on the right; one column on phones */
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #131315;
  --panel-2: #1a1a1d;
  --line: #29292d;
  --line-2: #3a3a40;
  --ink: #f3f0ea;
  --ink-2: #aaa59c;
  --ink-3: #6d6961;
  --accent: #F25C19;
  --accent-ink: #160903;
  --good: #3fc380;
  --warn: #f3b33d;
  --crit: #ff4433;
  --c-driver: #6aa7d8;
  --c-torque: #cfc9be;
  --c-smoke: #9a86e0;
  --c-prot: #ff4433;
  --font-body: "Saira", "Segoe UI", system-ui, sans-serif;
  --font-label: "Saira Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-display: "Saira Extra Condensed", "Saira Condensed", "Arial Narrow", sans-serif;
  --bar-h: 60px;
  --r: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--font-body);
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.wordmark {
  display: inline-flex; align-items: center; gap: 5px;
  font: italic 800 26px/1 var(--font-display); letter-spacing: 0.02em;
}
.wm-k { color: var(--accent-ink); background: var(--accent); padding: 2px 7px 2px 5px; transform: skewX(-10deg); display: inline-block; }
.wm-k { font-style: normal; }
.wm-slash { width: 3px; height: 22px; background: var(--accent); transform: skewX(-14deg); }
.wm-t { color: var(--ink); letter-spacing: 0.06em; }
.brand-sub { font: 600 11px/1 var(--font-label); letter-spacing: 0.22em; color: var(--ink-3); white-space: nowrap; }
.sim-flag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 600 11px/1 var(--font-label); letter-spacing: 0.14em; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: 99px; padding: 6px 10px;
}
.sim-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- layout ---------- */
.layout { display: block; padding: 12px 16px 16px; max-width: 1320px; margin: 0 auto; }
.col { display: none; flex-direction: column; gap: 10px; min-width: 0; }
body[data-view="dyno"] #view-dyno,
body[data-view="maps"] #view-maps,
body[data-view="challenge"] #view-challenge { display: flex; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; min-height: 22px; }
.panel h2 { font: 600 13px/1 var(--font-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.h-note { color: var(--ink-3); letter-spacing: 0.08em; margin-left: 6px; text-transform: none; font-weight: 500; }

/* ---------- scene ---------- */
.scene-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #0d0d0f; }
#scene { display: block; width: 100%; height: 142px; }
.scene-top { position: absolute; inset: 8px 10px auto 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.engine-tag { display: flex; flex-direction: column; gap: 3px; font: 600 12px/1 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; }
.engine-tag span { color: var(--ink-3); font-size: 10px; letter-spacing: 0.16em; }
.lamps { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 62%; }
.lamp {
  font: 700 10px/1 var(--font-label); letter-spacing: 0.12em;
  padding: 4px 6px; border-radius: 4px; border: 1px solid var(--line);
  color: #45423d; background: rgba(0,0,0,.35);
  transition: color .15s, background .15s, border-color .15s, box-shadow .15s;
}
.lamp.warn { color: #1a1204; background: var(--warn); border-color: var(--warn); box-shadow: 0 0 14px rgba(243,179,61,.5); }
.lamp.kill { color: #fff; background: var(--crit); border-color: var(--crit); box-shadow: 0 0 16px rgba(255,68,51,.65); animation: blink .45s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.banner {
  position: absolute; left: 10px; right: 10px; bottom: 8px;
  font: 700 15px/1.1 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; text-align: center;
  padding: 7px 10px; border-radius: 6px;
  animation: pop .25s ease-out;
}
.banner.warn { background: var(--warn); color: #1a1204; }
.banner.kill { background: var(--crit); color: #fff; }
.banner.good { background: var(--good); color: #05190d; }
.banner.info { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }

/* ---------- gauges ---------- */
.gauges { display: block; width: 100%; height: 104px; }

/* ---------- fuel chain ---------- */
.chain-at { font: 500 12px/1 var(--font-label); letter-spacing: 0.06em; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chain-rows { display: grid; gap: 4px; }
.chain-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px; font: 500 13px/1 var(--font-label); letter-spacing: 0.06em; color: var(--ink-2); }
.chain-row .track { height: 14px; background: var(--panel-2); border-radius: 3px; position: relative; overflow: hidden; }
.chain-row .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--line-2); border-radius: 3px; }
.chain-row b { font: 700 16px/1 var(--font-display); letter-spacing: 0.03em; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chain-row.low { color: var(--ink); }
.chain-row.low .fill { background: var(--accent); }
.chain-row.low b { color: var(--accent); }
.chain-row.low .track::after { content: "LOWEST"; position: absolute; right: 6px; top: 0; font: 700 9px/14px var(--font-label); letter-spacing: 0.14em; color: var(--accent); }
.chain-row.off b { color: var(--ink-3); }
.mini { display: grid; grid-template-columns: 4fr 6fr; gap: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.mini-item { white-space: nowrap; display: grid; grid-template-columns: auto minmax(20px, 1fr) auto; align-items: center; gap: 8px; font: 600 10px/1 var(--font-label); letter-spacing: 0.12em; color: var(--ink-3); }
.mini-item b { font: 700 15px/1 var(--font-display); color: var(--ink); letter-spacing: 0.03em; min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--panel-2); border-radius: 3px; position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ink-2); border-radius: 3px; }
.meter em { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); }
.meter i.warn { background: var(--warn); } .meter i.kill { background: var(--crit); }

/* ---------- graph ---------- */
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px; font: 500 12px/1 var(--font-label); letter-spacing: 0.05em; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sw { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.sw-power { border-color: var(--accent); } .sw-torque { border-color: var(--ink); }
.sw-stock { border-color: var(--ink-3); border-top-style: dashed; }
.graph-box { position: relative; }
#graph { display: block; width: 100%; height: 184px; touch-action: pan-y; cursor: crosshair; }
.tip {
  position: absolute; top: 6px; pointer-events: none; z-index: 2;
  background: #050506ee; border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 9px;
  font: 500 12px/1.5 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); white-space: nowrap;
}
.tip b { color: var(--ink); font-weight: 700; }
.tip .t-rpm { font: 700 14px/1.2 var(--font-display); color: var(--ink); letter-spacing: 0.05em; }
.strip-row, .pedal-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.strip-label { font: 600 10px/1 var(--font-label); letter-spacing: 0.14em; color: var(--ink-3); width: 64px; flex: none; }
.strip { flex: 1; display: flex; gap: 2px; height: 22px; min-width: 0; }
.strip button {
  border: 0; padding: 0 4px; min-width: 0; border-radius: 3px; overflow: hidden;
  font: 700 10px/22px var(--font-label); letter-spacing: 0.08em; color: #0d0d0f; white-space: nowrap; text-overflow: clip;
}
.strip .driverWish { background: var(--c-driver); } .strip .torqueLimiter { background: var(--c-torque); }
.strip .smokeLimiter { background: var(--c-smoke); } .strip .protection { background: var(--c-prot); color: #fff; }
.strip .empty { flex: 1; background: var(--panel-2); color: var(--ink-3); font-weight: 500; text-align: left; padding-left: 8px; }
.scrub-note { font: 500 11px/1.2 var(--font-label); letter-spacing: 0.04em; color: var(--ink-3); margin-left: auto; text-align: right; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; flex: none; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 5px; font: 600 12px/1 var(--font-label); letter-spacing: 0.08em; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: #0d0d0f; }

/* ---------- results ---------- */
.results { border-color: var(--line-2); animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.res-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rating { display: inline-flex; align-items: center; gap: 8px; font: 700 18px/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; padding: 7px 12px; border-radius: 6px; }
.rating i { width: 10px; height: 10px; display: inline-block; }
.rating.safe { background: rgba(63,195,128,.14); color: var(--good); } .rating.safe i { background: var(--good); border-radius: 50%; }
.rating.risky { background: rgba(243,179,61,.14); color: var(--warn); } .rating.risky i { background: var(--warn); transform: rotate(45deg); }
.rating.killer { background: var(--crit); color: #fff; } .rating.killer i { background: #fff; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.res-pedal { font: 500 12px/1 var(--font-label); letter-spacing: 0.08em; color: var(--ink-3); }
.figs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fig { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.fig .k { font: 600 10px/1 var(--font-label); letter-spacing: 0.16em; color: var(--ink-3); }
.fig .v { font: 700 40px/1 var(--font-display); letter-spacing: 0.01em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.fig .v small { font: 600 14px/1 var(--font-label); color: var(--ink-2); margin-left: 4px; letter-spacing: 0.06em; }
.fig .d { font: 600 13px/1.2 var(--font-label); letter-spacing: 0.05em; margin-top: 6px; color: var(--ink-2); }
.fig .d.up { color: var(--good); } .fig .d.down { color: var(--crit); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.fact { font: 600 10px/1 var(--font-label); letter-spacing: 0.12em; color: var(--ink-3); }
.fact b { display: block; font: 700 18px/1 var(--font-display); color: var(--ink); margin-top: 5px; letter-spacing: 0.03em; }
.fact b.warn { color: var(--warn); } .fact b.kill { color: var(--crit); }
.issues { display: grid; gap: 8px; margin-top: 12px; }
.issue { border-left: 3px solid var(--warn); background: var(--panel-2); border-radius: 0 8px 8px 0; padding: 10px 12px; }
.issue.kill { border-left-color: var(--crit); }
.issue.hint { border-left-color: var(--ink-3); }
.issue h3 { font: 700 15px/1.2 var(--font-label); letter-spacing: 0.06em; text-transform: uppercase; }
.issue p { color: var(--ink-2); font-size: 14px; margin-top: 4px; max-width: 65ch; }
.issue .fix { color: var(--ink); }
.issue button, .steps button {
  margin-top: 8px; border: 1px solid var(--line-2); background: none; border-radius: 6px; padding: 6px 10px;
  font: 600 12px/1 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink);
}
.issue button:hover, .steps button:hover, .ghost:hover { border-color: var(--accent); color: var(--accent); }
.res-score { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 8px; }
.res-score .num { font: 700 34px/1 var(--font-display); color: var(--accent); }
.res-score .num small { font: 600 13px/1 var(--font-label); color: var(--ink-3); }
.res-score p { font-size: 14px; color: var(--ink-2); }
.res-score p b { color: var(--ink); font: 600 12px/1 var(--font-label); letter-spacing: 0.12em; display: block; margin-bottom: 4px; }

/* ---------- editor ---------- */
.ghost { border: 1px solid var(--line-2); background: none; border-radius: 6px; padding: 6px 10px; font: 600 11px/1 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.map-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.map-tab {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 7px; padding: 8px 8px 7px; text-align: left; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.map-tab .n { font: 700 10px/1 var(--font-label); letter-spacing: 0.14em; color: var(--ink-3); display: flex; justify-content: space-between; }
.map-tab .n i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: none; }
.map-tab.changed .n i { display: block; }
.map-tab .t { font: 600 14px/1.05 var(--font-label); letter-spacing: 0.03em; color: var(--ink-2); }
.map-tab.on { border-color: var(--accent); background: rgba(242,92,25,.1); }
.map-tab.on .t { color: var(--ink); } .map-tab.on .n { color: var(--accent); }
.explain { margin: 12px 0 10px; font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.explain b { color: var(--ink); font-weight: 500; }
.explain details { margin-top: 4px; }
.explain summary { cursor: pointer; font: 600 11px/1.6 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); list-style: none; }
.explain summary::-webkit-details-marker { display: none; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ed-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ed-title b { font: 700 20px/1 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; }
.ed-title span { font: 500 12px/1 var(--font-label); letter-spacing: 0.06em; color: var(--ink-3); }

.grid-wrap { position: relative; }
.grid { display: grid; gap: 2px; touch-action: none; user-select: none; -webkit-user-select: none; font-variant-numeric: tabular-nums; }
.grid .hd {
  font: 600 11px/1 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); background: none; border: 0; padding: 0;
  display: flex; align-items: center; justify-content: center; min-height: 24px; border-radius: 3px;
}
.grid .hd.corner { color: var(--ink-3); font-size: 9px; letter-spacing: 0.08em; flex-direction: column; gap: 1px; }
.grid .hd:hover { color: var(--accent); }
.cell {
  position: relative; border: 0; padding: 0; min-width: 0; height: 34px; border-radius: 3px;
  font: 600 14px/34px var(--font-label); letter-spacing: 0.01em; text-align: center; color: var(--ink);
}
.cell.dark { color: #140a04; }
.cell.sel { outline: 2px solid #fff; outline-offset: -2px; z-index: 1; }
.cell.chg::after { content: ""; position: absolute; top: 0; right: 0; border: 4px solid transparent; border-top-color: #fff; border-right-color: #fff; border-top-right-radius: 3px; }
.cell.risk { box-shadow: inset 0 -4px 0 #ff2414, inset 0 -6px 0 rgba(0,0,0,.8); }
.cell.risk.sel { box-shadow: inset 0 -6px 0 #ff2414, inset 0 -8px 0 rgba(0,0,0,.8); }
.cell.used::before { content: ""; position: absolute; left: 3px; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .85; }
#surface { display: block; width: 100%; height: 300px; touch-action: none; cursor: grab; }
.single { display: grid; gap: 14px; padding: 6px 0 2px; }
.single .big { font: 700 64px/1 var(--font-display); letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.single .big small { font: 600 16px/1 var(--font-label); color: var(--ink-2); margin-left: 6px; letter-spacing: 0.06em; }
.single .eq { font: 500 13px/1.3 var(--font-label); color: var(--ink-2); letter-spacing: 0.04em; }
.scale { position: relative; height: 34px; }
.scale .rail { position: absolute; left: 0; right: 0; top: 12px; height: 10px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.scale .rail i { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, rgba(255,68,51,.55) 0 5px, rgba(255,68,51,.2) 5px 10px); }
.scale .mk { position: absolute; top: 6px; width: 2px; height: 22px; background: var(--ink-2); }
.scale .mk span { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font: 600 10px/1 var(--font-label); letter-spacing: 0.08em; color: var(--ink-3); white-space: nowrap; }
.scale .mk.you { background: var(--accent); width: 4px; margin-left: -2px; top: 2px; height: 30px; border-radius: 2px; }
.scale .mk.you span { top: -12px; color: var(--accent); }
.scale .mk.peak { background: var(--ink); }
.scale .mk.peak span { color: var(--ink); }
.scale-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font: 500 12px/1.2 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); }
.scale-key span { display: inline-flex; align-items: center; gap: 6px; }
.scale-key i { width: 4px; height: 12px; border-radius: 1px; background: var(--ink-2); }
.scale-key .k-you { background: var(--accent); } .scale-key .k-peak { background: var(--ink); }
.scale-key .k-danger { width: 12px; background: repeating-linear-gradient(135deg, rgba(255,68,51,.7) 0 3px, rgba(255,68,51,.25) 3px 6px); }
.grid-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font: 500 11px/1.3 var(--font-label); letter-spacing: 0.04em; color: var(--ink-3); }
.grid-key span { display: inline-flex; align-items: center; gap: 5px; }
.grid-key .k-chg { width: 9px; height: 9px; background: linear-gradient(225deg, #fff 50%, var(--panel-2) 50%); border-radius: 2px; }
.grid-key .k-used { width: 9px; height: 9px; background: var(--panel-2); border-radius: 2px; position: relative; }
.grid-key .k-used::after { content: ""; position: absolute; left: 2px; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
.grid-key .ramp { width: 60px; height: 8px; border-radius: 2px; }
.grid-key .k-risk { width: 9px; height: 9px; background: var(--panel-2); border-radius: 2px; box-shadow: inset 0 -3px 0 #ff2414; }

/* "how much?" meter + guide */
.hm { margin-top: 10px; padding: 9px 10px 7px; background: var(--panel-2); border-radius: 8px; }
.hm-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.hm-k { font: 600 10px/1 var(--font-label); letter-spacing: 0.14em; color: var(--ink-3); }
.hm-top b { font: 700 20px/1 var(--font-display); letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.hm-s { font: 600 12px/1 var(--font-label); letter-spacing: 0.05em; color: var(--ink-2); margin-left: auto; }
.hm-s.good { color: var(--good); } .hm-s.push { color: var(--warn); } .hm-s.over { color: var(--crit); }
.hm-track { position: relative; height: 8px; margin-top: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.hm-track i { position: absolute; top: 0; bottom: 0; }
.hm-good { background: rgba(63,195,128,.55); }
.hm-bad { right: 0; background: repeating-linear-gradient(135deg, rgba(255,68,51,.7) 0 4px, rgba(255,68,51,.25) 4px 8px); }
.hm-track em { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 0 2px var(--bg); }
.hm-ticks { position: relative; height: 16px; margin-top: 3px; font: 500 10px/16px var(--font-label); letter-spacing: 0.06em; color: var(--ink-3); }
.hm-ticks span { position: absolute; top: 0; white-space: nowrap; }
.hm-ticks .mid { transform: translateX(-50%); color: var(--ink-2); }
.hm-ticks .end { display: none; }
.guide { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.guide-head b { font: 700 12px/1 var(--font-label); letter-spacing: 0.16em; color: var(--accent); }
.guide p { font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.switch { display: inline-flex; align-items: center; gap: 7px; font: 600 11px/1 var(--font-label); letter-spacing: 0.08em; color: var(--ink-2); cursor: pointer; text-transform: uppercase; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 28px; height: 16px; border-radius: 8px; background: var(--line-2); position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(12px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.risk-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--ink); }
.risk-list li { display: grid; grid-template-columns: 10px 1fr; gap: 8px; align-items: baseline; }
.risk-list i { width: 10px; height: 10px; background: var(--panel-2); box-shadow: inset 0 -3px 0 var(--crit); border-radius: 2px; transform: translateY(1px); }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tool-group { display: inline-flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.tool-group button { border: 0; background: none; min-width: 44px; height: 40px; padding: 0 12px; border-radius: 6px; font: 600 14px/1 var(--font-label); letter-spacing: 0.06em; color: var(--ink); }
.tool-group button:hover { background: var(--line); }
.tool-group button:active { background: var(--accent); color: var(--accent-ink); }
.tool-group button:disabled { color: var(--ink-3); background: none; cursor: default; }
.tool-group button[data-act="dec"], .tool-group button[data-act="inc"] { font: 700 22px/1 var(--font-label); min-width: 52px; }
.pct { display: inline-flex; align-items: center; gap: 2px; padding: 0 4px; font: 600 13px/1 var(--font-label); color: var(--ink-2); }
.pct input { width: 34px; height: 30px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; text-align: center; font: 600 14px/1 var(--font-label); -moz-appearance: textfield; appearance: textfield; }
.pct input::-webkit-outer-spin-button, .pct input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sel-note { margin-top: 10px; font: 500 12px/1.4 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); min-height: 17px; }
.fiction { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); max-width: 65ch; }

/* ---------- challenge ---------- */
.eyebrow { font: 700 11px/1 var(--font-label); letter-spacing: 0.22em; color: var(--accent); }
.ch-title { font: 700 34px/1 var(--font-display) !important; letter-spacing: 0.03em !important; margin-top: 8px; text-wrap: balance; white-space: normal !important; }
.ch-lead { margin-top: 8px; color: var(--ink-2); max-width: 60ch; }
.ch-lead b { color: var(--ink); font-weight: 500; }
.score-row { display: flex; gap: 14px; align-items: center; margin-top: 14px; padding: 12px; background: var(--panel-2); border-radius: 8px; }
.score { font: 700 56px/1 var(--font-display); color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.score span { font: 600 14px/1 var(--font-label); color: var(--ink-3); letter-spacing: 0.06em; margin-left: 2px; }
.coach { font-size: 14px; color: var(--ink); max-width: 52ch; }
.best { margin-top: 6px; font: 600 11px/1 var(--font-label); letter-spacing: 0.12em; color: var(--ink-3); text-transform: uppercase; }
.goals { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.goals li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; font: 600 13px/1.15 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); }
.goals li i { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); position: relative; }
.goals li.ok { color: var(--ink); border-color: rgba(63,195,128,.5); }
.goals li.ok i { background: var(--good); border-color: var(--good); }
.goals li.ok i::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #05190d; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.goals li.no { border-color: rgba(255,68,51,.45); }
.goals li.no i { border-color: var(--crit); }
.goals li.no i::after { content: ""; position: absolute; left: 2px; right: 2px; top: 5px; height: 2px; background: var(--crit); }
.goals li small { display: block; font-weight: 500; color: var(--ink-3); margin-top: 2px; }
.steps-h { margin-top: 16px; font: 600 12px/1 var(--font-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.steps { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 6px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 4px 8px; padding: 10px; background: var(--panel-2); border-radius: 8px; }
.steps li::before { content: counter(s); font: 700 24px/1 var(--font-display); color: var(--accent); }
.steps h4 { margin: 0; font: 600 15px/1.2 var(--font-label); letter-spacing: 0.04em; }
.steps p { grid-column: 2; font-size: 14px; color: var(--ink-2); max-width: 60ch; }
.steps button { grid-column: 2; justify-self: start; margin-top: 4px; }

/* ---------- footer + bottom bar ---------- */
.legal { max-width: 1320px; margin: 0 auto; padding: 4px 16px 20px; font-size: 12px; color: var(--ink-3); }
.legal p { max-width: 80ch; }
.legal b { color: var(--ink-2); font-weight: 500; }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; align-items: stretch;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabs { display: flex; flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; min-width: 0; }
.tabs button { flex: 1; min-width: 0; border: 0; background: none; border-radius: 6px; font: 600 13px/1 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding: 0 4px; }
.tabs button.on { background: var(--ink); color: #0d0d0f; }
.run {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 132px; padding: 0 16px; border: 0; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font: 700 17px/1 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase;
  box-shadow: 0 0 0 0 rgba(242,92,25,.5); transition: transform .08s, box-shadow .3s;
}
.run:hover { box-shadow: 0 0 22px 0 rgba(242,92,25,.45); }
.run:active { transform: scale(.97); }
.run-ico { width: 0; height: 0; border: 7px solid transparent; border-left: 11px solid currentColor; border-right-width: 0; }
.run.running { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2); }
.run.running .run-ico { border: 0; width: 11px; height: 11px; background: currentColor; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 14px); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: #0d0d0f; border-radius: 8px; padding: 9px 14px; max-width: calc(100vw - 32px);
  font: 600 13px/1.3 var(--font-label); letter-spacing: 0.04em; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: rise .2s ease-out;
}

/* ---------- phone tweaks ---------- */
@media (max-width: 420px) {
  .brand-sub { display: none; }
  .sim-long { display: none; }
  .scrub-note { display: none; }

  .facts { grid-template-columns: repeat(2, 1fr); }
  .fig .v { font-size: 34px; }
  .cell { font-size: 13px; }
  .tool-group button { padding: 0 10px; }
  .h-note { display: none; }
  .tabs button { font-size: 12px; letter-spacing: 0.03em; }
  .run { min-width: 116px; padding: 0 12px; font-size: 16px; letter-spacing: 0.06em; }
  .panel { padding: 10px; }
  .layout { padding: 8px 12px 14px; }
  .col { gap: 8px; }
  .top { padding: 8px 12px; }
  .mini-item span { letter-spacing: 0.06em; }
}
@media (min-width: 700px) {
  #scene { height: 170px; }
  .gauges { height: 130px; }
  #graph { height: 240px; }
}

/* ---------- desktop: dyno left, workbench right ---------- */
@media (min-width: 1040px) {
  body { font-size: 15px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; padding-top: 16px; }
  #view-dyno { display: flex !important; }
  body[data-view="dyno"] #view-maps { display: flex; }
  .tab-dyno { display: none; }
  #scene { height: 210px; }
  .gauges { height: 150px; }
  #graph { height: 280px; }
  .cell { height: 40px; line-height: 40px; font-size: 15px; }
  #surface { height: 380px; }
  .top { min-height: 60px; }
  .bar { left: 50%; right: auto; top: 8px; bottom: auto; transform: translateX(-50%); width: 460px; height: 44px; padding: 0; border: 0; background: none; backdrop-filter: none; z-index: 31; }
  body { padding-bottom: 24px; }
  .toast { bottom: 24px; }
  body[data-view="dyno"] .tabs [data-view="maps"] { background: var(--ink); color: #0d0d0f; }
  .map-tabs { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ======================================================================
   JOBS
   ====================================================================== */
/* stars: a drawn star shape, so it looks the same on every phone */
.stars { display: inline-flex; gap: 3px; flex: none; }
.star { display: inline-block; width: 16px; height: 16px; background: var(--line-2);
  clip-path: polygon(50% 0, 61.8% 35.4%, 100% 35.4%, 69.1% 57.3%, 80.9% 92.7%, 50% 70.8%, 19.1% 92.7%, 30.9% 57.3%, 0 35.4%, 38.2% 35.4%); }
.star.on { background: var(--accent); }
.stars.sm .star { width: 13px; height: 13px; }
.star.big { width: 54px; height: 54px; }
.star.pop { animation: starpop .55s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes starpop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }

/* the job bar above the dyno */
.jobbar {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r);
  padding: 9px 12px; min-height: 48px;
}
.jobbar:hover { border-color: var(--line-2); border-left-color: var(--accent); }
.jb-k { flex: none; font: 700 11px/1.1 var(--font-label); letter-spacing: 0.14em; color: var(--accent); width: 54px; }
.jb-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font: 500 12px/1.25 var(--font-label); letter-spacing: 0.03em; color: var(--ink-2); }
.jb-t b { font: 700 16px/1.1 var(--font-label); letter-spacing: 0.04em; color: var(--ink); text-transform: uppercase; }
.jb-go { font: 600 11px/1 var(--font-label); letter-spacing: 0.12em; color: var(--accent); text-transform: uppercase; }

/* current job */
.job-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.customer { margin-top: 6px; font: 600 13px/1.3 var(--font-label); letter-spacing: 0.05em; color: var(--ink-2); }
.brief { margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid var(--line-2); background: var(--panel-2); border-radius: 0 8px 8px 0;
  font-size: 15px; color: var(--ink); max-width: 62ch; }
.lesson { margin-top: 10px; font-size: 14px; color: var(--ink-2); max-width: 62ch; }
.lesson b { display: block; font: 700 11px/1.4 var(--font-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.bonus { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.bonus li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font: 600 13px/1.2 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); }
.bonus li.ok { color: var(--ink); border-color: rgba(242,92,25,.45); }
.job-actions { display: flex; gap: 8px; margin-top: 14px; }

/* garage list */
.h-total { font: 600 12px/1 var(--font-label); letter-spacing: 0.08em; color: var(--ink-2); }
.chap { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
.chap:first-of-type { border-top: 0; margin-top: 0; padding-top: 2px; }
.chap-head { display: flex; align-items: center; gap: 10px; }
.chap-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chap-head b { font: 700 17px/1.1 var(--font-label); letter-spacing: 0.04em; text-transform: uppercase; }
.chap-head div span { font: 500 12px/1.25 var(--font-label); letter-spacing: 0.03em; color: var(--ink-3); }
.chap-n { flex: none; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2);
  font: 700 18px/1 var(--font-display); color: var(--ink-2); }
.badge { flex: none; font: 700 10px/1 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; padding: 5px 8px; border-radius: 99px; white-space: nowrap; }
.badge.free { background: rgba(242,92,25,.14); color: var(--accent); }
.badge.lock { border: 1px solid var(--line-2); color: var(--ink-2); }
.chap.locked .chap-head b { color: var(--ink-2); }
.chap.locked .chap-n { color: var(--ink-3); }
.chap-teaser { margin: 6px 0 0 40px; font-size: 13px; color: var(--ink-3); max-width: 60ch; }
.jrows { display: grid; gap: 5px; margin-top: 10px; }
.jrow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; min-height: 52px;
  background: var(--panel-2); border: 1px solid transparent; border-radius: 8px; }
.jrow:hover { border-color: var(--line-2); }
.jrow.cur { border-color: var(--accent); background: rgba(242,92,25,.08); }
.jrow.locked { opacity: .5; cursor: not-allowed; }
.jr-n { flex: none; width: 24px; font: 700 20px/1 var(--font-display); color: var(--accent); text-align: center; }
.jrow.locked .jr-n { color: var(--ink-3); }
.jr-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.jr-t b { font: 600 15px/1.15 var(--font-label); letter-spacing: 0.04em; }
.jr-t span { font: 500 12px/1.25 var(--font-label); letter-spacing: 0.02em; color: var(--ink-3); }
.lock-ico { flex: none; width: 12px; height: 9px; margin-top: 5px; border-radius: 2px; background: var(--ink-3); position: relative; }
.lock-ico::before { content: ""; position: absolute; left: 2px; top: -6px; width: 8px; height: 8px; border: 2px solid var(--ink-3); border-bottom: 0; border-radius: 5px 5px 0 0; box-sizing: border-box; }
.jrow.sandbox { margin-top: 12px; }
.jrow.sandbox .jr-n { color: var(--ink-2); }
.reset-prog { margin-top: 14px; }

/* score block stars on the results card */
.res-score .num { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.res-score.free { border-color: var(--line-2); }

/* job complete card */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(5,5,6,.78); backdrop-filter: blur(6px); animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 0 60px rgba(242,92,25,.25); animation: rise .3s ease-out; }
.done-title { margin-top: 8px; font: italic 800 42px/1 var(--font-display); letter-spacing: 0.03em; text-transform: uppercase; text-wrap: balance; }
.done-stars { display: flex; justify-content: center; gap: 10px; margin: 16px 0 14px; }
.done-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.done-figs div { background: var(--panel-2); border-radius: 8px; padding: 9px 6px; display: flex; flex-direction: column; gap: 3px; }
.done-figs b { font: 700 24px/1 var(--font-display); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.done-figs span { font: 600 10px/1.2 var(--font-label); letter-spacing: 0.1em; color: var(--ink-3); text-transform: uppercase; }
.modal-card p { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.done-actions { display: grid; gap: 8px; margin-top: 16px; }
.primary { border: 0; border-radius: 9px; padding: 13px 14px; background: var(--accent); color: var(--accent-ink);
  font: 700 15px/1.1 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; }
.primary:hover { box-shadow: 0 0 22px rgba(242,92,25,.45); }
.done-actions .ghost { padding: 11px 10px; font-size: 12px; }

@media (min-width: 1040px) {
  .jobbar { min-height: 52px; }
}

/* ======================================================================
   CHAPTER 2: WORKSHOP
   ====================================================================== */
.parts-tag { margin-top: 4px; color: var(--ink-3); }
.parts-tag.on { color: var(--accent); }
.badge.paid { background: var(--ink); color: #0d0d0f; }
.workshop { margin-top: 14px; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); }
.ws-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ws-head .steps-h { margin-top: 0; color: var(--accent); }
.ws-money { font: 600 12px/1.2 var(--font-label); letter-spacing: 0.06em; color: var(--ink-2); }
.ws-money b { color: var(--ink); font-weight: 700; }
.parts { display: grid; gap: 8px; margin-top: 10px; }
.part { padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid transparent; }
.part.on { border-color: var(--accent); }
.part-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.part-top b { font: 700 15px/1.2 var(--font-label); letter-spacing: 0.04em; text-transform: uppercase; }
.price { font: 700 16px/1 var(--font-display); letter-spacing: 0.03em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.part p { margin-top: 4px; font-size: 13px; color: var(--ink-2); max-width: 60ch; }
.part-act { margin-top: 8px; display: flex; }
.part-state { font: 600 11px/1 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); padding: 6px 0; }
.part-buy { border: 0; border-radius: 6px; padding: 8px 12px; background: var(--accent); color: var(--accent-ink);
  font: 700 12px/1 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; }
.part-buy:disabled { background: var(--line); color: var(--ink-3); cursor: not-allowed; }
@media (min-width: 700px) { .parts { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }

/* ======================================================================
   DO THIS NEXT: plan highlights and the job panel on the Maps screen
   ====================================================================== */
.cell.todo { outline: 2px dashed #fff; outline-offset: -3px; line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.cell.todo.sel { outline-style: solid; }
.cell .tgt { font: 700 10px/1 var(--font-label); letter-spacing: 0.01em; padding: 1px 3px; border-radius: 3px; background: #0d0d0f; color: #fff; }
.grid-key .k-todo { width: 9px; height: 9px; border: 1.5px dashed var(--ink); border-radius: 2px; }
.map-job { margin: -2px 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); }
.mj-head { display: flex; flex-direction: column; gap: 2px; }
.mj-k { font: 700 11px/1.2 var(--font-label); letter-spacing: 0.14em; color: var(--accent); }
.mj-goal { font: 600 14px/1.25 var(--font-label); letter-spacing: 0.03em; color: var(--ink); }
.mj-next { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.mj-label, .coach-k { display: block; font: 700 10px/1.2 var(--font-label); letter-spacing: 0.16em; color: var(--ink-3); margin-bottom: 3px; }
.mj-text { font-size: 14px; color: var(--ink); max-width: 65ch; }
.mj-how { margin-top: 8px; padding: 8px 10px; border-radius: 7px; background: var(--panel-2); font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.mj-how b { display: block; font: 700 11px/1.3 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.mj-how .plan-btn { margin-top: 8px; display: inline-block; }
.mj-plan { margin-top: 8px; }
.mj-plan summary { cursor: pointer; font: 600 11px/1.6 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.mj-plan p { font-size: 13px; color: var(--ink-2); margin-top: 4px; max-width: 65ch; }
.mj-plan p b { color: var(--ink); font-weight: 600; }
.plan-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.plan-btn { border: 1px solid var(--accent); background: rgba(242,92,25,.12); color: var(--ink); border-radius: 6px; padding: 7px 10px;
  font: 600 12px/1 var(--font-label); letter-spacing: 0.06em; text-transform: uppercase; }
.plan-btn:hover { background: rgba(242,92,25,.25); }
.plan-btn.done { border-color: var(--good); background: rgba(63,195,128,.12); color: var(--good); }
.plan-note { font-size: 13px; color: var(--ink-3); margin-top: 4px; max-width: 62ch; }
.res-next { flex: 1; min-width: 0; }
.setbox span { color: var(--ink-2); padding-right: 2px; }
.setbox input { width: 52px; }
.hm-track em.over { background: var(--crit); } .hm-track em.push { background: var(--warn); }
.scale .mk.tgt { background: none; border-left: 2px dashed #fff; width: 0; top: 0; height: 34px; }
.scale-key .k-tgt { background: none; border-left: 2px dashed #fff; width: 0; }

/* ======================================================================
   CHAPTER 3: the pump engine
   ====================================================================== */
.chain-row.deliv { margin-top: 3px; padding-top: 6px; border-top: 1px dashed var(--line-2); }
.chain-row.deliv .fill { background: var(--ink-2); }
.chain-row.deliv.short { color: var(--warn); }
.chain-row.deliv.short .fill { background: var(--warn); }
.chain-row.deliv.short b { color: var(--warn); }
.strip .duration { background: #5fc4b8; } .strip .injector { background: var(--warn); }
@media (min-width: 1040px) { .map-tabs { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); } }
.chain-row.deliv .track::after { content: attr(data-why); position: absolute; right: 6px; top: 0; font: 700 9px/14px var(--font-label); letter-spacing: 0.14em; color: var(--warn); }
@media (min-width: 1040px) { .map-tabs { grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); } }

/* ======================================================================
   BATCH 1: what changed, last pull, phone results sheet
   ====================================================================== */
.sw-last { border-color: var(--accent); opacity: .45; }
.changed { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border-left: 3px solid var(--ink-3); }
.changed b { display: block; font: 700 10px/1.3 var(--font-label); letter-spacing: 0.16em; color: var(--ink-3); margin-bottom: 3px; }
.changed p { font-size: 14px; color: var(--ink-2); max-width: 65ch; }
.changed p + p { margin-top: 3px; color: var(--ink); }
.changed .up { color: var(--good); font-weight: 600; } .changed .down { color: var(--crit); font-weight: 600; }

.sheet {
  position: fixed; left: 8px; right: 8px; z-index: 29;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 6px);
  background: var(--panel); border: 1px solid var(--line-2); border-top: 2px solid var(--accent); border-radius: 14px 14px 10px 10px;
  box-shadow: 0 -12px 40px rgba(0,0,0,.65); animation: sheetUp .28s cubic-bezier(.2,.9,.3,1);
  max-height: 64vh; display: flex; flex-direction: column; overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet.min .sh-body { display: none; }
.sh-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; flex: none; }
.sh-head .rating { font-size: 13px; padding: 5px 8px; gap: 6px; flex: none; }
.sh-head .rating i { width: 8px; height: 8px; }
.sh-fig { flex: 1; min-width: 0; font: 600 13px/1.2 var(--font-label); letter-spacing: 0.04em; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; }
.sh-fig b { font: 700 20px/1 var(--font-display); color: var(--ink); letter-spacing: 0.02em; }
.sh-fig small { flex-basis: 100%; font: 600 12px/1.3 var(--font-label); }
.sh-fig small.up { color: var(--good); } .sh-fig small.down { color: var(--crit); }
.sh-score { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font: 600 11px/1 var(--font-label); color: var(--ink-3); }
.sh-score b { font: 700 22px/1 var(--font-display); color: var(--accent); }
.chev { flex: none; width: 10px; height: 10px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); margin: 0 4px 4px; transition: transform .2s; }
.sheet.min .chev { transform: rotate(-135deg); margin-top: 6px; }
.sh-body { overflow-y: auto; padding: 0 12px 12px; display: grid; gap: 8px; }
.sh-next { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--accent); background: rgba(242,92,25,.06); }
.sh-next b { display: block; font: 700 10px/1.3 var(--font-label); letter-spacing: 0.16em; color: var(--accent); margin-bottom: 3px; }
.sh-next p { font-size: 14px; color: var(--ink); }
.sheet .changed { margin-top: 0; }
.sh-lamps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); }
.sh-lamps span:last-child { margin-left: 4px; }
.sh-actions { display: flex; gap: 8px; }
.sh-actions .ghost { flex: 1; padding: 9px; }
body.sheet-on { padding-bottom: calc(var(--bar-h) + 80px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1040px) { .sheet { display: none !important; } }

/* ---------- guided tour ---------- */
.tour-dim { position: fixed; inset: 0; z-index: 54; background: rgba(5,5,6,.72); backdrop-filter: blur(2px); }
.tour-spot { position: fixed; z-index: 55; border-radius: 10px; border: 2px solid var(--accent); pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(5,5,6,.66), 0 0 24px rgba(242,92,25,.55); transition: left .25s, top .25s, width .25s, height .25s; }
.tour-card { position: fixed; z-index: 56; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.tour-card.center { text-align: left; }
.tc-step { font: 700 10px/1 var(--font-label); letter-spacing: 0.18em; color: var(--accent); }
.tour-card h3 { margin-top: 6px; font: 700 22px/1.05 var(--font-display); letter-spacing: 0.04em; text-transform: uppercase; }
.tour-card.center h3 { font-size: 30px; }
.tour-card p { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.tc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.tc-actions .primary { padding: 10px 16px; font-size: 13px; }
.tc-wait { font: 700 12px/1.2 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.tc-wait::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; animation: blink 1s steps(2) infinite; }
.tc-skip { border: 0; background: none; padding: 6px 0; font: 600 12px/1 var(--font-label); letter-spacing: 0.06em; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; }
.tc-skip:hover { color: var(--ink); }
.garage-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.garage-actions .reset-prog { margin-top: 0; }
.sheet { max-height: 54vh; }
.sheet .changed { padding: 8px 10px; }
.sheet .changed p { font-size: 13px; }
.sh-next p { font-size: 13.5px; }
.sh-full { border: 0; background: none; padding: 2px 0 0; text-align: left; font: 600 12px/1.3 var(--font-label); letter-spacing: 0.05em; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.sh-head { padding: 8px 12px; }
.sh-score b { font-size: 20px; }

/* ---------- hint button ---------- */
.hint-btn { border: 1px dashed var(--ink-3); background: none; color: var(--ink-2); border-radius: 6px; padding: 7px 10px;
  font: 600 12px/1 var(--font-label); letter-spacing: 0.06em; text-transform: uppercase; }
.hint-btn::before { content: "?"; display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: 6px; border-radius: 50%;
  border: 1.5px solid currentColor; font-size: 10px; line-height: 1; }
.hint-btn:hover { color: var(--ink); border-color: var(--ink-2); }
.hint-btn.on { border-style: solid; color: var(--ink); }

/* ---------- Tap to explain ---------- */
button.term.term {
  display: inline; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  text-decoration: underline dotted rgba(242,92,25,.75); text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: help;
}
button.term.term:hover, button.term.term:focus-visible { color: var(--accent); text-decoration-style: solid; }
.fact .term { font: inherit; letter-spacing: inherit; color: inherit; }
.chain-row .nm.term { text-align: left; text-decoration-color: rgba(242,92,25,.45); }
.chain-row.low .nm.term { color: var(--ink); }
.lamps { pointer-events: auto; }
button.lamp { appearance: none; cursor: help; }
.sh-lamps button.lamp { margin-right: 4px; }
.term-pop {
  position: fixed; z-index: 80; padding: 12px 14px 10px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 24px rgba(242,92,25,.18);
  animation: fade .15s ease-out;
}
.term-pop b { display: block; font: 700 13px/1.2 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.term-pop p { margin-top: 6px; font-size: 14px; line-height: 1.45; color: var(--ink); }
.tp-all { margin-top: 8px; border: 0; background: none; padding: 4px 0; font: 600 11px/1 var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.tp-all:hover { color: var(--accent); }
.gloss-card { position: relative; text-align: left; width: min(560px, 100%); max-height: 86vh; overflow: auto; }
.gloss-x { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--panel-2); font: 400 22px/1 var(--font-label); color: var(--ink-2); }
.gloss-x:hover { color: var(--accent); border-color: var(--accent); }
.gloss-title { margin-top: 8px; font: italic 800 30px/1 var(--font-display); letter-spacing: 0.03em; text-transform: uppercase; }
.gloss-list { margin: 14px 0 0; display: grid; gap: 10px; }
.gloss-list div { padding: 9px 11px; background: var(--panel-2); border-radius: 8px; }
.gloss-list dt { font: 700 13px/1.2 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.gloss-list dd { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.45; }

/* ---------- One place for guidance ---------- */
.why-h { margin-top: 14px; font: 700 12px/1 var(--font-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.why-h + .issues { margin-top: 8px; }
.issue .cause { font: 600 12px/1.3 var(--font-label); letter-spacing: 0.06em; color: var(--ink-3); text-transform: uppercase; }
.issue .cause b { color: var(--ink-2); font-weight: 700; }
details.route { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
details.route summary, details.rot summary { cursor: pointer; font: 600 12px/1.6 var(--font-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
details.route summary:hover, details.rot summary:hover { color: var(--accent); }
details.rot { margin-top: 6px; }
details.rot p { margin-top: 4px; }
.hint-rows { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.hint-rows li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.hint-rows li .plan-btn { flex: none; padding: 6px 9px; }
.hint-rows b { color: var(--ink); font-weight: 600; }

/* ---------- Sound toggle ---------- */
.snd {
  margin-left: auto; flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: none; color: var(--ink-2);
}
.snd:hover, .snd:focus-visible { border-color: var(--accent); color: var(--accent); }
.snd svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.snd .spk { fill: currentColor; stroke: none; }
.snd .cross { display: none; }
.snd.off { color: var(--ink-3); }
.snd.off .wave { display: none; }
.snd.off .cross { display: inline; }

/* ---------- Coming soon / get notified ---------- */
a.primary, a.ghost { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
.notify { margin-top: 14px; padding: 14px; border-radius: 10px; border: 1px solid var(--accent); background: linear-gradient(160deg, rgba(242,92,25,.12), rgba(242,92,25,0) 60%); }
.notify h3 { margin-top: 8px; font: italic 800 24px/1.05 var(--font-display); letter-spacing: 0.03em; text-transform: uppercase; }
.notify p { margin-top: 6px; font-size: 14px; color: var(--ink-2); max-width: 62ch; }
.notify-btns { display: grid; gap: 8px; margin-top: 12px; max-width: 420px; }
.notify-links { display: flex; flex-wrap: wrap; gap: 8px; }
.notify-links .ghost { flex: 1 1 0; padding: 9px 10px; }
.done-actions .notify-links .ghost { padding: 10px; font-size: 11px; }
.legal .privacy { margin-top: 6px; }

/* Full Garage: buy button + licence key box (js/unlock.js) */
.key-form { display: grid; gap: 6px; margin-top: 4px; }
.key-form label { font: 600 11px/1.3 var(--font-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.key-row { display: flex; gap: 8px; min-width: 0; }
.key-row input { flex: 1 1 auto; min-width: 0; padding: 10px; border-radius: 6px; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); font: 500 14px/1.2 var(--font-body); letter-spacing: 0.04em; }
.key-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.key-row .ghost { flex: 0 0 auto; padding: 10px 14px; }
.key-msg { min-height: 1.2em; font-size: 13px; color: var(--ink-2); }
.key-msg.bad { color: var(--accent); }
.key-fine { margin-top: 10px; font-size: 12px; color: var(--ink-3); }

/* Petrol (Chapter 4): what is in control, on the strip under the graph */
.strip .boostTarget { background: #8fb3d9; } .strip .wastegate { background: #d9b45f; }
.strip .knock { background: var(--crit); color: #fff; } .strip .turbo { background: #a08ad6; }
