/* Circuit 12 Playground — isolated route styles */
:root {
  --play-bg: #07111f;
  --play-panel: #0d1e31;
  --play-panel-2: #11283f;
  --play-line: rgba(155, 216, 255, 0.22);
  --play-blue: #55b7ff;
  --play-blue-2: #9bd8ff;
  --play-lime: #d7f36b;
  --play-cyan: #66f4dd;
  --play-orange: #ffb45a;
  --play-red: #ff7586;
  --play-text: #f6fbff;
  --play-muted: #b5c7d8;
}

body {
  background:
    radial-gradient(circle at 78% 4%, rgba(85, 183, 255, 0.14), transparent 30rem),
    linear-gradient(180deg, #07111f 0%, #081421 55%, #050a11 100%);
}

.playground-hero,
.playground-shell,
.playground-footer-note {
  width: min(1480px, calc(100% - clamp(24px, 4vw, 72px)));
  margin-inline: auto;
}

.playground-hero {
  min-height: 360px;
  padding: clamp(3.5rem, 7vw, 7rem) 0 clamp(2.5rem, 5vw, 4.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 7rem);
}

.playground-hero h1 {
  max-width: 14ch;
  margin: 0.25rem 0 1rem;
  font-size: clamp(2.8rem, 6vw, 6.3rem);
  line-height: 0.94;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.playground-hero .hero-text {
  max-width: 65ch;
  color: var(--play-muted);
}

.playground-hero-board {
  position: relative;
  min-height: 260px;
  border: 1px solid var(--play-line);
  border-radius: 28px;
  background:
    linear-gradient(rgba(155, 216, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 216, 255, 0.05) 1px, transparent 1px),
    linear-gradient(145deg, rgba(17, 40, 63, 0.96), rgba(7, 17, 31, 0.94));
  background-size: 28px 28px, 28px 28px, auto;
  box-shadow: inset 0 0 80px rgba(85, 183, 255, 0.05), 0 24px 80px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.playground-hero-board::before,
.playground-hero-board::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
}

.playground-hero-board::before {
  width: 240px;
  height: 240px;
  right: -100px;
  top: -110px;
  background: rgba(85, 183, 255, 0.12);
}

.playground-hero-board::after {
  width: 180px;
  height: 180px;
  left: -90px;
  bottom: -100px;
  background: rgba(102, 244, 221, 0.08);
}

.hero-node {
  position: absolute;
  z-index: 2;
  width: 78px;
  height: 78px;
  border: 1px solid rgba(155, 216, 255, 0.42);
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #0a1a2b;
  color: var(--play-blue-2);
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 0 0 8px rgba(85, 183, 255, 0.04), 0 0 32px rgba(85, 183, 255, 0.16);
}

.hero-node-source { left: 8%; top: 34%; }
.hero-node-core {
  left: 50%;
  top: 50%;
  width: 104px;
  height: 104px;
  transform: translate(-50%, -50%);
  border-radius: 28px;
  color: var(--play-lime);
}
.hero-node-output { right: 8%; bottom: 22%; }

.hero-trace {
  position: absolute;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--play-blue), var(--play-cyan));
  box-shadow: 0 0 18px rgba(102, 244, 221, 0.55);
  transform-origin: left center;
}

.hero-trace::after {
  content: "";
  position: absolute;
  inset: -5px auto -5px 0;
  width: 24%;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.85);
  filter: blur(2px);
  animation: trace-scan 2.1s linear infinite;
}

.hero-trace-a { left: 23%; top: 49%; width: 29%; transform: rotate(5deg); }
.hero-trace-b { left: 60%; top: 55%; width: 25%; transform: rotate(18deg); }

@keyframes trace-scan {
  from { transform: translateX(-30%); opacity: 0; }
  20%, 80% { opacity: 0.9; }
  to { transform: translateX(420%); opacity: 0; }
}

.playground-shell {
  margin-bottom: clamp(4rem, 8vw, 8rem);
  border: 1px solid var(--play-line);
  border-radius: 28px;
  background: rgba(7, 17, 31, 0.78);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.playground-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--play-line);
  background: rgba(5, 12, 21, 0.74);
}

.playground-tabs button {
  min-height: 112px;
  padding: 1.3rem clamp(1rem, 2vw, 2rem);
  border: 0;
  border-right: 1px solid var(--play-line);
  background: transparent;
  color: var(--play-muted);
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 1rem;
  align-content: center;
  cursor: pointer;
}

.playground-tabs button:last-child { border-right: 0; }

