/* Sparks & Sprockets — Paper Workshop warmth + Field Guide clarity. */
:root {
  --paper: #fff4dc;
  --paper-2: #f6e3bd;
  --paper-3: #e7cc98;
  --card: #fffaf0;
  --ink: #1b2a33;
  --ink-soft: #4b5d66;
  --navy: #1f3442;
  --navy-2: #2a4657;
  --yellow: #f5b335;
  --yellow-d: #d48e17;
  --orange: #f2694a;
  --teal: #2aa6a3;
  --teal-d: #1d7f7d;
  --green: #78b061;
  --green-l: #c3e0a8;
  --wood: #b9773f;
  --wood-d: #8a5328;
  --sky: #cfe8ea;
  --red: #d24a30;
  --radius: 18px;
  --shadow: 0 5px 0 var(--ink);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next Rounded", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --brand: "Arial Rounded MT Bold", ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--teal); outline-offset: 3px; border-radius: 10px; }

/* ---------- buttons: chunky, physical ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; min-width: 52px; padding: .55em 1.1em;
  background: var(--card); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: var(--shadow); font-weight: 800; font-size: 1.05rem; cursor: pointer;
  transition: transform .08s, box-shadow .08s; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:active:not(:disabled), .btn.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--yellow); }
.btn.go { background: var(--green); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.small { min-height: 44px; min-width: 44px; padding: .35em .8em; font-size: .95rem; border-radius: 13px; }
.btn.icon { padding: 0; width: 52px; }
.btn.big { min-height: 64px; font-size: 1.25rem; padding: .6em 1.6em; border-radius: 20px; }
.btn svg { width: 1.3em; height: 1.3em; flex: none; }

/* ---------- top bar ---------- */
.topbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--paper-2); border-bottom: 3px solid var(--ink); z-index: 5; }
.brand { font-weight: 900; font-size: 1.05rem; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.brand small { display: block; font-weight: 700; font-size: .72rem; color: var(--ink-soft); letter-spacing: 0; margin-top: 3px; }
.goal { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .95rem; }
.goal span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); flex: none; }
.parts-chip { display: flex; gap: 4px; align-items: center; font-weight: 800; font-size: .9rem; white-space: nowrap; }
.parts-chip i { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); background: var(--paper-3); display: inline-block; }
.parts-chip i.on { background: var(--yellow); }
.scene { flex: 1; min-height: 0; position: relative; overflow: hidden; }

