/* Components added for search-agents, on top of the shared theme in style.css. */

.row-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.35rem 0.5rem; border: 1px solid var(--border); background: rgba(0,0,0,0.2);
}
.row-stat .lbl { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); }
.row-stat .val { font-family: var(--orb); font-size: 0.8rem; color: var(--cyan); }
.row-stat .val.pink { color: var(--pink); }
.row-stat .val.green { color: var(--green); }
.row-stat .val.purple { color: var(--purple); }
.row-stat .val.yellow { color: var(--yellow); }

.field-lbl { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); margin-bottom: 0.3rem; }
.field-hint { font-family: var(--raj); font-size: 0.8rem; color: var(--dim); }
.field-err { font-family: var(--mono); font-size: 0.65rem; color: var(--red); min-height: 1em; margin-top: 0.2rem; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.inline { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

input[type=range].cyber-range { width: 100%; accent-color: var(--pink); }

/* Playable board: tiles next to the blank can be clicked. */
.np-tile.clickable { cursor: pointer; }
.np-tile.clickable:hover { background: rgba(255,0,160,0.22); box-shadow: 0 0 12px rgba(255,0,160,0.4); }
.np-grid.solved { border-color: var(--green); box-shadow: 0 0 24px rgba(0,255,136,0.35); }

/* Live exploration panels */
.viz-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 1rem; align-items: stretch; }
.viz-panel { border: 1px solid var(--border); background: rgba(0,0,0,0.25); padding: 0.7rem; display: flex; flex-direction: column; gap: 0.4rem; }
.viz-panel .viz-title { font-family: var(--mono); font-size: 0.62rem; color: var(--dim); letter-spacing: 0.12em; text-transform: uppercase; }
.viz-panel canvas { width: 100%; height: 170px; display: block; }

.mini-grid { display: grid; gap: 3px; padding: 5px; border: 1px solid rgba(0,245,255,0.35); background: rgba(0,245,255,0.04); }
.mini-tile {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-family: var(--orb); font-size: 0.7rem; font-weight: 700; color: var(--cyan);
  background: rgba(0,245,255,0.08); border: 1px solid rgba(0,245,255,0.25);
}
.mini-tile.home { color: var(--green); border-color: rgba(0,255,136,0.35); background: rgba(0,255,136,0.08); }
.mini-tile.blank { background: rgba(0,0,0,0.3); color: transparent; border-color: rgba(0,245,255,0.08); }

/* Compare mode */
.cmp-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 0.8rem; }
.cmp-presets label { font-family: var(--mono); font-size: 0.68rem; color: var(--text); display: flex; gap: 0.4rem; align-items: center; cursor: pointer; }
.cmp-presets input { accent-color: var(--cyan); }
.cmp-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.72rem; }
.cmp-table th { text-align: left; color: var(--dim); font-weight: 400; border-bottom: 1px solid var(--border); padding: 0.35rem 0.4rem; }
.cmp-table td { padding: 0.35rem 0.4rem; border-bottom: 1px solid rgba(0,245,255,0.07); }
.cmp-table td.num, .cmp-table th.num { text-align: right; }
.cmp-table tr.best td { color: var(--green); }
.cmp-bar { height: 6px; background: linear-gradient(90deg, var(--cyan), var(--purple)); box-shadow: 0 0 6px var(--cyan); }
.status-solved { color: var(--green); }
.status-limit, .status-cancelled { color: var(--yellow); }
.status-unsolvable, .status-error { color: var(--red); }

.moves-list { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); word-break: break-word; line-height: 1.7; }
.moves-list .cur { color: var(--pink); text-shadow: 0 0 6px var(--pink); }

.banner { font-family: var(--mono); font-size: 0.72rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); background: rgba(0,0,0,0.3); }
.banner.warn { border-color: rgba(255,230,0,0.4); color: var(--yellow); }
.banner.err { border-color: rgba(255,59,59,0.4); color: var(--red); }

@media (max-width: 1100px) {
  .viz-grid { grid-template-columns: 1fr; }
}

