:root {
  --bg: #0c1020;
  --panel: #171d30;
  --ink: #eef2ff;
  --muted: #9aa7c7;
  --accent: #7aa2ff;
  --warn: #ff6b7a;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 20% -10%, #22315a 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.04em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pad {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #222a44;
  color: var(--muted);
}

.pad.is-pad {
  background: #1e4a3a;
  color: #b6f5d2;
}

button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #0c1020;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 220px;
  gap: 16px;
  align-items: stretch;
}

.stage-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 78vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
}

#field {
  display: block;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 18, 0.55);
  border-radius: 18px;
}

.overlay[hidden] { display: none !important; }

.panel {
  width: min(360px, 86%);
  background: #1c2440;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
  display: grid;
  gap: 10px;
}

.panel h2 { margin: 0; }
.panel p { margin: 0; color: var(--muted); line-height: 1.6; }
.panel button { width: 100%; }
.panel button.is-on { outline: 3px solid #fff3a1; }

.side {
  display: grid;
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.num {
  margin: 0;
  font-size: 34px;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.next-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.next-row div {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.next-row canvas {
  background: #101522;
  border-radius: 10px;
}

.next-1 canvas {
  width: 88px;
  height: 118px;
}

.next-2 canvas {
  width: 64px;
  height: 86px;
  opacity: 0.85;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.hint {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.btn-ghost {
  width: 100%;
  background: #2a3558;
  color: var(--ink);
}

.page-overlay {
  position: fixed;
  z-index: 20;
}

.help p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

#debug {
  margin-top: 12px;
  padding: 10px 12px;
  background: #0a0e18;
  color: #9dffb0;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  border-radius: 10px;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .stage-wrap { min-height: 0; }
  .app { padding: 10px; }
  h1 { font-size: 22px; }
}
