:root {
  color-scheme: dark;
  --bg: #06100f;
  --bg-raised: #0a1715;
  --panel: rgba(13, 29, 26, 0.88);
  --panel-solid: #0d1d1a;
  --panel-soft: #10231f;
  --line: rgba(190, 224, 213, 0.2);
  --line-strong: rgba(190, 224, 213, 0.38);
  --text: #f3f6ef;
  --muted: #b5c4be;
  --muted-2: #8da098;
  --lime: #c6f45f;
  --lime-deep: #8fbf31;
  --aqua: #57dfc1;
  --aqua-deep: #1f9e86;
  --amber: #ffbd66;
  --danger: #ff7e70;
  --radius: 18px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

button, select { font: inherit; }
button { color: inherit; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  z-index: 8;
  top: 0;
  width: 100%;
  margin: 0 auto;
  padding: 14px max(20px, calc((100vw - 1440px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 16, 15, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(198, 244, 95, 0.42);
  border-radius: 11px 4px 11px 4px;
  background: linear-gradient(145deg, rgba(198, 244, 95, 0.16), rgba(87, 223, 193, 0.05));
  transform: rotate(45deg);
  box-shadow: inset 0 0 20px rgba(198, 244, 95, 0.05);
}

.brand-mark span {
  width: 12px;
  height: 12px;
  border: 2px solid var(--lime);
  border-radius: 50%;
  transform: rotate(-45deg);
}

.brand strong,
.brand small { display: block; }
.brand strong { letter-spacing: -0.02em; font-size: 1rem; }
.brand small { color: var(--muted); font-size: 0.72rem; margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.source-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #dce8e2;
  border: 1px solid var(--line);
  background: rgba(10, 23, 21, 0.7);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.source-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
}

.source-pill.is-error { color: #ffd0ca; border-color: rgba(255, 126, 112, 0.28); }
.source-pill.is-error i { background: var(--danger); box-shadow: 0 0 12px var(--danger); }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 750;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.button:hover { transform: translateY(-1px); }
.button-quiet { background: transparent; border-color: var(--line); color: #d8e3de; }
.button-quiet:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.035); }

main {
  width: min(1440px, calc(100% - 40px));
  margin-inline: auto;
}

.tool-bar {
  margin: 18px 0 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.mission-control {
  flex: 1 1 470px;
  min-width: 0;
  max-width: 470px;
}
.mission-control > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mission-control select {
  height: 44px;
  color: var(--text);
  border-color: rgba(198, 244, 95, 0.24);
  background: #091714;
  font-weight: 760;
}

.tool-actions {
  display: flex;
  gap: 8px;
}
.tool-actions .button {
  min-height: 44px;
  white-space: nowrap;
  font-size: 0.72rem;
}

/* The route canvas is the tool; the counters are a readout. The map takes the
   flexible column and the results sit in a fixed rail beside it. */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
  align-items: start;
}

.panel,
.stat-card {
  border: 1px solid var(--line);
  background: rgba(11, 26, 23, 0.92);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.18);
}

.panel { border-radius: var(--radius); }
.observations-panel {
  overflow: hidden;
  padding: 0;
}
.observations-panel.is-unavailable .observed-map-shell {
  opacity: 0.4;
  pointer-events: none;
}

.map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-kicker {
  display: block;
  color: var(--aqua);
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2, h3, p { margin-top: 0; }
.map-heading h2 {
  margin: 5px 0 0;
  letter-spacing: -0.035em;
}
.map-heading h2 { font-size: 1.35rem; }

.observed-map-shell {
  overflow: hidden;
  border-radius: inherit;
  background:
    linear-gradient(rgba(87, 223, 193, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 223, 193, 0.025) 1px, transparent 1px),
    #081613;
  background-size: 22px 22px;
}
.observed-map-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 15px 8px;
  background: rgba(7, 18, 16, 0.76);
}
.observed-map-heading h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}
.observed-map-heading span {
  overflow: hidden;
  color: var(--muted-2);
  font-size: 0.64rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.observed-map-heading .text-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.68rem;
  font-weight: 760;
}
.observed-map-viewport {
  overflow-x: auto;
  overflow-y: hidden;
}
/* width / min-width / max-width are set per render in app.js. */
.observed-map {
  display: block;
  margin-inline: auto;
  min-height: 96px;
}
.observed-edge {
  stroke: rgba(87, 223, 193, 0.28);
  stroke-width: 9;
  stroke-linecap: square;
}
.observed-connection {
  outline: none;
}
.observed-connection:has(.connection-control:hover) .observed-edge,
.observed-connection:has(.connection-control:focus-visible) .observed-edge {
  stroke: var(--aqua);
}
.connection-control-object,
.room-control-object,
.connection-control-shell {
  overflow: visible;
  pointer-events: none;
}
.connection-control-shell {
  position: relative;
  width: 100%;
  height: 100%;
}
.connection-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  border: 1px solid rgba(190, 224, 213, 0.26);
  border-radius: 50%;
  background: #0b1d19;
  padding: 0;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}
.connection-control:hover {
  color: var(--text);
  border-color: var(--aqua);
}
.connection-control.is-key1,
.connection-control.is-key2 {
  color: #fff1d9;
  border-color: rgba(255, 169, 76, 0.82);
  background: #7a3712;
}
.connection-control.is-key2 {
  border-width: 2px;
  background: #a64b12;
  box-shadow: 0 0 8px rgba(255, 145, 48, 0.28);
}
.connection-control.is-seal {
  color: #cafff2;
  border-color: rgba(87, 223, 193, 0.72);
  background: #12332c;
}
.connection-control.is-normal {
  color: var(--lime);
  border-color: rgba(198, 244, 95, 0.48);
  background: #1a2816;
}
.connection-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(50% + 18px);
  z-index: 4;
  max-width: 160px;
  transform: translate(-50%, 4px);
  padding: 5px 8px;
  border: 1px solid rgba(190, 224, 213, 0.28);
  border-radius: 7px;
  color: var(--text);
  background: rgba(7, 17, 15, 0.96);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.34);
  font-size: 0.66rem;
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease, transform 120ms ease;
}
.connection-control:hover + .connection-tooltip,
.connection-control:focus-visible + .connection-tooltip,
.room-exits-control:hover + .connection-tooltip,
.room-exits-control:focus-visible + .connection-tooltip,
.connection-tooltip.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}
.room-rare-control,
.room-exits-control,
.room-remove-control {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(190, 224, 213, 0.28);
  border-radius: 50%;
  background: #0b1d19;
  padding: 0;
  cursor: pointer;
}
/* How many corridors leave this room, as read off the minimap. */
.room-exits-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}
.room-exits-control:hover {
  color: var(--text);
  border-color: var(--aqua);
}
.room-exits-control.is-known {
  color: #07110f;
  border-color: rgba(87, 223, 193, 0.82);
  background: var(--aqua);
}
/* Every onward corridor has been drawn, so this branch is finished. */
.room-exits-control.is-closed {
  color: #301906;
  border-color: #ffd29a;
  background: var(--amber);
  box-shadow: 0 0 9px rgba(255, 189, 102, 0.34);
}
/* Rare-room flag. Seen in only ~8% of seeds, but confirming one removes about
   99% of the remaining candidates, so it gets the loudest state in the set. */
