/* Logicnaut PID Lab. Control room blues with reactor cyan and amber, dark HUD on request or system setting.
   Base type stays at 18px for a young learner. */
:root {
  color-scheme: light;
  --ink: #0f1b2d;
  --ink-soft: #24344a;
  --muted: #5d6b80;
  --line: #d6deeb;
  --page: #f2f6fb;
  --surface: #ffffff;
  --white: #ffffff;
  --ws-bg: #e8eef7;
  --accent: #2f80ed;
  --accent-dark: #1f5fb8;
  --accent-soft: #4c97ff;
  --gold: #f2c14e;
  --gold-dark: #b8860b;
  --green: #17b3d6;
  --green-dark: #0f7f9a;
  --red: #d3261f;
  --orange: #e8a23b;
  --orange-dark: #b07414;
  --glow: rgba(53, 208, 238, 0.5);
  --tint-note: #fff3d6;
  --tint-win: #e3f6fb;
  --tint-try: #fde8e6;
  --tint-info: #e8f1ff;
  --display: "Exo 2", ui-sans-serif, system-ui, sans-serif;
  --body: "Exo 2", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  --shadow: 0 10px 28px rgba(15, 27, 45, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --hero: #0b1f3a;
  --hero-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #eef3fb; --ink-soft: #cdd8e8; --muted: #93a3ba; --line: #24344d; --page: #070d18; --surface: #0f1a2c; --ws-bg: #16233a;
    --accent: #4c97ff; --accent-dark: #1f5fb8; --gold-dark: #f2c14e; --green: #35d0ee; --green-dark: #1b8fa8;
    --tint-note: #2a2210; --tint-win: #0f2a33; --tint-try: #33110f; --tint-info: #10233d;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(53, 208, 238, 0.08); --hero: #04070f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef3fb; --ink-soft: #cdd8e8; --muted: #93a3ba; --line: #24344d; --page: #070d18; --surface: #0f1a2c; --ws-bg: #16233a;
  --accent: #4c97ff; --accent-dark: #1f5fb8; --gold-dark: #f2c14e; --green: #35d0ee; --green-dark: #1b8fa8;
  --tint-note: #2a2210; --tint-win: #0f2a33; --tint-try: #33110f; --tint-info: #10233d;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(53, 208, 238, 0.08); --hero: #04070f;
}

* { box-sizing: border-box; }

/* Layout rules below set display, so hidden needs to win over them. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  overflow-x: hidden;
}
/* HUD grid: a faint reactor blue lattice behind the page in dark mode, gold hairlines in light mode. */
body {
  background-image:
    linear-gradient(rgba(242, 193, 78, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 193, 78, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body {
    background-image:
      linear-gradient(rgba(53, 208, 238, 0.07) 1px, transparent 1px),
      linear-gradient(90deg, rgba(53, 208, 238, 0.07) 1px, transparent 1px);
  }
}
:root[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(53, 208, 238, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53, 208, 238, 0.07) 1px, transparent 1px);
}

body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.wrap {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--ink);
  color: var(--white);
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 50;
}
.skip-link:focus { top: 12px; }

a { color: var(--accent); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Header and hero. */
.hero-band {
  position: relative;
  background: radial-gradient(circle at 78% 30%, rgba(47, 128, 237, 0.4), transparent 42%), var(--hero);
  color: var(--hero-text);
  padding-bottom: 8px;
  overflow: hidden;
}
.hero-band::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, rgba(53, 208, 238, 0.06) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 82% 50%, rgba(53, 208, 238, 0.18), transparent 28%);
}
.hero-band::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--green), transparent);
  pointer-events: none;
}
.topbar, .intro { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand .mark { width: 46px; height: 46px; filter: drop-shadow(0 0 8px var(--glow)); }
.brand-words { display: flex; flex-direction: column; line-height: 1.05; }
.brand-words strong { font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: 0.08em; }
.brand-words small { font-family: var(--display); font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.28em; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ghost, .link-button {
  background: transparent;
  border: 2px solid currentColor;
  border-radius: var(--radius-sm) 2px var(--radius-sm) 2px;
  padding: 8px 16px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hero-band .ghost, .hero-band .link-button { color: var(--hero-text); }
main .ghost, main .link-button { color: var(--ink-soft); }
.ghost.small { padding: 6px 12px; font-size: 15px; }

.primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: var(--white);
  border: 0;
  border-radius: var(--radius-sm) 2px var(--radius-sm) 2px;
  box-shadow: 0 5px 0 var(--accent-dark);
  font-family: var(--display);
  letter-spacing: 0.04em;
  padding: 12px 22px;
  font-weight: 800;
  font-size: 18px;
  min-height: 48px;
}
.primary.small { padding: 8px 16px; font-size: 16px; min-height: 40px; }
.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-dark); }
.primary:focus-visible, .ghost:focus-visible, .tool:focus-visible, .puzzle-chip:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; box-shadow: 0 0 0 6px var(--glow); }
.primary:disabled { opacity: 0.5; cursor: default; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 28px 0 12px;
}
.eyebrow, .instruction {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dark);
  font-weight: 400;
}
.intro h1 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(30px, 4vw, 50px);
  line-height: 1.08;
  margin: 0 0 14px;
  text-transform: uppercase;
}
.intro h1 span { color: var(--green); text-shadow: 0 0 18px var(--glow); }
.lede { margin: 0 0 18px; color: var(--ink-soft); }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stats div {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.stats strong { font-family: var(--mono); font-weight: 600; font-size: 32px; line-height: 1; color: var(--accent); }
.stats span { font-family: var(--mono); font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; margin-top: 4px; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }

/* Shells. */
.shell, .world, .palette, .workspace-card, .stage-card, .stats div { position: relative; border: 1px solid var(--line); }
.shell::before, .world::before, .stage-card::before, .workspace-card::before, .palette::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border-radius: 6px;
  background:
    linear-gradient(var(--gold-dark), var(--gold-dark)) top left / 22px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) top left / 2px 22px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) bottom right / 22px 2px no-repeat,
    linear-gradient(var(--gold-dark), var(--gold-dark)) bottom right / 2px 22px no-repeat;
  opacity: 0.7;
}
.shell {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin: 20px 0;
}
.shell-title { font-family: var(--display); font-weight: 700; letter-spacing: 0.02em; font-size: 22px; margin: 0 0 10px; line-height: 1.2; }
.path-head { margin: 26px 0 6px; }
.path-head .shell-title { margin-bottom: 0; }
.shell-title.small { font-size: 17px; }
.shell-note { color: var(--muted); font-size: 16px; margin: 6px 0; }
.field-label { display: block; font-weight: 700; margin: 12px 0 6px; }