/* Connect Four */
.c4-board {
  display: grid; grid-template-columns: repeat(7, 62px); gap: 6px; padding: 10px;
  background: rgba(0,60,140,0.25); border: 2px solid rgba(0,245,255,0.35);
  box-shadow: 0 0 24px rgba(0,245,255,0.15);
}
.c4-col { display: grid; grid-template-rows: repeat(6, 62px); gap: 6px; cursor: pointer; padding: 2px; border-radius: 6px; }
.c4-col.disabled { cursor: default; }
.c4-col:not(.disabled):hover { background: rgba(0,245,255,0.08); }
.c4-cell { border-radius: 50%; background: rgba(2,6,16,0.9); border: 1px solid rgba(0,245,255,0.15); box-shadow: inset 0 2px 6px rgba(0,0,0,0.6); }
.c4-cell.red { background: radial-gradient(circle at 35% 35%, #ff5cc6, var(--pink) 60%); box-shadow: 0 0 14px rgba(255,0,160,0.6); border-color: var(--pink); }
.c4-cell.yellow { background: radial-gradient(circle at 35% 35%, #fff59a, var(--yellow) 60%); box-shadow: 0 0 14px rgba(255,230,0,0.5); border-color: var(--yellow); }
.c4-cell.drop { animation: c4drop 0.28s ease-in; }
.c4-cell.win { outline: 3px solid var(--green); outline-offset: 2px; box-shadow: 0 0 22px var(--green); }
.c4-cell.last { outline: 2px solid rgba(255,255,255,0.6); outline-offset: 1px; }
@keyframes c4drop { from { transform: translateY(-260px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }

.c4-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; padding: 6px 4px 0; }
.c4-bar-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; }
.c4-bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 110px; }
.c4-bar { width: 14px; min-height: 1px; transition: height 0.3s; }
.c4-bar.prior { background: var(--purple); box-shadow: 0 0 6px var(--purple); }
.c4-bar.visits { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.c4-bar-lbl { font-family: var(--mono); font-size: 0.62rem; color: var(--dim); text-align: center; min-height: 2.4em; }
.c4-bar-col.chosen .c4-bar-lbl { color: var(--green); }
.legend-dot { display: inline-block; width: 10px; height: 10px; margin-right: 0.35rem; vertical-align: middle; }
.c4-value { height: 10px; background: rgba(255,0,160,0.25); border: 1px solid var(--border); }
.c4-value > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); transition: width 0.3s; }

/* 2048 */
.g-board { display: grid; grid-template-columns: repeat(4, 86px); gap: 8px; padding: 10px; background: rgba(155,0,255,0.06); border: 2px solid rgba(155,0,255,0.4); }
.g-cell { width: 86px; height: 86px; display: flex; align-items: center; justify-content: center; font-family: var(--orb); font-weight: 900; border: 1px solid rgba(155,0,255,0.2); background: rgba(0,0,0,0.35); transition: background 0.12s; }
.g-cell.new { animation: tileAppear 0.15s ease; }
.dir-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; height: 140px; }
.dir-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.dir-bar { width: 38px; min-height: 2px; background: var(--purple); box-shadow: 0 0 8px var(--purple); transition: height 0.2s; }
.dir-col.chosen .dir-bar { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dir-lbl { font-family: var(--mono); font-size: 0.65rem; color: var(--dim); text-align: center; }
.dir-col.chosen .dir-lbl { color: var(--green); }

/* Sudoku */
.s-board { display: grid; grid-template-columns: repeat(9, 44px); border: 2px solid rgba(0,255,136,0.5); background: rgba(0,255,136,0.03); }
.s-cell { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-family: var(--orb); font-size: 1.05rem; font-weight: 700; border: 1px solid rgba(0,255,136,0.12); color: var(--cyan); transition: background 0.1s; }
.s-cell.given { color: var(--text); background: rgba(255,255,255,0.03); }
.s-cell.br { border-right: 2px solid rgba(0,255,136,0.45); }
.s-cell.bb { border-bottom: 2px solid rgba(0,255,136,0.45); }
.s-cell.assign { background: rgba(0,245,255,0.25); }
.s-cell.propagate { color: var(--purple); }
.s-cell.undo { background: rgba(255,59,59,0.35); }

/* Phones: shrink the game boards so they fit a 360-400px viewport. */
@media (max-width: 600px) {
  .c4-board { grid-template-columns: repeat(7, 40px); gap: 4px; padding: 6px; }
  .c4-col { grid-template-rows: repeat(6, 40px); gap: 4px; padding: 0; }
  .g-board { grid-template-columns: repeat(4, 70px); gap: 6px; padding: 8px; }
  .g-cell { width: 70px; height: 70px; }
  .s-board { grid-template-columns: repeat(9, 34px); }
  .s-cell { width: 34px; height: 34px; font-size: 0.9rem; }
  .c4-bars { gap: 4px; }
  .c4-bar { width: 9px; }
}

/* Connect Four status chip: the full matchup from 790px up, the names only below (connect4.js setStatus). */
.status-narrow { display: none; }
@media (max-width: 789px) {
  .status-wide { display: none; }
  .status-narrow { display: inline; }
}

/* Phones: one compact bar. The logo drops its subtitle, and the links scroll sideways inside the bar, so a page's
   active item can sit past the edge without wrapping above the logo. The sound toggle stays pinned (.sound-li). */
@media (max-width: 600px) {
  .nav-logo span { display: none; }
  .nav-links { flex: 1; min-width: 0; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; scroll-padding-right: 2.6rem; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links > li { flex-shrink: 0; }
  .nav-links > li:first-child { margin-left: auto; }  /* groups the links at the right while they fit; 0 once they scroll */
  .nav-links a { padding-left: 0.6rem; padding-right: 0.6rem; font-size: 0.6rem; }
}

/* Games menu: MAIN, then GAMES opens a neon panel of every game, then the current game as the active item.
   The panel opens on hover (pointer devices only, so a tap does not leave it stuck open), and on click, Enter
   or Space, which is what a <details> disclosure does. Escape and a click outside close it (nav.js). */
.games-menu { position: relative; }
.nav-links a, .games-menu summary { white-space: nowrap; }
.games-menu summary {
  display: block;
  padding: 0.4rem 1rem;
  font-family: var(--orb);
  font-size: 0.65rem;
  color: var(--dim);
  letter-spacing: 0.1em;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  list-style: none;
}
.games-menu summary::-webkit-details-marker { display: none; }
.games-menu summary:hover, .games-menu details[open] summary {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
.games-menu summary:focus-visible, .games-panel a:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
.games-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 22rem;
  margin: 0;
  padding: 0.75rem;
  list-style: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  background: rgba(2, 6, 16, 0.96);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.45), inset 0 0 14px rgba(0, 245, 255, 0.12);
}
.games-menu details[open] + .games-panel { display: grid; }
@media (hover: hover) {
  .games-menu:hover .games-panel { display: grid; }
}
.games-panel a {
  display: block;
  padding: 0.5rem 0.6rem;
  font-family: var(--orb);
  font-size: 0.6rem;
  color: var(--dim);
  letter-spacing: 0.1em;
  white-space: nowrap;
  border-bottom: 0;
  border-left: 2px solid transparent;
}
.games-panel a:hover, .games-panel a.act {
  color: var(--pink);
  border-left-color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
}
/* Sound toggle (sfx.js): the last item of the nav links, a speaker icon. Waves show when sound is on, a slash when
   off. Neon when on; the focus ring matches the games menu. */
.sound-li { display: flex; align-items: center; margin-left: 0.4rem; }
.sound-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.sound-toggle svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .body { fill: currentColor; stroke: none; }
.sound-toggle .slash { display: none; }
.sound-toggle[aria-pressed="false"] .wave { display: none; }
.sound-toggle[aria-pressed="false"] .slash { display: inline; }
.sound-toggle:hover { color: var(--cyan); border-color: var(--borderb); }
.sound-toggle[aria-pressed="true"] {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.45), inset 0 0 8px rgba(0, 245, 255, 0.15);
  text-shadow: 0 0 8px var(--cyan);
}
.sound-toggle:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
.sound-toggle .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* On phones the panel spans the bar under the nav instead of hanging from the GAMES item. The sound toggle keeps
   the right edge of the bar while the links scroll under it (its background hides them). */
@media (max-width: 600px) {
  .games-menu { position: static; }
  .games-panel { left: 0.75rem; right: 0.75rem; width: auto; }
  .sound-li { position: sticky; right: 0; background: #010208; }
}

/* ── Game pages: maximalist layer ─────────────────────────────────────── */

/* Perspective neon floor behind the labs and hidden games (the game pages have .game-bg instead). The plane is
   clipped by a viewport-sized fixed wrapper (.neon-floor, the first child of .proj-page). Its far, sideways projection would otherwise
   count toward the document's scrollable width (scrollWidth ~8800px at 1280) until layout settles. */
body:not(.landing-page)::before { z-index: 0; }
.proj-page { position: relative; z-index: 2; }
.neon-floor { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
/* Each game's own night scene (web/img/bg/<page>.svg, generated from the design sources) in place of the neon
   floor: fixed behind the page, covering the window, cropped at the edges on other shapes. It sits before
   .proj-page, not inside it, so the vignette and scanlines still paint over it. */
.game-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: #020610 center / cover no-repeat; }
.neon-floor-plane {
  position: absolute; left: -50%; right: -50%; bottom: -10vh; height: 60vh;
  background-image:
    linear-gradient(rgba(255,0,160,0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,245,255,0.28) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: center top;
  mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent 85%);
  animation: floor 6s linear infinite;
}
@keyframes floor { to { background-position: 0 64px, 0 0; } }

/* Glitching titles (shared with the landing page). */
.glitch {
  position: relative; font-family: var(--orb); font-weight: 900; font-size: clamp(2.6rem, 8vw, 6.2rem);
  line-height: 0.95; letter-spacing: -0.02em; color: #fff;
  text-shadow: 0 0 18px var(--cyan), 0 0 44px rgba(0,245,255,0.5);
}
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen;
}
.glitch::before { color: var(--pink); transform: translate(3px, 0); clip-path: inset(0 0 55% 0); animation: glitch-a 3.2s infinite steps(1); }
.glitch::after { color: var(--cyan); transform: translate(-3px, 0); clip-path: inset(55% 0 0 0); animation: glitch-b 2.6s infinite steps(1); }
@keyframes glitch-a { 0%, 86%, 100% { transform: translate(3px,0); } 88% { transform: translate(-7px,-2px); } 92% { transform: translate(9px,1px); } }
@keyframes glitch-b { 0%, 80%, 100% { transform: translate(-3px,0); } 83% { transform: translate(8px,2px); } 89% { transform: translate(-10px,-1px); } }
.proj-pg-title.glitch { font-size: clamp(2rem, 5vw, 3.4rem); }

/* HUD corner brackets on panels. */
.viz-panel, .heuristic-card { position: relative; }
.viz-panel::before, .viz-panel::after {
  content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--cyan); border-style: solid; filter: drop-shadow(0 0 4px var(--cyan));
}
.viz-panel::before { top: -2px; left: -2px; border-width: 2px 0 0 2px; }
.viz-panel::after { bottom: -2px; right: -2px; border-width: 0 2px 2px 0; }

/* CRT flicker on the boards. */
.np-grid, .c4-board, .g-board, .s-board { animation: crt 7s infinite; }
@keyframes crt { 0%, 96%, 100% { filter: none; } 97% { filter: brightness(1.35) saturate(1.4); } 98% { filter: brightness(0.85) hue-rotate(12deg); } }

/* Effects (fx.js). */
.fx-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.fx-shake { animation: shake 0.28s; }
.fx-shake-big { animation: shake-big 0.5s; }
@keyframes shake { 25% { transform: translate(-3px, 2px); } 50% { transform: translate(3px, -2px); } 75% { transform: translate(-2px, -1px); } }
@keyframes shake-big { 15% { transform: translate(-8px, 4px) rotate(-0.6deg); } 35% { transform: translate(8px, -5px) rotate(0.6deg); }
  55% { transform: translate(-6px, 3px); } 75% { transform: translate(5px, -2px); } }
.fx-pop { position: fixed; z-index: 61; pointer-events: none; transform: translate(-50%, -50%);
  font-family: var(--orb); font-weight: 900; font-size: 1.3rem; text-shadow: 0 0 10px currentColor; animation: pop 0.9s ease-out forwards; }
@keyframes pop { from { opacity: 1; transform: translate(-50%, -50%) scale(0.8); } to { opacity: 0; transform: translate(-50%, -160%) scale(1.25); } }
/* Outcome toast: a small card in the top-right corner, under the nav, so it never hides the board. It is
   informational only (pointer-events off) and fades after about two seconds. On phones it spans the top edge. */
.fx-banner { position: fixed; top: 64px; right: 16px; z-index: 62; pointer-events: none; max-width: min(280px, calc(100vw - 24px)); overflow-wrap: anywhere;
  padding: 0.45rem 0.65rem; text-align: left; background: rgba(2,6,16,0.94); border: 1px solid var(--fx-c);
  border-left: 3px solid var(--fx-c); box-shadow: 0 0 14px color-mix(in srgb, var(--fx-c) 35%, transparent);
  animation: banner-in 0.25s ease-out; }
.fx-banner.fx-out { opacity: 0; transition: opacity 0.5s; }
.fx-banner-main { display: block; font-family: var(--orb); font-weight: 800; font-size: 0.85rem; color: #fff;
  text-shadow: 0 0 8px var(--fx-c); letter-spacing: 0.05em; }
.fx-banner-sub { display: block; font-family: var(--mono); font-size: 0.65rem; color: var(--fx-c); margin-top: 0.15rem; }
.fx-banner-sub:empty { display: none; }
@keyframes banner-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 600px) { .fx-banner { right: 12px; top: 60px; } }