/* ---------- title ---------- */
.title-screen { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(#dcece6, #f7f0e1 70%); overflow: auto; }
.title-card { text-align: center; padding: 24px 16px; max-width: 820px; }
.title-card h1 { font-size: clamp(2.4rem, 8vw, 4.2rem); line-height: .95; margin: 0 0 .1em; font-weight: 900; letter-spacing: -.01em; }
.title-card h1 .amp { color: var(--orange); }
.title-card p { font-size: 1.1rem; color: var(--ink-soft); margin: .4em 0 1.2em; }
.title-art { width: min(420px, 90vw); height: auto; display: block; margin: 0 auto 8px; }
.title-actions { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.title-foot { margin-top: 18px; font-size: .85rem; color: var(--ink-soft); }

/* ---------- world ---------- */
.world-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.world-ui { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); pointer-events: none; }
.world-ui > * { pointer-events: auto; }
.walk-pad { display: flex; gap: 10px; }
.walk-pad .btn { width: 64px; height: 64px; font-size: 1.6rem; }
.here-card { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; display: flex; align-items: center; gap: 12px; max-width: min(460px, 60vw); }
.here-card b { display: block; font-size: 1.05rem; }
.here-card small { color: var(--ink-soft); font-weight: 600; }
.stop-hit { cursor: pointer; }
.stop-label { font-weight: 800; font-size: 20px; }
.badge-done { font-weight: 900; }
.sign { cursor: pointer; }

/* ---------- panels / dialogs ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(38,54,64,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); max-width: 560px; width: 100%; max-height: calc(100% - 20px); overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 .3em; font-size: 1.5rem; }
.modal p { line-height: 1.45; margin: .4em 0; }
.modal .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.speech { position: relative; background: var(--card); border: 3px solid var(--ink); border-radius: 18px; padding: 10px 14px; font-weight: 700; line-height: 1.35; }
.toast { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; z-index: 60; max-width: calc(100% - 24px); text-align: center; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.reward-art { width: 180px; height: 130px; display: block; margin: 0 auto 6px; }
.reward-card { text-align: center; }
.reward-card .tag { display: inline-block; background: var(--yellow); border: 2.5px solid var(--ink); border-radius: 999px; padding: 4px 12px; font-weight: 900; margin-bottom: 6px; }

/* ---------- encounter ---------- */
.enc { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr); background: var(--paper); }
.enc-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 2.5px dashed var(--paper-3); }
.enc-head h2 { margin: 0; font-size: 1.3rem; line-height: 1.1; }
.enc-head h2 small { display: block; font-size: .86rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.enc-head .spacer { flex: 1; }
.enc-stage { position: relative; min-height: 0; }
.enc-stage svg.stage { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.enc-side { border-left: 3px solid var(--ink); background: var(--paper-2); padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.enc-side h3 { margin: 0; font-size: 1rem; }
.robot-bubble { display: flex; gap: 10px; align-items: flex-start; }
.robot-bubble svg { width: 58px; height: 70px; flex: none; }
.control { background: var(--card); border: 2.5px solid var(--ink); border-radius: 16px; padding: 10px 12px; }
.control label { font-weight: 800; display: block; margin-bottom: 6px; }
.control * + label { margin-top: 12px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper output { flex: 1; text-align: center; font-weight: 900; font-size: 1.2rem; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row .btn.sel { background: var(--yellow); }
.meters { display: grid; gap: 8px; }
.meter { font-weight: 700; font-size: .92rem; }
.meter .bar { position: relative; height: 18px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; margin-top: 3px; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--teal); border-radius: 999px; transition: width .25s; }
.meter .fill.bad { background: var(--orange); }
.meter .mark { position: absolute; top: -3px; bottom: -3px; width: 4px; background: var(--ink); }
.meter .val { float: right; font-variant-numeric: tabular-nums; }
.feedback { font-weight: 800; line-height: 1.35; padding: 10px 12px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; min-height: 3em; }
.feedback.good { background: #dff0d2; }
.feedback.bad { background: #fde3d6; }
.hint-box { background: #fff7d6; border: 2.5px dashed var(--yellow-d); border-radius: 14px; padding: 8px 12px; font-weight: 700; }
.guide { font-size: .88rem; color: var(--ink-soft); line-height: 1.4; }
.guide b { color: var(--ink); }
.enc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.enc-actions .btn { flex: 1; }
.expert-chip { display: inline-block; background: var(--teal); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 900; }
.handle { cursor: grab; }
.handle:active { cursor: grabbing; }
.handle-ring { fill: var(--yellow); stroke: var(--ink); stroke-width: 3; }
.pulse { animation: pulse 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.12); } }
/* Straining: a steady crouch, not a shake (it's redrawn every frame, so it must not animate). */
.strain { transform: translateY(3px) scale(1.05, .93); transform-box: fill-box; transform-origin: 50% 100%; }
.stage-label { font-family: var(--font); font-weight: 800; fill: var(--ink); }
.stage-note { font-family: var(--font); font-weight: 700; fill: var(--ink-soft); }

/* ---------- workshop ---------- */
.shop { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr) auto; }
.shop-board { position: relative; min-height: 0; background:
  linear-gradient(var(--paper) 0 0) padding-box,
  repeating-linear-gradient(0deg, transparent 0 39px, rgba(47,127,134,.12) 39px 40px),
  repeating-linear-gradient(90deg, transparent 0 39px, rgba(47,127,134,.12) 39px 40px);
  background: #f3ead6; background-image: repeating-linear-gradient(0deg, transparent 0 39px, rgba(47,127,134,.13) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(47,127,134,.13) 39px 40px); }
.shop-board svg { width: 100%; height: 100%; display: block; touch-action: none; }
.socket { cursor: pointer; }
.socket .ring { fill: rgba(255,255,255,.55); stroke: var(--ink-soft); stroke-width: 2.5; stroke-dasharray: 7 6; }
.socket.ok .ring { stroke: var(--teal); stroke-width: 4; fill: rgba(47,127,134,.18); stroke-dasharray: none; }
.socket.hover .ring { fill: rgba(242,182,50,.5); stroke: var(--ink); }
.socket.filled .ring { stroke: transparent; fill: transparent; }
.socket.sel .ring { stroke: var(--yellow-d); stroke-width: 5; stroke-dasharray: none; fill: rgba(242,182,50,.25); }
.socket text { font-family: var(--font); font-weight: 800; font-size: 15px; fill: var(--ink-soft); pointer-events: none; }
.shop-side { border-left: 3px solid var(--ink); background: var(--paper-2); padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.shop-tray { grid-column: 1 / -1; border-top: 3px solid var(--ink); background: var(--paper-2); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 10px; overflow-x: auto; align-items: stretch; }
.part-card { flex: none; width: 108px; min-height: 104px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6px 4px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; font-weight: 800; font-size: .88rem; text-align: center; line-height: 1.1; position: relative; }
.part-card svg { width: 84px; height: 56px; pointer-events: none; }
.part-card.sel { background: var(--yellow); }
.part-card.empty { opacity: .4; box-shadow: none; cursor: default; }
.part-card .count { position: absolute; top: -9px; right: -9px; background: var(--ink); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; display: grid; place-items: center; font-size: .8rem; }
.part-card.new::after { content: 'NEW'; position: absolute; top: -10px; left: -8px; background: var(--orange); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-size: .65rem; padding: 2px 6px; }
.drag-ghost { position: fixed; pointer-events: none; z-index: 70; width: 96px; height: 70px; transform: translate(-50%, -50%) scale(1.1); filter: drop-shadow(0 6px 0 rgba(38,54,64,.35)); }
.stat-list { display: grid; gap: 8px; }
.missing { color: var(--red); font-weight: 800; font-size: .92rem; }
.route-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.route-pick .btn { flex-direction: column; gap: 2px; font-size: .92rem; line-height: 1.1; padding: .5em; }
.route-pick .btn small { font-weight: 700; font-size: .84rem; color: var(--ink-soft); }
.route-pick .btn.sel { background: var(--yellow); }
.inspect { background: var(--card); border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; font-size: .92rem; line-height: 1.35; }

/* ---------- race ---------- */
.race { position: absolute; inset: 0; display: flex; flex-direction: column; background: linear-gradient(#dcece6, #f2ead6); }
.race-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 14px; flex-wrap: wrap; }
.race-head > .btn { flex: none; white-space: nowrap; }
.race-head .mara-quip { flex: 1 1 14ch; max-width: 34ch; min-width: 0; }
.race-head .clock { font-weight: 900; font-size: 1.6rem; font-variant-numeric: tabular-nums; min-width: 5ch; }
.race-lanes { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; }
.lane { position: relative; min-height: 0; border-top: 2.5px dashed rgba(38,54,64,.25); }
.lane svg { width: 100%; height: 100%; display: block; padding: 6px 8px; box-sizing: border-box; }
.lane-tag { position: absolute; left: 12px; top: 8px; font-weight: 900; background: var(--card); border: 2.5px solid var(--ink); border-radius: 999px; padding: 3px 12px; font-size: .9rem; z-index: 2; }
.race-gauges { flex: none; display: flex; gap: 14px; padding: 8px 14px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--paper-2); border-top: 3px solid var(--ink); align-items: center; flex-wrap: wrap; }
.race-gauges .meter { flex: 1; min-width: 140px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 7rem; font-weight: 900; color: var(--ink); text-shadow: 0 5px 0 var(--yellow); pointer-events: none; z-index: 10; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.result-grid > div { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.result-grid b { display: block; font-size: 1.4rem; }
.result-grid b { font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.result-grid small { display: block; color: var(--ink-soft); font-size: .85rem; }
.result-grid > div.win { background: #f2b632; }
.result-gap { margin: 0 0 10px; font-weight: 800; text-align: center; }
.diag { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; }
.diag svg { width: 48px; height: 48px; flex: none; }
.changes { font-size: .92rem; color: var(--ink-soft); margin: 6px 0 0; padding-left: 1.1em; }

/* ---------- notebook ---------- */
.notebook { background: #fdf8ec; background-image: repeating-linear-gradient(#fdf8ec 0 31px, #d9e6ea 31px 32px); }
.run-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--paper-3); }
.run-row svg { width: 120px; height: 64px; }
.run-row .meta { font-size: .9rem; line-height: 1.3; }
.stamp { display: inline-block; border: 2.5px solid var(--ink); border-radius: 10px; padding: 2px 8px; font-weight: 900; font-size: .8rem; margin: 2px; background: var(--card); }
.stamp.on { background: var(--yellow); }
.stamp.expert.on { background: var(--teal); color: #fff; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs .btn.sel { background: var(--yellow); }
.settings-note { font-weight: 600; color: var(--ink-soft); }
.btn.settings-title { display: block; width: 100%; margin-top: 14px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px dashed var(--paper-3); font-weight: 700; }

/* ---------- motion ---------- */
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before { animation: none !important; transition: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .enc { grid-template-columns: 1fr; grid-template-rows: auto minmax(220px, 46%) minmax(0, 1fr); }
  .enc-side { border-left: 0; border-top: 3px solid var(--ink); }
  .shop { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 42%) minmax(0, 1fr) auto; }
  .shop-side { border-left: 0; border-top: 3px solid var(--ink); }
  .here-card { max-width: none; flex: 1; }
}
@media (max-width: 560px) {
  .brand small, .parts-chip .lbl { display: none; }
  .topbar { gap: 6px; padding: 6px 8px; }
  .goal { font-size: .82rem; padding: 5px 10px; }
  .world-ui { flex-direction: column-reverse; align-items: stretch; }
  .walk-pad { justify-content: space-between; }
  .run-row { grid-template-columns: 84px 1fr; }
  .run-row svg { width: 84px; }
  .run-row .btn { grid-column: 1 / -1; }
  .result-grid b { font-size: 1.5rem; }
  .countdown { font-size: 5rem; }
  .part-card { width: 96px; }
}
.enc-side > *, .shop-side > * { flex-shrink: 0; }
.shop-board, .shop-tray, .enc-stage, .world-svg, .race-lanes { user-select: none; -webkit-user-select: none; }
.socket.ok.filled .ring { stroke: var(--teal); stroke-width: 4; fill: rgba(47,127,134,.12); stroke-dasharray: 8 5; }
.socket.ok.filled.hover .ring, .socket.ok.hover .ring { fill: rgba(242,182,50,.5); stroke: var(--ink); }
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .brand { font-size: .95rem; flex: 1; }
  .goal { order: 10; flex-basis: 100%; }
  .parts-chip i { width: 11px; height: 11px; }
  .topbar .btn.small { min-height: 40px; padding: .25em .6em; font-size: .88rem; }
  .topbar .btn.small.icon { width: 40px; min-width: 40px; }
  .enc-head { padding: 6px 10px; gap: 8px; }
  .enc-head h2 { font-size: 1.05rem; }
  .race-head .clock { font-size: 1.2rem; }
  .race-head { gap: 6px; padding: 6px 10px; }
  .race-gauges { gap: 6px; padding: 6px 10px; }
  .race-gauges .meter { min-width: 100%; font-size: .8rem; }
  .race-gauges .meter .bar { height: 12px; }
}
@media (max-width: 430px) { .parts-chip { display: none; } .brand { font-size: .9rem; } }
@media (max-width: 860px) {
  .enc-side .control { order: 1; } .enc-side .act-row { order: 2; } .enc-side .live { order: 3; }
  .enc-side .feedback { order: 4; } .enc-side .hint-box, .enc-side > div:has(.hint-box) { order: 5; }
  .enc-side .robot-bubble { order: 6; } .enc-side .robot-row { order: 7; } .enc-side .meters { order: 8; } .enc-side details { order: 9; }
  .enc-side { gap: 10px; padding: 10px; }
}
@media (max-width: 860px) { .shop-side .race-btn { order: -1; } }
@media (max-width: 900px) { .topbar { flex-wrap: wrap; row-gap: 6px; } .brand { flex: 1; } .goal { order: 10; flex-basis: 100%; } }

/* ---------- Sprocket Station (explorable building) ---------- */
.works-hud { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.works-hud > * { pointer-events: auto; }
.bag { display: flex; align-items: center; gap: 6px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; padding: 4px 10px; box-shadow: var(--shadow); min-height: 48px; }
.bag-label { font-weight: 900; font-size: .85rem; }
.bag-empty { color: var(--ink-soft); font-weight: 700; font-size: .85rem; }
.bag-item svg { width: 46px; height: 32px; display: block; }
.prompt { display: flex; align-items: center; gap: 10px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; padding: 6px 8px 6px 14px; box-shadow: var(--shadow); max-width: min(480px, 60vw); }
.prompt b { font-size: .95rem; }
.works-pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); pointer-events: none; }
.works-pad > div { display: flex; gap: 10px; pointer-events: auto; }
.btn.ctl { width: 68px; height: 68px; font-size: 1.6rem; border-radius: 20px; touch-action: none; opacity: .92; }
.btn.ctl.jump { width: 92px; background: var(--yellow); font-size: 1.15rem; }
.bob { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
@media (max-width: 560px) {
  .btn.ctl { width: 56px; height: 56px; font-size: 1.3rem; }
  .btn.ctl.jump { width: 72px; }
  .works-pad > div { gap: 6px; }
  .works-hud { flex-direction: column; }
  .prompt { max-width: none; }
}
.parts-chip i.carry { background: #fde3d6; }

/* ---------- Bold Cartoon chrome ---------- */
html, body { background: var(--navy); }
.brand-type { font-family: var(--brand); font-weight: 900; }
.btn { border-width: 4px; box-shadow: 0 5px 0 var(--ink); font-weight: 900; letter-spacing: .01em; }
.btn:active:not(:disabled), .btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: linear-gradient(#ffc957, var(--yellow) 55%, #eaa222); }
.btn.go { background: linear-gradient(#8fc679, var(--green) 55%, #64994f); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 2px var(--ink); }
.btn.teal { background: var(--teal); }
.topbar { background: var(--navy); border-bottom: 4px solid var(--ink); color: var(--paper); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.brand { font-family: var(--brand); font-weight: 900; color: var(--yellow); text-shadow: 0 2px 0 var(--ink); letter-spacing: .03em; }
.brand small { color: #a9c3cc; text-shadow: none; }
.goal { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); }
.goal .dot { background: var(--orange); }
.parts-chip { color: var(--paper); }
.parts-chip i { border-color: var(--paper); background: var(--navy-2); }
.parts-chip i.on { background: var(--yellow); border-color: var(--ink); }
.modal { border-width: 4px; box-shadow: 0 7px 0 var(--ink); background: var(--card); }
.modal h2 { display: inline-block; font-family: var(--brand); background: var(--wood); color: var(--paper); padding: 6px 16px; border: 4px solid var(--ink); border-radius: 12px; margin: -2px 0 10px; text-shadow: 0 2px 0 var(--ink); transform: rotate(-1deg); box-shadow: 0 4px 0 var(--ink); }
.toast { background: var(--navy); border: 3px solid var(--ink); box-shadow: 0 5px 0 rgba(0,0,0,.35); color: var(--paper); }
.enc-head, .race-head { background: var(--paper-2); border-bottom: 4px solid var(--ink); }
.enc-head h2 { font-family: var(--brand); }
.enc-side, .shop-side, .shop-tray, .race-gauges { background: var(--paper-2); }
.enc-side, .shop-side { border-left-width: 4px; }
.control, .feedback, .inspect, .speech, .here-card, .bag, .prompt { border-width: 3px; }
.speech { background: #fff; box-shadow: 0 4px 0 var(--ink); }
.part-card { border-width: 4px; box-shadow: 0 5px 0 var(--ink); }
.lane-tag { font-family: var(--brand); }
.title-screen { background: radial-gradient(ellipse at 50% 30%, #4a7f96 0%, #2a4657 45%, var(--navy) 100%); }
.title-card p { color: var(--paper); text-shadow: 0 2px 0 var(--ink); font-weight: 800; }
.title-foot { color: #a9c3cc !important; text-shadow: none !important; }
.title-card h1 { display: none; }
.title-logo { width: min(560px, 92vw); height: auto; display: block; margin: 0 auto 4px; filter: drop-shadow(0 8px 0 rgba(0,0,0,.35)); }
.title-cast { width: min(900px, 96vw); height: auto; display: block; margin: 0 auto 4px; }
.topbar .btn { color: var(--ink); }
.shop-board { background-color: #ecd6a8 !important; background-image: radial-gradient(circle, rgba(27,42,51,.22) 2.2px, transparent 2.6px) !important; background-size: 28px 28px !important; box-shadow: inset 0 0 0 8px var(--wood), inset 0 0 0 11px var(--ink); margin: 8px; border: 4px solid var(--ink); border-radius: 20px; }
.shop { background: var(--wood-d, #8a5a3c); }
.race { background: var(--navy); }
.lane { border-top: 4px solid var(--ink); }
.enc-stage { background: #f6e7c8; }
.stage-note { fill: #3b4a52; }

/* ---------------------------------------------------------------- challenge rooms & banter */
.scoreboard { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-weight: 800; }
.scoreboard b { font-family: var(--brand); font-size: 1.4rem; background: var(--yellow); border: 3px solid var(--ink); border-radius: 12px; padding: 0 10px; }
.scoreboard span { font-size: .88rem; color: var(--ink-soft); text-align: right; }
.shot-log { margin: 0; padding-left: 1.4em; font-weight: 700; font-size: .9rem; line-height: 1.5; }
.shot-log:empty { display: none; }
.medal-row { display: flex; flex-wrap: wrap; gap: 6px; }
.medal { border: 2.5px solid var(--ink); border-radius: 10px; padding: 2px 8px; font-weight: 900; font-size: .8rem; }
.medal.bronze { background: #e9b98a; } .medal.silver { background: #e3eaee; } .medal.gold { background: #ffd23f; } .medal.robot { background: var(--card); }
.big-score { font-family: var(--brand); font-size: 2rem; margin: .2em 0; }
.medal-art { width: 90px; height: 90px; display: block; margin: 0 auto; }
.modal.chat { max-width: 520px; }
.chat-row { display: flex; gap: 12px; align-items: center; }
.chat-face svg { width: 92px; height: 140px; flex: none; display: block; }
.chat-row .speech { flex: 1; font-size: 1.05rem; }
.modal.chat .actions { flex-direction: column; align-items: stretch; }
.modal.chat .actions .btn.reply { text-align: left; justify-content: flex-start; }
.modal.chat .actions .btn.small { align-self: flex-end; }
small.tone { display: inline-block; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; margin-right: 4px; vertical-align: 1px; background: var(--card); }
small.tone[data-tone="bold"] { background: #fbc1a8; } small.tone[data-tone="kind"] { background: #c9e7bd; } small.tone[data-tone="brainy"] { background: #bfe0f0; }
.you-said { color: var(--ink-soft); }
.chips { border-top: 2.5px dashed var(--paper-3); padding-top: 8px; margin-top: 6px; }
.chip-row { display: flex; flex-direction: column; gap: 6px; }
.chip-row .btn { text-align: left; justify-content: flex-start; }
.mara-quip { font-size: .9rem; max-width: 34ch; line-height: 1.3; background: var(--card); border: 2.5px solid var(--ink); border-radius: 14px; padding: 4px 10px; }
@media (max-width: 860px) { .mara-quip { display: none; } .scoreboard span { display: none; } }
.upgrades { margin: 0; padding-left: 1.2em; font-size: .9rem; line-height: 1.4; }
@media (max-width: 860px) {
  .challenge .enc-side > * { order: 10; }
  .challenge .enc-side .control { order: 1; } .challenge .enc-side .act-row { order: 2; }
  .challenge .enc-side .feedback { order: 3; } .challenge .enc-side .shot-log { order: 4; } .challenge .enc-side .robot-bubble { order: 5; }
}
.medal.best { background: #dff0d2; }
.changes-box summary { cursor: pointer; font-weight: 800; }
/* The buttons stay in view when a dialog scrolls (the Hall is taller than an iPad screen). */
.modal .actions { position: sticky; bottom: -20px; background: var(--card); padding: 10px 0 14px; margin-bottom: -20px; z-index: 2; }
.modal.hall-modal .actions { background: #f3e2bd; }

/* Calmer copy: short result line first, working folded underneath. */
.feedback:empty { display: none; }
details.numbers { margin-top: 6px; font-size: .85rem; }
details.numbers summary { cursor: pointer; font-weight: 700; opacity: .75; }
details.numbers p { margin: 4px 0 0; }
.medal-q { margin-left: 4px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); font: inherit; font-size: .75rem; font-weight: 800; line-height: 1; padding: 0; cursor: pointer; }

/* Challenge your rivals */
.modal.rivals { max-width: 520px; }
.rival-list { display: flex; flex-direction: column; gap: 10px; }
.rival-card { display: flex; align-items: center; gap: 12px; text-align: left; justify-content: flex-start; width: 100%; padding: 8px 12px; }
.rival-card.sel { box-shadow: 0 0 0 4px var(--yellow); }
.rival-card.locked { border: 3px dashed var(--ink); border-radius: 14px; opacity: .75; }
.rival-face svg { width: 64px; height: 100px; display: block; flex: none; }
.rival-face.locked svg { filter: brightness(0) opacity(.35); }
.rival-info { display: flex; flex-direction: column; gap: 2px; }
.rival-info b { font-size: 1.15rem; }
.rival-next { font-size: .9rem; }
.race-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Challenge rooms: the goal under the title, medal targets in the score box. */
.enc-head h2 .room-goal { display: block; font-family: var(--font); font-size: .95rem; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.scoreboard .medal-targets { display: block; font-size: .88rem; font-weight: 700; white-space: nowrap; }
.feedback .free-go { display: block; font-weight: 700; color: var(--ink-soft); margin-top: 4px; }

/* Hidden always wins over component display rules. */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- play-test pass: one bottom control bar */
html, body { touch-action: pan-x pan-y; }
.topbar { gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); flex-wrap: nowrap !important; }
.topbar .goal { order: 0 !important; flex: 1 1 auto !important; flex-basis: auto !important; }
.topbar .btn.small.icon { width: 48px; min-width: 48px; min-height: 44px; position: relative; font-size: 1.3rem; }
.badge { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 999px; background: var(--orange); color: #fff; border: 2px solid var(--ink); font-size: .72rem; font-weight: 900; display: grid; place-items: center; line-height: 1; }
.badge.warn { background: var(--red); }
.menu-list { display: grid; gap: 10px; }
.menu-list .btn { justify-content: flex-start; position: relative; }
.menu-list .btn.menu-grownups { font-size: .88rem; padding-top: 7px; padding-bottom: 7px; background: var(--paper-2, #f3ead6); box-shadow: none; }
.menu-list .badge { position: static; margin-left: auto; }

.ctlbar { flex: none; position: relative; z-index: 6; display: flex; align-items: center; gap: 12px; min-height: 104px;
  padding: 8px max(18px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--navy); border-top: 4px solid var(--ink); box-shadow: 0 -3px 0 rgba(0,0,0,.25);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ctlbar[hidden] { display: none !important; }
.bar-back { flex: none; display: flex; }
.bar-back:empty { display: none; }
.bar-left { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar-right { flex: none; display: flex; align-items: center; gap: 12px; margin-left: 20px; margin-right: 6px; }
.ctlbar.swap .bar-left, .ctlbar.swap .bar-right, .ctlbar.swap .bar-back { animation: barIn .24s ease-out; }
@keyframes barIn { from { transform: translateY(16px); opacity: 0; } }
.back-btn { background: var(--paper-2); white-space: nowrap; }
.ctlbar .control { padding: 6px 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctlbar .control label { margin: 0 !important; display: inline; }
.ctlbar .control > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctlbar .control > div > div[style] { margin-top: 0 !important; }
.ctlbar .stepper { min-width: 220px; }
.ctlbar .enc-actions { flex-wrap: nowrap; }
.ctlbar .btn.big.go { min-width: 168px; }
.ctlbar .guide { color: #cfe0e6; }

/* D-pad: left and right, with up over down in the middle. */
.dpad { display: grid; grid-template-columns: 76px 76px 76px; grid-template-rows: 46px 46px; gap: 6px; }
.dpad .btn.ctl { width: 76px; height: 46px; border-radius: 16px; font-size: 1.3rem; opacity: 1; }
.dpad .left, .dpad .right { grid-row: 1 / span 2; height: 98px; }
.dpad .left { grid-column: 1; } .dpad .up { grid-column: 2; grid-row: 1; } .dpad .down { grid-column: 2; grid-row: 2; } .dpad .right { grid-column: 3; }
.btn.ctl.jump { width: 104px; height: 88px; border-radius: 26px; font-size: 1.2rem; }
.use-btn { min-height: 64px; align-self: flex-start; margin-top: -2px; max-width: 220px; line-height: 1.1; }
.use-btn[disabled] { opacity: .35; }

/* Press-and-hold start buttons: a ring fills while you hold; a quick tap only nudges. */
.deliberate { position: relative; overflow: hidden; }
.deliberate::after { content: ''; position: absolute; left: 0; bottom: 0; height: 7px; width: 0; background: rgba(255,255,255,.9); border-top: 2px solid var(--ink); }
.deliberate.charging::after { width: 100%; transition: width var(--hold, 380ms) linear; }
.deliberate.nudge { animation: nudge .3s ease-out; }
@keyframes nudge { 40% { transform: translateY(3px); } }

/* First-time prompts. */
.tip { position: fixed; z-index: 80; max-width: min(320px, calc(100vw - 20px)); background: #fff3b0; color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); padding: 10px 12px; font-weight: 800; line-height: 1.3; display: flex; gap: 10px; align-items: center; animation: tipIn .25s ease-out; }
.tip .tip-ok { flex: none; min-height: 38px; }
.tip-arrow { position: absolute; left: var(--arrow-x, 50%); bottom: -14px; width: 0; height: 0; transform: translateX(-50%); border: 12px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.tip.below .tip-arrow { top: -14px; bottom: auto; border-top: 0; border-bottom: 12px solid var(--ink); }
@keyframes tipIn { from { transform: translateY(6px); opacity: 0; } }
.tip-target { outline: 4px solid #ffd23f !important; outline-offset: 3px; border-radius: 12px; animation: tipGlow 1.2s ease-in-out infinite; }
@keyframes tipGlow { 50% { outline-color: #f2694a; } }
svg .tip-target, g.tip-target { outline: none !important; }

/* Backpack and shop storage. */
.backpack h3 { margin: 10px 0 6px; font-size: 1.05rem; }
.backpack h3 small { font-size: .78rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink); }
.backpack .risk { background: #fde3d6; } .backpack .safe { background: #dff0d2; }
.bp-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-item { width: 104px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 6px; border: 3px solid var(--ink); border-radius: 14px; background: var(--card); font-weight: 800; font-size: .8rem; }
.bp-item small { font-weight: 700; font-size: .8rem; color: var(--ink-soft); }
.bp-item.carry { background: #fde3d6; } .bp-item.held { background: #f6c7c0; border-style: dashed; } .bp-item.safe { background: #eef6e6; }
.bp-icon svg { width: 72px; height: 50px; display: block; }
.bag-item.carry { position: relative; }
.bag-item.carry::after { content: '!'; position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; background: var(--red); color: #fff; font-size: .7rem; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--ink); }

@media (max-width: 760px) {
  .ctlbar { gap: 8px; min-height: 96px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .bar-right { margin-left: 8px; }
  .dpad { grid-template-columns: 62px 62px 62px; grid-template-rows: 42px 42px; }
  .dpad .btn.ctl { width: 62px; height: 42px; }
  .dpad .left, .dpad .right { height: 90px; }
  .btn.ctl.jump { width: 84px; height: 80px; }
  .ctlbar .btn.big.go { min-width: 120px; padding: .5em .8em; font-size: 1.05rem; }
  .use-btn { max-width: 140px; font-size: .95rem; }
  .back-btn { font-size: 0; padding: 0; width: 48px; } .back-btn::before { content: '←'; font-size: 1.3rem; }
}

/* Workshop: checklist, help, tags, snap glide. */
.checklist h3 { margin: 0 0 6px; font-size: 1rem; }
.checklist { background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.checklist h3 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.check i { width: 22px; height: 22px; border-radius: 7px; border: 2.5px solid var(--ink); background: #fff; display: grid; place-items: center; font-style: normal; font-weight: 900; flex: none; }
.check.done i { background: var(--green); color: #fff; }
.check:not(.done) { color: var(--red); }
.help-card { background: #fff3b0; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; font-weight: 700; line-height: 1.35; }
.tray-label { flex: none; display: flex; flex-direction: column; justify-content: center; width: 112px; font-size: .85rem; line-height: 1.2; }
.tray-label small { color: var(--ink-soft); font-weight: 700; }
.part-card .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.part-card .tags i { font-style: normal; font-size: .76rem; font-weight: 800; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 5px; }
.part-card { min-height: 120px; }
.drag-ghost.glide { transition: left .17s ease-out, top .17s ease-out; }
.drag-ghost.glide.back { transition: left .24s cubic-bezier(.3,1.5,.6,1), top .24s cubic-bezier(.3,1.5,.6,1); opacity: .85; }
.race-pick { justify-content: space-between; font-weight: 800; }

/* Explorer: the selected door's card grows; an arrow chip points to a marked robot. */
.prompt { font-size: 1.05rem; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 14px; }
.prompt b { font-size: 1.15rem; }
.prompt .btn { align-self: flex-start; }
.prompt.grow { animation: grow .25s ease-out; }
@keyframes grow { from { transform: scale(.85); opacity: .4; } }
.mark-chip { background: #ffd23f; border: 3px solid var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 900; box-shadow: var(--shadow); }

/* Test drive */
.td-lane { border-radius: 16px; overflow: hidden; height: 200px; }
.td-lane svg { width: 100%; height: 100%; display: block; }
.td-result { margin-top: 10px; }
.modal.testdrive-modal { max-width: 640px; }

/* Dress up */
.modal.dress-modal { max-width: 720px; }
.dressup { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: start; }
.dress-preview { background: radial-gradient(circle at 50% 70%, #fff4dc, #e7cc98); border: 3px solid var(--ink); border-radius: 18px; position: sticky; top: 0; }
.dress-preview svg { width: 100%; height: 230px; display: block; }
.dress-rows { display: grid; gap: 10px; }
.dress-row b { display: block; margin-bottom: 4px; }
.dress-row .btn.sel { background: var(--yellow); }
.dress-row .btn.new { box-shadow: 0 0 0 4px var(--orange), 0 5px 0 var(--ink); }
.swatch { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--ink); display: inline-block; }
.dressup .guide { grid-column: 1 / -1; }
.name-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.name-input { flex: 1; min-width: 0; font: inherit; font-size: 1.3rem; font-weight: 800; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); }
.name-input:focus { outline: 4px solid var(--yellow); }
@media (max-width: 560px) { .dressup { grid-template-columns: 1fr; } .dress-preview { position: static; } .dress-preview svg { height: 170px; } }
.pad-row { display: flex; gap: 10px; }
.btn.big.pad { width: 84px; min-width: 84px; height: 72px; font-size: 1.6rem; color: #fff; text-shadow: 0 2px 0 var(--ink); }
@media (max-width: 760px) { .btn.big.pad { width: 60px; min-width: 60px; height: 60px; padding: 0; } }
.rival-card { transition: transform .15s; }
.rival-card.sel { transform: scale(1.04); background: #fff3b0; }
.rival-go { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.ctlbar .control label { font-size: .82rem; color: var(--ink-soft); max-width: 8em; line-height: 1.1; }

/* UX pass: bar pairs, compact choices, door card by the Go button. */
.ctlbar .pair { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.ctlbar .pair > label { font-size: .88rem !important; font-weight: 800; color: var(--ink-soft); max-width: none; }
.ctlbar .choice-row { flex-wrap: nowrap; gap: 6px; }
.ctlbar .choice-row .btn.small { padding: .3em .6em; min-width: 44px; }
.ctlbar .stepper { min-width: 200px; }
.bar-left { flex-wrap: nowrap; }
.ctlbar .control { flex-wrap: nowrap; }
.ctlbar .control > div { flex-wrap: nowrap; }
.door-card.prompt { position: absolute; right: 16px; bottom: 14px; max-width: min(380px, 50vw); padding: 10px 16px; box-shadow: 0 5px 0 var(--ink); z-index: 3; }
.door-card.prompt b { font-size: 1.25rem; }
.works-hud { justify-content: flex-start; }
.works-hud .mark-chip { margin-left: auto; }
.bag:empty { display: none; }

/* Landscape only: on a touch screen held upright, ask to turn it sideways. */
.rotate-note { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-note { display: grid; place-items: center; position: fixed; inset: 0; z-index: 300; background: var(--navy); color: var(--paper); text-align: center; padding: 24px; }
  .rotate-note b { display: block; font-family: var(--brand); font-size: 1.8rem; color: var(--yellow); text-shadow: 0 2px 0 var(--ink); margin-top: 12px; }
  .rotate-note p { font-weight: 700; margin: 8px 0 0; }
  .rotate-icon { font-size: 4rem; animation: turn 2s ease-in-out infinite; }
  @keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}
/* Title fits a landscape iPad without scrolling. */
.title-logo { max-height: 24vh; width: auto !important; max-width: min(560px, 92vw); }
.title-cast { max-height: 40vh; width: auto !important; max-width: min(900px, 96vw); }
.title-card { padding: 12px 16px; }
.title-card p { margin: .2em 0 .7em; }
.title-actions { flex-direction: row; justify-content: center; gap: 14px; }
.ctlbar .btn, .ctlbar output { white-space: nowrap; }
.ctlbar .stepper output { font-size: 1.1rem; }
.bar-left { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 4px 2px 6px; }
.bar-left::-webkit-scrollbar { display: none; }

/* Hall of Victories: one arched space per world, trophies on pedestals inside it. */
.modal.hall-modal { max-width: 900px; background: linear-gradient(#fdf3dc, #f3e2bd); }
.hall-motto { font-family: var(--brand); font-size: 1.15rem; margin: 0 0 12px; color: var(--ink); }
.hall-spaces { display: grid; grid-template-columns: 1fr 1.5fr; gap: 14px; align-items: stretch; }
.hall-space { border: 4px solid var(--ink); border-radius: 120px 120px 18px 18px; padding: 26px 16px 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 6px 0 var(--ink); }
.hall-space.hill { background: linear-gradient(#bfe3ea 0, #dff0d2 60%, #c3e0a8); }
.hall-space.works { background: linear-gradient(#e7cc98, #f6e3bd 60%, #e2c189); }
.hall-space.locked { filter: grayscale(.6); opacity: .8; }
.hall-space.new { box-shadow: 0 0 0 6px var(--yellow), 0 6px 0 var(--ink); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 10px var(--yellow), 0 6px 0 var(--ink); } }
.space-head { display: flex; align-items: center; gap: 10px; justify-content: center; text-align: left; }
.space-head b { display: block; font-family: var(--brand); font-size: 1.3rem; }
.space-head small { font-weight: 800; color: var(--ink-soft); }
.space-icon { font-size: 2.2rem; }
.pedestals { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; flex: 1; align-content: flex-start; }
.hall-champ { display: flex; flex-direction: column; align-items: center; margin: 2px 0 8px; }
.hall-champ svg { width: 120px; height: auto; display: block; }
.hall-champ small { font-weight: 700; opacity: .8; }
.pedestal { width: 104px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; font-weight: 800; font-size: .86rem; line-height: 1.15; }
.pedestal i { font-style: normal; font-size: 2rem; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50% 50% 10px 10px; border: 3px dashed var(--ink-soft); color: var(--ink-soft); background: rgba(255,255,255,.4); font-family: var(--brand); }
.pedestal.won i { border: 3px solid var(--ink); background: radial-gradient(circle at 50% 40%, #fff6c2, #ffd23f); box-shadow: 0 4px 0 var(--ink); }
.pedestal:not(.won) span { color: var(--ink-soft); }
.hall-space .btn { align-self: center; }
.space-lock { margin: 0; text-align: center; font-weight: 800; }
.hall-next { margin: 16px 0 8px; font-size: 1rem; }
.hall-future { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.future-door { border: 3px dashed var(--ink-soft); border-radius: 60px 60px 12px 12px; padding: 14px 8px 10px; text-align: center; display: flex; flex-direction: column; gap: 3px; background: rgba(255,255,255,.35); }
.future-door span { font-size: 1.6rem; }
.future-door small { font-weight: 700; color: var(--ink-soft); line-height: 1.2; }
@media (max-width: 760px) { .hall-spaces { grid-template-columns: 1fr; } .hall-future { grid-template-columns: 1fr 1fr; } }
.dpad .btn.ctl:disabled { opacity: .3; box-shadow: none; }
.hall-space { padding: 18px 14px 12px; gap: 8px; }
.pedestal i { width: 54px; height: 54px; font-size: 1.7rem; }
.pedestal small { font-weight: 700; color: var(--ink-soft); font-size: .8rem; }
.hall-motto { margin-bottom: 8px; }
.hall-next { margin: 12px 0 6px; }
.future-door { padding: 10px 8px 8px; }

/* Modals stay inside the screen on iPad: safe areas, dynamic viewport height. */
.modal-back { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.modal { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
/* Challenge your rivals: two by two when there's room, so all four fit without scrolling. */
.modal.rivals { max-width: min(760px, 100%); }
@media (min-width: 640px) { .rival-list { display: grid; grid-template-columns: 1fr 1fr; } }
@media (max-height: 820px) { .rival-face svg { width: 48px; height: 76px; } .rival-card { padding: 6px 10px; } .modal.rivals h2 { margin-bottom: 6px; } }
.rival-info { min-width: 0; }
.rival-info small { overflow-wrap: anywhere; }
/* Test drive track picker */
.td-tracks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.td-tracks .btn.sel { background: #fff3b0; box-shadow: 0 0 0 3px var(--yellow); }
.modal.testdrive-modal { max-width: 720px; }
.goal-space { flex: 1; }
/* The desert joins the Hall: three spaces side by side, three future doors. */
.hall-spaces { grid-template-columns: .85fr 1.3fr 1.2fr; }
.hall-space.desert { background: linear-gradient(#ffd99a 0, #fbe7c0 55%, #e9cf8f); }
.hall-future { grid-template-columns: repeat(3, 1fr); }
.pedestal { width: 88px; }
@media (max-width: 900px) { .hall-spaces { grid-template-columns: 1fr 1fr; } }
/* Desert race gate: Normal / Expert under the rivals. */
.desert-mode { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.desert-mode .guide { margin: 0; flex: 1; min-width: 180px; }
/* Workshop wiring view. */
.wiring { background: #fff8ea; border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.wiring-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wiring-head h3 { margin: 0; }
.wiring .guide { margin: 4px 0 0; font-size: .85rem; }
.wiring-head .choice-row { flex-wrap: nowrap; }
.wiring-head .btn.small { padding: .2em .8em; font-size: .9rem; min-height: 44px; }
.wiring summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.wiring summary::-webkit-details-marker { display: none; }
.wiring summary::after { content: '▸'; font-weight: 900; transition: transform .12s ease-out; }
.wiring[open] summary::after { transform: rotate(90deg); }
.wiring summary h3 { margin: 0; }
.wiring[open] .wiring-head { margin: 4px 0 6px; }
/* Desert races: the mid-race decision card, over the lanes while the race waits. */
.race-lanes { position: relative; }
.decision { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; width: min(560px, calc(100% - 24px)); background: var(--card); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 14px 16px; text-align: center; animation: pop .25s ease-out; }
.decision > b { display: block; font-family: var(--brand); font-size: 1.4rem; }
.decision p { margin: 4px 0 12px; font-weight: 700; }
.decision-options { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.decision-options .btn { flex: 1 1 200px; flex-direction: column; display: flex; gap: 2px; min-height: 72px; }
.decision-options .btn small { font-weight: 700; color: var(--ink-soft); font-size: .8rem; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.85); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
/* Bottom bar: when the left controls overflow, fade the edge and show a › to scroll on. */
.bar-left-wrap { flex: 1 1 auto; min-width: 0; position: relative; display: flex; }
.bar-left-wrap .bar-left { flex: 1 1 auto; }
.bar-more { display: none; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 40px; height: 52px; border: 3px solid var(--ink); border-radius: 14px; background: var(--card); font-size: 1.6rem; font-weight: 900; line-height: 1; box-shadow: 0 3px 0 var(--ink); z-index: 2; }
.bar-left-wrap.more .bar-more { display: block; }
.bar-left-wrap.more .bar-left { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 70px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 70px), transparent); }
.ctlbar .bar-left .choice-row .btn.small { padding: .3em .6em; }
/* Shop storage: tabs by kind of part on top, that tab's cards underneath. */
.shop-tray { flex-direction: column; gap: 6px; overflow: hidden; padding-top: 8px; }
.tray-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none; padding: 2px 2px 4px; }
.tray-tabs::-webkit-scrollbar { display: none; }
.tray-tab { flex: none; min-height: 40px; position: relative; gap: 6px; }
.tray-tab.sel { background: var(--yellow); }
.tab-count { background: var(--ink); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; font-size: .72rem; }
.tab-new { position: absolute; top: -4px; right: -4px; width: 13px; height: 13px; border-radius: 50%; background: var(--orange); border: 2px solid var(--ink); }
.tray-cards { display: flex; gap: 10px; overflow-x: auto; align-items: stretch; padding: 10px 4px 4px; min-height: 120px; }
/* Prototype race view: one shared road filling the race area. */
.race-road { flex: 1; min-height: 0; position: relative; overflow: hidden; border-top: 4px solid var(--ink); }
.race-road > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* The painted races: one GPU canvas filling the race area. */
.paint-stage { position: absolute; inset: 0; background: #9fd0e6; }
.paint-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.paint-hud { position: absolute; top: 12px; left: 12px; z-index: 1; background: rgba(255, 244, 220, .92); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 14px 10px; min-width: 220px; box-shadow: 0 4px 14px rgba(20, 40, 50, .25); pointer-events: none; }
.paint-hud b { display: block; font-size: .9rem; margin-bottom: 6px; }
.paint-track { position: relative; height: 8px; border-radius: 4px; background: #78b061; border: 2px solid var(--ink); margin: 0 8px; }
.paint-track i { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid var(--ink); }
/* Shop storage sits under the cart board only, so the right rail keeps the full height
   (the checklist, the cart check and the race picker all stay in reach). */
@media (min-width: 861px) {
  .shop-side { grid-column: 2; grid-row: 1 / -1; }
  .shop-tray { grid-column: 1; }
}
.shop-tray { padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.tray-cards { padding-top: 8px; min-height: 0; }
.shop-side .stat-list { gap: 5px; }
.shop-side .meter { font-size: .86rem; }
.shop-side .meter .bar { height: 12px; margin-top: 2px; }

.hall-space.yard { background: linear-gradient(#dfe9ec 0, #e8e2d4 55%, #cfc6b4); }

/* Robot room end cards: a centred row of equal buttons, Leave as the quiet one. */
.modal.end-card { text-align: center; }
.end-card .actions { justify-content: center; gap: 12px; flex-wrap: nowrap; }
.end-card .actions .btn { flex: 1 1 0; min-width: 0; min-height: 56px; padding-inline: 12px; justify-content: center; }
.end-card .actions .btn.quiet { flex: 0.7 1 0; background: transparent; box-shadow: none; border-color: var(--ink-soft); color: var(--ink-soft); }

/* Robotics Yard race: the stop panel opens under the road while the clock is stopped. */
.yard-race .race-road { flex: 1 1 45%; }
.stop-panel { flex: 1 1 55%; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(240px, 1fr); gap: 12px; padding: 10px 14px; background: var(--paper-2); border-top: 4px solid var(--ink); }
.stop-panel[hidden] { display: none; }
.stop-view { width: 100%; height: 100%; min-height: 0; display: block; border: 3px solid var(--ink); border-radius: 14px; background: #cfc6b4; }
.stop-info { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; }
.stop-info h3 { margin: 0; font-family: var(--brand); font-size: 1.3rem; }
.stop-info p { margin: 0; font-weight: 700; }
.race-table { width: 100%; border-collapse: collapse; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.race-table th, .race-table td { padding: 5px 8px; border-bottom: 2px solid var(--paper-3); text-align: right; }
.race-table th:first-child { text-align: left; font-weight: 700; }
.race-table thead th { font-family: var(--brand); }
.race-table .total th, .race-table .total td { font-weight: 900; border-bottom: none; }
.modal.race-card { max-width: 620px; }
/* Pivot Point joins the Hall: four spaces, two by two; two future doors. */
.hall-spaces { grid-template-columns: 1fr 1fr; }
.hall-future { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 760px) { .hall-spaces { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- motion polish (29 Oct)
   One small set of timings: short 120ms, medium 220ms, long 400ms; ease-out to arrive. */
.scene-in { animation: sceneIn .22s ease-out; }
@keyframes sceneIn { from { opacity: 0; } }
.modal-back { animation: backIn .18s ease-out; }
@keyframes backIn { from { background: rgba(38,54,64,0); } }
.modal { animation: modalIn .22s cubic-bezier(.2,.9,.3,1.15); }
@keyframes modalIn { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.toast { animation: toastIn .22s ease-out; }
@keyframes toastIn { from { transform: translate(-50%, -8px); opacity: 0; } }
.countdown .cd-n { display: inline-block; animation: cdPop .3s cubic-bezier(.2,.9,.3,1.2); }
@keyframes cdPop { from { transform: scale(1.35); opacity: 0; } }
/* Race gauges follow the race directly; a transition here made them lag behind. */
.race-gauges .meter .fill, .race .meter .fill { transition: none; }
/* Reduced motion: the html[data-motion="reduced"] rule above already turns these off. */

/* The ready checklist: one line. */
.checklist.ready { display: flex; align-items: center; gap: 8px; font-weight: 900; padding: 8px 10px; }
.checklist.ready i { font-style: normal; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: #fff; border: 2.5px solid var(--ink); }
/* A soft fade at the bottom of the Shed's side panel shows there's more below. */
.shop-side::after { content: ''; position: sticky; bottom: -12px; display: block; flex: none; height: 30px; margin-top: -30px; pointer-events: none; background: linear-gradient(rgba(255,255,255,0), var(--paper-2)); }

/* A part clicking into its socket. */
.snap-ring { position: fixed; z-index: 40; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; border: 4px solid var(--yellow); pointer-events: none; animation: snapRing .4s ease-out forwards; }
@keyframes snapRing { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }

/* ---------------------------------------------------------------- Booster Basin (Level 4) */
.hall-space.basin { background: linear-gradient(#cfe6f0 0, #f3e6cc 55%, #e2d6bc); }
.basin-race .race-road { flex: 1 1 50%; }
.basin-panel { grid-template-columns: minmax(0, 1fr) minmax(260px, 1.2fr); align-items: center; }
.basin-panel .start-art svg, .basin-panel .chute-art svg { width: 100%; max-height: 100%; display: block; }
.basin-panel .meter .bar { height: 16px; }
/* Push and drag, live, over the race road. */
.force-hud { position: absolute; right: 12px; bottom: 12px; z-index: 5; width: 210px; padding: 8px 10px; background: var(--paper, #fff4dc); border: 3px solid var(--ink); border-radius: 14px; font-weight: 800; font-size: .85rem; pointer-events: none; }
.force-hud .force-speed { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.force-row { display: grid; grid-template-columns: 3.4em 1fr; align-items: center; gap: 6px; margin-top: 3px; }
.force-row .bar { position: relative; height: 13px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.force-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.force-row .fill.push { background: var(--teal); }
.force-row .fill.drag { background: var(--orange); }
/* The distance-time replay. */
.dt-graph { display: block; width: 100%; height: auto; max-height: 48vh; }
.modal.basin-card { max-width: 940px; width: min(940px, calc(100vw - 32px)); }
.basin-result { display: grid; gap: 8px; }
.basin-result .race-table { margin: 0; }
@media (min-width: 900px) { .basin-result { grid-template-columns: minmax(190px, 1fr) minmax(0, 2.8fr); align-items: start; } .basin-result details.numbers { grid-column: 1 / -1; } }

/* Trophy Track: the course card, the workbench and the live race. */
.trophy { position: absolute; inset: 0; overflow-y: auto; padding: 12px 18px 20px; background: linear-gradient(#f6e3bd, #fff4dc 40%); }
.tt-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.tt-head h2 { margin: 0; font-family: var(--brand); font-size: 1.7rem; }
.tt-league { display: flex; flex-direction: column; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; }
.tt-league small, .tt-medals small { font-weight: 700; color: var(--ink-soft); }
.tt-medals { display: flex; gap: 12px; align-items: center; font-weight: 900; font-size: 1.2rem; }
.tt-course { margin-top: 10px; background: var(--card); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 10px 14px; }
.tt-course-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tt-course h3 { margin: 0; font-family: var(--brand); font-size: 1.4rem; }
.tt-profile svg { width: 100%; height: 90px; display: block; margin: 6px 0; border: 2.5px solid var(--ink); border-radius: 10px; background: #dff0f4; }
.tt-brief { margin: 4px 0; padding-left: 20px; font-weight: 700; line-height: 1.4; }
.tt-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tt-chip { background: #fff3b0; border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: .9rem; }
.tt-vs { margin: 8px 0 0; font-weight: 700; color: var(--ink-soft); }
.tt-yours { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.tt-yours small { display: block; font-weight: 700; color: var(--ink-soft); }
.tt-pic svg { width: 150px; height: 88px; display: block; }
.tt-pic.empty { display: grid; place-items: center; width: 150px; height: 88px; font-size: 2rem; font-weight: 900; opacity: .5; }
.tt-bench { position: absolute; inset: 0; display: grid; grid-template-columns: 330px 1fr; gap: 12px; padding: 10px 14px; background: linear-gradient(#e7cc98, #f6e3bd); }
.tt-bench-left { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; }
.tt-bench-left .tt-pic svg { width: 300px; height: 140px; background: #fffaf0; border: 3px solid var(--ink); border-radius: 16px; }
.tt-bench-course small { display: block; font-weight: 700; color: var(--ink-soft); }
.tt-start { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tt-start small { font-weight: 800; width: 100%; }
.tt-stats { background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 10px; }
.tt-bench-right { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.tt-sock { background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; }
.tt-sock-name { font-weight: 900; margin-bottom: 4px; }
.tt-sock-name small { font-weight: 700; color: var(--ink-soft); }
.tt-parts { display: flex; gap: 6px; flex-wrap: wrap; }
.tt-part { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 88px; min-height: 76px; padding: 4px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; font: inherit; cursor: pointer; }
.tt-part svg { width: 40px; height: 40px; }
.tt-part small { font-weight: 800; font-size: .72rem; line-height: 1.1; text-align: center; }
.tt-part.on { background: #f2b632; box-shadow: 0 3px 0 var(--ink); }
.tt-part:disabled { opacity: .35; }
.tt-live .race-road { position: relative; }
.tt-pos { font-family: var(--brand); font-size: 1.6rem; font-weight: 900; background: #f2b632; border: 3px solid var(--ink); border-radius: 12px; padding: 0 10px; }
.tt-ctl { min-width: 96px; min-height: 84px; font-size: 1.6rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.tt-ctl.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); filter: brightness(.92); }
.tt-go { min-width: 150px; }
.tt-brake { background: #e9e1d2; }
.tt-coast { font-weight: 900; max-width: 16ch; background: var(--card); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; line-height: 1.2; }
.tt-medals span { display: inline-flex; align-items: center; gap: 4px; }
.tt-medals i { font-style: normal; font-size: 1.6rem; }
.tt-bench-course { position: sticky; top: 0; z-index: 2; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; }
.tt-bench-course summary { cursor: pointer; font-family: var(--brand); }
.tt-bench-course .tt-brief { font-size: .85rem; line-height: 1.3; }
.tt-bench-course .tt-chip { font-size: .78rem; }
.tt-picked { margin: 0; font-size: .85rem; font-weight: 700; line-height: 1.3; }
.tt-bench-left .help-card ul { margin: 4px 0 0; padding-left: 18px; }
.tt-progress { height: 16px; margin: 0 auto 4px; max-width: 320px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.tt-progress .fill { height: 100%; width: 0; background: var(--teal, #2f8f8a); transition: width .15s linear; }
.tt-intro p { margin: 0 0 8px; }
.tt-intro ul { margin: 0 0 10px; padding-left: 20px; font-weight: 700; line-height: 1.5; }
.tt-grid { width: min(820px, calc(100% - 24px)); }
.tt-gridlist { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tt-gridlist > div { display: flex; flex-direction: column; align-items: center; font-weight: 800; }
.tt-gridlist .tt-pic svg { width: 120px; height: 70px; }
.tt-table { width: 100%; border-collapse: collapse; margin: 6px 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-table td { padding: 4px 6px; border-bottom: 2px solid #e6dcc6; }
.tt-table tr.you td { background: #fbe7b2; font-weight: 900; }
.tt-up { background: #fff3b0; border: 2.5px solid var(--ink); border-radius: 12px; padding: 6px 10px; }

/* Tow & Release */
.tt-dual { margin: 6px 0 0; background: #fde3c4; border: 2.5px solid var(--ink); border-radius: 12px; padding: 4px 10px; font-weight: 700; }
.tt-locked { margin: 10px 0 0; font-weight: 800; color: var(--ink-soft); }
.tt-tabs { display: flex; gap: 6px; }
.tt-tabs .btn { flex: 1; }
.tt-tabs .btn.on { background: #f2b632; }
.tt-release { background: #fde3c4; min-width: 130px; font-size: 1.2rem; }
/* Booster Basin parts: one tap each, then the button is spent. */
.tt-once { min-width: 110px; font-size: 1.15rem; }
.tt-fire { background: #ffd27a; }
.tt-chute { background: #e9e1d2; }
.tt-once:disabled { opacity: .35; }
.tt-pair { display: flex; align-items: flex-end; }
.tt-pair .tt-pic + .tt-pic { margin-left: -24px; }

/* ---------- Level 5, Rover Ridge: the robot room and the program builder ---------- */
.rover-room { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr) auto; background: var(--paper); }
.rr-stage { position: relative; min-height: 0; background: #141c2b; }
.paint-moon { position: absolute; inset: 0; }
.paint-moon canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.rr-stage svg.stage { position: relative; z-index: 1; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.rr-side { grid-row: 1; grid-column: 2; gap: 10px; padding: 12px; }
.rr-side .choice-row .btn.small { padding: .3em .7em; }
.rr-title small { display: block; font-size: .8rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.rr-title b { font-size: 1.2rem; }
.rr-side .feedback:empty { display: none; }
.rr-prog { grid-column: 1 / -1; border-top: 3px solid var(--ink); background: var(--paper-2); padding: 8px 12px 10px; min-width: 0; }
.rr-ctl { display: flex; gap: 8px; padding: 6px 8px; }
.rr-ctl .btn { min-height: 56px; min-width: 96px; }
.rr-steer { display: flex; flex-direction: column; gap: 4px; padding: 14px 6px; font-size: 1.1rem; }
.rr-steer span { color: var(--ink-soft); font-weight: 700; }

.rr-card { background: var(--card); border: 2.5px solid var(--ink); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.rr-mass { display: flex; flex-direction: column; }
.rr-mass span { font-weight: 700; color: var(--ink-soft); font-size: .92rem; }
.rr-bar { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 8px; font-weight: 800; font-size: .95rem; }
.rr-track { position: relative; height: 18px; }
.rr-track i, .rr-key i { display: inline-block; height: 16px; border-radius: 6px; }
.rr-track i { position: absolute; left: 0; top: 0; }
.rr-track .earth, .rr-key .earth { width: 100%; border: 2.5px dashed var(--ink-soft); background: transparent; box-sizing: border-box; }
.rr-track .moon, .rr-key .moon { background: var(--teal); border: 2.5px solid var(--ink); box-sizing: border-box; }
.rr-key { color: var(--ink-soft); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.rr-key .earth { margin-left: 8px; }
.rr-key i, .rr-key i.earth, .rr-key i.moon { width: 22px; height: 12px; }

.prog { display: grid; grid-template-columns: 74px minmax(0, 1fr); grid-template-rows: auto auto; gap: 6px 8px; align-items: center; }
.prog-label { font-weight: 900; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.prog-row { display: flex; align-items: center; gap: 8px; min-height: 92px; padding: 6px 8px; overflow-x: auto; background: var(--card); border: 3px solid var(--ink); border-radius: 18px; touch-action: pan-x; }
.prog-row.target { box-shadow: inset 0 0 0 3px var(--yellow); }
.prog-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.prog .slot { color: var(--ink-soft); font-weight: 700; font-size: .95rem; padding: 0 8px; white-space: nowrap; }
.tile { position: relative; flex: none; width: 70px; height: 76px; padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); font: inherit; font-weight: 900; font-size: .9rem; color: var(--ink); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.tile svg { width: 34px; height: 34px; }
.tile .w { line-height: 1; }
.tile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tile:disabled { opacity: .35; cursor: default; }
.tile.k-move { background: #bfe6e4; }
.tile.k-arm { background: #ddd0f2; }
.tile.k-kit { background: #fbe3a6; }
.tile.k-ctl { background: #fbd0c4; }
.tile.k-loop { background: #ffd8a8; }
.tile.k-cond { background: #cfe6b8; }
.tile.head { width: 86px; }
.tile .sub { font-size: .66rem; font-weight: 800; line-height: 1; color: var(--ink-soft); }
.tile .left { position: absolute; top: -9px; right: -9px; background: var(--ink); color: #fff; font-size: .78rem; border-radius: 999px; padding: 2px 6px; }
.tile .count { position: absolute; top: -12px; right: -10px; min-width: 30px; height: 30px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); font-size: 1.05rem; display: none; align-items: center; justify-content: center; }
.tile .count.on { display: flex; animation: tick .3s ease-out; }
.tile .light { position: absolute; top: -12px; right: -12px; padding: 2px 8px; border-radius: 999px; border: 3px solid var(--ink); font-size: .85rem; display: none; }
.tile .light.yes { display: block; background: var(--yellow); }
.tile .light.no { display: block; background: #c9d2d6; }
@keyframes tick { from { transform: scale(1.5); } to { transform: scale(1); } }
.tile.now { outline: 5px solid var(--yellow); outline-offset: 2px; transform: translateY(-4px); }
.tile.wrong { outline: 5px dashed #d9452b; outline-offset: 2px; }
.tile.wrong::after { content: '?'; position: absolute; top: -16px; left: -12px; width: 28px; height: 28px; border-radius: 50%; background: #d9452b; color: #fff; border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.tile.pop { animation: tilePop .25s ease-out; }
@keyframes tilePop { from { transform: scale(.6); } to { transform: scale(1); } }
.tile.lifted, .group.lifted { opacity: .3; }
.tile.ghost, .group.ghost { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; opacity: .95; box-shadow: 0 10px 18px rgba(0,0,0,.25); }
.drop-mark { flex: none; width: 6px; height: 70px; border-radius: 4px; background: var(--teal); }
.group { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border: 3px solid var(--ink); border-radius: 18px; background: #fff3df; }
.group.k-cond { background: #eef7e4; }
.group-body { display: flex; align-items: center; gap: 6px; min-height: 80px; min-width: 120px; padding: 0 6px; border: 2.5px dashed var(--ink-soft); border-radius: 14px; cursor: pointer; }
.group-body.target { border-color: var(--yellow-d); background: #fff7d6; }
.group-body .slot { font-size: .8rem; white-space: normal; max-width: 110px; }
.prog.running .prog-palette { opacity: .5; }

/* Base camp */
.rover-hub { position: absolute; inset: 0; background: #0e1524; overflow: hidden; }
.rh-art, .rh-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rh-top { position: absolute; left: 16px; top: 14px; }
.rh-chip { background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 800; }
.rh-doors { position: absolute; left: 47%; bottom: 26px; display: flex; flex-direction: column; gap: 12px; }
.rh-door { display: flex; align-items: center; gap: 12px; text-align: left; padding: .5em 1.2em .5em .7em; }
.rh-door-text { display: flex; flex-direction: column; line-height: 1.15; }
.rh-door-text small { font-size: .82rem; color: var(--ink-soft); font-weight: 700; }

/* Rover Ridge: GRUNT's landing pad */
.land-room { grid-template-rows: minmax(0, 1fr); }
.rr-track.force { height: 20px; background: #eef1f3; border-radius: 6px; }
.rr-track.force i { height: 20px; border: 2.5px solid var(--ink); box-sizing: border-box; border-radius: 6px; }
.rr-track.force .weight { background: var(--orange); }
.rr-track.force .thrust { background: var(--yellow); }
.thrust-ctl { display: flex; align-items: center; gap: 10px; }
.stepper.thrust { display: flex; align-items: center; gap: 8px; }
.stepper.thrust .btn { min-width: 64px; min-height: 60px; font-size: 1.6rem; }
.thrust-mid { display: flex; flex-direction: column; gap: 4px; width: 260px; }
.thrust-meter { position: relative; height: 22px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; overflow: visible; }
.thrust-meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--yellow); border-radius: 5px; transition: width .12s; }
.thrust-meter .weight-mark { position: absolute; top: -7px; bottom: -7px; width: 5px; margin-left: -2px; background: var(--orange); border: 1.5px solid var(--ink); border-radius: 3px; }
.thrust-out { font-weight: 800; font-size: .95rem; }

/* Rover Ridge: groups with a count button and an "otherwise" row */
.count-btn { flex: none; width: 60px; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); font: inherit; cursor: pointer; }
.count-btn b { font-size: 1.4rem; line-height: 1; }
.count-btn small { font-size: .7rem; font-weight: 800; }
.count-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.prog.running .count-btn { pointer-events: none; opacity: .6; }
.otherwise { font-weight: 900; font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; }
.group-body.alt { border-style: dotted; }
.group .group { background: #fff; }
.rr-prog .prog + .prog { margin-top: 6px; }
.rr-tiles { font-weight: 800; font-size: .9rem; color: var(--ink-soft); margin-top: 4px; text-align: right; }
.rr-tiles.over { color: var(--red); }

/* The race gate and race screen */
.rr-gate { display: flex; flex-direction: column; gap: 10px; }
.rr-rival { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 2.5px solid var(--ink); border-radius: 16px; padding: 6px 10px; }
.rr-rival small { display: block; color: var(--ink-soft); font-weight: 700; }
.rr-rival-btns { display: flex; gap: 6px; }
.rr-rival-btns .btn { min-height: 60px; min-width: 110px; flex-direction: column; display: flex; padding: .3em .6em; }
.rr-rival-btns .btn small { font-size: .7rem; max-width: 110px; }
.rr-gate-modal { max-width: 640px; }
.rr-raceinfo { display: flex; flex-direction: column; gap: 10px; }
.rr-vs { flex-direction: row; align-items: center; gap: 8px; }
.rr-vs small, .rr-card small { display: block; color: var(--ink-soft); font-weight: 700; }

/* Your Shed on the Moon */
.rover-bay { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; padding: 14px 18px; background: linear-gradient(#1b2438, #2a3550 60%, #a39d92 60%); overflow: auto; }
.rb-left h2 { margin: 0; color: #fff; }
.rb-left .guide { color: #dbe4ee; }
.rb-art { width: 100%; max-height: 300px; }
.rb-panel { display: flex; flex-direction: column; gap: 10px; }
.rb-group { background: var(--card); border: 2.5px solid var(--ink); border-radius: 16px; padding: 10px 12px; }
.rb-group h3 { margin: 0 0 6px; font-size: 1rem; }
.rb-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rb-choice { min-height: 72px; flex-direction: column; align-items: flex-start; display: flex; text-align: left; padding: .5em .8em; }
.rb-choice small { font-weight: 700; color: var(--ink-soft); font-size: .82rem; }
.rb-choice.sel { background: var(--yellow); }
.rb-bar { grid-template-columns: 92px 1fr 56px; }
.rb-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.rb-tile svg { width: 34px; height: 34px; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 2px; }
.hall-space.moon { background: linear-gradient(#26324f 0, #4a5672 45%, #bdb7ac); }
.hall-space.moon .space-head { color: #fff; }
.hall-space.moon .pedestal span, .hall-space.moon .pedestal small { color: var(--ink); }
.hall-space.moon .space-head small { color: #e3e9f2; }
.rover-room .prog-palette .tile { width: 66px; height: 70px; }
.rover-room .prog-palette .tile svg { width: 30px; height: 30px; }
.rover-room .prog-palette { gap: 6px; }
/* Long programs wrap onto a second line instead of scrolling. */
.prog-row { flex-wrap: wrap; overflow-x: visible; touch-action: none; }
.group, .group-body { flex-wrap: wrap; }
.champ-row { display: flex; align-items: flex-end; justify-content: center; gap: 6px; flex-wrap: wrap; background: linear-gradient(#26324f, #4a5672 70%, #bdb7ac 70%); border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; }
.champ-row:empty { display: none; }
.champ-pic { width: 92px; height: 60px; }

/* Inventors on the title screen, and the quiet Grown-ups button */
.title-corner { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.btn.quiet { background: transparent; color: #c9d4da; border-color: #5b6f7a; box-shadow: none; font-weight: 700; }
.who { margin: 6px 0 14px; }
.who h2 { margin: 0 0 8px; font-size: 1.1rem; color: #fff4dc; }
.who-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn.who { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 110px; padding: 6px 12px 10px; }
.btn.who.sel { background: var(--yellow); }
.who-face svg { width: 64px; height: 86px; display: block; }

/* Grown-ups */
.gate-word { font-size: 1.6rem; font-weight: 900; margin: 4px 0 12px; }
.modal.grownups-modal { max-width: 640px; font-weight: 500; }
.gu-section { border-top: 2px solid #e6dcc6; padding: 12px 0 4px; }
.gu-section:first-child { border-top: 0; padding-top: 0; }
.gu-section h3 { margin: 0 0 6px; font-size: 1.05rem; }
.gu-section p { margin: 0 0 10px; line-height: 1.45; }
.gu-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.gu-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.gu-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gu-small { font-size: .85rem; color: var(--ink-soft); }
.gu-row-btns { display: flex; gap: 6px; }
.gu-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 2px dashed #e6dcc6; }
.btn.small.danger { background: transparent; box-shadow: none; color: #9b3b22; border-color: #c9826c; }
.gu-why summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.gu-why p { margin: 6px 0 0; }
/* Done stays in view: the panel scrolls, the buttons don't */
.modal.grownups-modal .actions { position: sticky; bottom: -20px; margin: 12px -20px -20px; padding: 10px 20px 14px; background: var(--card); border-top: 2px solid #e6dcc6; }

/* The learning report: a plain sheet, over everything, printable */
.report-page { position: fixed; inset: 0; z-index: 80; background: #f4f1ea; overflow: auto; padding: max(12px, env(safe-area-inset-top)) 16px 40px; }
.report-bar { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 10px; max-width: 760px; margin: 0 auto 12px; padding: 6px 0; background: #f4f1ea; }
.report { max-width: 760px; margin: 0 auto; background: #fff; color: #1b2a33; border-radius: 14px; padding: 28px 32px; font-family: Georgia, 'Times New Roman', serif; line-height: 1.5; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.report h1 { font-size: 1.7rem; margin: 0 0 4px; }
.report h2 { font-size: 1.3rem; margin: 26px 0 6px; padding-top: 18px; border-top: 1px solid #ddd; }
.report h3 { font-size: .95rem; margin: 14px 0 4px; font-family: system-ui, -apple-system, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: #4b5d66; }
.report ul { margin: 0; padding-left: 1.2em; }
.report p { margin: 0 0 6px; }
.report-sub, .report-time, .report footer { color: #5b6a72; font-size: .9rem; }
.report-facts { font-weight: 700; }
.report-about { font-style: italic; }
.report-intro { margin-top: 12px; font-size: 1.08rem; padding: 12px 14px; background: #f7f3e8; border-left: 4px solid #e2b65a; border-radius: 6px; }
.report-skillrow { margin: 0 0 9px; padding-left: 1.2em; }
.report-skill { font-weight: 700; }
.report-level { display: inline-block; font-family: system-ui, -apple-system, sans-serif; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; vertical-align: 1px; }
.report-level.shown { background: #dcefdc; color: #24572b; }
.report-level.help { background: #dde9f6; color: #1f4a78; }
.report-level.working { background: #f6e6c8; color: #7a4f0e; }
.report-evidence { color: #4b5d66; font-size: .92rem; }
.report footer { margin-top: 28px; padding-top: 12px; border-top: 1px solid #ddd; }
@media (max-width: 560px) { .report { padding: 20px 16px; } }
/* Printed (Save as PDF): a plain one-column document, black on white, about 11pt. Nothing of the
   game shows. A page breaks between a world's parts or between skills, never inside one, and a
   world's heading always stays with its first skill. */
@page { margin: 16mm 17mm 18mm; }
@media print {
  html, body.printing-report { background: #fff !important; height: auto !important; min-height: 0 !important; overflow: visible !important; }
  body.printing-report > *:not(.report-page) { display: none !important; }
  .report-page { position: static; inset: auto; padding: 0; background: #fff; overflow: visible; }
  .report-bar { display: none; }
  .report { max-width: none; margin: 0; padding: 0; border-radius: 0; box-shadow: none; background: #fff; color: #000;
    font: 11pt/1.38 Georgia, 'Times New Roman', serif; }
  .report h1 { font-size: 20pt; margin: 0 0 2pt; }
  .report-sub, .report-time, .report-evidence, .report footer { color: #333; font-size: 9.5pt; }
  .report-facts { font-size: 10pt; margin-bottom: 8pt; }
  .report-intro { font-size: 11.5pt; background: none; border: 0; border-left: 2pt solid #000; border-radius: 0; padding: 2pt 0 2pt 10pt; margin: 8pt 0 4pt; }
  .report h2 { font-size: 14pt; margin: 14pt 0 3pt; padding-top: 10pt; border-top: .75pt solid #999; break-after: avoid; }
  .report h3 { font-size: 8.5pt; color: #000; margin: 8pt 0 2pt; break-after: avoid; }
  .report-about { font-size: 10pt; color: #222; }
  .report p, .report li { orphans: 2; widows: 2; }
  .report-part { break-inside: avoid; }
  .report-skillrow { margin: 0 0 5pt; }
  .report-level { background: none !important; color: #000 !important; border: .75pt solid #000; padding: 0 5pt; font-size: 8pt; }
  .report footer { margin-top: 16pt; padding-top: 6pt; border-top: .75pt solid #999; break-inside: avoid; }
  .report footer p { margin: 0 0 2pt; }
}
/* Switch inventor (from the menu): the sheet title already asks */
.who-sheet .who h2 { display: none; }

/* Wayfinding: checkered flags at race entrances, the Pebble Peak "Race Mara" sign and edge cue. */
.flag-cloth { animation: flag-wave 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: left center; }
.race-entrance > g:first-child .flag-cloth { transform-origin: right center; }
@keyframes flag-wave { 50% { transform: skewY(-4deg) scaleX(.94); } }
.cta-bob { animation: bob 1.3s ease-in-out infinite; }
.edge-cue { position: absolute; right: 12px; top: 42%; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-weight: 800; pointer-events: none; animation: edge-nudge 1.2s ease-in-out infinite; z-index: 2; }
.edge-cue span { display: flex; }
@keyframes edge-nudge { 50% { transform: translateX(6px); } }

/* Wayfinding: the map (was the Hall of Victories). Six nodes on a winding path, with a side panel
   for the node you tapped. Path order: top row left to right, then bottom row right to left. */
.modal.map-modal { max-width: 980px; }
.map-cue { background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 16px; display: inline-block; box-shadow: 0 4px 0 var(--ink); }
.map-wrap { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: start; }
.map-path { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: auto auto; gap: 18px 10px; padding: 6px; }
.map-trail { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.map-trail svg { width: 100%; height: 100%; display: block; }
.map-node[data-world="0"] { grid-area: 1 / 1; } .map-node[data-world="1"] { grid-area: 1 / 2; } .map-node[data-world="2"] { grid-area: 1 / 3; }
.map-node[data-world="3"] { grid-area: 2 / 3; } .map-node[data-world="4"] { grid-area: 2 / 2; } .map-node[data-world="5"] { grid-area: 2 / 1; }
.map-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 10px; border: 3px solid var(--ink); border-radius: 22px; background: var(--card); box-shadow: 0 4px 0 var(--ink); font: inherit; color: var(--ink); cursor: pointer; text-align: center; min-height: 128px; }
.map-node b { font-family: var(--brand); font-size: .98rem; line-height: 1.1; }
.map-node small { font-weight: 800; color: var(--ink-soft); }
.map-node.hill { background: linear-gradient(#bfe3ea, #dff0d2); } .map-node.works { background: linear-gradient(#e7cc98, #f6e3bd); }
.map-node.desert { background: linear-gradient(#ffd99a, #fbe7c0); } .map-node.yard { background: linear-gradient(#cfd8dc, #eef2f3); }
.map-node.basin { background: linear-gradient(#bfe0f2, #e6f3fa); } .map-node.moon { background: linear-gradient(#c9c6d9, #ecebf2); }
.map-node.locked { filter: grayscale(.85) contrast(.75); }
.map-node.locked small { color: var(--ink); }
.map-node.done small { color: var(--teal-d); }
.map-node.current small { color: var(--orange); }
.map-node.sel { outline: 4px solid var(--teal); outline-offset: 2px; }
.map-node.glow { box-shadow: 0 0 0 6px var(--yellow), 0 4px 0 var(--ink); animation: glow 1.6s ease-in-out infinite; }
.map-node.dim { filter: grayscale(.8) brightness(1.06) contrast(.6); }
.map-dot { position: relative; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #fffaf0; border: 3px solid var(--ink); font-size: 1.7rem; }
.map-node.done .map-dot { background: radial-gradient(circle at 50% 40%, #fff6c2, #ffd23f); }
.map-flag { position: absolute; right: -14px; top: -10px; display: flex; }
.map-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; font-size: .9rem; margin-top: 2px; }
.map-badges i { font-style: normal; }
.map-detail { border: 3px solid var(--ink); border-radius: 18px; padding: 12px; background: var(--card); box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; gap: 10px; }
.map-detail .btn { align-self: center; }
.map-lock { margin: 0; font-weight: 400; line-height: 1.35; }
.map-complete { margin: 0; font-weight: 800; color: var(--teal-d); text-align: center; }
.map-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-weight: 400; }
.map-checklist li { display: flex; align-items: center; gap: 8px; }
.map-checklist li.done { color: var(--ink-soft); text-decoration: line-through; }
.map-checklist .tick { width: 22px; display: inline-grid; place-items: center; color: var(--teal-d); }
.map-detail .pedestals { gap: 6px; }
.map-detail .pedestal { width: 76px; font-size: .78rem; }
.map-detail .pedestal i { width: 44px; height: 44px; font-size: 1.4rem; }
@media (max-width: 760px) { .map-wrap { grid-template-columns: 1fr; } .map-node { min-height: 112px; } }
/* The world's goal: small, always in the top bar, opens the map. */
.goal { cursor: pointer; }
.world-goal { flex: none; max-width: 34%; display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper-3); font: inherit; font-size: .78rem; font-weight: 800; color: var(--ink); cursor: pointer; }
.world-goal .wg-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-goal.done { background: var(--green-l); }
.world-goal.done .wg-icon { color: var(--teal-d); font-weight: 900; }
@media (max-width: 700px) { .world-goal { max-width: 46%; } }
/* Bonus trophies on the map: a gold tag and a gold dashed pedestal, so they read as extra. */
.pedestal.bonus i { border-color: var(--yellow-d); background: rgba(255, 214, 90, .25); }
.pedestal.bonus.won i { border-color: var(--ink); }
.bonus-tag { font-style: normal; font-size: .68rem; font-weight: 900; letter-spacing: .06em; padding: 1px 7px; border-radius: 999px; background: var(--yellow); border: 2px solid var(--ink); }
/* The world-complete card: a title, one line, two buttons. */
.modal.complete-card { max-width: 440px; text-align: center; }
.complete-line { font-weight: 400; font-size: 1.1rem; margin: 4px 0 8px; }
/* The ✕ on win cards: closes to the world screen. */
.modal-x { float: right; margin: -8px -8px 0 8px; width: 40px; height: 40px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--card); font: inherit; font-size: 1.1rem; font-weight: 900; color: var(--ink); cursor: pointer; }
/* Expert races are open: a small tappable note on the world screen. */
.expert-note { pointer-events: auto; align-self: flex-start; padding: 6px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--yellow); box-shadow: 0 3px 0 var(--ink); font: inherit; font-size: .9rem; font-weight: 800; color: var(--ink); cursor: pointer; }
