/* ============ TOKENS: neutral screens, one accent per game (set on <body data-game>) ============ */
:root {
  --ground: #f5f5f2;
  --surface: #ffffff;
  --raised: #f0f0ec;
  --border: #e4e4df;
  --rule: #eeeee9;
  --control: #d0d0ca;
  --text: #121212;
  --muted: #5d6066;
  --primary: #121212;
  --accent: #0a6e8c;         /* replaced per game */
  --accent-soft: #e3f1f5;
  --good: #23784b; --good-bg: #dcf6e6;
  --warn: #8a4b08; --warn-bg: #fff3d6;
  --bad: #b8262b;  --bad-bg: #ffe8e6;
  --radius: 16px;
  --font: "Outfit", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --pad: 16px;
}
body[data-game="pond"] { --accent: #0a6e8c; --accent-soft: #e3f1f5; }
body[data-game="plant"] { --accent: #2e7a34; --accent-soft: #e6f3e2; }
body[data-game="room"] { --accent: #a2482a; --accent-soft: #f7e9e2; }
body[data-game="detective"] { --accent: #5b3f8c; --accent-soft: #eee8f6; }
body[data-game="circuit"] { --accent: #1f5fa8; --accent-soft: #e4eef9; }

/* ============ BASE ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
p, h1, h2, h3 { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 var(--pad); }
.muted { color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--control); border-radius: 999px; background: var(--surface); font-size: 15px; font-weight: 600; text-decoration: none;
}
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { transform: translateY(1px); }

/* ============ HUB ============ */
.hub-head { padding: 32px 0 20px; }
.hub-mark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 20px; }
.hub-mark svg { width: 34px; height: 34px; }
.hub-head h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.05; letter-spacing: -0.02em; font-weight: 700; }
.hub-head p { margin-top: 10px; max-width: 46ch; color: var(--muted); font-size: 17px; }
.games { display: grid; gap: 12px; grid-template-columns: 1fr; padding-bottom: 28px; }
@media (min-width: 700px) { .games { grid-template-columns: 1fr 1fr; } .games .game:first-child { grid-column: 1 / -1; } }
.game {
  display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit;
}
.game svg { width: 96px; height: 96px; border-radius: 12px; }
.game h2 { font-size: 19px; line-height: 1.2; }
.game p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.game .tag { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--good-bg); color: var(--good); }
.game.is-soon { opacity: 0.72; }
.game.is-soon .tag { background: var(--raised); color: var(--muted); }
.projects { padding: 8px 0 8px; border-top: 1px solid var(--border); }
.projects > h2 { margin-top: 20px; font-size: 22px; letter-spacing: -0.01em; }
.projects > p { margin: 6px 0 14px; max-width: 62ch; color: var(--muted); font-size: 15px; }
.projects .games .game:first-child { grid-column: auto; }
.how { padding: 20px 0 32px; border-top: 1px solid var(--border); display: grid; gap: 14px; }
@media (min-width: 700px) { .how { grid-template-columns: repeat(3, 1fr); } }
.how h3 { font-size: 16px; }
.how p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.foot { padding: 0 0 32px; color: var(--muted); font-size: 13px; }

/* ============ SOUND BUTTON: a speaker in the top bar with two switches ============ */
.sound { position: relative; flex: none; }
.sound-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--control); border-radius: 999px; background: var(--surface); }
.sound-menu { position: absolute; right: 0; top: 46px; z-index: 30; display: grid; gap: 2px; min-width: 210px; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.sound-menu[hidden] { display: none; }
.sound-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; font-size: 15px; font-weight: 600; text-align: left; }
.sound-menu i { position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--control); transition: background 150ms; }
.sound-menu i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 150ms; }
.sound-menu [aria-checked="true"] i { background: var(--accent); }
.sound-menu [aria-checked="true"] i::after { transform: translateX(16px); }