@media (prefers-reduced-motion: reduce) {
  .neon-floor-plane, .np-grid, .c4-board, .g-board, .s-board { animation: none; }
  .fx-banner { animation: none; }
}

/* Checkers */
/* The board is n x n, with n set by --n (8, 10 or 12). It scales down to the width of its
   container, so a 12x12 board still fits a 390 px phone; the squares stay square and tappable. */
.ck-board { display: grid; grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr)); grid-template-rows: repeat(var(--n, 8), minmax(0, 1fr)); width: min(100%, calc(var(--n, 8) * 58px)); aspect-ratio: 1; container-type: inline-size; border: 2px solid var(--pink); box-shadow: 0 0 28px rgba(255,0,160,0.35), inset 0 0 40px rgba(0,0,0,0.6); }
.ck-cell { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.ck-cell.light { background: rgba(155,0,255,0.07); }
.ck-cell.dark { background: rgba(2,6,16,0.95); box-shadow: inset 0 0 0 1px rgba(255,0,160,0.12); }
.ck-cell.trail { background: rgba(0,245,255,0.14); }
.ck-cell.hint { background: rgba(0,255,136,0.22); box-shadow: inset 0 0 0 2px var(--green); }
.ck-cell.target { cursor: pointer; }
.ck-cell.target::after { content: ''; width: 34%; height: 34%; border: 2px solid var(--green); transform: rotate(45deg); box-shadow: 0 0 12px var(--green); animation: target 0.9s ease-in-out infinite alternate; }
@keyframes target { to { transform: rotate(45deg) scale(1.25); } }
.ck-piece { width: 76%; height: 76%; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: transform 0.15s; }
.ck-piece.red { background: radial-gradient(circle at 35% 30%, #ff6ad0, var(--pink) 55%, #8a0058); box-shadow: 0 0 14px rgba(255,0,160,0.7), inset 0 -4px 0 rgba(0,0,0,0.35); }
.ck-piece.white { background: radial-gradient(circle at 35% 30%, #ffffff, #9feeff 50%, #2b7f99); box-shadow: 0 0 14px rgba(0,245,255,0.6), inset 0 -4px 0 rgba(0,0,0,0.3); }
.ck-piece.king::after { content: '♛'; font-size: clamp(0.6rem, 3.6cqw, 1.35rem); color: var(--yellow); text-shadow: 0 0 8px var(--yellow), 0 1px 0 #000; }
.ck-piece.movable { cursor: pointer; outline: none; }
.ck-piece.movable:hover, .ck-piece.movable:focus-visible { transform: scale(1.1); }
.ck-piece.movable:focus-visible { box-shadow: 0 0 0 3px var(--yellow), 0 0 18px var(--yellow); }
.ck-piece.selected { transform: scale(1.12); box-shadow: 0 0 0 3px var(--yellow), 0 0 22px var(--yellow); }

.cyber-btn[hidden] { display: none; }
.prune-meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 0.8rem; }
.prune-meter[hidden] { display: none; }
.prune-row { border: 1px solid var(--border); background: rgba(0,0,0,0.3); padding: 0.5rem 0.7rem; display: flex; flex-direction: column; gap: 0.2rem; }
.prune-row span { font-family: var(--mono); font-size: 0.62rem; color: var(--dim); }
.prune-row b { font-family: var(--orb); font-size: 1.1rem; color: var(--pink); text-shadow: 0 0 10px var(--pink); }
.prune-row:nth-child(2) b { color: var(--cyan); text-shadow: 0 0 10px var(--cyan); }
.prune-row:nth-child(3) b { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }
.ck-root { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.ck-root li { display: grid; grid-template-columns: 6.5rem 1fr 6rem; gap: 0.6rem; align-items: center; font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }
.ck-root .bar { height: 8px; background: rgba(255,255,255,0.05); }
.ck-root .bar i { display: block; height: 100%; background: var(--purple); box-shadow: 0 0 6px var(--purple); }
.ck-root li.chosen { color: var(--green); }
.ck-root li.chosen .bar i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.ck-root .sc { text-align: right; }

@media (max-width: 600px) {
  .prune-meter { grid-template-columns: 1fr; }
}

/* Route planner */
.rt-map { width: min(640px, 100%); aspect-ratio: 1; border: 2px solid var(--green); box-shadow: 0 0 28px rgba(0,255,136,0.3); cursor: crosshair; }
.rt-chart { width: 100%; height: 190px; display: block; }
.rt-race { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.rt-race figure { margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.rt-race canvas { width: 100%; aspect-ratio: 1; border: 1px solid var(--border); }
.rt-race figcaption { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); text-align: center; }
#btn-draw[aria-pressed="true"] { border-color: var(--pink); color: var(--pink); box-shadow: 0 0 16px rgba(255,0,160,0.5); }
@media (max-width: 600px) { .rt-race { grid-template-columns: 1fr; } }

/* ── HOW IT WORKS ──
   Every game page ends with the same explainer section, below the game and its controls:
   a lede, one card per algorithm (with a plain-language box for newcomers), a table of
   heuristics and their values, how those values were chosen, training details, and links
   to the source files. Markup lives in each page so it is readable without JavaScript. */
.hiw { position: relative; z-index: 2; padding: 2.2rem 2rem 3rem; border-top: 1px solid var(--border); background: linear-gradient(180deg, rgba(0,245,255,0.03), transparent 40%); }
.hiw > .section-title { font-size: 0.85rem; }
.hiw-lede { font-family: var(--raj); font-size: 1.05rem; line-height: 1.55; color: var(--text); max-width: 75ch; margin: 0 0 1.4rem; }
.hiw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.hiw-card { border: 1px solid var(--border); background: rgba(0,0,0,0.3); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.55rem; position: relative; }
.hiw-card::before { content: ''; position: absolute; top: -1px; left: -1px; width: 18px; height: 18px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.hiw-card h3 { font-family: var(--orb); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); margin: 0; }
.hiw-card p, .hiw-card li { font-family: var(--raj); font-size: 0.95rem; line-height: 1.5; color: var(--text); margin: 0; }
.hiw-card ul, .hiw-card ol { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.hiw-plain { border-left: 2px solid var(--pink); background: rgba(255,0,160,0.06); padding: 0.55rem 0.7rem; }
.hiw-plain b:first-child { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pink); display: block; margin-bottom: 0.2rem; }
.hiw-sub { font-family: var(--orb); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--yellow); margin: 1.4rem 0 0.6rem; }
.hiw-table { max-width: 100%; }
.hiw-table td:first-child { color: var(--cyan); white-space: nowrap; }
.hiw-table td { vertical-align: top; }
.hiw-scroll { overflow-x: auto; }
.hiw-note { font-family: var(--raj); font-size: 0.95rem; line-height: 1.5; color: var(--text); max-width: 85ch; margin: 0.6rem 0 0; }
.hiw-note code, .hiw-card code, .hiw-table code { font-family: var(--mono); font-size: 0.8em; color: var(--green); }
.hiw-src { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); margin-top: 1.4rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.hiw-src a { color: var(--cyan); }

/* Explanation sections (shared by the game pages). The How to play block sits above the game. Formulas are typeset
   by web/js/math.js with KaTeX from web/vendor/katex. Pseudocode boxes are built by web/js/pseudo.js. */
.howto { position: relative; max-width: 85ch; margin: 0 0 1.6rem; padding: 1rem 1.2rem; border: 1px solid var(--border); border-left: 2px solid var(--green); background: rgba(0,255,136,0.04); }
.howto-title { font-family: var(--orb); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--green); margin: 0 0 0.5rem; }
.howto p { font-family: var(--raj); font-size: 1rem; line-height: 1.55; color: var(--text); margin: 0; }

/* Collapsible sections (web/js/fold.js wraps HOW TO PLAY and each HOW IT WORKS topic in <details>). The summary
   keeps the heading's look; a triangle before it turns when the section opens. */
.howto-fold > summary, .hiw-fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.6rem; }
.howto-fold > summary::-webkit-details-marker, .hiw-fold > summary::-webkit-details-marker { display: none; }
.howto-fold > summary::before, .hiw-fold > summary::before { content: "▸"; font-size: 0.8rem; transition: transform 0.15s; }
.howto-fold[open] > summary::before, .hiw-fold[open] > summary::before { transform: rotate(90deg); }
.howto-fold > summary::before { color: var(--green); }
.hiw-fold > summary::before { color: var(--yellow); }
.howto-fold > summary .howto-title { margin: 0; }
.howto-fold[open] > summary { margin-bottom: 0.5rem; }
.hiw-fold { border-top: 1px solid var(--border); }
.hiw-fold > summary { padding: 0.7rem 0; }
.hiw-fold > summary .hiw-sub { margin: 0; }
.hiw-fold[open] { padding-bottom: 0.8rem; }
.howto-fold > summary:focus-visible, .hiw-fold > summary:focus-visible, .fold-all:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.howto-fold > summary:hover .howto-title, .hiw-fold > summary:hover .hiw-sub { text-shadow: 0 0 8px currentColor; }
.fold-all { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--cyan); background: transparent; border: 1px solid var(--border); padding: 0.15rem 0.5rem; margin-left: 0.6rem; cursor: pointer; vertical-align: middle; text-transform: none; }
.fold-all:hover { border-color: var(--cyan); }
@media (prefers-reduced-motion: reduce) { .howto-fold > summary::before, .hiw-fold > summary::before { transition: none; } }
/* Folded panels in the play area: secondary settings ("More settings") and long lists such as a move log. They use
   native <details>, start closed, and look like the sidebar's small section labels. */
.more-settings, .log-fold { margin-top: 0.8rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.more-settings > summary, .log-fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-family: var(--orb); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); padding: 0.3rem 0; }
.more-settings > summary::-webkit-details-marker, .log-fold > summary::-webkit-details-marker { display: none; }
.more-settings > summary::before, .log-fold > summary::before { content: "▸"; font-size: 0.75rem; transition: transform 0.15s; }
.more-settings[open] > summary::before, .log-fold[open] > summary::before { transform: rotate(90deg); }
.more-settings > summary:focus-visible, .log-fold > summary:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.more-settings[open] > summary, .log-fold[open] > summary { margin-bottom: 0.5rem; }
@media (prefers-reduced-motion: reduce) { .more-settings > summary::before, .log-fold > summary::before { transition: none; } }


/* Formulas. KaTeX takes its colour from the surrounding text, so formulas stay light on the dark background. */
.math { min-width: 0; }
.katex { color: inherit; font-size: 1.05em; }
.math-block { display: block; max-width: 100%; margin: 0.8rem 0; padding: 0.3rem 0; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.math-block .katex-display { margin: 0.2rem 0; }

/* Pseudocode boxes. The box stays inside the column. Long lines scroll inside the <pre>, never the page. */
.pseudo { position: relative; min-width: 0; max-width: 100%; margin: 0.8rem 0; border: 1px solid var(--border); background: rgba(0,0,0,0.45); }
.pseudo pre { margin: 0; padding: 2.2rem 0.9rem 0.8rem; max-width: 100%; overflow-x: auto; white-space: pre; tab-size: 4; font-family: var(--mono); font-size: 0.8rem; line-height: 1.55; color: var(--text); }
.pseudo pre[hidden] { display: none; }
.pseudo pre:focus-visible { outline: 1px solid var(--cyan); outline-offset: -1px; }
/* The toggle is a bare plus sign (a minus sign while the full version shows). The glyph is drawn in KaTeX_Main, the
   same face as the pseudocode tokens, and the button is a 32px square so it is easy to hit. It has no box or text. */
.pseudo-toggle { position: absolute; top: 0.15rem; right: 0.15rem; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; margin: 0; padding: 0; font-family: KaTeX_Main, var(--mono); font-size: 1.15rem; line-height: 1; color: var(--cyan); background: none; border: 0; cursor: pointer; }
.pseudo-toggle:hover, .pseudo-toggle:focus-visible { text-shadow: 0 0 8px var(--cyan); }
.pseudo-toggle:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }

/* Code references. Each small number links to the cited lines on GitHub. The button is raised with relative
   positioning, so its line box stays the same height as the text beside it. Its ::before pseudo-element extends the
   tap target to about 24px tall on touch, without changing the layout. */
/* inline, not inline-block, so a button never wraps onto a line apart from the word before it */
.ref { position: relative; display: inline; vertical-align: 0.45em; margin: 0 0.1em; padding: 0.1rem 0.3rem; font-family: var(--mono); font-size: 0.62rem; line-height: 1; letter-spacing: 0; text-decoration: none; color: var(--cyan); background: rgba(2,6,16,0.6); border: 1px solid var(--borderb); cursor: pointer; white-space: nowrap; }
.ref::before { content: ""; position: absolute; inset: -0.3rem -0.2rem; }
.ref:hover { color: #fff; border-color: var(--cyan); box-shadow: 0 0 6px rgba(0,245,255,0.55); text-shadow: 0 0 6px var(--cyan); }
.ref:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
/* A formula's refs sit in a strip above the formula, at its top right. The formula gets the same strip, so they never overlap it. */
.math-fig { position: relative; min-width: 0; max-width: 100%; }
.math-refs { position: absolute; top: 0.2rem; right: 0.3rem; z-index: 1; display: flex; gap: 0.25rem; }
.math-refs .ref { top: 0; }
.math-fig:has(.math-refs) > .math-block { padding-top: 1.1rem; }
/* A pseudocode box's refs sit beside its toggle, in the same top-right corner. */
.pseudo-bar { position: absolute; top: 0.15rem; right: 0.15rem; z-index: 1; display: flex; align-items: center; gap: 0.2rem; min-height: 2rem; }
.pseudo-bar .ref { top: 0; }
.pseudo-bar .pseudo-toggle { position: static; }

/* Syntax colours, Python-like, on the site's neon palette. Greek is a lighter tint of --purple so it stays legible
   on the dark background. */
.tk-kw { color: var(--pink); }
.tk-proc { color: var(--cyan); }
.tk-num { color: var(--yellow); }
.tk-builtin { color: var(--green); }
.tk-greek { color: #c77dff; }
.tk-arrow { color: var(--pink); font-weight: 700; }
.tk-com { color: var(--dim); font-style: italic; }
/* JetBrains Mono draws its minus sign (U+2212) as a bar as short as its hyphen, so "−1" reads as "-1", and its arrow
   is small. KaTeX_Main, from the vendored KaTeX stylesheet every pseudocode page loads, draws both at full size.
   The minus and the arrow sit in a one-column box in the page's monospace face, so the columns stay put (ch is
   measured in that box's own font, which is the monospace one). The glyph inside is KaTeX_Main. Its margin centres
   it: the KaTeX minus is 0.78em wide and the arrow 1em, both wider than the 0.6em column, and the margin is half the
   difference. The KaTeX arrow is also compressed to 70% width, so its ink does not run into the next character;
   a transform changes only the painted ink, not the layout. */
.tk-op, .tk-arrow { display: inline-block; width: 1ch; text-align: center; }
.tk-glyph { font-family: KaTeX_Main, var(--mono); }
/* The minus is squeezed about its centre until its ink (0.53em) fits the 0.6em column, still about 1.7 times the
   hyphen's ink, so it never touches its neighbours. The arrow stays in the monospace face: its KaTeX_Main glyph is a
   full em wide and crowds the characters beside it, so it only gets the bold pink. */
.tk-op > .tk-glyph { display: inline-block; margin-left: -0.09em; transform: scaleX(0.85); }
.tk-arrow { display: inline; width: auto; }
.tk-arrow > .tk-glyph { font-family: var(--mono); }

/* Lecture-notes cards hold formulas and boxes, so they get tighter margins. */
.hiw .math-block { margin: 0.9rem 0 1rem; padding: 0.5rem 0.8rem; border-left: 2px solid var(--cyan); background: rgba(0,245,255,0.04); }
.hiw .pseudo { margin: 0.9rem 0 1rem; }
.hiw-card .math-block, .hiw-card .pseudo { margin: 0.4rem 0; }
.hiw .pseudo pre { font-size: 0.76rem; }
@media (max-width: 720px) {
  .hiw { padding: 1.6rem 1rem 2.4rem; }
  .hiw-table td:first-child { white-space: normal; }
}

/* AGENT OVERDRIVE (overdrive.js): a temporary layer on every page. Nothing here is part of the normal look. */
.od-root { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.od-scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,245,255,0.09) 2px 3px);
  animation: od-scan-roll 2.2s linear infinite; }
@keyframes od-scan-roll { to { background-position: 0 60px; } }
.od-pulse { position: absolute; inset: 0; box-shadow: inset 0 0 90px rgba(255,0,160,0.5), inset 0 0 24px rgba(0,245,255,0.35);
  animation: od-pulse 1.6s ease-in-out infinite alternate; }
@keyframes od-pulse { from { opacity: 0.4; } to { opacity: 1; } }
.od-banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; padding: 1.1rem 1rem;
  background: linear-gradient(90deg, transparent, rgba(2,6,16,0.94) 14%, rgba(2,6,16,0.94) 86%, transparent);
  border-top: 2px solid var(--pink); border-bottom: 2px solid var(--pink); box-shadow: 0 0 40px rgba(255,0,160,0.5);
  transition: opacity 0.6s; animation: od-storm 0.9s steps(4) 2; }
.od-banner.out { opacity: 0; }
.od-banner-title.glitch { display: block; font-size: clamp(2rem, 7vw, 4.4rem); color: #fff; line-height: 1.05;
  text-shadow: 0 0 12px var(--pink), 0 0 32px var(--pink); }
.od-banner-sub { display: block; font-family: var(--mono); font-size: 0.8rem; color: var(--yellow); margin-top: 0.4rem; letter-spacing: 0.08em; }
/* A short glitch storm when the banner lands: a few jolts, then still. */
@keyframes od-storm {
  0% { transform: translateX(0); }
  25% { transform: translateX(-7px) skewX(-4deg); }
  50% { transform: translateX(6px) skewX(3deg); }
  75% { transform: translateX(-3px); }
  100% { transform: none; }
}
.od-badge { position: fixed; left: 12px; bottom: 12px; pointer-events: auto; cursor: pointer; font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.08em; color: var(--yellow); background: rgba(2,6,16,0.9);
  border: 1px solid var(--yellow); padding: 0.35rem 0.6rem; box-shadow: 0 0 12px rgba(255,230,0,0.4); }
.od-badge:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
/* The hero race panel (landing.js): A* and BFS counters side by side, bottom-right of the hero. */
.od-race { position: absolute; right: 14px; bottom: 14px; z-index: 3; width: min(340px, calc(100% - 28px)); pointer-events: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0.6rem 0.7rem; background: rgba(2,6,16,0.88);
  border: 1px solid var(--border); font-family: var(--mono); font-size: 0.66rem; color: var(--dim); }
.od-race-col { display: flex; flex-direction: column; gap: 0.2rem; }
.od-race-col b { font-family: var(--orb); font-size: 0.8rem; color: var(--text); }
.od-race-name { font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; }
.od-race-col.a .od-race-name { color: var(--cyan); }
.od-race-col.a b { color: var(--cyan); }
.od-race-col.b .od-race-name { color: var(--yellow); }
.od-race-col.b b { color: var(--yellow); }
.od-race-note { grid-column: 1 / -1; color: var(--text); border-top: 1px solid var(--border); padding-top: 0.35rem; }
@media (prefers-reduced-motion: reduce) {
  .od-scan, .od-pulse, .od-banner { animation: none; }
  .od-banner-title.glitch::before, .od-banner-title.glitch::after { display: none; }
}
