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

* { 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; }
.rules-panel { 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; }
.subhead { margin: 12px 0 0; max-width: 620px; 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; }
.secondary-button { background: rgba(255, 255, 255, 0.08); color: #d9dbc8; }

.stats { margin-top: 18px; display: grid; grid-template-columns: repeat(5, 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; }

.play-wrap { margin-top: 16px; width: 100%; display: grid; grid-template-columns: minmax(0, 560px) minmax(160px, 220px); gap: 12px; align-items: start; }
#game-canvas { width: 100%; height: auto; border: 1px solid rgba(241, 217, 164, 0.2); border-radius: 10px; background: rgba(9, 10, 15, 0.9); display: block; }
.preview-panel {
  border: 1px solid rgba(241, 217, 164, 0.2);
  border-radius: 10px;
  background: rgba(9, 10, 15, 0.9);
  padding: 10px;
}
.preview-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#next-canvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(241, 217, 164, 0.15);
  border-radius: 8px;
  display: block;
}
.status { margin: 12px 0 0; color: #abffcf; min-height: 24px; }

.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; }
.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; }

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