* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1b1d16; color: #e9e3cf; overflow: hidden;
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

#sceneWrap { position: relative; flex: 1 1 auto; min-height: 150px; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#topbar { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; align-items: center; gap: 10px;
  font-size: 13px; letter-spacing: .04em; text-shadow: 0 1px 2px #000; pointer-events: none; }
#topbar #runName { font-weight: 700; text-transform: uppercase; }
#topbar #progress { flex: 1; opacity: .8; }
#topbar button { pointer-events: auto; }
.icon { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #ffffff33; background: #00000055; font-weight: 700; }
.icon.off { opacity: .45; text-decoration: line-through; }
#hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: min(92%, 640px);
  background: #12140ecc; border: 1px solid #c8b98a55; border-radius: 8px; padding: 6px 12px; font-size: 14px;
  text-align: center; pointer-events: none; opacity: 0; transition: opacity .2s; }
#hint.show { opacity: 1; }
#hint.warn { border-color: #e0643f; color: #ffd8c8; }
#hint.good { border-color: #7fbf5a; color: #dff5cf; }

#console { flex: 0 0 auto; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: 1fr minmax(260px, 2.2fr) minmax(150px, 1.2fr) 0.8fr;
  grid-template-areas: "left dash gate right"; height: 230px;
  background: linear-gradient(#2a2c22, #1e2018); border-top: 2px solid #4b5320; }
#left { grid-area: left; } #right { grid-area: right; } #dashWrap { grid-area: dash; } #gateWrap { grid-area: gate; }
#dashWrap, #gateWrap { position: relative; min-height: 0; }
#dash, #gate { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gate { touch-action: none; }
.pedals { display: flex; gap: 8px; min-height: 0; }
.pedal { flex: 1; position: relative; border-radius: 10px; border: 2px solid #0008; overflow: hidden;
  background: repeating-linear-gradient(0deg, #3b3d33 0 6px, #2f3129 6px 12px); box-shadow: inset 0 -6px 0 #0006;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: none; }
.pedal b { font-size: 13px; letter-spacing: .08em; position: relative; z-index: 1; }
.pedal small { opacity: .55; font-size: 11px; position: relative; z-index: 1; }
.pedal.down { transform: translateY(3px); box-shadow: inset 0 -2px 0 #0006; filter: brightness(1.35); }
.pedal.clutch.down { border-color: #e0b84a; }
.pedal.brake.down { border-color: #e0643f; }
.pedal.gas.down { border-color: #7fbf5a; }
.pedal.disabled { opacity: .35; }
#gasFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: #7fbf5a44; }
.start { position: absolute; right: 4px; bottom: 4px; padding: 6px 10px; border-radius: 8px; border: 1px solid #e0643f;
  background: #4a1d12; font-weight: 700; display: none; }
.start.show { display: block; animation: pulse 1s infinite; }
.start small { opacity: .6; font-weight: 400; }
@keyframes pulse { 50% { filter: brightness(1.5); } }

@media (max-width: 760px) {
  #console { grid-template-columns: 1.1fr 1.3fr 0.8fr; grid-template-rows: 150px 1fr;
    grid-template-areas: "dash dash dash" "left gate right"; height: 330px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #console { height: 150px; grid-template-columns: 1fr 1.7fr 1.2fr 0.7fr; grid-template-rows: 1fr;
    grid-template-areas: "left dash gate right"; }
  #sceneWrap { min-height: 120px; }
}

/* overlays */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, #1b1d16cc, #0b0c08f2); z-index: 10; }
.overlay.show { display: flex; }
.card { max-width: 620px; width: 100%; background: #24261d; border: 1px solid #4b5320; border-radius: 14px;
  padding: 20px 22px; box-shadow: 0 12px 40px #000a; }
.card.scroll { max-height: calc(100% - 10px); overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.card h1 { font-size: 46px; letter-spacing: .12em; margin: 2px 0 8px; color: #f0e6c4;
  text-shadow: 3px 3px 0 #8a2a1a; }
.card h2 { margin: 2px 0 10px; color: #f0e6c4; }
.card h3 { margin: 14px 0 6px; font-size: 15px; color: #c8b98a; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .18em; font-size: 12px; color: #c9473a; font-weight: 700; }
.lede { font-size: 16px; }
.fine { font-size: 12.5px; opacity: .7; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row.col { flex-direction: column; }
.row button, #runList button { padding: 10px 16px; border-radius: 10px; border: 1px solid #6b7340; background: #33362a; }
.row button.primary { background: #8a2a1a; border-color: #c9473a; font-weight: 700; }
.row button:focus-visible, #runList button:focus-visible { outline: 2px solid #e0b84a; }
ol { padding-left: 22px; } li { margin: 4px 0; }
.cw { color: #fff7e0; } .ca { color: #f0a640; } .cg { color: #8fe06a; }
table.keys { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.keys td { padding: 3px 6px; border-bottom: 1px solid #ffffff14; }
table.keys td:first-child { color: #c8b98a; white-space: nowrap; }
#runList { display: flex; flex-direction: column; gap: 8px; }
#runList button { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; text-align: left; width: 100%; }
#runList .n { font-size: 20px; font-weight: 800; color: #c9473a; text-align: center; }
#runList .t b { display: block; } #runList .t small { opacity: .7; }
#runList .g { font-size: 22px; font-weight: 800; min-width: 30px; text-align: center; color: #e0b84a; }
.grade { font-size: 64px; font-weight: 900; line-height: 1; margin: 6px 0 10px; color: #e0b84a; text-shadow: 3px 3px 0 #000; }
.grade small { font-size: 18px; font-weight: 600; color: #e9e3cf; margin-left: 10px; text-shadow: none; }
table.log { width: 100%; border-collapse: collapse; font-size: 14px; }
table.log td { padding: 3px 4px; border-bottom: 1px dashed #ffffff1c; }
table.log td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .start.show { animation: none; } #hint { transition: none; } }