.how-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }

/* Worlds. */
.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin: 10px 0 40px;
}
.world {
  background: var(--surface);
  border-radius: var(--radius-md);
  border-top: 10px solid var(--world);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}
.world-locked { opacity: 0.72; }
.world-number { font-family: var(--mono); font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--world-dark); }
.world-head h3 { font-family: var(--display); font-weight: 700; font-size: 19px; margin: 2px 0 4px; letter-spacing: 0.03em; }
.world-tagline { margin: 0 0 6px; color: var(--ink-soft); }
.world-progress { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

.puzzle-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.puzzle-chip {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--page);
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.puzzle-chip.is-solved { border-color: var(--world); background: var(--surface); }
.puzzle-chip.is-solved .chip-meta { color: var(--gold-dark); }
.puzzle-chip.is-locked { color: var(--muted); cursor: default; }
.chip-meta { font-size: 15px; color: var(--gold-dark); letter-spacing: 0.08em; white-space: nowrap; }
.puzzle-chip.is-locked .chip-meta, .puzzle-chip:not(.is-solved) .chip-meta { color: var(--muted); }

/* Play screen. */
.play-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 22px 0 8px;
  flex-wrap: wrap;
}
.play-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.goal { margin: 4px 0 6px; font-size: 20px; max-width: 70ch; }
.ask-note { margin: 0 0 6px; color: var(--ink-soft); font-size: 16px; background: var(--tint-info); border-radius: var(--radius-sm); padding: 8px 12px; max-width: 70ch; }
.par-line { margin: 0; color: var(--muted); font-size: 15px; font-weight: 600; }

