  :root {
    --bg: #000;
    --fg: #fff;
    --fg-2: rgba(255,255,255,.62);
    --fg-3: rgba(255,255,255,.36);
    --line: rgba(255,255,255,.22);
    --red: #e31937;
    --ease: cubic-bezier(.2,.6,.2,1);
    --gutter: clamp(16px, 3.2vw, 48px);
    --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
    font-family: Inter, system-ui, -apple-system, sans-serif; font-weight: 300; -webkit-font-smoothing: antialiased; }
  #game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

  .label, .h-label { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }

  /* ---------- landing ---------- */
  #title { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: space-between;
    padding: calc(var(--gutter) * 1.2) var(--gutter) var(--gutter); overflow-y: auto;
    background: radial-gradient(ellipse at 60% 45%, rgba(0,0,0,0) 30%, rgba(0,0,0,.78) 100%),
                linear-gradient(90deg, rgba(0,0,0,.72) 0%, rgba(0,0,0,0) 55%);
    transition: opacity .4s var(--ease); }
  #title.hidden { opacity: 0; pointer-events: none; }
  .hero { max-width: 640px; }
  .hero h1 { font-weight: 300; font-size: clamp(56px, 11vw, 148px); line-height: .95; letter-spacing: -.02em; margin: 18px 0 14px; }
  .hero p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--fg-2); max-width: 440px; }

  .config { display: flex; flex-direction: column; gap: 28px; margin-top: 40px; }
  .trims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); max-width: 860px; }
  .trim { position: relative; text-align: left; padding: 18px 20px 20px 0; transition: opacity .3s var(--ease); opacity: .5; }
  .trim + .trim { padding-left: 20px; border-left: 1px solid var(--line); }
  .trim:hover, .trim.sel { opacity: 1; }
  .trim::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--red);
    transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
  .trim.sel::before { transform: scaleX(1); }
  .trim .name { display: block; font-size: 12px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
  .trim .z { display: block; font-size: clamp(28px, 4.4vw, 44px); font-weight: 300; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
  .trim .z small { font-size: 12px; letter-spacing: .1em; color: var(--fg-2); margin-left: 6px; }
  .trim .spec { display: block; font-size: 12px; color: var(--fg-2); }

  .actions { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
  #start { min-width: 220px; height: 44px; border: 1px solid var(--fg); font-size: 12px; font-weight: 500; letter-spacing: .2em;
    text-transform: uppercase; transition: background .25s var(--ease), color .25s var(--ease); }
  #start:hover, #start:focus-visible { background: var(--fg); color: var(--bg); outline: none; }
  #ctrl-toggle { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2);
    padding: 6px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
  #ctrl-toggle:hover, #ctrl-toggle[aria-expanded="true"] { color: var(--fg); border-color: var(--red); }
  .keys { display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); gap: 0 40px; max-width: 680px;
    max-height: 0; overflow: hidden; opacity: 0; transition: max-height .4s var(--ease), opacity .3s var(--ease); }
  .keys.open { max-height: 400px; opacity: 1; }
  .keys div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.1); font-size: 13px; color: var(--fg-2); }
  .keys b { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--fg); white-space: nowrap; }
  .note { font-size: 11px; color: var(--fg-3); letter-spacing: .04em; }

  /* ---------- home (game-style selector) ---------- */
  #title { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    padding: var(--gutter); background: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0) 35%, rgba(0,0,0,.75) 100%); transition: opacity .35s var(--ease); }
  #title.hidden { opacity: 0; pointer-events: none; }
  .h-brand { position: absolute; top: var(--gutter); left: 50%; transform: translateX(-50%); padding-left: .32em; text-align: center; white-space: nowrap; font-size: 12px; font-weight: 500; letter-spacing: .32em; text-transform: uppercase; }
  .h-stage { width: 100%; max-width: 1180px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
  .h-head { display: flex; align-items: center; justify-content: center; gap: 28px; width: 100%; }
  .h-namewrap { text-align: center; min-width: 0; }
  .h-name { font-size: clamp(30px, 5.4vw, 56px); font-weight: 300; letter-spacing: -.01em; white-space: nowrap; }
  .h-name.in-r { animation: inR .3s var(--ease); } .h-name.in-l { animation: inL .3s var(--ease); }
  @keyframes inR { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
  @keyframes inL { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
  .h-sub { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-3); min-height: 14px; margin-top: 4px; }
  .h-arrow { width: 44px; height: 44px; font-size: 30px; font-weight: 300; color: var(--fg-2); transition: color .2s; }
  .h-arrow:hover { color: var(--fg); }
  .h-track { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; width: 100%; overflow: visible; padding: 10px 4px; }
  .h-track::-webkit-scrollbar { display: none; }
  .h-track > button { flex: 0 0 auto; transition: transform .3s var(--ease), opacity .3s var(--ease), border-color .3s var(--ease); animation: fade .3s var(--ease); }
  .h-sw { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line);
    background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), rgba(255,255,255,0) 38%), var(--c); }
  .h-sw.sel { transform: scale(1.18); border-color: var(--fg); }
  .h-card { width: 220px; padding: 22px 20px; text-align: left; border: 1px solid var(--line); opacity: .45; display: flex; flex-direction: column; gap: 10px; }
  .h-card.sel { opacity: 1; border-color: var(--fg); border-bottom-color: var(--red); }
  .c-name { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
  .c-num { font-family: var(--mono); font-weight: 300; font-size: 48px; line-height: 1; }
  .c-num small { font-size: 16px; color: var(--fg-2); margin-left: 4px; }
  .c-glyph { display: flex; gap: 4px; min-height: 6px; }
  .c-glyph i { width: 5px; height: 5px; border-radius: 50%; border: 1px solid var(--fg-3); }
  .c-glyph i.on { background: var(--fg); border-color: var(--fg); }
  .h-tile { width: 172px; min-height: 112px; padding: 16px; text-align: left; border: 1px solid var(--line); opacity: .45; display: flex; flex-direction: column; gap: 8px; }
  .h-tile.sel { opacity: 1; border-color: var(--fg); border-bottom-color: var(--red); }
  .t-ico { width: 26px; height: 26px; fill: none; stroke: var(--fg); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
  .h-tile.sel .t-ico { stroke: var(--red); }
  .t-name { font-size: 22px; font-weight: 500; }
  .t-obj { font-size: 13px; color: var(--fg-2); }
  .t-best { margin-top: auto; font-family: var(--mono); font-size: 12px; color: var(--fg); min-height: 14px; }
  .h-track { position: relative; }


  .h-foot { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 520px; gap: 16px; }
  .h-btn { min-width: 120px; }
  #title[data-step="paint"] #h-back { visibility: hidden; }
  .h-dots { display: flex; gap: 10px; }
  .h-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3); transition: background .3s, transform .3s; cursor: pointer; }
  .h-dots i.on { background: var(--fg); transform: scale(1.3); }
  .h-keys { position: absolute; right: var(--gutter); bottom: var(--gutter); font-size: 10px; color: var(--fg-3); display: flex; gap: 4px; }
  .h-keys kbd { font-family: var(--mono); font-size: 10px; border: 1px solid rgba(255,255,255,.18); padding: 1px 5px; color: var(--fg-2); }
  @media (max-width: 720px) { .h-keys { display: none; } .h-head { gap: 8px; } .h-card, .h-tile { width: calc(50% - 7px); } .h-sw { width: 44px; height: 44px; } }
  /* ---------- HUD ---------- */
  .hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-variant-numeric: tabular-nums; }
  .h-corner { position: absolute; width: 220px; padding-top: 10px; border-top: 1px solid var(--line); }
  .h-tl { top: var(--gutter); left: var(--gutter); }
  .h-tr { top: var(--gutter); right: var(--gutter); text-align: right; width: 160px; }
  .h-bl { bottom: var(--gutter); left: var(--gutter); }
  .h-br { bottom: var(--gutter); right: var(--gutter); width: 120px; text-align: right; }
  .h-num { font-family: var(--mono); font-weight: 300; line-height: 1; color: var(--fg); }
  .h-num-md { font-size: 28px; margin: 8px 0 10px; }
  .h-num-md span { font-size: 13px; color: var(--fg-2); }
  .h-num-xl { font-size: clamp(56px, 8vw, 96px); letter-spacing: -.03em; }
  .h-mono, .h-row b { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--fg); }
  .h-rows { display: flex; flex-direction: column; }
  .h-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }
  .h-stats { flex-direction: row; gap: 24px; margin-top: 10px; }
  .h-stats .h-row { gap: 10px; }
  .h-sub { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-3); min-height: 14px; margin-top: 6px; }
  .h-rowhead { display: flex; justify-content: space-between; align-items: baseline; margin-top: 2px; }
  .h-rowhead + .h-bar { margin-top: 8px; }
  .h-bar { height: 1px; background: var(--line); overflow: hidden; }
  .h-bar i { display: block; height: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); transition: transform .12s linear; }
  .h-bar i.low { background: var(--red); }
  .h-bl .h-sub { margin-bottom: 14px; }
  .h-speed { position: absolute; left: 50%; bottom: var(--gutter); transform: translateX(-50%); text-align: center; }
  .h-speed .h-label { margin-top: 8px; }
  .h-flags { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 14px; margin-top: 8px;
    font-size: 10px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--red); }
  .h-flags i { width: 1px; height: 9px; background: var(--line); }
  .thr-svg { display: block; width: 64px; height: 118px; margin: 12px 0 6px auto; overflow: visible; }
  .thr-body, .thr-line { fill: none; stroke: rgba(255,255,255,.55); stroke-width: .035; }
  .thr-line { stroke: rgba(255,255,255,.25); }
  .thr-dot { fill: #000; stroke: rgba(255,255,255,.7); stroke-width: .04; transition: fill .15s, stroke .15s; }
  .thr-dot.on { fill: var(--fg); stroke: var(--red); }
  .thr-dot.off { stroke: rgba(255,255,255,.18); }
  .thr-dir { stroke: var(--red); stroke-width: .05; opacity: 0; transition: opacity .15s; }
  .thr-dir.on { opacity: 1; }
  .h-callouts { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; width: 90vw; }
  .h-callout { display: flex; align-items: baseline; gap: 14px; font-size: 13px; font-weight: 300; letter-spacing: .32em; text-transform: uppercase;
    opacity: 0; transform: translateY(4px); transition: opacity .2s ease, transform .2s ease; white-space: nowrap; }
  .h-callout.on { opacity: 1; transform: none; }
  .h-callout b { font-family: var(--mono); font-weight: 400; font-size: 12px; letter-spacing: .04em; color: var(--fg-2); }
  .h-callout.accent b, .h-callout.accent span { color: var(--fg); }
  .h-callout.accent::before { content: ""; width: 16px; height: 1px; background: var(--red); align-self: center; }
  .h-callout.bad span { color: var(--fg-3); }
  .h-combo { position: absolute; left: 50%; bottom: calc(var(--gutter) + 160px); transform: translateX(-50%); text-align: center;
    opacity: 0; transition: opacity .3s var(--ease); max-width: 90vw; }
  .h-combo.on { opacity: 1; }
  .h-combo .h-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .h-hint { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px;
    font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); opacity: 0; transition: opacity .3s var(--ease); white-space: nowrap; }
  .h-hint.on { opacity: 1; }
  .h-hint b { font-weight: 500; color: var(--fg); padding: 5px 9px; border: 1px solid var(--line); border-bottom-color: var(--red); }
  #toast { position: fixed; top: calc(var(--gutter) + 6px); left: 50%; transform: translateX(-50%); z-index: 12; font-size: 11px; font-weight: 500;
    letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); opacity: 0; transition: opacity .25s var(--ease); pointer-events: none; white-space: nowrap; }
  #toast.on { opacity: 1; }
  #speedlines { position: fixed; inset: 0; z-index: 9; pointer-events: none; opacity: 0;
    background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0) 0deg, rgba(255,255,255,.035) .3deg, rgba(255,255,255,0) 1deg, rgba(255,255,255,0) 5deg);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 40%, #000 80%); mask-image: radial-gradient(circle at 50% 50%, transparent 40%, #000 80%); }

  .stepnav { display: flex; gap: 28px; }
  .stepnav button { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-3); padding: 6px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
  .stepnav button.sel { color: var(--fg); border-color: var(--red); }
  .step { display: none; min-height: 120px; }
  .step.on { display: block; animation: fade .3s var(--ease); }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .swatches { display: flex; gap: 18px; padding-top: 6px; }
  .swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 1px solid var(--line); outline: 1px solid transparent; outline-offset: 4px; transition: outline-color .2s; }
  .swatch.sel { outline-color: var(--red); }
  .paint-name { margin-top: 16px; font-size: 12px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
  .levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); max-width: 860px; border-top: 1px solid var(--line); }
  .lvl { display: grid; grid-template-columns: 34px 1fr; gap: 2px 8px; text-align: left; padding: 12px 16px 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); opacity: .55; transition: opacity .2s; position: relative; }
  .lvl:hover, .lvl.sel { opacity: 1; }
  .lvl.sel::before { content: ""; position: absolute; left: 0; top: -1px; width: 100%; height: 1px; background: var(--red); }
  .lvl .n { font-family: var(--mono); font-size: 11px; color: var(--fg-3); grid-row: span 2; padding-top: 2px; }
  .lvl .t { font-size: 14px; font-weight: 500; }
  .lvl .o { font-size: 12px; color: var(--fg-2); }
  .primary, .ghost { min-width: 140px; height: 44px; padding: 0 22px; border: 1px solid var(--fg); font-size: 12px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; transition: background .25s var(--ease), color .25s var(--ease); }
  .ghost { border-color: var(--line); color: var(--fg-2); }
  .primary:hover, .primary:focus-visible { background: var(--fg); color: var(--bg); outline: none; }
  .ghost:hover, .ghost:focus-visible { border-color: var(--fg); color: var(--fg); outline: none; }
  [hidden] { display: none !important; }
  .letterbox { position: fixed; inset: 0; z-index: 25; pointer-events: none; opacity: 0; transition: opacity .4s var(--ease); }
  .letterbox.on { opacity: 1; }
  .letterbox::before, .letterbox::after { content: ""; position: absolute; left: 0; right: 0; height: var(--lb, 11vh); background: #000; transition: transform .4s var(--ease); }
  .letterbox::before { top: 0; transform: translateY(-100%); } .letterbox::after { bottom: 0; transform: translateY(100%); }
  .letterbox.on::before, .letterbox.on::after { transform: none; }
  .letterbox .lt { position: absolute; left: var(--gutter); bottom: calc(var(--lb, 11vh) + 18px); z-index: 1; font-size: 11px; font-weight: 500; letter-spacing: .24em; text-transform: uppercase; color: var(--fg);
    padding-left: 12px; border-left: 1px solid var(--red); }
  .h-watch { position: absolute; top: calc(var(--gutter) + 26px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
    font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); padding: 6px 2px; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; white-space: nowrap; }
  .h-watch span { font-size: 9px; color: var(--red); letter-spacing: 0; }
  .h-watch:hover, .h-watch:focus-visible { color: var(--fg); border-color: var(--red); outline: none; }
  .cineblack { position: fixed; inset: 0; z-index: 24; background: #000; opacity: 0; pointer-events: none; }
  .cinecard { position: fixed; inset: 0; z-index: 26; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; opacity: 0; pointer-events: none; text-align: center; }
  .cc-title { font-size: clamp(14px, 1.6vw, 18px); font-weight: 300; letter-spacing: .5em; text-transform: uppercase; padding-left: .5em; }
  .cc-big { font-size: clamp(48px, 9vw, 120px); font-weight: 300; letter-spacing: -.02em; }
  .cc-sub { font-size: 12px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--fg-2); }
  .demotel { position: fixed; z-index: 26; left: var(--gutter); bottom: calc(var(--lb, 11vh) + 54px); width: 240px; pointer-events: none; display: none; font-variant-numeric: tabular-nums; }
  .demotel.on { display: block; }
  .dt-list { line-height: 1.7; color: var(--fg); }
  .dt-black { position: fixed; inset: 0; z-index: 24; background: #000; opacity: 0; pointer-events: none; }
  .dt-title { position: fixed; inset: 0; z-index: 27; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none;
    font-size: clamp(13px, 1.4vw, 16px); font-weight: 300; letter-spacing: .5em; text-transform: uppercase; padding-left: .5em; }
  .dt-item { position: absolute; left: 0; bottom: 0; width: 100%; padding-top: 10px; border-top: 1px solid var(--line); opacity: 0; transform: translateY(6px); transition: opacity .4s var(--ease), transform .4s var(--ease); }
  .dt-item.on { opacity: 1; transform: none; }
  .dt-label { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }
  .dt-red { color: var(--red); }
  .dt-num { margin: 8px 0 6px; display: flex; align-items: baseline; gap: 8px; }
  .dt-num b { font-family: var(--mono); font-weight: 300; font-size: 34px; line-height: 1; }
  .dt-num span { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }
  .dt-sub { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-2); margin-top: 6px; }
  .dt-sub b { font-family: var(--mono); font-weight: 400; color: var(--fg); letter-spacing: 0; }
  .dt-bar { height: 1px; background: var(--line); overflow: hidden; margin-top: 4px; }
  .dt-bar i { display: block; height: 100%; background: var(--fg); transform-origin: left; transform: scaleX(1); transition: transform .15s linear; }
  .dt-svg { display: block; width: 58px; height: 106px; margin-top: 10px; overflow: visible; }
  @media (max-width: 720px) { .demotel { width: 190px; } .dt-num b { font-size: 26px; } }
  .levelbar { position: fixed; z-index: 11; top: calc(var(--gutter) + 26px); left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; transition: opacity .3s var(--ease); max-width: 60vw; }
  .levelbar.on { opacity: 1; }
  .lb-name { font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
  .lb-obj { font-size: 12px; color: var(--fg-2); margin-top: 4px; }
  .lb-row { display: flex; justify-content: center; gap: 14px; margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--fg); }
  .lb-status { color: var(--red); }
  .overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
  .overlay.on { opacity: 1; pointer-events: auto; }
  .card { width: min(420px, 100%); border-top: 1px solid var(--red); background: #000; padding: 28px; }
  .r-title { font-size: 32px; font-weight: 300; margin: 10px 0 22px; }
  .overlay.fail .r-title { color: var(--fg-2); }
  .r-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
  .r-stats b { display: block; font-family: var(--mono); font-weight: 300; font-size: 24px; margin-top: 6px; }
  .r-detail { font-size: 12px; color: var(--fg-2); min-height: 16px; margin: 14px 0 22px; }
  .r-actions { display: flex; gap: 10px; flex-wrap: wrap; }
  .r-actions.col { flex-direction: column; margin-top: 18px; }
  .r-actions button { flex: 1; min-width: 0; }
  @media (max-width: 720px) { .levelbar { top: calc(var(--gutter) + 90px); max-width: 90vw; } .levels { grid-template-columns: 1fr; } }
  @media (max-width: 720px) {
    .trims { grid-template-columns: 1fr; }
    .trim, .trim + .trim { padding: 14px 0; border-left: 0; border-bottom: 1px solid var(--line); }
    .trim .z { margin: 6px 0 2px; }
    .keys { grid-template-columns: 1fr; }
    .keys.open { max-height: 800px; }
    #start { width: 100%; }
    .h-corner { width: 150px; }
    .h-tr { width: 110px; }
    .h-br { display: none; }
    .h-speed { left: auto; right: var(--gutter); transform: none; text-align: right; }
    .h-num-md { font-size: 22px; }
    .h-stats { gap: 12px; }
    .h-callout { letter-spacing: .2em; font-size: 12px; }
    .h-combo { bottom: calc(var(--gutter) + 190px); }
  }
  @media (prefers-reduced-motion: reduce) { * { transition-duration: 0s !important; } }

/* ================= Proving Grounds additions ================= */
#title.hidden { opacity: 0; pointer-events: none; }
.h-settings, .h-garage { position: absolute; top: var(--gutter); display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); padding: 6px 2px; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.h-settings { left: var(--gutter); }
.h-garage { right: var(--gutter); }
.h-settings:hover, .h-garage:hover, #title[data-screen="garage"] .h-garage { color: var(--fg); border-color: var(--red); }
.g-sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c, #e9e7e1); border: 1px solid var(--line); }
.g-trim { font-size: 10px; color: var(--fg-3); letter-spacing: .14em; }
.h-kicker { font-size: 11px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase; color: var(--fg-3); min-height: 14px; }
.h-tile.locked, .h-tt.locked { opacity: .28; }
#title[data-screen="garage"] .h-track { flex-direction: column; align-items: center; gap: 22px; }
.g-row { display: flex; gap: 14px; justify-content: center; padding: 8px 12px; border-bottom: 1px solid transparent; transition: border-color .3s var(--ease); }
.g-row.focus { border-bottom-color: var(--red); }
.h-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; width: 100%; max-width: 1040px; }
.h-col { display: flex; flex-direction: column; gap: 8px; }
.h-colhead { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.h-colhead small { color: var(--fg-3); letter-spacing: .14em; }
.h-tt { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; text-align: left; padding: 10px 12px; border: 1px solid rgba(255,255,255,.1);
  opacity: .6; transition: opacity .2s, border-color .2s; min-height: 42px; }
.h-tt.sel { opacity: 1; border-color: var(--fg); border-bottom-color: var(--red); }
.h-final { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 18px; }
.h-tt.empty { color: var(--fg-3); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; }
.tt-n { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.tt-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-meta { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--fg-2); }
.tt-lock { width: 14px; height: 14px; fill: none; stroke: var(--fg-2); stroke-width: 1.4; }
.m-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--fg-3); margin-right: 6px; vertical-align: middle; }
.m-dot.m-bronze { background: #a5714a; border-color: #a5714a; }
.m-dot.m-silver { background: #b9bcc2; border-color: #b9bcc2; }
.m-dot.m-gold { background: #d4b46a; border-color: #d4b46a; }
.m-dot.m-demo { background: var(--red); border-color: var(--red); }
/* modal (pause / results / settings) */
.modal .card { max-height: 86vh; overflow: auto; }
.modal button.focus { outline: 1px solid var(--red); outline-offset: 3px; }
.modal .set-row.focus { border-bottom-color: var(--red); }
.r-actions.col button { flex: 0 0 auto; }
/* settings: volumes + toggles stay on screen, the key list scrolls (fits 900 px tall windows) */
.modal.settings .card { display: flex; flex-direction: column; }
.modal.settings .set-list { margin: 10px 0 12px; }
.modal.settings .set-keys-wrap { flex: 1 1 auto; min-height: 72px; overflow: auto; border-bottom: 1px solid rgba(255,255,255,.08); }
.modal.settings .set-keys { margin-bottom: 0; }
.modal.settings .r-actions.col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; flex: 0 0 auto; }
.modal.settings .r-actions button { min-width: 0; height: auto; min-height: 38px; padding: 6px 10px; font-size: 10px; letter-spacing: .14em; white-space: normal; }
.modal.settings .r-actions button.primary { grid-column: 1 / -1; min-height: 44px; }
.rr-time { font-family: var(--mono); font-weight: 300; font-size: 48px; margin: 12px 0 6px; }
.rr-medal { font-size: 12px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.rr-medal em { font-style: normal; color: var(--red); margin-left: 10px; }
.rr-pb { font-size: 12px; color: var(--fg-2); margin: 8px 0 14px; font-family: var(--mono); }
.rr-pb .behind, .rr-splits .behind, .r-split.behind { color: var(--red); }
.rr-splits { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; margin-bottom: 18px; }
.rr-splits td { padding: 6px 0; border-top: 1px solid rgba(255,255,255,.08); }
.rr-splits td:first-child { font-family: Inter, sans-serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-2); }
.rr-splits td:nth-child(2), .rr-splits td:nth-child(3) { text-align: right; }
.rr-unlock { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg); margin-bottom: 18px; border-left: 1px solid var(--red); padding-left: 10px; }
.set-list { display: flex; flex-direction: column; margin: 16px 0 22px; }
.set-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }
.set-row b { font-family: var(--mono); font-weight: 400; color: var(--fg); text-align: right; letter-spacing: 0; }
.set-row input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 1px; background: var(--line); outline: none; }
.set-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); cursor: pointer; }
.set-row input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--fg); border: 0; }
.set-toggle { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--fg-2); }
/* time-attack HUD */
.hud.run .r-top { position: absolute; top: var(--gutter); left: 50%; transform: translateX(-50%); text-align: center; }
.r-timer { font-family: var(--mono); font-weight: 300; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.01em; }
.r-split { font-family: var(--mono); font-size: 18px; min-height: 22px; margin-top: 4px; opacity: 0; transition: opacity .2s; }
.r-split.on { opacity: 1; }
.r-cp { font-size: 11px; letter-spacing: .2em; color: var(--fg-3); margin-top: 4px; min-height: 14px; font-family: var(--mono); }
.r-target { font-size: 12px; margin: 10px 0 6px; } .r-target b { font-family: var(--mono); font-weight: 400; margin-left: 6px; }
.r-fan { margin-top: 12px; }
.r-big { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(56px, 10vw, 120px); font-weight: 300; letter-spacing: -.02em;
  opacity: 0; transition: opacity .2s; text-transform: uppercase; }
