:root {
  --rosso: #d40000;
  --rosso-deep: #8f0000;
  --giallo: #ffcc00;
  --giallo-deep: #e0a800;
  --verde-it: #009246;
  --rosso-it: #ce2b37;
  --nero: #0b0b0c;
  --nero-2: #141416;
  --nero-3: #1d1d21;
  --line: rgba(255, 255, 255, 0.09);
  --bianco: #f4f1ea;
  --muted: #9a978f;
  --accent: var(--rosso);
  --chamfer: 18px;
  --radius: 6px;
  --f-num: 'Saira Condensed', 'Arial Narrow', system-ui, sans-serif;
  --f-it: 'Bodoni Moda', 'Didot', Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--nero);
  color: var(--bianco);
  font-family: var(--f-num);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid var(--giallo); outline-offset: 3px; }
[hidden] { display: none !important; }

/* carbon fibre weave */
.carbon {
  background-color: #111113;
}
.app {
  height: 100dvh;
  display: grid;
  gap: 14px;
  padding: calc(10px + var(--safe-t)) 16px calc(14px + var(--safe-b));
  background:
    radial-gradient(1200px 600px at 50% 35%, rgba(212, 0, 0, 0.13), transparent 65%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.018) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.35) 0 2px, transparent 2px 6px),
    var(--nero);
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top top"
    "speed tach engine"
    "ctl ctl ctl";
}