/* ============ GAME SCREEN ============ */
/* One screen, no page scrolling: bar, stage (scene), gauges, controls and a dock of tabs whose panel scrolls inside
   itself. Phones stack these; from 900px the stage, gauges and controls sit left and the dock right. Very short
   screens (a phone on its side) fall back to a normal scrolling page. */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: 54px;
  padding: env(safe-area-inset-top) var(--pad) 0; background: var(--ground); border-bottom: 1px solid var(--border);
}
.bar .back { min-height: 40px; padding: 0 12px; }
.bar h1 { min-width: 0; font-size: 17px; font-weight: 700; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--control); border-radius: 999px; background: var(--surface); font-size: 17px; font-weight: 700; }
.speed { flex: none; display: flex; border: 1px solid var(--control); border-radius: 999px; overflow: hidden; }
.speed button { min-height: 40px; min-width: 38px; padding: 0 6px; border: 0; background: var(--surface); font-size: 14px; font-weight: 600; }
.speed button[aria-pressed="true"] { background: var(--primary); color: #fff; }
@media (max-width: 520px) { .wide-only { display: none; } .bar { gap: 6px; padding-left: 12px; padding-right: 12px; } .bar .back { padding: 0 12px; } }
@media (max-width: 370px) { .bar h1 { display: none; } .bar .back { margin-right: auto; } .speed button { min-width: 34px; } }

.shell { display: flex; flex-direction: column; gap: 8px; max-width: 1180px; margin: 0 auto; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); height: calc(100dvh - 55px - env(safe-area-inset-top)); }
.shell > * { min-width: 0; flex: none; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr; gap: 12px 16px; padding: 14px 20px 16px; }
  .stage { grid-column: 1; grid-row: 1; }
  .gauges { grid-column: 1; grid-row: 2; }
  .manual { grid-column: 1; grid-row: 3; align-self: start; }
  .dock { grid-column: 2; grid-row: 1 / span 3; min-height: 0; }
}
@media (max-height: 560px) and (max-width: 899px) { .shell { height: auto; } .dock .panel { max-height: none; overflow: visible; } }