.lab {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.palette {
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 10px;
  max-height: 680px;
  display: flex;
  flex-direction: column;
}
.palette-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.palette-tab {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cat-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.palette-body { overflow-y: auto; flex: 1 1 auto; min-width: 0; max-width: 100%; padding-top: 6px; overscroll-behavior: contain; }
.palette-heading { font-size: 15px; margin: 12px 0 4px; display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.palette-item { margin: 8px 0; width: max-content; max-width: 100%; }
.make-variable {
  border: 0;
  background: #ff8c1a;
  color: var(--white);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 15px;
  margin: 4px 0 8px;
}

.workspace-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 10px;
  min-width: 0;
}
.workspace-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 2px 8px; }
.block-count { font-size: 15px; color: var(--muted); font-weight: 600; }
.toolbar-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.tool {
  border: 1px solid var(--line);
  background: var(--page);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 600;
}
.tool:disabled { opacity: 0.45; cursor: default; }

.workspace {
  position: relative;
  height: 600px;
  overflow: auto;
  background: var(--ws-bg);
  border-radius: 12px;
  border: 1px solid var(--line);
  touch-action: pan-x pan-y;
}
.workspace:focus-visible { outline: 3px solid var(--gold); }
.ws-canvas { position: relative; width: 1600px; height: 1400px; min-width: 100%; }
.ws-canvas.is-empty::before {
  content: "Drag a block here, or tap one in the palette.";
  position: absolute;
  left: 24px;
  top: 24px;
  color: var(--muted);
  font-weight: 600;
}
.workspace-help { margin: 8px 2px 0; font-size: 15px; color: var(--muted); }

.script { position: absolute; display: flex; flex-direction: column; align-items: flex-start; }
.static-script { display: flex; flex-direction: column; align-items: flex-start; margin: 6px 0; }

/* Blocks. */
.block {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: max-content;
  max-width: 100%;
  color: var(--white);
  background: var(--block);
  border: 1px solid var(--block-dark);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.block-row { display: flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 42px; }
.label { white-space: nowrap; }

/* Bottom tab that hooks into the block below. */
.shape-stack::after, .shape-c::after, .shape-e::after, .shape-hat::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -7px;
  width: 26px;
  height: 8px;
  background: var(--block);
  border: 1px solid var(--block-dark);
  border-top: 0;
  border-radius: 0 0 5px 5px;
  z-index: 1;
}
.script > .block + .block, .mouth-stack > .block + .block, .static-script > .block + .block { margin-top: 0; }
.script > .block, .mouth-stack > .block, .static-script > .block { margin-bottom: 1px; }

.shape-hat { border-radius: 26px 26px 6px 6px; }
.shape-hat .block-row { padding-top: 12px; }
.shape-cap { border-radius: 6px 6px 12px 12px; }

.mouth {
  align-self: stretch;
  margin-left: 16px;
  min-height: 34px;
  background: var(--ws-bg);
  border-radius: 6px 0 0 6px;
  padding: 4px 0 6px 0;
}
.in-palette .mouth, .drag-layer .mouth, .peek-blocks .mouth { background: var(--ws-bg); }
.mouth-stack { display: flex; flex-direction: column; align-items: flex-start; min-width: 90px; }
.block-foot { height: 22px; align-self: stretch; }
.block-row-else { min-height: 36px; }

.shape-reporter { border-radius: 999px; }
.shape-reporter .block-row { min-height: 32px; padding: 2px 10px; }
.shape-boolean {
  border-radius: 0;
  border: 0;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0 50%);
}
.shape-boolean .block-row { min-height: 32px; padding: 2px 18px; }

.slot { display: inline-flex; align-items: center; min-height: 30px; }
.slot-filled { padding: 0; }
.field {
  font: inherit;
  font-weight: 600;
  color: #24292f;
  background: #ffffff;
  border: 0;
  height: 30px;
  padding: 0 10px;
  text-align: center;
  text-shadow: none;
  min-width: 42px;
}
.field-number { border-radius: 999px; }
.field-text { border-radius: 6px; }
.field:focus { outline: 3px solid var(--gold); }
.field-menu {
  appearance: none;
  -webkit-appearance: none;
  background: var(--block-dark) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center / 10px 7px;
  color: var(--white);
  border-radius: 999px;
  padding: 0 28px 0 12px;
  min-width: 60px;
  text-align: left;
}
.field-menu option { color: var(--ink); background: var(--surface); }
.slot-variable-name .variable-name { padding: 0 6px; font-weight: 600; }
/* Palette fields are read only, so taps pass through to the block and start a drag. */
.in-palette .field { pointer-events: none; }
.slot-boolean.slot-empty {
  width: 46px;
  height: 28px;
  background: var(--block-dark);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
}
.slot-hot .field, .slot-hot.slot-empty { outline: 3px solid var(--white); box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.55); }
.slot-hot.slot-empty { background: #ffffff; }

.block.selected { outline: 3px solid var(--gold); outline-offset: 1px; }
.block.running { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255, 204, 77, 0.7); filter: brightness(1.08); }
.in-palette { cursor: grab; }