.playground-tabs button:hover,
.playground-tabs button[aria-selected="true"] {
  color: var(--play-text);
  background: linear-gradient(180deg, rgba(85, 183, 255, 0.12), rgba(85, 183, 255, 0.035));
}

.playground-tabs button[aria-selected="true"] {
  box-shadow: inset 0 -3px 0 var(--play-lime);
}

.playground-tabs strong { font-size: 1.04rem; }
.playground-tabs small { grid-column: 2; color: var(--play-muted); }
.game-number {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--play-blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.game-panel {
  padding: clamp(1.25rem, 3vw, 3rem);
}

.game-panel[hidden] { display: none !important; }

.game-panel-head {
  margin-bottom: clamp(1.25rem, 3vw, 2.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
}

.game-panel-head h2 {
  margin: 0.15rem 0 0.45rem;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.game-panel-head p:last-child {
  max-width: 72ch;
  margin-bottom: 0;
  color: var(--play-muted);
}

.game-scoreboard {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(88px, auto);
  border: 1px solid var(--play-line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(5, 12, 21, 0.7);
}

.game-scoreboard span {
  min-height: 74px;
  padding: 0.7rem 1rem;
  border-right: 1px solid var(--play-line);
  display: grid;
  place-items: center;
  align-content: center;
}

.game-scoreboard span:last-child { border-right: 0; }
.game-scoreboard strong { font-size: 1.45rem; color: var(--play-lime); }
.game-scoreboard small { color: var(--play-muted); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }

.stack-layout {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(240px, 340px);
  justify-content: center;
  gap: clamp(1.25rem, 4vw, 4rem);
  align-items: start;
}

.stack-stage {
  position: relative;
  width: min(100%, 520px);
  margin-inline: auto;
  padding: 12px;
  border: 1px solid rgba(155, 216, 255, 0.32);
  border-radius: 18px;
  background: #050c15;
  box-shadow: inset 0 0 40px rgba(85, 183, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.32);
}

.stack-grid {
  aspect-ratio: 10 / 14;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(14, minmax(0, 1fr));
  gap: 3px;
  background:
    linear-gradient(rgba(155, 216, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 216, 255, 0.035) 1px, transparent 1px);
  background-size: 10% calc(100% / 14);
}

.stack-cell {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(155, 216, 255, 0.045);
  border-radius: 4px;
  background: rgba(17, 40, 63, 0.24);
}

.stack-cell.is-filled,
.stack-cell.is-active {
  border-color: rgba(155, 216, 255, 0.7);
  background:
    radial-gradient(circle at center, var(--play-lime) 0 8%, transparent 9%),
    linear-gradient(90deg, transparent 46%, rgba(155, 216, 255, 0.82) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(155, 216, 255, 0.82) 47% 53%, transparent 54%),
    linear-gradient(145deg, #163b59, #0c2439);
  box-shadow: inset 0 0 12px rgba(85, 183, 255, 0.18);
}

.stack-cell.is-active {
  border-color: var(--play-lime);
  filter: brightness(1.2);
  box-shadow: 0 0 14px rgba(215, 243, 107, 0.28), inset 0 0 12px rgba(215, 243, 107, 0.14);
}

.stack-cell.is-clearing { animation: bus-clear 220ms ease-in-out 2 alternate; }

@keyframes bus-clear {
  to { background-color: var(--play-lime); filter: brightness(2); transform: scale(0.88); }
}

.stack-overlay {
  position: absolute;
  inset: 12px;
  z-index: 5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.4rem;
  text-align: center;
  border-radius: 8px;
  background: rgba(4, 10, 18, 0.84);
  backdrop-filter: blur(4px);
}

.stack-overlay[hidden] { display: none; }
.stack-overlay strong { font-size: 2rem; color: var(--play-lime); }
.stack-overlay span { color: var(--play-muted); }

.game-control-panel,
.trace-tray,
.trace-brief {
  border: 1px solid var(--play-line);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(17, 40, 63, 0.78), rgba(7, 17, 31, 0.86));
  padding: 1.25rem;
}

.game-control-panel { display: grid; gap: 1.25rem; }

.control-label {
  margin: 0 0 0.75rem;
  color: var(--play-blue-2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stack-next {
  width: 132px;
  height: 96px;
  display: grid;
  grid-template-columns: repeat(4, 26px);
  grid-template-rows: repeat(3, 26px);
  place-content: center;
  gap: 3px;
  border: 1px solid var(--play-line);
  border-radius: 12px;
  background: rgba(5, 12, 21, 0.62);
}

.stack-next-cell {
  border-radius: 4px;
  background: transparent;
}

.stack-next-cell.is-filled {
  border: 1px solid var(--play-blue-2);
  background:
    radial-gradient(circle, var(--play-lime) 0 8%, transparent 9%),
    linear-gradient(90deg, transparent 46%, var(--play-blue) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, var(--play-blue) 47% 53%, transparent 54%),
    #112d45;
}

.control-copy p { margin: 0.2rem 0; color: var(--play-muted); }

.stack-touch-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stack-touch-controls button {
  min-height: 48px;
  border: 1px solid var(--play-line);
  border-radius: 10px;
  background: rgba(85, 183, 255, 0.08);
  color: var(--play-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.stack-touch-controls button[data-stack-action="down"],
.stack-touch-controls button[data-stack-action="drop"] {
  grid-column: span 1;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.game-actions button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.game-status {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--play-blue);
  background: rgba(85, 183, 255, 0.065);
  color: var(--play-muted);
}

.trace-layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(360px, 680px) minmax(210px, 280px);
  gap: clamp(1rem, 2.6vw, 2.5rem);
  align-items: start;
}

.trace-piece-list {
  display: grid;
  gap: 0.55rem;
}

.trace-piece-list button {
  min-height: 52px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--play-line);
  border-radius: 10px;
  background: rgba(5, 12, 21, 0.45);
  color: var(--play-text);
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  cursor: grab;
}

.trace-piece-list button:hover,
.trace-piece-list button.is-selected {
  border-color: var(--play-lime);
  background: rgba(215, 243, 107, 0.08);
}

.trace-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background-color: #0a1b2b;
  display: block;
}

.trace-icon::before,
.trace-icon::after {
  content: "";
  position: absolute;
  background: var(--play-blue-2);
  box-shadow: 0 0 8px rgba(85, 183, 255, 0.45);
}

.trace-straight::before,
.trace-tee::before,
.trace-cross::before {
  left: 3px; right: 3px; top: 16px; height: 4px;
}

.trace-corner::before {
  left: 16px; right: 3px; top: 16px; height: 4px;
}

.trace-corner::after {
  left: 16px; top: 3px; bottom: 16px; width: 4px;
}

.trace-tee::after,
.trace-cross::after {
  left: 16px; top: 3px; bottom: 16px; width: 4px;
}

.trace-eraser {
  place-items: center;
  color: var(--play-red);
  font-size: 1.5rem;
  font-weight: 800;
}

.tray-selection {
  min-height: 2.6rem;
  margin: 0.9rem 0;
  color: var(--play-lime);
}

.trace-stage {
  position: relative;
  padding: 14px;
  border: 1px solid rgba(155, 216, 255, 0.36);
  border-radius: 20px;
  background: #050c15;
  box-shadow: inset 0 0 50px rgba(85, 183, 255, 0.055);
}

.trace-grid {
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.trace-cell {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(155, 216, 255, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(155, 216, 255, 0.14) 0 7%, transparent 8%),
    rgba(17, 40, 63, 0.38);
  cursor: pointer;
  overflow: hidden;
}

.trace-cell:hover { border-color: rgba(155, 216, 255, 0.55); }
.trace-cell.is-blocked {
  cursor: not-allowed;
  background:
    repeating-linear-gradient(135deg, rgba(255, 117, 134, 0.13) 0 7px, rgba(255, 117, 134, 0.03) 7px 14px),
    #09131f;
  border-color: rgba(255, 117, 134, 0.32);
}

.trace-cell.is-source,
.trace-cell.is-output {
  display: grid;
  place-items: center;
  color: #06101a;
  font-weight: 900;
  font-size: clamp(0.58rem, 1.2vw, 0.9rem);
}

.trace-cell.is-source { background: var(--play-lime); border-color: var(--play-lime); }
.trace-cell.is-output { background: var(--play-orange); border-color: var(--play-orange); }

.trace-cell .cell-wire {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--rotation, 0) * 90deg));
}

.trace-cell .cell-wire::before,
.trace-cell .cell-wire::after {
  content: "";
  position: absolute;
  background: var(--play-blue-2);
  box-shadow: 0 0 7px rgba(85, 183, 255, 0.44);
}

.trace-cell[data-tile="straight"] .cell-wire::before {
  left: -1px; right: -1px; top: calc(50% - 3px); height: 6px;
}

.trace-cell[data-tile="corner"] .cell-wire::before {
  left: 50%; right: -1px; top: calc(50% - 3px); height: 6px;
}
.trace-cell[data-tile="corner"] .cell-wire::after {
  left: calc(50% - 3px); top: -1px; bottom: 50%; width: 6px;
}

.trace-cell[data-tile="tee"] .cell-wire::before,
.trace-cell[data-tile="cross"] .cell-wire::before {
  left: -1px; right: -1px; top: calc(50% - 3px); height: 6px;
}
.trace-cell[data-tile="tee"] .cell-wire::after {
  left: calc(50% - 3px); top: -1px; bottom: 50%; width: 6px;
}
.trace-cell[data-tile="cross"] .cell-wire::after {
  left: calc(50% - 3px); top: -1px; bottom: -1px; width: 6px;
}

.trace-cell.is-powered .cell-wire::before,
.trace-cell.is-powered .cell-wire::after {
  background: var(--play-lime);
  box-shadow: 0 0 12px rgba(215, 243, 107, 0.88);
}

.trace-cell.is-powered {
  border-color: rgba(215, 243, 107, 0.7);
  background-color: rgba(215, 243, 107, 0.08);
}

.trace-cell.is-complete {
  animation: powered-pulse 760ms ease-in-out infinite alternate;
}

@keyframes powered-pulse {
  to { box-shadow: inset 0 0 22px rgba(215, 243, 107, 0.24), 0 0 14px rgba(215, 243, 107, 0.2); }
}

.trace-voltage {
  position: absolute;
  inset: 14px;
  pointer-events: none;
  overflow: hidden;
  border-radius: 10px;
}

.trace-voltage span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--play-lime);
  box-shadow: 0 0 18px var(--play-lime);
  opacity: 0;
}

.trace-stage.is-complete .trace-voltage span {
  opacity: 1;
  animation: voltage-run 1.1s linear infinite;
}

@keyframes voltage-run {
  0% { left: 4%; top: 50%; }
  50% { left: 50%; top: 42%; }
  100% { left: 96%; top: 50%; }
}

.trace-brief h3 { margin-top: 0; }
.trace-brief > p:not(.control-label):not(.game-status) { color: var(--play-muted); }

.trace-legend {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.trace-legend span { display: flex; gap: 0.55rem; align-items: center; color: var(--play-muted); }
.trace-legend i {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--play-line); background: #10243a;
}
.trace-legend .legend-source { background: var(--play-lime); }
.trace-legend .legend-output { background: var(--play-orange); }
.trace-legend .legend-block { background: rgba(255, 117, 134, 0.2); }
.trace-legend .legend-powered { background: var(--play-lime); box-shadow: 0 0 8px rgba(215, 243, 107, 0.7); }

.signal-stage {
  position: relative;
  width: min(100%, 900px);
  min-height: 540px;
  margin-inline: auto;
  border: 1px solid var(--play-line);
  border-radius: 28px;
  background:
    radial-gradient(circle at center, rgba(85, 183, 255, 0.13), transparent 30%),
    linear-gradient(rgba(155, 216, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 216, 255, 0.045) 1px, transparent 1px),
    #050c15;
  background-size: auto, 34px 34px, 34px 34px, auto;
  overflow: hidden;
}

.signal-core {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(155, 216, 255, 0.6);
  border-radius: 34px;
  display: grid;
  place-items: center;
  align-content: center;
  background: linear-gradient(145deg, #102c45, #081522);
  box-shadow: 0 0 50px rgba(85, 183, 255, 0.22), inset 0 0 30px rgba(85, 183, 255, 0.1);
}

.signal-core strong { color: var(--play-lime); font-size: 2rem; letter-spacing: 0.04em; }
.signal-core small { color: var(--play-blue-2); letter-spacing: 0.16em; }

.signal-core-ring {
  position: absolute;
  inset: -22px;
  border: 1px dashed rgba(155, 216, 255, 0.3);
  border-radius: 44px;
  animation: ring-rotate 14s linear infinite;
}

@keyframes ring-rotate { to { transform: rotate(360deg); } }

.signal-node-grid { position: absolute; inset: 0; }

.signal-node {
  position: absolute;
  z-index: 3;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(155, 216, 255, 0.42);
  border-radius: 50%;
  background: #0b2034;
  color: var(--play-blue-2);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 0 8px rgba(85, 183, 255, 0.035);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.signal-node:hover { transform: scale(1.05); }
.signal-node.is-lit {
  background: var(--play-lime);
  color: #07111f;
  border-color: var(--play-lime);
  box-shadow: 0 0 0 10px rgba(215, 243, 107, 0.08), 0 0 36px rgba(215, 243, 107, 0.68);
  transform: scale(1.08);
}

.node-a { left: 10%; top: 12%; }
.node-b { right: 10%; top: 12%; }
.node-c { left: 5%; top: 50%; transform: translateY(-50%); }
.node-d { right: 5%; top: 50%; transform: translateY(-50%); }
.node-e { left: 18%; bottom: 9%; }
.node-f { right: 18%; bottom: 9%; }

.node-c:hover,
.node-d:hover { transform: translateY(-50%) scale(1.05); }
.node-c.is-lit,
.node-d.is-lit { transform: translateY(-50%) scale(1.08); }

.signal-lines {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(35deg, transparent 49.7%, rgba(85, 183, 255, 0.2) 49.8% 50.2%, transparent 50.3%),
    linear-gradient(-35deg, transparent 49.7%, rgba(85, 183, 255, 0.2) 49.8% 50.2%, transparent 50.3%),
    linear-gradient(90deg, transparent 49.7%, rgba(85, 183, 255, 0.16) 49.8% 50.2%, transparent 50.3%);
  opacity: 0.75;
}

.signal-controls {
  width: min(100%, 900px);
  margin: 1rem auto 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.signal-controls .game-status { flex: 1; margin: 0; }

.playground-footer-note {
  margin-bottom: clamp(4rem, 8vw, 8rem);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  border: 1px solid var(--play-line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(17, 40, 63, 0.66), rgba(7, 17, 31, 0.7));
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: end;
}

.playground-footer-note h2 { margin: 0.2rem 0 0; }
.playground-footer-note > p { color: var(--play-muted); margin: 0; }

@media (max-width: 1050px) {
  .trace-layout {
    grid-template-columns: minmax(180px, 240px) minmax(360px, 1fr);
  }
  .trace-brief { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .playground-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .playground-hero-board { min-height: 220px; }
  .playground-tabs { grid-template-columns: 1fr; }
  .playground-tabs button {
    min-height: 82px;
    border-right: 0;
    border-bottom: 1px solid var(--play-line);
  }
  .playground-tabs button:last-child { border-bottom: 0; }
  .playground-tabs button[aria-selected="true"] {
    box-shadow: inset 4px 0 0 var(--play-lime);
  }
  .game-panel-head { grid-template-columns: 1fr; }
  .game-scoreboard { justify-self: stretch; }
  .stack-layout,
  .trace-layout { grid-template-columns: 1fr; }
  .game-control-panel { order: -1; }
  .stack-next { width: 104px; height: 78px; grid-template-columns: repeat(4, 21px); grid-template-rows: repeat(3, 21px); }
  .signal-stage { min-height: 480px; }
  .signal-controls { align-items: stretch; flex-direction: column; }
  .playground-footer-note { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .playground-hero,
  .playground-shell,
  .playground-footer-note {
    width: min(100% - 16px, 1480px);
  }
  .playground-hero { padding-top: 2.4rem; }
  .playground-hero h1 { font-size: clamp(2.6rem, 14vw, 4.4rem); }
  .playground-hero-board { min-height: 190px; }
  .hero-node { width: 58px; height: 58px; border-radius: 14px; font-size: 0.72rem; }
  .hero-node-core { width: 78px; height: 78px; }
  .game-panel { padding: 0.85rem; }
  .game-scoreboard { grid-auto-columns: 1fr; }
  .game-scoreboard span { min-width: 0; padding-inline: 0.45rem; }
  .stack-stage { padding: 7px; }
  .stack-grid { gap: 2px; }
  .trace-stage { padding: 7px; }
  .trace-grid { gap: 3px; }
  .signal-stage { min-height: 420px; }
  .signal-core { width: 104px; height: 104px; border-radius: 26px; }
  .signal-core-ring { inset: -15px; border-radius: 34px; }
  .signal-node { width: 62px; height: 62px; }
  .node-a { left: 7%; top: 10%; }
  .node-b { right: 7%; top: 10%; }
  .node-c { left: 3%; }
  .node-d { right: 3%; }
  .node-e { left: 12%; bottom: 8%; }
  .node-f { right: 12%; bottom: 8%; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-trace::after,
  .signal-core-ring,
  .trace-stage.is-complete .trace-voltage span,
  .trace-cell.is-complete {
    animation: none !important;
  }
}