.room-rare-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  color: var(--muted-2);
  font-size: 0.7rem;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}
.room-rare-control:hover {
  color: var(--amber);
  border-color: var(--amber);
}
.room-rare-control.is-rare {
  color: #301906;
  border-color: #ffe1ae;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 189, 102, 0.5);
}
.room-rare-control.is-plain {
  color: var(--muted-2);
  border-color: rgba(190, 224, 213, 0.18);
  background: #0a1614;
}
.observed-marker.confirmed-rare path {
  filter: drop-shadow(0 0 5px rgba(255, 189, 102, 0.7));
}
.room-remove-control {
  color: var(--muted-2);
  font-size: 1rem;
  line-height: 1;
}
.room-remove-control:hover {
  color: #ffd1cb;
  border-color: var(--danger);
  background: #321b19;
}
.candidate-edge {
  stroke: rgba(130, 177, 165, 0.34);
  stroke-width: 8;
  stroke-linecap: square;
  stroke-dasharray: 6 5;
}
.consensus-edge {
  stroke: var(--aqua);
  stroke-width: 8;
  stroke-linecap: square;
  stroke-dasharray: 3 6;
  pointer-events: none;
}
.consensus-room {
  color: var(--aqua);
  pointer-events: none;
}
.consensus-room-shape {
  fill: rgba(36, 90, 78, 0.72);
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-dasharray: 4 3;
}
.consensus-room.is-rare {
  color: var(--amber);
}
.consensus-room.is-rare .consensus-room-shape {
  fill: rgba(118, 78, 37, 0.72);
}
.consensus-room-label {
  fill: #dffaf3;
  text-anchor: middle;
  font-size: 9px;
  font-weight: 850;
}
.candidate-room {
  opacity: 0.34;
  pointer-events: none;
}
.candidate-room-shape {
  fill: rgba(37, 71, 63, 0.78);
  stroke: #82a79d;
  stroke-width: 1.6;
  stroke-dasharray: 4 3;
  stroke-linejoin: round;
}
.candidate-room.is-rare .candidate-room-shape {
  fill: rgba(118, 78, 37, 0.8);
  stroke: var(--amber);
}
.candidate-room-label {
  fill: #d5e2dc;
  text-anchor: middle;
  font-size: 9px;
  font-weight: 800;
}
.observed-node {
  color: var(--muted);
  cursor: pointer;
  outline: none;
}
.observed-node-shape {
  fill: #0b1d19;
  stroke: rgba(190, 224, 213, 0.32);
  stroke-width: 2;
  stroke-linejoin: round;
  transition: fill 120ms ease, stroke 120ms ease;
}
.observed-node:hover .observed-node-shape,
.observed-node:focus .observed-node-shape {
  fill: #102922;
  stroke: var(--aqua);
}
.observed-node.is-selected .observed-node-shape {
  fill: var(--lime);
  stroke: var(--lime);
  filter: drop-shadow(0 0 8px rgba(198, 244, 95, 0.2));
}
.observed-node text {
  text-anchor: middle;
  pointer-events: none;
}
.observed-node-title {
  fill: #e5ede9;
  font-size: 12px;
  font-weight: 850;
}
.observed-node-summary {
  fill: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.observed-node.is-selected .observed-node-title,
.observed-node.is-selected .observed-node-summary {
  fill: #07110f;
}
.observed-node.is-dead-end .observed-node-shape {
  stroke: var(--amber);
}
.observed-marker {
  pointer-events: none;
}
.observed-marker rect,
.observed-marker path,
.observed-marker line,
.observed-marker circle {
  vector-effect: non-scaling-stroke;
}
.observed-marker.icon-rare path {
  fill: var(--amber);
  stroke: #ffe1ae;
  stroke-width: 1;
  filter: drop-shadow(0 0 4px rgba(255, 189, 102, 0.45));
}
.observed-marker.icon-locked rect {
  fill: var(--danger);
  stroke: #ffd1cb;
  stroke-width: 1.2;
}
.observed-marker.icon-locked path,
.observed-marker.icon-locked line {
  fill: none;
  stroke: #ffd1cb;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.observed-marker.icon-seal path:first-child {
  fill: rgba(87, 223, 193, 0.2);
  stroke: var(--aqua);
  stroke-width: 1.5;
}
.observed-marker.icon-seal path:last-child {
  fill: none;
  stroke: #cafff2;
  stroke-width: 1.3;
  stroke-linecap: round;
}
.observed-barrier {
  pointer-events: none;
}
.observed-barrier > line {
  stroke-width: 3.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px currentColor);
}
.observed-barrier.is-key1,
.observed-barrier.is-key2 {
  color: var(--amber);
}
.observed-barrier.is-key1 > line,
.observed-barrier.is-key2 > line {
  stroke: var(--amber);
}
.observed-barrier.is-seal { color: var(--aqua); }
.observed-barrier.is-seal > line {
  stroke: var(--aqua);
  stroke-dasharray: 4 2;
}
.observed-barrier.is-ghost {
  opacity: 0.34;
}
.observed-barrier .barrier-icon {
  filter: drop-shadow(0 0 4px currentColor);
}
.barrier-key-count {
  fill: #fff1d9;
  paint-order: stroke;
  stroke: #4b250d;
  stroke-width: 2.5;
  font-size: 8px;
  font-weight: 950;
  text-anchor: middle;
}
/* Add-a-room ports. Drawn as a doorway rather than a bare plus: tapping one
   places the room and immediately opens that corridor's barrier control,
   which is the evidence that narrows the search fastest. */