.drag-layer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  filter: drop-shadow(0 10px 18px rgba(27, 31, 59, 0.3));
  will-change: transform;
}
.drag-layer.will-delete { opacity: 0.45; }
.drop-marker {
  position: absolute;
  height: 8px;
  border-radius: 4px;
  background: rgba(27, 31, 59, 0.4);
  pointer-events: none;
  z-index: 5;
}

/* Stage. */
.stage-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}
.stage-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.run { background: var(--green); box-shadow: 0 5px 0 var(--green-dark); padding: 10px 18px; }
.run:active { box-shadow: 0 2px 0 var(--green-dark); }
.stop, .check {
  border: 0;
  border-radius: var(--radius-sm) 2px var(--radius-sm) 2px;
  font-family: var(--display);
  letter-spacing: 0.04em;
  padding: 10px 18px;
  font-weight: 800;
  color: var(--white);
  font-size: 17px;
  min-height: 48px;
}
.stop { background: var(--red); box-shadow: 0 5px 0 #b83237; }
.stop:disabled { opacity: 0.45; cursor: default; }
.check { background: var(--orange); box-shadow: 0 5px 0 var(--orange-dark); color: var(--ink); }
.check:active, .stop:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }

.stage-holder {
  aspect-ratio: 4 / 3;
  max-width: 100%;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stage-svg { display: block; width: 100%; height: 100%; }
.stage-grid line { stroke: var(--line); stroke-width: 0.6; }
.stage-axes line { stroke: var(--gold-dark); stroke-width: 1; opacity: 0.55; }
.star path { fill: var(--gold); stroke: #b8860b; stroke-width: 1.5; }
.star-collected path { fill: var(--green); stroke: var(--green-dark); }
.bubble-box { fill: var(--surface); stroke: var(--gold-dark); stroke-width: 1.5; }
.bubble-text { font: 700 13px var(--body); fill: var(--ink); }
.stage-readout { margin: 8px 2px 0; font-family: var(--mono); font-size: 14px; color: var(--muted); font-weight: 500; white-space: pre; }

.watchers { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.watcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--tint-info);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px 4px 10px;
  font-size: 15px;
}
.watcher-name { font-weight: 700; color: var(--ink-soft); }
.watcher-value { background: #ff8c1a; color: var(--white); border-radius: 6px; padding: 1px 8px; font-family: var(--mono); font-weight: 600; min-width: 30px; text-align: center; }

.ask-form { margin-top: 10px; background: var(--tint-info); border-radius: 12px; padding: 10px 12px; }
.ask-form label { display: block; font-weight: 700; margin-bottom: 6px; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1 1 auto; min-width: 0; font: inherit; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); }

.said-log {
  margin: 10px 0 0;
  padding: 8px 12px 8px 32px;
  max-height: 130px;
  overflow-y: auto;
  background: var(--page);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 14px;
  border: 1px solid var(--line);
}
.said-log li { padding: 1px 0; }

.feedback { margin-top: 10px; border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.feedback p { margin: 0 0 6px; }
.feedback-win { background: var(--tint-win); border: 2px solid var(--green); box-shadow: 0 0 24px var(--glow); }
.feedback-try { background: var(--tint-try); border: 2px solid var(--accent); }
.feedback-note { background: var(--tint-note); border: 2px solid var(--gold); }
.feedback-win > p:first-child { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--green-dark); letter-spacing: 0.04em; text-transform: uppercase; }
.problem-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.celebrate .star-row { font-size: 34px; color: var(--gold-dark); letter-spacing: 4px; line-height: 1; }
.bolt-line { font-family: var(--mono); font-weight: 600; color: var(--gold-dark); }
.sandbox-note { margin: 10px 0 0; font-size: 15px; color: var(--muted); }

.play-extras { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 40px; }
@media (max-width: 1180px) { .play-extras { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .play-extras .setup { grid-column: 1 / -1; } }
.play-extras 

@media (max-width: 1180px) {
  .play-extras { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .play-extras   .lab { grid-template-columns: minmax(0, 280px) minmax(0, 1fr); }
  .stage-card { grid-column: 1 / -1; }
  .stage-holder { max-width: 560px; }
}

@media (max-width: 820px) {
  .intro { grid-template-columns: 1fr; }
  .lab { grid-template-columns: minmax(0, 1fr); }
  .stage-card { order: -1; }
  .palette { max-height: none; }
  .palette-body { display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden; padding-bottom: 8px; }
  .palette-group { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
  .palette-heading { margin: 0; }
  .palette-item { margin: 0; }
  .workspace { height: 420px; }
  .play-extras { grid-template-columns: minmax(0, 1fr); }
  .shell { padding: 18px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats strong { font-size: 28px; }
  .header-actions .ghost { padding: 6px 12px; font-size: 15px; }
  .brand .mark { width: 38px; height: 38px; }
  .goal { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Field, telemetry chart, and Brain screen. */
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 6px; }
.choice-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 4px 0 6px; }
.chip-button { border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm) 2px var(--radius-sm) 2px; padding: 4px 12px; font-weight: 700; font-size: 15px; }
.chip-button.is-active { border-color: var(--accent); background: var(--tint-info); }
.robot-note { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.field-holder { aspect-ratio: 33 / 16; max-width: 100%; border: 2px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: radial-gradient(circle at 50% 50%, rgba(53, 208, 238, 0.06), transparent 70%), var(--surface); }
.field-svg { display: block; width: 100%; height: 100%; }
.field-grid line { stroke: var(--line); stroke-width: 3; }
.field-centre { stroke: var(--gold-dark); stroke-width: 4; stroke-dasharray: 24 18; opacity: 0.7; }
.field-finish { stroke: var(--green); stroke-width: 8; }
.field-corridor { stroke: var(--accent); stroke-width: 4; stroke-dasharray: 16 16; opacity: 0.7; }
.field-home { fill: rgba(53, 208, 238, 0.12); stroke: var(--green); stroke-width: 4; }
.field-label { font: 600 var(--label-size, 40px) var(--body); fill: var(--muted); }
.field-trail { stroke: var(--accent); stroke-width: 8; stroke-linejoin: round; stroke-linecap: round; opacity: 0.8; }
.robot-body { fill: #2b3448; stroke: var(--green); stroke-width: 6; }
.robot-wheel { fill: #111827; }
.robot-brain { fill: #35d0ee; }
.robot-nose { fill: var(--gold); }
.chart { display: block; width: 100%; height: auto; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chart-zero { stroke: var(--line); stroke-width: 1; }
.chart-target { stroke: var(--gold-dark); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart-line { stroke: var(--green); stroke-width: 2; }
.chart-label { font: 11px var(--mono); fill: var(--muted); }
.chart-caption { margin: 4px 2px 0; font-size: 13px; color: var(--muted); }
.brain-screen { margin: 10px 0 0; padding: 10px 12px; min-height: 96px; background: #0a1a12; color: #7dffb0; border-radius: var(--radius-sm); font: 15px/1.4 var(--mono); white-space: pre-wrap; border: 3px solid #22303f; }
.robot-results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.robot-results .is-pass { color: var(--green-dark); }
.robot-results .is-fail { color: var(--red); }

/* Telemetry cells, the Brain, and the BaseBot diagram. */
.telemetry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 0; }
.telemetry div { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 8px; min-width: 0; }
.telemetry dt { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.telemetry dd { margin: 0; font-family: var(--mono); font-size: 17px; color: var(--ink); overflow-wrap: anywhere; }
.brain { margin-top: 12px; background: #1d2330; border-radius: 16px; padding: 10px 12px 8px; border: 2px solid #333c4d; }
.brain-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.brain-name { font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: #aab4c8; }
.brain-hint { font-size: 12px; color: #8a95ab; }
.brain-screen { margin: 0; padding: 12px 14px; min-height: 132px; background: #07130c; color: #7dffb0; border-radius: 8px; font: 17px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; border: 3px solid #0e2417; box-shadow: inset 0 0 24px rgba(125, 255, 176, 0.12); }
.brain-screen:empty::before { content: attr(data-empty); color: #3f7d55; font-family: var(--body); font-size: 14px; }
.brain-buttons { display: flex; justify-content: center; gap: 14px; margin-top: 8px; }
.brain-buttons span { width: 22px; height: 12px; border-radius: 6px; background: #3b4557; }
.brain-buttons .is-check { background: #4c97ff; }
.basebot { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto 8px; }
.bb-chassis { fill: #2b3448; stroke: var(--green); stroke-width: 3; }
.bb-wheel { fill: #111827; stroke: #3b4557; stroke-width: 2; }
.bb-motor { fill: #4c97ff; stroke: #1f5fb8; stroke-width: 2; }
.bb-brain { fill: #e6ecf5; stroke: #8a95ab; stroke-width: 2; }
.bb-screen { fill: #07130c; }
.bb-inertial { fill: var(--gold); stroke: #8a6d1c; stroke-width: 2; }
.bb-arrow { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.bb-label { font: 700 14px var(--body); fill: var(--ink); }
.bb-small { font-weight: 500; font-size: 12px; fill: var(--muted); }
.bb-centre { text-anchor: middle; }
.setup-list { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