/* ── Header ── */
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; flex-direction: column; gap: 5px; }
.wordmark, .welcome-mark { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
.w-ghost { font-family: var(--f-it); font-style: italic; font-weight: 800; font-size: 30px; color: var(--bianco); letter-spacing: -0.5px; }
.w-engine { font-weight: 800; font-size: 20px; letter-spacing: 6px; color: var(--rosso); transform: skewX(-10deg); }
.tricolore { display: flex; width: 120px; height: 4px; transform: skewX(-30deg); }
.tricolore i { flex: 1; }
.tricolore i:nth-child(1) { background: var(--verde-it); }
.tricolore i:nth-child(2) { background: #fff; }
.tricolore i:nth-child(3) { background: var(--rosso-it); }
.tricolore.wide { width: 220px; height: 6px; margin: 14px auto 0; }

.top-actions { display: flex; gap: 10px; align-items: center; }
.pill {
  min-height: 52px; min-width: 76px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--nero-2); border: 1px solid var(--line);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  font-weight: 700; letter-spacing: 2px; font-size: 17px; text-transform: uppercase;
}
.pill .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(255,255,255,0.05); }
.pill[data-state="ok"] .dot { background: #29d36a; box-shadow: 0 0 12px #29d36a; }
.pill[data-state="search"] .dot { background: var(--giallo); animation: blink 1s infinite; }
.pill[data-state="err"] .dot { background: var(--rosso); box-shadow: 0 0 12px var(--rosso); }
.pill[data-state="demo"] .dot { background: #4aa3ff; box-shadow: 0 0 12px #4aa3ff; }
.icon-btn {
  width: 60px; height: 52px; display: grid; place-items: center;
  background: var(--nero-2); border: 1px solid var(--line);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ── Panels ── */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
  padding: 20px 22px;
  min-width: 0;
}
.label, .meter-label, .s-title {
  font-weight: 700; text-transform: uppercase; letter-spacing: 3px; font-size: 14px; color: var(--muted);
}
.speed-panel { grid-area: speed; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.speed { display: flex; align-items: baseline; gap: 10px; line-height: 0.85; }
.speed span {
  font-weight: 800; font-size: clamp(84px, 11vw, 168px); letter-spacing: -2px;
  font-variant-numeric: tabular-nums; transform: skewX(-6deg); display: inline-block;
  text-shadow: 0 0 30px rgba(255,255,255,0.08);
}
.speed small { font-size: 26px; font-weight: 700; color: var(--giallo); letter-spacing: 2px; text-transform: uppercase; }
.meter-label { display: flex; justify-content: space-between; margin-bottom: 8px; }
.meter-label span:last-child { color: var(--bianco); font-variant-numeric: tabular-nums; }
.bar { height: 14px; background: #000; border: 1px solid var(--line); transform: skewX(-20deg); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--giallo), var(--rosso)); transition: width 80ms linear; }
.status-line { font-size: 18px; font-weight: 600; color: var(--muted); letter-spacing: 1px; min-height: 1.2em; }
.status-line b { color: var(--bianco); }

/* ── Tach ── */
.tach-wrap {
  grid-area: tach; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: min(62vh, 44vw); max-width: 680px; min-height: 0;
}
.tach { width: 100%; height: auto; max-height: 100%; display: block; overflow: visible; filter: drop-shadow(0 20px 50px rgba(0,0,0,0.8)); }
.shift-lights { display: flex; gap: 8px; margin-bottom: 10px; }
.shift-lights i {
  width: clamp(16px, 2.4vw, 26px); aspect-ratio: 1; border-radius: 50%;
  background: #1a1a1d; border: 2px solid #26262b; transition: background 60ms, box-shadow 60ms;
}
.shift-lights i.on.g { background: #22e06b; box-shadow: 0 0 14px #22e06b; }
.shift-lights i.on.r { background: #ff1f1f; box-shadow: 0 0 14px #ff1f1f; }
.shift-lights i.on.b { background: #3c8bff; box-shadow: 0 0 14px #3c8bff; }
.shift-lights.flash i { background: #3c8bff; box-shadow: 0 0 18px #3c8bff; animation: blink 90ms steps(1) infinite; }

/* SVG tach parts */
.t-bezel { fill: url(#bezelGrad); }
.t-face { fill: url(#faceGrad); }
.t-tick { stroke: #111; }
.t-tick.red { stroke: #b30000; }
.t-num { font-family: var(--f-num); font-weight: 800; fill: #111; text-anchor: middle; dominant-baseline: central; }
.t-num.red { fill: #b30000; }
.t-redzone { fill: none; stroke: var(--rosso); }
.t-caption { font-family: var(--f-num); font-weight: 700; fill: #3a2c00; letter-spacing: 3px; text-anchor: middle; font-size: 13px; }
.t-brand { font-family: var(--f-it); font-style: italic; font-weight: 800; fill: #1a1300; text-anchor: middle; font-size: 22px; }
.t-needle { transform-origin: 200px 200px; transition: none; }
.t-hub { fill: #0d0d0f; stroke: #2a2a2e; stroke-width: 2; }
.t-gear { font-family: var(--f-num); font-weight: 800; fill: var(--bianco); text-anchor: middle; dominant-baseline: central; font-size: 64px; }
.t-gear-label { font-family: var(--f-num); font-weight: 700; fill: var(--giallo); text-anchor: middle; font-size: 11px; letter-spacing: 3px; }
.t-rpm { font-family: var(--f-num); font-weight: 700; fill: #111; text-anchor: middle; font-size: 20px; font-variant-numeric: tabular-nums; }

/* ── Engine card ── */
.engine-panel { grid-area: engine; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.engine-card { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; gap: 10px; align-items: stretch; }
.arrow {
  font-size: 54px; font-weight: 400; line-height: 1; min-height: 120px;
  background: var(--nero-2); border: 1px solid var(--line);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.arrow:active, .pill:active, .icon-btn:active { background: var(--nero-3); }
.engine-face {
  position: relative; text-align: left; padding: 16px 18px 14px 22px; min-width: 0;
  display: flex; flex-direction: column; gap: 4px; justify-content: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.0));
  border: 1px solid var(--line);
}
.engine-face::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--accent); box-shadow: 0 0 22px var(--accent); }
.badge {
  align-self: flex-start; font-weight: 800; font-size: 14px; letter-spacing: 2px; color: #000; background: var(--giallo);
  padding: 3px 10px; transform: skewX(-12deg);
}
.badge-row { display: flex; gap: 10px; align-items: center; }
.rec { font-size: 13px; font-weight: 800; letter-spacing: 2px; color: #ff3b3b; text-shadow: 0 0 10px rgba(255,59,59,0.7); }
.car .rec { position: absolute; left: 92px; top: 18px; }
.about a { color: var(--giallo); }
.eng-name { font-family: var(--f-it); font-style: italic; font-weight: 800; font-size: clamp(30px, 3.2vw, 46px); line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eng-spec { font-size: 18px; font-weight: 600; color: #cfcac0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eng-hint { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }

/* ── Manettino ── */
.manettino { position: relative; width: 300px; height: 210px; align-self: center; flex: 0 0 auto; }
.m-label {
  position: absolute; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; font-size: 17px;
  padding: 10px 12px; color: var(--muted); min-height: 48px;
}
.m-label[data-mode="comfort"] { left: 0; top: 34px; }
.m-label[data-mode="sport"] { left: 50%; top: 0; transform: translateX(-50%); }
.m-label[data-mode="corsa"] { right: 0; top: 34px; }
.m-label[aria-checked="true"] { color: var(--bianco); text-shadow: 0 0 14px var(--giallo); }
.m-label[aria-checked="true"]::after { content: ""; display: block; height: 3px; background: var(--giallo); margin-top: 4px; }
.knob {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 124px; height: 124px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ff4a4a, var(--rosso) 45%, var(--rosso-deep) 100%);
  box-shadow: 0 0 0 6px #1b1b1f, 0 0 0 8px #34343a, 0 14px 30px rgba(0,0,0,0.7), inset 0 -8px 16px rgba(0,0,0,0.35);
}
.knob-pointer {
  position: absolute; left: 50%; top: 50%; width: 10px; height: 54px; margin-left: -5px; margin-top: -54px;
  background: var(--bianco); border-radius: 5px; transform-origin: 50% 100%;
  transition: transform 260ms cubic-bezier(.3,1.6,.5,1);
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}
.knob::after { content: ""; position: absolute; inset: 44px; border-radius: 50%; background: #2a0000; box-shadow: inset 0 2px 4px rgba(0,0,0,0.6); }

/* ── Controls ── */
.controls { grid-area: ctl; display: flex; gap: 14px; align-items: stretch; }
.start-btn {
  position: relative; flex: 0 0 auto; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #2b2b30, #0e0e10 70%);
  box-shadow: 0 0 0 5px #222226, 0 0 0 8px #3a3a40, 0 10px 30px rgba(0,0,0,0.7);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 80ms;
}
.start-btn:active { transform: scale(0.96); }
.start-btn .ring { position: absolute; inset: 10px; border-radius: 50%; border: 3px solid var(--rosso); box-shadow: 0 0 18px rgba(212,0,0,0.7), inset 0 0 18px rgba(212,0,0,0.5); }
.start-top, .start-bot { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.start-main { font-size: 34px; font-weight: 800; letter-spacing: 2px; color: var(--bianco); }
.running .start-btn .ring { border-color: var(--giallo); box-shadow: 0 0 26px rgba(255,204,0,0.8), inset 0 0 18px rgba(255,204,0,0.5); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 8px rgba(255,204,0,0.4), inset 0 0 8px rgba(255,204,0,0.2); } }

.pedal {
  flex: 1 1 0; min-height: 150px; padding: 0 28px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px;
  clip-path: polygon(26px 0, 100% 0, calc(100% - 26px) 100%, 0 100%);
  transition: filter 80ms, transform 80ms;
  touch-action: none;
}
.pedal-main { font-size: clamp(30px, 3.6vw, 48px); font-weight: 800; text-transform: uppercase; letter-spacing: 2px; transform: skewX(-8deg); }
.pedal-sub { font-size: 16px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; opacity: 0.75; }
.pedal { position: relative; overflow: hidden; }
.pedal > span { position: relative; z-index: 1; }
.pedal > .pedal-fill {
  position: absolute; inset: 0; z-index: 0; transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, rgba(255,255,255,0.0), rgba(255,255,255,0.45)); transition: transform 40ms linear;
}
.brake > .pedal-fill { background: linear-gradient(90deg, rgba(255,255,255,0.0), rgba(255,255,255,0.3)); }
.pedal > .pedal-pct {
  position: absolute; right: 40px; top: 50%; transform: translateY(-50%) skewX(-8deg);
  font-size: clamp(34px, 4vw, 56px); font-weight: 800; font-variant-numeric: tabular-nums; opacity: 0.9;
}
.pedal-scale { display: flex; justify-content: space-between; width: 100%; padding-right: 30px; font-size: 13px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; opacity: 0.55; }
.pedal-scale i { font-style: normal; }
.gas {
  color: #160f00;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.08) 0 6px, transparent 6px 22px),
    linear-gradient(180deg, #ffd633, var(--giallo-deep));
}
.brake { flex: 0 1 38%; color: #fff; background: repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0 6px, transparent 6px 22px), linear-gradient(180deg, #e01414, var(--rosso-deep)); }
.pedal.down { filter: brightness(1.25); transform: translateY(3px) scale(0.99); }
.pedal:disabled { filter: grayscale(1) brightness(0.45); }

/* ── Sheets ── */
.sheet {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overscroll-behavior: contain;
  background: rgba(6, 6, 7, 0.94); backdrop-filter: blur(10px);
  animation: fadein 160ms ease-out;
}
@keyframes fadein { from { opacity: 0; transform: translateY(12px); } }
.sheet-inner { max-width: 1200px; margin: 0 auto; padding: calc(18px + var(--safe-t)) 16px calc(40px + var(--safe-b)); }
.sheet-inner.narrow { max-width: 760px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-family: var(--f-it); font-style: italic; font-weight: 800; font-size: 46px; margin: 0; }
.close { width: 72px; height: 72px; font-size: 30px; background: var(--nero-2); border: 1px solid var(--line); clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); }
.group-title { margin: 26px 0 12px; font-size: 22px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: var(--giallo); display: flex; align-items: baseline; gap: 12px; }
.group-title small { font-family: var(--f-it); font-style: italic; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 20px; font-weight: 600; }
.group-title.duck { color: #9fb3c0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px; }
.car {
  position: relative; text-align: left; min-height: 150px; padding: 16px 16px 14px 24px;
  display: flex; flex-direction: column; gap: 4px;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.01)); border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.car::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c); }
.car.sel { border-color: var(--giallo); background: linear-gradient(135deg, rgba(255,204,0,0.16), rgba(255,204,0,0.02)); }
.car .badge { font-size: 12px; }
.car .c-name { font-family: var(--f-it); font-style: italic; font-weight: 800; font-size: 30px; line-height: 1.1; }
.car .c-spec { font-size: 16px; font-weight: 700; color: #d8d3c8; }
.car .c-tag { font-size: 15px; color: var(--muted); line-height: 1.3; }
.car .c-red { position: absolute; right: 14px; top: 14px; font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }

.setting { padding: 20px 0; border-bottom: 1px solid var(--line); }
.s-title { margin-bottom: 12px; display: flex; justify-content: space-between; }
.s-title span { color: var(--bianco); }
.s-help { color: var(--muted); font-size: 17px; margin: 10px 0 0; line-height: 1.35; }
.s-help b { color: var(--bianco); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 140px; min-height: 68px; font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px;
  background: var(--nero-2); border: 1px solid var(--line);
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
.seg button[aria-pressed="true"] { background: var(--rosso); border-color: var(--rosso); box-shadow: 0 0 22px rgba(212,0,0,0.5); }
.seg.test button { background: #222227; }
.seg.test button:active { background: var(--giallo); color: #000; }
input[type="range"] { width: 100%; height: 60px; -webkit-appearance: none; appearance: none; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 12px; background: linear-gradient(90deg, var(--giallo), var(--rosso)); }
input[type="range"]::-moz-range-track { height: 12px; background: linear-gradient(90deg, var(--giallo), var(--rosso)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 46px; height: 46px; margin-top: -17px; border-radius: 50%; background: var(--bianco); border: 6px solid var(--rosso); box-shadow: 0 4px 12px rgba(0,0,0,0.6); }
input[type="range"]::-moz-range-thumb { width: 34px; height: 34px; border-radius: 50%; background: var(--bianco); border: 6px solid var(--rosso); }
.about p { color: var(--muted); font-size: 16px; line-height: 1.45; }
.about b { color: var(--bianco); }

/* ── Welcome ── */
.welcome { display: flex; align-items: center; }
.welcome .sheet-inner { text-align: center; }
.welcome-mark { justify-content: center; }
.welcome-mark .w-ghost { font-size: 72px; }
.welcome-mark .w-engine { font-size: 42px; letter-spacing: 12px; }
.welcome-lead { font-size: 22px; line-height: 1.4; color: #d8d3c8; margin: 26px auto 18px; max-width: 600px; }
.steps { text-align: left; max-width: 560px; margin: 0 auto 28px; padding-left: 28px; font-size: 20px; line-height: 1.5; color: var(--muted); }
.steps b { color: var(--bianco); }
.welcome-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.big-cta {
  flex: 1 1 240px; min-height: 84px; font-size: 26px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase;
  background: var(--rosso); color: #fff; clip-path: polygon(18px 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
  box-shadow: 0 0 30px rgba(212,0,0,0.5);
}
.big-cta.ghost { background: var(--nero-3); border: 1px solid var(--line); box-shadow: none; }

/* ── Portrait phones: one fixed screen, no scrolling ──
   Rows: header · tach (takes whatever is left) · speed · engine · drive mode · pedals */
@media (max-aspect-ratio: 5/4) {
  .app {
    height: 100dvh; overflow: hidden; gap: 8px;
    padding: calc(6px + var(--safe-t)) 12px calc(10px + var(--safe-b));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top" "tach" "speed" "engine" "ctl";
  }
  .panel { padding: 8px 12px; --chamfer: 12px; }

  /* header */
  .w-ghost { font-size: 22px; } .w-engine { font-size: 13px; letter-spacing: 3px; }
  .tricolore { width: 80px; height: 3px; }
  .top-actions { gap: 6px; }
  .pill { min-height: 40px; min-width: 0; padding: 0 12px; font-size: 13px; letter-spacing: 1px; }
  .icon-btn { width: 46px; height: 40px; }
  .icon-btn svg { width: 24px; height: 24px; }

  /* tach: fills the leftover height, stays square */
  .tach-wrap { width: 100%; height: 100%; min-height: 0; justify-self: center; }
  .shift-lights { gap: 5px; margin-bottom: 4px; }
  .shift-lights i { width: clamp(10px, 3vw, 16px); }
  .tach { flex: 1 1 0; min-height: 0; width: 100%; height: 100%; filter: drop-shadow(0 10px 24px rgba(0,0,0,0.8)); }

  /* speed + throttle + status in one compact row */
  .speed-panel { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
  .speed-panel .label { display: none; }
  .speed { gap: 6px; }
  .speed span { font-size: clamp(44px, 13vw, 64px); letter-spacing: -1px; }
  .speed small { font-size: 15px; }
  .speed-panel .meter { flex: 1 1 120px; }
  .meter-label { font-size: 11px; letter-spacing: 2px; margin-bottom: 5px; }
  .bar { height: 10px; }
  .status-line { flex-basis: 100%; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* engine card + compact manettino */
  .engine-panel { flex-direction: column; align-items: stretch; gap: 8px; }
  .engine-card { grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 6px; }
  .arrow { min-height: 0; font-size: 36px; }
  .engine-face { padding: 6px 10px 6px 16px; gap: 1px; flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
  .engine-face::before { width: 5px; }
  .badge-row { order: 0; }
  .badge { font-size: 11px; padding: 2px 7px; }
  .rec { font-size: 11px; }
  .eng-name { font-size: clamp(22px, 6.5vw, 30px); flex: 1 1 auto; min-width: 0; }
  .eng-spec { font-size: 13px; flex-basis: 100%; }
  .eng-hint { display: none; }

  .manettino { position: static; display: flex; align-items: center; gap: 6px; width: 100%; height: auto; }
  .m-label { position: static; transform: none; flex: 1 1 0; min-height: 40px; padding: 6px 4px; font-size: 13px; letter-spacing: 1px;
    background: var(--nero-2); border: 1px solid var(--line); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
  .manettino .m-label[data-mode] { left: auto; right: auto; top: auto; transform: none; }
  .m-label[aria-checked="true"] { background: rgba(255, 204, 0, 0.14); border-color: var(--giallo); }
  .m-label[aria-checked="true"]::after { display: none; }
  .knob { position: relative; left: auto; bottom: auto; transform: none; order: -1; flex: 0 0 auto; width: 42px; height: 42px;
    box-shadow: 0 0 0 3px #1b1b1f, 0 0 0 4px #34343a, 0 6px 14px rgba(0,0,0,0.7); }
  .knob::after { inset: 15px; }
  .knob-pointer { width: 5px; height: 18px; margin-left: -2.5px; margin-top: -18px; border-radius: 3px; }

  /* pedals: one thumb-reach row */
  .controls { gap: 8px; }
  .start-btn { width: 86px; height: 86px; box-shadow: 0 0 0 3px #222226, 0 0 0 5px #3a3a40, 0 8px 20px rgba(0,0,0,0.7); }
  .start-btn .ring { inset: 7px; border-width: 2px; }
  .start-top, .start-bot { font-size: 9px; letter-spacing: 2px; }
  .start-main { font-size: 22px; }
  .pedal { min-height: 86px; padding: 0 16px; gap: 2px; clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%); }
  .pedal-main { font-size: clamp(20px, 5.6vw, 28px); }
  .pedal-sub { font-size: 11px; letter-spacing: 1px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pedal-main .long { display: none; }
  .pedal-scale { font-size: 10px; letter-spacing: 1px; padding-right: 14px; }
  .pedal > .pedal-pct { right: 18px; font-size: clamp(22px, 6vw, 32px); }
  .brake { flex: 0 0 30%; }
  .brake .pedal-sub { display: none; }
}
/* Very short portrait screens (small phones, browser bars showing) */
@media (max-aspect-ratio: 5/4) and (max-height: 640px) {
  .speed span { font-size: 42px; }
  .eng-spec { display: none; }
  .start-btn { width: 74px; height: 74px; }
  .pedal { min-height: 74px; }
  .pedal-sub, .pedal-scale { display: none; }
  .start-top, .start-bot { display: none; }
  .m-label { min-height: 34px; }
  .knob { width: 36px; height: 36px; }
}
@media (max-width: 520px) {
  .welcome-mark .w-ghost { font-size: 52px; } .welcome-mark .w-engine { font-size: 28px; letter-spacing: 8px; }
}
/* Short landscape (phones held sideways) */
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
  .app { gap: 8px; padding-top: 6px; }
  .panel { padding: 12px 14px; }
  .start-btn { width: 104px; height: 104px; }
  .start-main { font-size: 24px; }
  .pedal { min-height: 104px; }
  .arrow { min-height: 92px; }
  .manettino { transform: scale(0.72); margin: -30px 0; }
  .speed span { font-size: 72px; }
}