.r-big.on { opacity: 1; }
.r-bigsub { position: absolute; top: calc(34% + clamp(40px, 6vw, 70px)); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 500; letter-spacing: .3em;
  text-transform: uppercase; color: var(--red); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.r-bigsub.on { opacity: 1; }
/* stunt show bar */
.hud.show .s-top { position: absolute; top: calc(var(--gutter) + 4px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.s-clock { font-family: var(--mono); font-weight: 300; font-size: 30px; }
.s-clock.low { color: var(--red); }
.s-hype { display: flex; align-items: center; gap: 10px; width: 220px; } .s-hype .h-bar { flex: 1; }
.s-list { display: flex; gap: 12px; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--fg-3); }
.s-ch.done { color: var(--fg); border-bottom: 1px solid var(--red); }
@media (max-width: 720px) { .h-grid { grid-template-columns: 1fr; } .s-list { display: none; }
  .h-track.campaign, .h-track.timeattack { max-height: 50vh; overflow-y: auto; } } /* one column of 16: scroll, selection kept in view */
#title, .hud, .modal { -webkit-user-select: none; user-select: none; }
/* phones: Settings + Garage share the top row, brand and Watch drop below them; the foot buttons fit 360 px */
@media (max-width: 520px) {
  .h-brand { top: calc(var(--gutter) + 40px); }
  .h-watch { top: calc(var(--gutter) + 64px); }
  .g-trim { display: none; }
  .h-foot { gap: 10px; }
  .h-btn { min-width: 96px; }
}

.h-card.locked { opacity: .3; } .h-card .tt-lock { margin-left: 8px; vertical-align: -2px; } .c-need { font-style: normal; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-3); }

/* ================= touch devices (html.touch, set by src/ui/touch.js) ================= */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html.touch, html.touch body, html.touch #game canvas { touch-action: none; }
html.touch button { touch-action: manipulation; }
html.touch .h-track, html.touch .modal .card, html.touch .set-keys-wrap { touch-action: pan-y; -webkit-overflow-scrolling: touch; }
/* safe areas (notch / home indicator): every overlay layer shrinks to the safe rectangle */
#title, .hud, .touchui { top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px); bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px); }
#toast { margin-top: env(safe-area-inset-top, 0px); }
.modal { padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
html.touch .h-keys { display: none !important; }

.touchui { position: fixed; z-index: 11; display: none; pointer-events: none; -webkit-user-select: none; user-select: none; }
html.touch.driving .touchui { display: block; }
.t-zone { position: absolute; left: 0; bottom: 0; width: 46%; height: 72%; pointer-events: auto; touch-action: none; }
.t-base { position: absolute; left: 22%; top: 62%; width: 128px; height: 128px; margin: -64px 0 0 -64px; border-radius: 50%; border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.12); opacity: .45; transition: opacity .15s; }
.t-base.on { opacity: 1; transition: none; }
.t-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.5); transform: translate(-50%, -50%); }
.t-top { position: absolute; top: var(--gutter); left: var(--gutter); display: flex; gap: 10px; pointer-events: auto; }
.t-btn { pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid rgba(255,255,255,.32);
  background: rgba(0,0,0,.28); color: var(--fg); font-size: 10px; font-weight: 500; letter-spacing: .14em; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.t-btn.on { background: rgba(255,255,255,.28); border-color: var(--fg); }
.t-btn[hidden] { display: none; }
.t-pause, .t-cam { width: 42px; height: 42px; font-size: 9px; }
.t-pause { gap: 4px; } .t-pause i { width: 3px; height: 13px; background: var(--fg); }
.t-pad { position: absolute; right: var(--gutter); bottom: var(--gutter); width: 260px; height: 230px; }
.t-pad .t-btn { position: absolute; }
.t-gas { right: 0; bottom: 0; width: 92px; height: 92px; border-color: rgba(255,255,255,.55); }
.t-brake { right: 104px; bottom: 0; width: 70px; height: 70px; }
.t-boost { right: 10px; bottom: 104px; width: 64px; height: 64px; border-color: rgba(227,25,55,.7); }
.t-lift { right: 86px; bottom: 86px; width: 60px; height: 60px; }
.t-fan { right: 186px; bottom: 6px; width: 56px; height: 56px; }
.t-fan.latched { background: rgba(227,25,55,.35); border-color: var(--red); }
.t-rl, .t-rr { width: 46px; height: 46px; font-size: 18px; letter-spacing: 0; bottom: 168px; }
.t-rl { right: 132px; } .t-rr { right: 80px; }
/* HUD room for the controls: pause sits top-left, corner stats move down under it; thruster diagram hidden */
html.touch .hud .h-tl { top: calc(var(--gutter) + 52px); }
html.touch .hud .h-br { display: none; }
html.touch .hud .h-bl { bottom: auto; top: calc(var(--gutter) + 52px); }
html.touch .hud:not(.run) .h-tl { width: 210px; }
html.touch .hud:not(.run) .h-tl .h-rows, html.touch .hud:not(.run) .h-bl .h-stats, html.touch .hud:not(.run) .h-bl .h-sub { display: none; }
html.touch .hud:not(.run) .h-bl { top: calc(var(--gutter) + 132px); width: 210px; }
html.touch .hud .h-label, html.touch .hud .h-mono { white-space: nowrap; }
html.touch .hud .h-speed { left: 50%; right: auto; transform: translateX(-50%); text-align: center; }
/* portrait while driving: ask for landscape */
.rotate-hint { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: #000; text-align: center; }
.rotate-hint div { display: flex; flex-direction: column; align-items: center; gap: 16px; font-size: 11px; font-weight: 500; letter-spacing: .24em; text-transform: uppercase; color: var(--fg-2); }
.rotate-hint svg { width: 46px; height: 46px; fill: none; stroke: var(--fg); stroke-width: 1.2; }
@media (orientation: portrait) { html.touch.inrun .rotate-hint { display: flex; } }
@media (max-height: 480px) { html.touch .hud .h-num-xl { font-size: 54px; } html.touch .t-pad { transform: scale(.88); transform-origin: right bottom; } }
/* short landscape screens (phones on their side): one compact tile row, scrolling track grid */
@media (max-height: 480px) {
  #title { padding-top: 8px; padding-bottom: 10px; }
  .h-stage { gap: 8px; }
  .h-name { font-size: 28px; } .h-kicker { display: none; }
  .h-track { flex-wrap: nowrap; gap: 8px; padding: 4px; }
  .h-tile { width: 132px; min-height: 0; padding: 10px 12px; gap: 2px; }
  .h-tile .t-ico { display: none; } .t-name { font-size: 15px; } .t-obj { font-size: 11px; }
  .h-card { width: 150px; padding: 12px; } .c-num { font-size: 32px; }
  .h-track.campaign, .h-track.timeattack { max-height: 48vh; overflow-y: auto; flex-wrap: wrap; }
  .h-colhead { padding-bottom: 4px; } .h-tt { min-height: 32px; padding: 6px 10px; } .h-col { gap: 5px; } .h-grid { gap: 10px; }
  .h-foot .h-btn { height: 38px; }
  #title[data-screen="garage"] .h-track { gap: 8px; }
}
