:root {
  color-scheme: dark;
  --bg: #11110f;
  --panel: rgba(18, 18, 16, 0.88);
  --panel-border: rgba(225, 207, 171, 0.24);
  --text: #f3ead8;
  --muted: #c7baa2;
  --accent: #f1d9a4;
  --good: #8dffbc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 36% 20%, rgba(216, 185, 122, 0.14), transparent 32%),
    linear-gradient(180deg, #1b1a16 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.014) 1px, transparent 1px);
  background-size: 52px 52px;
  opacity: 0.62;
}

.nav-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(225, 207, 171, 0.32);
  border-radius: 8px;
  background: rgba(15, 15, 13, 0.72);
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: currentColor;
  display: block;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.nav-panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(300px, 86vw);
  z-index: 35;
  padding: 72px 18px 20px;
  background: rgba(13, 13, 11, 0.96);
  border-right: 1px solid rgba(225, 207, 171, 0.2);
  transform: translateX(-104%);
  transition: transform 180ms ease;
}

.nav-panel.is-open { transform: translateX(0); }

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
  z-index: 34;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.nav-overlay.is-open { opacity: 1; pointer-events: auto; }

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.nav-list a {
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  display: block;
  border: 1px solid rgba(225, 207, 171, 0.2);
  border-radius: 8px;
  background: rgba(30, 30, 26, 0.6);
}

.neural-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.44;
}
.neural-bg svg { width: 100%; height: 100%; display: block; }
.neural-lines path {
  fill: none;
  stroke: rgba(222, 194, 142, 0.22);
  stroke-width: 2;
}
.neural-core circle {
  fill: rgba(247, 227, 188, 0.8);
  filter: drop-shadow(0 0 18px rgba(245, 219, 164, 0.8));
}
.neural-signals circle {
  fill: rgba(255, 236, 201, 0.95);
  filter: drop-shadow(0 0 12px rgba(255, 227, 168, 0.92));
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  align-items: start;
  padding: 64px 22px 22px;
}

.layout {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 24px 68px rgba(0, 0, 0, 0.5);
  padding: 20px;
}

.game-panel { width: 100%; }
.rules-panel { width: 100%; position: sticky; top: 22px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 7vw, 56px);
  line-height: 0.96;
}

.rules-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 50px;
  line-height: 0.94;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.08);
  color: #d9dbc8;
}

.rules-content {
  border-top: 1px solid rgba(241, 217, 164, 0.2);
  padding-top: 12px;
}

.rules-lead {
  margin: 0 0 8px;
  color: var(--muted);
}

.rules-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.rules-subhead {
  margin: 14px 0 8px;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rules-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: #f4ddb0;
}

.subhead {
  margin: 12px 0 0;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.5;
}

button {
  appearance: none;
  border: 1px solid rgba(241, 217, 164, 0.36);
  border-radius: 8px;
  background: rgba(217, 184, 121, 0.16);
  color: var(--accent);
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stats div {
  border: 1px solid rgba(241, 217, 164, 0.2);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}
.stats span { display: block; color: var(--muted); font-size: 12px; }
.stats strong { font-size: 28px; font-family: Georgia, "Times New Roman", serif; }

.mode-picker {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.op-button {
  background: rgba(255, 255, 255, 0.08);
  color: #d9dbc8;
}

.op-button.is-active {
  background: rgba(217, 184, 121, 0.24);
  color: #f4ddb0;
  border-color: rgba(241, 217, 164, 0.55);
}

.play-area {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.node {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid rgba(241, 217, 164, 0.26);
  background: rgba(24, 23, 19, 0.86);
  position: relative;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 160ms ease;
}

.node:hover { transform: translateY(-1px); }
.node:disabled { cursor: not-allowed; opacity: 0.86; }

.tile {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  color: #f7e9cc;
  text-shadow: 0 0 16px rgba(241, 217, 164, 0.24);
  display: grid;
  place-items: center;
}

.tile[data-symbol="0"] { background: rgba(66, 118, 217, 0.24); }
.tile[data-symbol="1"] { background: rgba(191, 74, 165, 0.24); }
.tile[data-symbol="2"] { background: rgba(57, 170, 120, 0.24); }
.tile[data-symbol="3"] { background: rgba(212, 148, 42, 0.24); }

.target-board .tile {
  cursor: default;
}

.status {
  margin: 14px 0 0;
  color: var(--good);
  min-height: 24px;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .rules-panel { position: static; }
  .top { flex-direction: column; }
  .stats strong { font-size: 24px; }
  .board { gap: 6px; }
  .play-area { grid-template-columns: 1fr; }
  h2 { font-size: 42px; }
  .app-shell { padding: 58px 14px 16px; }
}