.observed-add {
  cursor: pointer;
  outline: none;
}
.observed-add circle {
  fill: var(--aqua);
  stroke: #07110f;
  stroke-width: 2;
  transition: fill 120ms ease, transform 120ms ease;
  transform-box: fill-box;
  transform-origin: center;
}
.observed-add text {
  fill: #07110f;
  text-anchor: middle;
  pointer-events: none;
  font-size: 17px;
  font-weight: 950;
}
.observed-add:hover circle,
.observed-add:focus circle {
  fill: var(--lime);
  transform: scale(1.12);
}
.observed-entry {
  cursor: pointer;
  outline: none;
}
.observed-entry > line:not(.entry-hit) {
  stroke: rgba(87, 223, 193, 0.38);
  stroke-width: 9;
  transition: stroke 120ms ease;
}
.observed-entry .entry-hit {
  stroke: transparent;
  stroke-width: 30;
}
.observed-entry:hover > line:not(.entry-hit),
.observed-entry:focus > line:not(.entry-hit) {
  stroke: var(--aqua);
}
.observed-entry .entry-room-shape {
  fill: #10231f;
  stroke: rgba(87, 223, 193, 0.58);
  stroke-width: 2;
}
.observed-entry .entry-teleporter {
  fill: rgba(108, 228, 255, 0.22);
  stroke: #8ceeff;
  stroke-width: 2;
}
.observed-entry text {
  fill: var(--muted-2);
  font-size: 8px;
  font-weight: 850;
  text-anchor: middle;
  transition: fill 120ms ease;
}
.observed-entry:hover .entry-room-shape,
.observed-entry:focus .entry-room-shape {
  stroke: var(--aqua);
}
.observed-entry:hover text,
.observed-entry:focus text {
  fill: var(--aqua);
}

