:root {
  --bg: #15161a;
  --panel: #1e2026;
  --panel-2: #262932;
  --line: #31343f;
  --text: #e8e6e1;
  --muted: #8d909b;
  --accent: #f2b544;
  --accent-ink: #1b1406;
  --good: #7fd18b;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: #4a4e5c; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; width: 100%; margin-top: 10px; }
button.ghost, .ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.hidden { display: none !important; }

.top {
  display: flex; gap: 16px; align-items: center; padding: 12px 20px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.logo { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo-mark {
  width: 18px; height: 18px; border-radius: 3px;
  background: conic-gradient(var(--accent) 0 25%, #6b7cff 0 50%, #7fd18b 0 75%, #8d909b 0);
}
.theme { flex: 1; display: flex; gap: 8px; min-width: 260px; }
.theme input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; outline: none;
}
.theme input:focus { border-color: var(--accent); }
.themes { flex: 1; display: flex; gap: 8px; flex-wrap: wrap; }
.theme-btn { border-radius: 999px; padding: 7px 16px; color: var(--muted); background: transparent; }
.theme-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.top-actions { display: flex; gap: 8px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 20px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.stage-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stage {
  position: relative; height: min(72vh, 760px); border-radius: var(--radius);
  background: repeating-conic-gradient(#1a1b20 0 25%, #1d1f25 0 50%) 0 0 / 24px 24px;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden;
  cursor: none;
}
#board { image-rendering: pixelated; image-rendering: crisp-edges; display: block; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.brush-ring {
  position: absolute; pointer-events: none; border: 1.5px solid rgba(255,255,255,.75); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4); transform: translate(-50%, -50%); display: none;
}
button.next-btn { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); width: auto; margin: 0;
  padding: 10px 18px; cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center;
  background: rgba(21,22,26,.72); text-align: center; padding: 20px; cursor: default; font-size: 16px;
}
.quiz { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.quiz-q { color: var(--muted); font-size: 13px; }
.quiz-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-opts button { font-size: 13px; }
.quiz-opts button.right { background: var(--good); color: #0e2412; border-color: var(--good); opacity: 1; }
.quiz-opts button.wrong { border-color: #e0796f; color: #e0796f; opacity: 1; }
.quiz-msg { font-size: 13px; color: var(--muted); }
.buff { margin-top: 6px; color: var(--good); font: 600 13px/1.3 var(--mono); }
.credit { color: var(--muted); font-size: 12.5px; min-height: 18px; }
.credit a { color: var(--muted); }

.panel { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.sub { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.points { font: 700 32px/1.1 var(--mono); color: var(--accent); margin: 4px 0 2px; }
.mono { font-family: var(--mono); }
.progress-big { font: 700 26px/1.1 var(--mono); margin-top: 6px; }
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.sizes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sizes button { padding: 5px 9px; font-family: var(--mono); font-size: 12.5px; }
.sizes button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sizes button.locked { opacity: .35; }

.upgrades { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.upg { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.upg:first-child { border-top: 0; }
.upg .name { font-weight: 600; }
.upg .lvl { color: var(--muted); font-weight: 400; font-size: 12px; }
.upg .eff { color: var(--muted); font-size: 12px; grid-column: 1; }
.upg button { grid-row: 1 / span 2; grid-column: 2; font-family: var(--mono); font-size: 12.5px; min-width: 92px; }
.upg button.can { border-color: var(--accent); color: var(--accent); }

.danger { color: #e0796f; border-color: #5a3330 !important; align-self: flex-start; font-size: 12.5px; }
.danger:hover { border-color: #e0796f !important; }

.gallery-wrap { padding: 0 20px 30px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; }
.gallery a { flex: none; }
.gallery img { height: 72px; border-radius: 6px; border: 1px solid var(--line); image-rendering: pixelated; display: block; }
.gallery .empty { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 10;
}

.help-btn { width: 34px; padding: 7px 0; font-weight: 700; }
.help {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(10,11,14,.72); padding: 16px;
}
.help-card {
  max-width: 460px; width: 100%; max-height: 100%; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.help-card h2 { margin: 0 0 12px; font-size: 20px; }
.help-steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; line-height: 1.4; font-size: 15px; }
.help-steps b { color: var(--accent); font-weight: 600; }
.help-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
