:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: rgba(10, 21, 42, 0.92);
  --panel-strong: rgba(7, 15, 31, 0.96);
  --line: rgba(136, 183, 255, 0.18);
  --text: #edf4ff;
  --muted: #a4b6d3;
  --accent: #8fbcff;
  --accent-2: #7af7e3;
  --danger: #ff9582;
  --glow: rgba(122, 247, 227, 0.28);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(84, 142, 255, 0.2), transparent 35%),
    linear-gradient(180deg, #081224 0%, #050b16 100%);
  color: var(--text);
}

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

.site-shell,
.doc-card {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
}

.site-shell {
  padding: 28px 0 44px;
}

.hero-card,
.board-card,
.side-card,
.doc-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  padding: 28px;
  margin-bottom: 22px;
}

.hero-topline {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.hero-card h1,
.doc-card h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.96;
}

.hero-copy {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 12px 0 0;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  max-width: 320px;
}

.hero-badges span,
.section-label,
.eyebrow,
.rail-badge {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.hero-badges span {
  border: 1px solid rgba(143, 188, 255, 0.28);
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--muted);
}

.eyebrow,
.section-label {
  color: var(--accent-2);
  margin: 0 0 10px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.board-card { padding: 24px; }
.side-column { display: grid; gap: 18px; }
.side-card { padding: 20px; }
.quiet-card p:last-child { margin-bottom: 0; }

.board-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.board-head h2 { margin: 0; font-size: 1.8rem; }
.level-blurb { margin: 10px 0 0; color: var(--muted); max-width: 55ch; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 12px;
  min-width: 250px;
}

.stats-grid article {
  background: var(--panel-strong);
  border: 1px solid rgba(143, 188, 255, 0.14);
  border-radius: 18px;
  padding: 12px 14px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.stats-grid strong {
  font-size: 1.15rem;
  color: var(--text);
}

.feedback {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(122, 247, 227, 0.08);
  border: 1px solid rgba(122, 247, 227, 0.16);
  color: #dffcf6;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: 22px;
  border: 1px solid rgba(143, 188, 255, 0.12);
}

.cell {
  appearance: none;
  border: 1px solid rgba(143, 188, 255, 0.13);
  background: rgba(8, 20, 39, 0.92);
  color: var(--text);
  border-radius: 18px;
  min-height: 70px;
  font-size: 1.35rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.cell:disabled { cursor: default; }
.cell.fold { cursor: pointer; }
.cell.fold:hover,
.cell.fold:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(143, 188, 255, 0.42);
  box-shadow: 0 12px 28px rgba(9, 20, 39, 0.4);
  outline: none;
}

.cell.energy {
  background: radial-gradient(circle at center, rgba(122, 247, 227, 0.18), rgba(8, 20, 39, 0.95));
  box-shadow: inset 0 0 0 1px rgba(122, 247, 227, 0.16);
}

.cell.fold.energy {
  box-shadow:
    0 0 0 1px rgba(122, 247, 227, 0.2),
    0 0 22px rgba(122, 247, 227, 0.18);
}

.cell.source {
  color: var(--accent);
  background: linear-gradient(180deg, rgba(46, 87, 163, 0.6), rgba(16, 32, 62, 0.9));
}

.cell.star {
  color: #fdf3a5;
}

.cell.star.energy {
  background: radial-gradient(circle at center, rgba(253, 243, 165, 0.25), rgba(12, 22, 39, 0.95));
  box-shadow: 0 0 24px rgba(253, 243, 165, 0.2);
}

.cell.wall {
  background: linear-gradient(180deg, rgba(38, 46, 63, 0.95), rgba(20, 26, 38, 0.98));
  color: rgba(255,255,255,0.55);
}

.cell-floor {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(143, 188, 255, 0.22);
}

.cell-label {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.58rem;
  color: rgba(164, 182, 211, 0.52);
  font-weight: 600;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #9dc4ff, #6fa1ff);
  color: #081224;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.48;
}

#summaryButton,
#resetButton {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(143, 188, 255, 0.14);
}

.legend-list,
.hint-list,
.level-rail {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.legend-list li,
.hint-list li,
.level-rail li { margin-bottom: 10px; }

.legend-swatch {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border-radius: 8px;
  border: 1px solid rgba(143, 188, 255, 0.16);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 700;
}

.legend-swatch.source { color: var(--accent); }
.legend-swatch.star { color: #fdf3a5; }
.legend-swatch.wall { color: rgba(255,255,255,0.6); }

.level-rail {
  list-style: none;
  padding-left: 0;
  display: grid;
  gap: 10px;
}

.level-rail button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(143, 188, 255, 0.12);
}

.level-rail button.active {
  border-color: rgba(122, 247, 227, 0.3);
  box-shadow: inset 0 0 0 1px rgba(122, 247, 227, 0.18);
}

.rail-title {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

.rail-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 6px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.doc-body {
  padding: 32px 0;
  background:
    radial-gradient(circle at top, rgba(122, 247, 227, 0.12), transparent 30%),
    linear-gradient(180deg, #081224 0%, #050b16 100%);
}

.doc-card {
  padding: 28px;
  line-height: 1.65;
}

.doc-card h2 { margin-top: 28px; }
.doc-card code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 6px; }
.doc-footer { margin-top: 26px; color: var(--muted); }

@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .hero-topline,
  .board-head,
  .site-footer {
    flex-direction: column;
  }
  .hero-badges { justify-content: start; max-width: none; }
  .stats-grid { width: 100%; min-width: 0; }
  .cell { min-height: 58px; }
}