.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.text-button { color: var(--muted); padding: 8px; font-size: 0.82rem; }
.text-button:hover { color: var(--text); }

.room-label { display: block; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; }
.field > span,
.field legend {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

select {
  width: 100%;
  height: 43px;
  color: #e7eeea;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a1816;
  padding: 0 34px 0 12px;
}
select:hover { border-color: var(--line-strong); }
.results-column { display: grid; gap: 12px; }
/* Two-up in the side rail, with the seed count spanning the top. */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-primary { grid-column: 1 / -1; }
.stat-card { min-width: 0; border-radius: 14px; padding: 14px 16px; }
.stat-card span { display: block; color: var(--muted); font-size: 0.69rem; font-weight: 750; }
.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
.stat-card small { display: block; overflow: hidden; color: var(--muted-2); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.stat-primary { border-color: rgba(198, 244, 95, 0.28); }
.stat-primary strong { color: var(--lime); }
.stat-secret strong { color: var(--amber); }

.identification-note {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(11, 26, 23, 0.92);
  padding: 9px 12px;
  font-size: 0.68rem;
  line-height: 1.42;
}
.identification-note i {
  flex: 0 0 auto;
  color: var(--aqua);
  font-style: normal;
  font-size: 0.92rem;
}
.identification-note.is-identified {
  color: #dce7e2;
  border-color: rgba(255, 189, 102, 0.3);
  background: rgba(255, 189, 102, 0.055);
}
.identification-note.is-identified i { color: var(--amber); }
.identification-note.is-success {
  color: #e7f2cf;
  border-color: rgba(198, 244, 95, 0.38);
  background: rgba(198, 244, 95, 0.075);
}
.identification-note.is-success i { color: var(--lime); }
/* The single unknown that would cut the candidate list the most. */
.hint-note {
  color: #dbeae5;
  border-color: rgba(87, 223, 193, 0.3);
  background: rgba(87, 223, 193, 0.06);
}
.hint-note[hidden] { display: none; }

.candidate-browser {
  border-top: 1px solid rgba(87, 223, 193, 0.18);
  border-bottom: 1px solid rgba(87, 223, 193, 0.18);
  background: rgba(10, 29, 25, 0.92);
  padding: 9px 12px 10px;
}
.candidate-browser[hidden] { display: none; }
.candidate-browser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}
.candidate-browser-heading strong {
  color: #dfe9e4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.64rem;
}
.candidate-browser-heading span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 0.6rem;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.candidate-browser-heading span i {
  width: 8px;
  height: 8px;
  border: 1px dashed var(--aqua);
  border-radius: 2px;
  background: rgba(87, 223, 193, 0.12);
}
.candidate-browser-nav {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  gap: 6px;
}
.candidate-options {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.candidate-options button {
  flex: 1 0 27px;
  min-width: 27px;
  min-height: 29px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #091613;
  padding: 4px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
}
.candidate-options button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.candidate-options button.is-selected {
  color: #07110f;
  border-color: var(--aqua);
  background: var(--aqua);
}
.candidate-step {
  min-width: 30px;
  min-height: 29px;
  color: var(--aqua);
  border: 1px solid rgba(87, 223, 193, 0.26);
  border-radius: 7px;
  background: rgba(87, 223, 193, 0.07);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 850;
}
.candidate-step:hover:not(:disabled) {
  color: #07110f;
  border-color: var(--aqua);
  background: var(--aqua);
}
.candidate-step:disabled {
  opacity: 0.28;
  cursor: default;
}

.map-panel { overflow: hidden; }
.map-heading {
  padding: 20px 25px 16px;
  border-bottom: 1px solid var(--line);
}
.status-badge { flex: 0 0 auto; color: var(--lime); border-color: rgba(198, 244, 95, 0.2); background: rgba(198, 244, 95, 0.06); }

/* Fallback panel for the states that have no candidate map to show:
   a blocked file:// origin, a missing index, or a fixed-sequence area. */
.status-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  color: var(--muted);
  padding: 22px 25px;
}
.status-panel strong { color: var(--text); font-size: 1rem; }
.status-panel p { max-width: 460px; margin: 9px 0 0; font-size: 0.75rem; line-height: 1.55; }
.status-panel code {
  margin-top: 14px;
  color: var(--aqua);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050e0c;
  padding: 8px 11px;
  font-size: 0.69rem;
  overflow-x: auto;
  max-width: 100%;
}

.candidate-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0 25px;
  border-bottom: 1px solid var(--line);
}
.candidate-summary > div { padding: 17px 12px; border-right: 1px solid var(--line); }
.candidate-summary > div:first-child { padding-left: 0; }
.candidate-summary > div:last-child { border-right: 0; }
.candidate-summary span { display: block; color: var(--muted-2); font-size: 0.66rem; }
.candidate-summary strong { display: block; margin-top: 5px; font-size: 0.84rem; font-variant-numeric: tabular-nums; }

