/* Layout: one-screen instrument. Board fills the stage; a narrow parts panel sits right on wide
   screens and below on phones. Single dark world by design: additive light needs a dark ground. */
:root {
  color-scheme: dark;
  --ink: #0b0f1a;        /* breadboard ground, blue-black */
  --plate: #121828;      /* board plate */
  --plate-2: #1a2236;    /* raised surfaces */
  --line: #2a3450;       /* hairlines, holes */
  --text: #dfe5f2;
  --muted: #8691ab;
  --brass: #d8b26a;      /* machined accent: mounts, primary actions */
  --brass-ink: #1b1406;
  --red: #ff4a5c;
  --green: #3dff8a;
  --blue: #4a7dff;
  --yellow: #ffe24a;
  --magenta: #ff4ae0;
  --cyan: #4af2ff;
  --white: #ffffff;
  --danger: #ff7a7a;
  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(1200px 700px at 30% 20%, #141c30 0%, transparent 60%),
    var(--ink);
}

/* ---------- Top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px 0;
  font: 800 15px/1 var(--font-display);
  letter-spacing: 0.22em;
}
.wm-glyph {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: conic-gradient(var(--red), var(--yellow), var(--green), var(--cyan), var(--blue), var(--magenta), var(--red));
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.25);
}
.bar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font: 500 13px/1.2 var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-title b { color: var(--text); font-weight: 500; }
.bar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--plate-2);
  border: 1px solid var(--line);
  font: 600 15px/1 var(--font-body);
}
.icon-btn:hover { border-color: var(--muted); }
#btn-sound .snd-off { display: none; }
#btn-sound[aria-pressed="false"] .snd-on { display: none; }
#btn-sound[aria-pressed="false"] .snd-off { display: inline; }

/* ---------- Stage ---------- */
.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
}
.board-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}
.board-wrap.building #board { opacity: 0.3; transition: opacity 0.2s; }
#board {
  display: block;
  outline: none;
  touch-action: none;
  border-radius: 14px;
}
#board:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(440px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(18, 24, 40, 0.94);
  border: 1px solid var(--line);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  animation: toast-in 0.25s ease-out;
}
.toast b { color: var(--brass); font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Panel ---------- */
.panel {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 16px;
  border-left: 1px solid var(--line);
  background: rgba(10, 14, 24, 0.5);
}
.label {
  font: 500 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 10px;
}
.label-meta { float: right; letter-spacing: 0.04em; }
.tray { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.part {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 8px;
  border-radius: var(--r);
  background: var(--plate);
  border: 1px solid var(--line);
  touch-action: none;
}
.part[aria-pressed="true"] { border-color: var(--brass); background: var(--plate-2); }
.part[disabled] { opacity: 0.4; cursor: default; }
.part-icon { width: 44px; height: 44px; }
.part-name { font-size: 13px; }
.part-count {
  position: absolute;
  top: 6px; right: 8px;
  font: 500 13px/1 var(--font-mono);
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}
.part.bump { animation: bump 0.35s; }
@keyframes bump { 30% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }

.targets { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.targets li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--plate);
  font-size: 13px;
}
.targets .swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--c);
  background: transparent;
}
.targets .now { font: 12px/1 var(--font-mono); color: var(--muted); }
.targets li.ok .swatch { background: var(--c); box-shadow: 0 0 10px var(--c); }
.targets li.ok .now { color: var(--text); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--plate-2);
  border: 1px solid var(--line);
  font-size: 14px;
}
.act:hover:not([disabled]) { border-color: var(--muted); }
.act[disabled] { opacity: 0.4; cursor: default; }
.act-hint { color: var(--brass); }
.act-solve { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.panel-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font: 12px/1 var(--font-mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Workshop ---------- */
.sizes { display: grid; gap: 6px; }
.stepper { display: grid; grid-template-columns: 1fr 34px 30px 34px; align-items: center; gap: 6px; font-size: 13px; }
.stepper .act { padding: 4px 0; }
.stepper output { text-align: center; font: 500 14px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px 5px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--plate);
  font-size: 11px;
  line-height: 1.1;
}
.tool[aria-checked="true"] { border-color: var(--brass); background: var(--plate-2); }
.tool i { width: 16px; height: 16px; border-radius: 4px; background: var(--c, var(--muted)); }
.tool i.round { border-radius: 50%; }
.tool i.ring { background: transparent; border: 3px solid var(--c); border-radius: 4px; }
.tool i.glass { background: transparent; border: 1.5px solid var(--c); background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--c) 3px 4px); opacity: 0.8; }
.tool i.tri { width: 0; height: 0; border-radius: 0; background: none; border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 15px solid #9fb6ff; }
.tool i.stroke { height: 3px; width: 18px; transform: rotate(-45deg); margin-block: 6px; border-radius: 2px; }
.ed-tip { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.checks li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: baseline; }
.checks li::before { content: "·"; color: var(--muted); text-align: center; }
.checks li.ok::before { content: "✓"; color: var(--green); }
.checks li.bad::before { content: "!"; color: var(--danger); font-weight: 600; }
.checks li.info::before { content: "~"; color: var(--brass); }
.editor .actions { grid-template-columns: 1fr 1fr; }
.act-primary { grid-column: 1 / -1; background: var(--brass); color: var(--brass-ink); border-color: var(--brass); font-weight: 600; }
.act-primary:hover:not([disabled]) { border-color: var(--brass); filter: brightness(1.08); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  padding: 16px;
  background: rgba(6, 9, 16, 0.72);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  margin: auto;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-radius: 18px;
  background: var(--plate);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.sheet.wide { width: min(760px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font: 600 20px/1.2 var(--font-display); letter-spacing: 0.02em; text-wrap: balance; }
.close {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  font-size: 20px; line-height: 1;
}
.muted { color: var(--muted); margin: 0; }

.home { text-align: center; align-items: stretch; padding-top: 12px; overflow: hidden; }
.home-art { width: 100%; height: 150px; display: block; }
.title {
  margin: -8px 0 0;
  font: 800 clamp(40px, 11vw, 64px)/1 var(--font-display);
  letter-spacing: 0.18em;
  padding-left: 0.18em;
}
.tagline { margin: 0; color: var(--muted); }
.home-actions { display: grid; gap: 8px; }
.big {
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--plate-2);
  border: 1px solid var(--line);
  font-size: 16px;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
}
.big:hover { border-color: var(--muted); }
.big.primary { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.big.primary:hover { filter: brightness(1.08); }
.big .sub { font: 12px/1 var(--font-mono); color: var(--muted); }
.linkish { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 2px; }
.linkish:hover { color: var(--text); }
.about { display: grid; gap: 12px; font-size: 14px; }
.about p { margin: 0; max-width: 62ch; }
/* Title intro: the wordmark rises out of the light, then the menu settles in one row at a time. */
.home.intro .title { animation: title-in 0.9s cubic-bezier(.2,.7,.2,1) both 0.15s; }
.home.intro .tagline { animation: rise 0.5s ease-out both 0.55s; }
.home.intro .home-actions > * { animation: rise 0.45s ease-out both; }
.home.intro .home-actions > :nth-child(1) { animation-delay: 0.65s; }
.home.intro .home-actions > :nth-child(2) { animation-delay: 0.71s; }
.home.intro .home-actions > :nth-child(3) { animation-delay: 0.77s; }
.home.intro .home-actions > :nth-child(4) { animation-delay: 0.83s; }
.home.intro .home-actions > :nth-child(5) { animation-delay: 0.89s; }
.home.intro .home-actions > :nth-child(6) { animation-delay: 0.95s; }
.home.intro .home-actions > :nth-child(7) { animation-delay: 1.01s; }
.home.intro .home-foot, .home.intro .linkish { animation: fade 0.6s ease-out both 1.1s; }
@keyframes title-in {
  from { opacity: 0; letter-spacing: 0.6em; filter: blur(8px); }
  60% { opacity: 1; filter: blur(0); text-shadow: 0 0 24px rgba(255, 255, 255, 0.6); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.home-foot { margin: 0; font: 12px/1.4 var(--font-mono); color: var(--muted); }

.map-total { margin-left: auto; margin-right: 12px; font-size: 13px; color: var(--muted); }
.map { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.map-path {
  max-height: min(68vh, 680px);
  overflow-y: auto;
  border-radius: 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  padding: 4px;
}
.map-path svg { display: block; max-width: 100%; height: auto; }
.map-rail { fill: none; stroke: var(--line); stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; }
.map-beam { fill: none; stroke: url(#spec); stroke-width: 3; stroke-linecap: round; }
.map-beam-glow { fill: none; stroke: url(#spec); stroke-width: 12; opacity: 0.18; stroke-linecap: round; }
.node { cursor: pointer; outline: none; }
.node circle { fill: var(--plate-2); stroke: var(--c); stroke-width: 2.5; transition: r 0.15s; }
.node text { fill: var(--text); font: 600 13px var(--font-mono); pointer-events: none; }
.node .node-name { fill: var(--muted); font: 500 11px var(--font-body); }
.node.done circle { fill: var(--c); }
.node.done text:not(.node-name) { fill: var(--ink); }
.node.bonus circle { stroke-dasharray: 4 3; }
.node.bonus.done circle { stroke-dasharray: none; }
.node.locked { cursor: default; }
.node.locked circle { stroke: var(--line); }
.node.locked text { fill: var(--line); }
.node.sel circle { stroke-width: 4; filter: drop-shadow(0 0 6px var(--c)); }
.node.sel .node-name { fill: var(--text); }
.node:focus-visible circle { stroke: var(--brass); stroke-width: 4; }
.map-card {
  padding: 18px;
  border-radius: 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.map-card h3 { margin: 0; font: 600 22px/1.15 var(--font-display); letter-spacing: 0.02em; text-wrap: balance; }
.map-card p { margin: 0; color: var(--muted); font-size: 14px; max-width: 60ch; }
.map-card .locked-note { color: var(--danger); }
.levels { display: grid; grid-template-columns: repeat(5, minmax(0, 58px)); gap: 8px; }
.lvl {
  aspect-ratio: 1;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--plate-2);
  font: 500 13px/1 var(--font-mono);
  display: grid;
  place-items: center;
  position: relative;
}
.lvl[disabled] { opacity: 0.3; cursor: default; }
.lvl.done { border-color: var(--brass); color: var(--brass); }
.lvl .pips { position: absolute; bottom: 4px; left: 0; right: 0; font-size: 8px; letter-spacing: 1px; line-height: 1; }
.lvl .bt { position: absolute; top: 4px; left: 0; right: 0; font-size: 8px; line-height: 1; color: var(--muted); }

.tiers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tier {
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--plate-2);
  font: 500 14px/1 var(--font-mono);
}
.tier[aria-checked="true"] { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.code-form { display: flex; gap: 8px; }
.recent { display: grid; gap: 4px; }
.recent-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--plate-2);
  color: var(--text); font-size: 13px; text-align: left;
}
.recent-row .rc-code { font: 500 13px var(--font-mono); }
.recent-row .rc-state { color: var(--muted); font-size: 12px; }
.recent-row.done .rc-code { color: var(--brass); }
.mechs { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px 16px; font-size: 14px; }
.mechs label { display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 420px) { .mechs { grid-template-columns: 1fr 1fr; } }
.code-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--text);
  font: 15px/1 var(--font-mono);
  letter-spacing: 0.04em;
}
.backup { display: grid; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.backup .muted { font-size: 13px; }
.save-out { align-self: center; min-width: 0; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-error.ok { color: var(--muted); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.rules { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.rules b { font-weight: 600; }
.mixes { display: flex; flex-wrap: wrap; gap: 8px 16px; font: 14px/1 var(--font-mono); color: var(--muted); }
.mix { display: inline-flex; align-items: center; gap: 5px; }
.mix i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.keys { font-size: 13px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 6px 14px; }
.legend li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.legend canvas { width: 36px; height: 36px; }
.legend b { color: var(--text); font-weight: 600; margin-right: 4px; }
.legend .ch { font: normal 11px var(--font-mono); color: var(--brass); white-space: nowrap; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 14px; }

.win { text-align: center; }
.stars { display: flex; justify-content: center; gap: 10px; font-size: 34px; line-height: 1; }
.stars span { color: var(--line); }
.stars span.on { color: var(--brass); text-shadow: 0 0 18px rgba(216, 178, 106, 0.6); animation: star 0.5s backwards; }
.stars span.on:nth-child(2) { animation-delay: 0.12s; }
.stars span.on:nth-child(3) { animation-delay: 0.24s; }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.win-code { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.win-code .mono { min-width: 0; max-width: 100%; overflow-wrap: anywhere; font-size: 13px; }
.mono { font-family: var(--font-mono); letter-spacing: 0.06em; }

/* ---------- Daily ---------- */
.daily-today { display: grid; gap: 10px; padding: 16px; border-radius: 12px; background: var(--ink); border: 1px solid var(--line); }
.daily-today .dt-theme { font: 600 18px/1.2 var(--font-display); text-wrap: balance; }
.daily-today .dt-meta { font: 12px/1.4 var(--font-mono); color: var(--muted); }
.daily-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dday {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--plate-2);
  font: 500 12px/1 var(--font-mono);
  min-width: 0;
}
.dday .dd-w { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.dday .dd-n { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.dday .dd-s { font-size: 9px; letter-spacing: 1px; color: var(--brass); min-height: 9px; }
.dday.done { border-color: var(--brass); }
.dday.late { border-style: dashed; }
.dday.today { outline: 2px solid var(--brass); outline-offset: 1px; }
.daily-note { font-size: 13px; }

/* ---------- Gallery ---------- */
.g-sort { display: flex; gap: 6px; margin-left: auto; margin-right: 12px; }
.g-sort .act[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.g-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.g-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--ink); border: 1px solid var(--line); }
.g-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.g-title { font-weight: 600; overflow-wrap: anywhere; }
.g-meta { font: 12px/1.3 var(--font-mono); color: var(--muted); }
.g-like[aria-pressed="true"] { color: var(--red); border-color: var(--red); }
.gallery-empty { padding: 20px 4px; }

.win-board { text-align: left; }
.daily-board { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: 14px; }
.daily-board li { padding: 2px 0; }
.daily-board li > span { display: inline-block; }
.daily-board .db-name { min-width: 45%; overflow-wrap: anywhere; }
.daily-board .db-num { min-width: 22%; font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.daily-board li.me .db-name { color: var(--brass); font-weight: 600; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; background: var(--ink); border: 1px solid var(--line); min-width: 0; }
.stat-v { font: 600 20px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.stat-k { font: 11px/1.2 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.ach-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.ach-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 10px; border-radius: 10px; background: var(--ink); border: 1px solid var(--line); opacity: 0.55; }
.ach-list li.got { opacity: 1; border-color: rgba(216, 178, 106, 0.5); }
.ach-mark { color: var(--brass); font-size: 16px; line-height: 1.2; }
.ach-list b { display: block; font-weight: 600; font-size: 14px; }
.ach-list small { display: block; color: var(--muted); font-size: 12px; }
.bar-title .trial-clock { color: var(--brass); }

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .board-wrap { padding: 10px 16px 6px; }
  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
    overflow: visible;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "tray targets" "actions actions";
    align-items: start;
  }
  .panel-block:nth-child(1) { grid-area: tray; }
  .panel-block:nth-child(2) { grid-area: targets; min-width: 0; }
  .actions { grid-area: actions; grid-template-columns: repeat(4, 1fr); }
  .act-solve { padding: 5px; }
  .panel-foot { display: none; }
  .panel.editor { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; }
  .panel.editor .actions { order: -1; grid-template-columns: repeat(4, 1fr); }
  .tools { grid-template-columns: repeat(6, 1fr); }
  .map { grid-template-columns: minmax(0, 1fr); }
  .sheet { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-v { font-size: 17px; }
  .g-sort { margin-right: 8px; }
  .g-sort .act { padding: 6px 8px; font-size: 12px; }
  .map-path { max-height: 220px; order: 2; }
  .map-path svg { margin: 0 auto; }
  .label { margin-bottom: 6px; }
  .tray { grid-template-columns: repeat(2, 68px); }
  .part { padding: 6px 4px; }
  .part-icon { width: 32px; height: 32px; }
  .part-name { font-size: 11px; }
  .part-count { position: static; order: 3; font-size: 11px; }
  .targets { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .targets li { padding: 6px 8px; gap: 6px; grid-template-columns: auto 1fr; }
  .targets .name { display: none; }
  .bar { padding: 8px 16px; gap: 8px; }
  .wordmark { font-size: 13px; letter-spacing: 0.16em; }
  .icon-btn { width: 32px; height: 32px; }
  .bar-title { text-align: left; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Language ---------- */
.lang-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.lang-row .label { margin-bottom: 0; }
.sheet a { color: var(--brass); text-underline-offset: 3px; }
.lang-row a { display: inline-flex; align-items: center; min-height: 44px; }
.lang { display: flex; gap: 6px; }
.lang .tier { padding: 7px 12px; font-family: var(--font-body); }
.home-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.feedback-form { display: grid; gap: 8px; }
.feedback-form input, .feedback-form select, .feedback-form textarea {
  min-width: 0; width: 100%; padding: 10px; border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); background: var(--ink); font: inherit;
}
.feedback-form textarea { resize: vertical; }
.overlay { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.icon-btn, .close { min-width: 44px; min-height: 44px; }
.act, .linkish { min-height: 44px; }
@media (max-height: 540px) and (max-width: 760px) {
  body { overflow-y: auto; }
  .app { min-height: 600px; }
}