/* The stage: the scene with the clock, weather buttons and status line laid over it */
.stage { position: relative; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: #cfe8f0; height: clamp(150px, 29dvh, 300px); }
@media (min-width: 900px) { .stage { height: auto; aspect-ratio: 16 / 10; max-height: calc(100dvh - 330px); min-height: 220px; } }
.scene { position: absolute; inset: 0; }
.scene svg { display: block; width: 100%; height: 100%; }
.wx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scene-clock[data-slow="true"]::after { content: " · slow motion"; color: var(--accent); }
.scene-clock { position: absolute; left: 8px; top: 8px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.88); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wx-pick { position: absolute; right: 8px; top: 8px; display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.88); }
.wx-btn { width: 36px; height: 36px; border: 0; border-radius: 999px; background: transparent; font-size: 18px; line-height: 1; }
.wx-btn[aria-pressed="true"] { background: var(--primary); }
.stage-foot { position: absolute; left: 8px; right: 8px; bottom: 8px; display: grid; gap: 6px; justify-items: start; pointer-events: none; }
.status { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); font-size: 14px; font-weight: 600; line-height: 1.25; }
.status .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.status[data-level="warn"] .dot { background: #d08a14; }
.status[data-level="bad"] { background: #fff1ef; color: var(--bad); }
.status[data-level="bad"] .dot { background: var(--bad); }
.toast { padding: 4px 10px; border-radius: 999px; background: rgba(18, 18, 18, 0.78); color: #fff; font-size: 13px; font-weight: 600; opacity: 0; transform: translateY(4px); transition: opacity 200ms, transform 200ms; }
.toast[data-show="true"] { opacity: 1; transform: none; }

/* Controls: one row of switches and action buttons */
.manual { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--control); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg span { padding: 0 8px 0 12px; font-size: 13px; font-weight: 700; }
.seg button { min-height: 40px; padding: 0 10px; border: 0; border-left: 1px solid var(--rule); background: transparent; font-size: 13px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 14px; }
@media (max-width: 899px) {
  .seg button:not([aria-pressed="true"]) { display: none; }
  .seg button[aria-pressed="true"] { min-width: 64px; }
  .seg button[aria-pressed="true"]::after { content: " ⇄"; font-size: 11px; opacity: 0.75; }
  .seg button[data-mode="on"][aria-pressed="true"] { background: var(--good); }
  .seg button[data-mode="off"][aria-pressed="true"] { background: #5d6066; }
}
@media (min-width: 900px) { .seg span, .seg button { font-size: 14px; } }

/* World tab: sliders and choices for free play */
.env { margin-top: 12px; display: grid; gap: 10px; }
.env label, .env-row { display: grid; grid-template-columns: 112px 1fr minmax(56px, auto); align-items: center; gap: 10px; font-size: 14px; }
.env-row { grid-template-columns: 112px 1fr; }
.env output { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.env input[type="range"] { width: 100%; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--control); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.sub { margin-top: 16px; font-size: 15px; }

/* Gauges: compact tiles in one row on phones; a label, the value and a bar with the healthy range marked */
.gauges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.gauges[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gauges[data-n="5"], .gauges[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gauges[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gauge { min-width: 0; text-align: left; padding: 6px 8px 7px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.gauge .label { display: flex; justify-content: space-between; align-items: center; gap: 4px; color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.gauge .name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gauge .ico { font-weight: 400; margin-right: 3px; }
.gauge .value { font-size: clamp(15px, 4.6vw, 18px); letter-spacing: -0.01em; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gauge .value small { font-size: clamp(9.5px, 2.8vw, 11px); font-weight: 500; color: var(--muted); margin-left: 2px; }
.gauge .track { position: relative; height: 5px; margin-top: 4px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.gauge .band { position: absolute; top: 0; bottom: 0; background: var(--good-bg); }
.gauge .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--text); }
/* on phones the tile colour shows the level; the Good / Watch / Problem word is kept for screen readers */
.gauge .pill { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.gauge { position: relative; }
.gauge[data-level="warn"] { border-color: #e9b04a; background: #fffaf0; box-shadow: inset 0 -3px 0 #e9b04a; }
.gauge[data-level="bad"] { border-color: #e2716a; background: #fff3f2; box-shadow: inset 0 -3px 0 var(--bad); }
.gauge[data-level="bad"] .value { color: var(--bad); }
@media (min-width: 900px) {
  .gauge { padding: 10px 12px; }
  .gauge .label { font-size: 13px; }
  .gauge .value { font-size: 24px; }
  .gauge .value small { font-size: 13px; }
  .gauge .pill { position: static; width: auto; height: auto; clip: auto; flex: none; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--good-bg); color: var(--good); }
  .gauge[data-level="warn"] .pill { background: var(--warn-bg); color: var(--warn); }
  .gauge[data-level="bad"] .pill { background: var(--bad-bg); color: var(--bad); }
}

/* The dock: mission strip, tabs and a panel that fills the rest of the screen and scrolls inside itself */
.dock { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.strip { flex: none; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 13px; font-weight: 600; }
.strip[data-kind="won"] { background: var(--good-bg); color: var(--good); }
.strip[data-kind="lost"] { background: var(--bad-bg); color: var(--bad); }
.strip .progress { height: 6px; margin-top: 6px; }
.tabs { flex: none; display: flex; gap: 2px; overflow-x: auto; padding: 3px; border-radius: 999px; background: var(--raised); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; min-height: 38px; padding: 0 clamp(5px, 1.6vw, 12px); border: 0; border-radius: 999px; background: transparent; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.tabs[data-n="7"] button { padding: 0 clamp(3px, 1vw, 12px); font-size: clamp(12px, 3.3vw, 13.5px); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.panel { flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel[hidden] { display: none; }
.panel h2 { font-size: 17px; }
.panel > p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.credit { margin-top: 10px !important; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text) !important; font-size: 13.5px !important; }
.steps { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li { padding-left: 4px; }

/* Evidence tab (Curb-E): the sign's website, one row per record */
.ev-tally { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.ev-count { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 1.25; }
.ev-count b { font-size: 22px; line-height: 1; }
.ev-count.good { background: var(--good-bg); color: var(--good); }
.ev-count.bad { background: var(--bad-bg); color: var(--bad); }
.ev-count.warn { background: var(--warn-bg); color: var(--warn); }
.ev-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ev { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-left-width: 5px; border-radius: 12px; }
.ev.good { border-left-color: var(--good); }
.ev.warn { border-left-color: #d08a14; }
.ev.bad { border-left-color: var(--bad); }
.ev-photo { width: 96px; height: auto; display: block; border-radius: 6px; }
.ev-info { display: grid; gap: 2px; min-width: 0; }
.ev-meta { font-size: 13px; color: var(--muted); }
.ev-verdict { font-size: 13.5px; font-weight: 600; }
.ev.good .ev-verdict { color: var(--good); }
.ev.warn .ev-verdict { color: var(--warn); }
.ev.bad .ev-verdict { color: var(--bad); }

/* Rule cards */
.rules { display: grid; gap: 8px; margin-top: 12px; }
.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--border); font-weight: 600; }
.rule .kw { font-size: 13px; letter-spacing: 0.04em; color: var(--accent); }
.rule select, .rule input { min-height: 40px; padding: 0 8px; border: 1px solid var(--control); border-radius: 10px; background: var(--surface); font-weight: 500; }
.rule input[type="number"] { width: 84px; }
.rule input::placeholder { color: var(--muted); font-size: 13px; }
.rule input[type="time"] { width: 120px; }
.rule .del { margin-left: auto; min-height: 40px; min-width: 40px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hint { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--raised); font-size: 14px; color: var(--muted); }

/* Missions */
.missions { display: grid; gap: 8px; margin-top: 12px; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }
.mission h3 { font-size: 16px; }
.mission p { grid-column: 1; color: var(--muted); font-size: 14px; }
.mission .stars { grid-column: 1; color: #c9971a; letter-spacing: 2px; font-size: 15px; }
.mission .btn { grid-row: 1 / span 3; grid-column: 2; }
.banner { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.banner[data-kind="run"] { background: var(--accent-soft); }
.banner[data-kind="won"] { background: var(--good-bg); color: var(--good); }
.banner[data-kind="lost"] { background: var(--bad-bg); color: var(--bad); }
.progress { height: 8px; margin-top: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }

/* Graph, code, learn */
.graph svg { width: 100%; height: 200px; display: block; margin-top: 10px; }
.graph .axis { stroke: var(--rule); stroke-width: 1; }
.graph .band { fill: var(--good-bg); }
.graph .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.graph text { font-size: 16px; fill: var(--muted); font-family: var(--font); }
.code pre { margin: 12px 0 0; padding: 14px; border-radius: 12px; background: #16181c; color: #e8e8e3; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; overflow: auto; max-height: 420px; }
.learn dl { margin: 12px 0 0; display: grid; gap: 12px; }
.learn dt { font-weight: 700; }
.learn dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.learn .sources { margin-top: 14px; font-size: 13px; color: var(--muted); }
.log { margin-top: 6px; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* ============ SENSOR DETECTIVE ============ */
.detective { max-width: 760px; padding-top: 18px; padding-bottom: 40px; }
@media (max-width: 640px) {
  .detective { padding-top: 10px; }
  .case-intro h2 { font-size: 18px; }
  .case-intro p { font-size: 13.5px; }
  .detective .case-list { margin: 10px 0; }
  .case { padding: 14px; }
  .case-title { font-size: 20px; }
  .story { font-size: 15px; }
  .chart svg { max-height: 150px; }
}
.case-intro h2 { font-size: 22px; }
.case-intro p { margin-top: 4px; font-size: 15px; }
.case-list { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0; padding-bottom: 6px; scrollbar-width: thin; }
.case-chip { flex: none; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; width: 190px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: left; }
.case-chip[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.case-chip .num { grid-row: 1 / span 2; font-weight: 700; color: var(--accent); }
.case-chip .t { font-size: 14px; font-weight: 600; line-height: 1.25; }
.case-chip .stars { color: #c9971a; font-size: 13px; letter-spacing: 1px; }
.case { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.case-meta { color: var(--muted); font-size: 13px; font-weight: 600; }
.case-title { font-size: 24px; line-height: 1.15; margin-top: 4px; }
.case-title:focus { outline: none; }
.story { margin-top: 8px; font-size: 16px; }
.chart { margin: 14px 0 0; }
.chart figcaption { font-size: 14px; }
.chart svg { display: block; width: 100%; height: auto; margin-top: 6px; }
.chart .axis { stroke: var(--rule); stroke-width: 1; }
.chart .band { fill: var(--good-bg); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; }
.chart .mark { stroke: #9a8fb0; stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart text { font-size: 17px; fill: var(--muted); font-family: var(--font); }
.clue { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.clue p { font-weight: 600; }
.ask { margin-top: 18px; font-size: 18px; }
.options { display: grid; gap: 8px; margin-top: 10px; }
.option { min-height: 52px; padding: 10px 14px; border: 1px solid var(--control); border-radius: 12px; background: var(--surface); text-align: left; font-size: 15px; font-weight: 600; }
.option[data-state="wrong"] { background: var(--bad-bg); border-color: transparent; color: var(--bad); text-decoration: line-through; cursor: default; }
.option[data-state="right"] { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.feedback { margin-top: 12px; padding: 14px; border-radius: 12px; }
.feedback[data-kind="won"] { background: var(--good-bg); }
.feedback[data-kind="lost"] { background: var(--bad-bg); }
.feedback h3 { font-size: 17px; }
.feedback p { margin-top: 6px; }
.feedback .btn { margin-top: 12px; }

/* ============ CIRCUIT PLAYGROUND ============ */
.circuit { padding-top: 14px; padding-bottom: 40px; }
@media (max-width: 899px) and (min-height: 561px) {
  .circuit { display: flex; flex-direction: column; height: calc(100dvh - 55px); padding-top: 8px; padding-bottom: 8px; }
  .circuit > .case-list { flex: none; margin-bottom: 8px; }
  .circuit .circuit-layout { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
  .circuit .board-col { flex: none; }
  .circuit .board { height: 47dvh; width: auto; max-width: 100%; }
  .circuit .circuit-side { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px; }
  .circuit .case-title { font-size: 19px; }
}
@media (max-width: 899px) { .case-chip { width: 150px; min-height: 52px; padding: 6px 10px; } .case-chip .t { font-size: 13px; } }
.circuit .case-list { margin-top: 0; }
.circuit-layout { display: grid; gap: 14px; }
.circuit-layout > * { min-width: 0; }
@media (min-width: 900px) { .circuit-layout { grid-template-columns: minmax(0, 460px) 1fr; align-items: start; } .board-col { position: sticky; top: 72px; } }
.board { display: block; width: 100%; max-width: 460px; margin: 0 auto; height: auto; border-radius: var(--radius); border: 1px solid var(--border); background: #e9e4d8; touch-action: manipulation; }
.board .term { cursor: pointer; }
.board .term:focus { outline: none; }
.board .term:focus-visible .ring { opacity: 1; stroke: var(--accent); }
.board .wire-hit { cursor: pointer; }
.circuit-side { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.goal { margin-top: 6px; }
.problems { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.problems li { padding: 10px 12px; border-radius: 10px; font-size: 14px; background: var(--raised); }
.problems li[data-level="bad"] { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.problems li[data-level="warn"] { background: var(--warn-bg); color: var(--warn); }
.problems li[data-level="good"] { background: var(--good-bg); color: var(--good); font-weight: 600; }
.controls { display: grid; gap: 10px; margin-top: 12px; }
.controls .slider { display: grid; grid-template-columns: 1fr; gap: 4px; font-size: 14px; font-weight: 600; }
.controls .slider input { width: 100%; accent-color: var(--accent); }
.controls output { font-variant-numeric: tabular-nums; color: var(--muted); }
.hold { user-select: none; -webkit-user-select: none; touch-action: none; }
.hold[data-on] { background: var(--accent); border-color: var(--accent); color: #fff; }
.monitor-label { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.monitor { margin: 4px 0 0; padding: 10px 12px; border-radius: 10px; background: #16181c; color: #9fe6a8; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; min-height: 42px; }
.circuit .sub { margin-top: 18px; font-size: 16px; }
.small { font-size: 13px; }
.wire-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.wire-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 2px 10px; border-left: 3px solid var(--accent); }
.wire-list .del { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.code-box { margin: 8px 0 0; padding: 14px; border-radius: 12px; background: #16181c; color: #e8e8e3; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; overflow: auto; max-height: 380px; }

/* Sheet that explains one sensor */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; background: rgba(0, 0, 0, 0.35); }
.sheet[hidden] { display: none; }
.sheet > div { max-width: 640px; width: 100%; margin: 0 auto; padding: 20px var(--pad) max(20px, env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--surface); }
.sheet h2 { font-size: 20px; }
.sheet p { margin-top: 8px; color: var(--muted); }
.sheet .btn { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) { .anim { animation: none !important; } .sound-menu i, .sound-menu i::after, .toast { transition: none; } }