.seed-details { padding: 0 25px; }
.debug-details {
  margin: 0 25px;
  border-bottom: 1px solid var(--line);
}
.debug-details > summary {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}
.debug-details > summary::-webkit-details-marker { display: none; }
.debug-details > summary > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dce7e2;
  font-size: 0.78rem;
  font-weight: 800;
}
.debug-details > summary small {
  color: var(--muted-2);
  font-size: 0.65rem;
  font-weight: 500;
}
.debug-details[open] > summary .summary-action i { transform: rotate(180deg); }
.debug-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--amber);
  border: 1px solid rgba(255, 189, 102, 0.28);
  border-radius: 7px;
  background: rgba(255, 189, 102, 0.07);
  font-style: normal;
  font-size: 0.7rem;
}
.debug-body { padding: 2px 0 22px; }
.debug-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d1d9d5;
  border: 1px solid rgba(255, 189, 102, 0.18);
  border-radius: 10px;
  background: rgba(255, 189, 102, 0.055);
  padding: 10px 12px;
  font-size: 0.69rem;
}
.debug-warning strong {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.debug-seed-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 9px;
  align-items: end;
}
.debug-seed-row label > span,
.code-heading span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}
.debug-seed-row input {
  width: 100%;
  height: 42px;
  color: var(--lime);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #071310;
  padding: 0 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
}
.debug-seed-row input[aria-invalid="true"] { color: var(--danger); border-color: rgba(255, 126, 112, 0.6); }
.code-heading {
  margin-top: 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.code-heading span { margin-bottom: 2px; color: #dce7e2; }
.code-heading small { color: var(--muted-2); font-size: 0.64rem; }
.copy-code {
  color: var(--aqua);
  border: 0;
  background: transparent;
  padding: 5px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 800;
}
.copy-code:hover { color: var(--lime); }
.cheat-code {
  max-height: 250px;
  overflow: auto;
  margin: 9px 0 0;
  color: #cfeadc;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #050d0c;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.55;
  tab-size: 2;
}
.debug-steps {
  margin: 16px 0 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.58;
}
.debug-steps li + li { margin-top: 7px; }
kbd {
  color: #dce7e2;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #13231f;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.65rem;
}
.memory-details {
  margin-top: 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 13px;
  font-size: 0.68rem;
}
.memory-details > summary { cursor: pointer; color: #bfcac5; font-weight: 750; }
.memory-details dl { margin: 13px 0; }
.memory-details dl > div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(178, 222, 207, 0.07);
}
.memory-details dt { color: var(--muted-2); }
.memory-details dd { min-width: 0; margin: 0; color: #c6d3cd; overflow-wrap: anywhere; }
.memory-details code { color: var(--aqua); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.memory-details p { margin: 11px 0 0; line-height: 1.55; }
.seed-details summary {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: #d8e3de;
  font-size: 0.76rem;
  font-weight: 750;
}
.seed-details summary::-webkit-details-marker { display: none; }
.summary-action { color: var(--muted); font-weight: 500; }
.summary-action i { display: inline-block; margin-left: 5px; font-style: normal; transition: transform 150ms ease; }
.seed-details[open] .summary-action i { transform: rotate(180deg); }
.seed-list {
  max-height: 180px;
  overflow: auto;
  padding: 0 0 18px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.71rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.help-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  overflow: hidden;
  color: var(--text);
  border: 1px solid rgba(87, 223, 193, 0.28);
  border-radius: 16px;
  background: #0a1916;
  padding: 0;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}
.help-dialog::backdrop {
  background: rgba(2, 8, 7, 0.78);
  backdrop-filter: blur(4px);
}
.help-dialog-card {
  max-height: min(760px, calc(100dvh - 28px));
  display: flex;
  flex-direction: column;
}
.help-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 19px 20px 16px;
}
.help-dialog-heading h2 {
  margin: 4px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.help-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 1.3rem;
}
.help-close:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.help-dialog-body {
  overflow-y: auto;
  padding: 5px 20px 20px;
}
.help-dialog-body section {
  border-bottom: 1px solid rgba(190, 224, 213, 0.09);
  padding: 14px 0;
}
.help-dialog-body section:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}
.help-dialog-body h3 {
  margin: 0 0 5px;
  color: #e5ede9;
  font-size: 0.79rem;
}
.help-dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}
.help-dialog-body strong {
  color: #dfe9e4;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 22px;
  bottom: 22px;
  max-width: min(340px, calc(100vw - 44px));
  color: #07110f;
  background: var(--lime);
  border-radius: 11px;
  padding: 11px 15px;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 800;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .observations-panel { order: 1; }
  .results-column { order: 2; }
  /* Stacked, the readout has the full width back, so spread it evenly. */
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat-primary { grid-column: auto; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-primary { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .site-header,
  main { width: min(100% - 24px, 1240px); }
  .site-header { padding: 12px; }
  .brand small, .source-pill { display: none; }
  .button-quiet { min-height: 38px; padding: 7px 10px; font-size: 0.75rem; }
  .tool-bar {
    margin-top: 12px;
  }
  .mission-control { max-width: none; }
  .tool-actions .button {
    width: 40px;
    min-height: 44px;
    padding: 0;
  }
  .tool-actions .button-label { display: none; }
  .observations-panel { padding: 0; }
  .observed-map-heading {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 12px 12px 6px;
  }
  .observed-map-heading h2 { font-size: 0.96rem; }
  .observed-map-heading span { font-size: 0.58rem; }
  .stat-card { padding: 15px; }
  .map-heading { align-items: flex-start; padding: 20px 18px 15px; }
  .map-heading h2 { font-size: 1.1rem; }
  .status-panel { padding: 18px; }
  .status-badge { padding: 6px 9px; font-size: 0.62rem; }
  .candidate-summary { margin: 0 18px; grid-template-columns: 1fr 1fr; }
  .candidate-summary > div { padding: 14px 10px; }
  .candidate-summary > div:nth-child(2) { border-right: 0; }
  .seed-details { padding: 0 18px; }
  .debug-details { margin: 0 18px; }
  .debug-details > summary small { display: none; }
  .debug-warning { align-items: flex-start; flex-direction: column; gap: 4px; }
  .debug-seed-row { grid-template-columns: 1fr; }
  .memory-details dl > div { grid-template-columns: 100px minmax(0, 1fr); }
  .candidate-browser-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
  .help-dialog-heading { padding: 16px; }
  .help-dialog-body { padding: 4px 16px 16px; }
}

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

/* Area-exit flag. Only shown on a confirmed dead end, since the exit room
   always is one. Sits below the room so it never collides with the rare and
   exit-count badges on the corners. */
.room-goal-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  border: 1px solid rgba(190, 224, 213, 0.28);
  border-radius: 50%;
  background: #0b1d19;
  padding: 0;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}
.room-goal-control:hover { color: var(--lime); border-color: var(--lime); }
.room-goal-control.is-goal {
  color: #07110f;
  border-color: #eaffb0;
  background: var(--lime);
  box-shadow: 0 0 10px rgba(198, 244, 95, 0.45);
}
.room-goal-control.is-plain {
  color: var(--muted-2);
  border-color: rgba(190, 224, 213, 0.18);
  background: #0a1614;
}
.room-goal-control:hover + .connection-tooltip,
.room-goal-control:focus-visible + .connection-tooltip {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

/* Wall pad. One cell per wall the corridor controls do not cover, arranged as a
   mini compass matching the room. Every corridor leaving a room is visible from
   inside it, and reporting all of them is the largest early-search win there
   is — three rooms fully reported goes from ~12,000 candidates to ~100. */
.room-side-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  border: 1px solid rgba(190, 224, 213, 0.24);
  border-radius: 6px;
  background: #0a1917;
  padding: 0;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: auto;
}
.room-side-control:hover { color: var(--text); border-color: var(--aqua); }
.room-side-control.is-wall {
  color: #6d7f79;
  border-color: rgba(190, 224, 213, 0.14);
  background: #06100f;
}
.room-side-control.is-open { color: var(--aqua); border-color: rgba(87, 223, 193, 0.5); }
.room-side-control.is-normal {
  color: #07110f;
  border-color: rgba(198, 244, 95, 0.6);
  background: var(--lime);
}
.room-side-control.is-seal {
  color: #cafff2;
  border-color: rgba(87, 223, 193, 0.7);
  background: #12332c;
}
.room-side-control.is-key1,
.room-side-control.is-key2 {
  color: #fff1d9;
  border-color: rgba(255, 169, 76, 0.8);
  background: #7a3712;
}
.room-side-control.is-key2 { background: #a64b12; border-width: 2px; }
.room-side-control:hover + .connection-tooltip,
.room-side-control:focus-visible + .connection-tooltip {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

/* Frame tying the four wall cells together as one mini-compass for the room.
   The centre shows the onward corridor count the walls imply, so there is no
   separate exit-count control to keep in step. */
.wall-pad-frame {
  fill: rgba(7, 20, 17, 0.72);
  stroke: rgba(190, 224, 213, 0.14);
  stroke-width: 1;
  pointer-events: none;
}
.wall-pad-count {
  fill: var(--muted-2);
  text-anchor: middle;
  pointer-events: none;
  font-size: 11px;
  font-weight: 900;
}

/* The pad has to float over the grid: a 92x74 cell leaves no 54px gap that is
   free of both the room and its neighbours, so it reads as a panel on top
   rather than fighting for space in the layout. */
.wall-pad-frame {
  fill: rgba(6, 15, 14, 0.97);
  stroke: rgba(190, 224, 213, 0.26);
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
}

/* Per-room editor. Lives in the rail because four walls plus the rare, area-exit
   and remove controls cannot fit around a 92x74 grid cell without overlapping
   neighbouring rooms — and in the rail each state can be spelled out instead of
   encoded as a glyph the player has to learn. */
.inspector { padding: 15px 16px 6px; }
.inspector-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.inspector-heading h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.inspector-remove { padding: 4px 6px; font-size: 0.7rem; }
.inspector-remove:hover { color: #ffd1cb; }
.inspector-lede {
  margin: 4px 0 10px;
  color: var(--muted-2);
  font-size: 0.68rem;
  line-height: 1.4;
}
.inspector-rows { display: grid; gap: 4px; padding-bottom: 10px; }
.inspector-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}
.inspector-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}
.inspector-label small {
  display: block;
  color: var(--muted-2);
  font-size: 0.6rem;
  font-weight: 600;
}
.inspector-value {
  min-height: 30px;
  max-width: 168px;
  overflow: hidden;
  color: #dfe9e4;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1816;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 720;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease;
}
.inspector-value:hover { border-color: var(--aqua); background: #0d201d; }
.inspector-value.is-fixed {
  color: var(--muted-2);
  border-color: transparent;
  background: transparent;
  cursor: default;
}
.inspector-value.tone-wall { color: #8fa39c; }
.inspector-value.tone-open { color: var(--aqua); border-color: rgba(87, 223, 193, 0.4); }
.inspector-value.tone-normal {
  color: #07110f;
  border-color: rgba(198, 244, 95, 0.6);
  background: var(--lime);
}
.inspector-value.tone-seal {
  color: #cafff2;
  border-color: rgba(87, 223, 193, 0.6);
  background: #12332c;
}
.inspector-value.tone-key1,
.inspector-value.tone-key2 {
  color: #fff1d9;
  border-color: rgba(255, 169, 76, 0.75);
  background: #7a3712;
}
.inspector-value.tone-rare {
  color: #301906;
  border-color: #ffe1ae;
  background: var(--amber);
}
.inspector-value.tone-goal {
  color: #07110f;
  border-color: #eaffb0;
  background: var(--lime);
}
