:root {
  --bg: #16141f;
  --bg-2: #1c1a28;
  --panel: #221f31;
  --panel-2: #2a2740;
  --stage: #2e2b42;
  --line: #36324f;
  --line-2: #474166;
  --ink: #efedf7;
  --muted: #a7a2c0;
  --faint: #7c779a;
  --accent: #ec4899;
  --accent-2: #f472b6;
  --accent-ink: #1a0b14;
  --gold: #facc15;
  --good: #34d399;
  --bad: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); }
button { font: inherit; color: inherit; }
img.pixel, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink); border-radius: 10px; padding: 9px 15px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .12s, border-color .12s, transform .06s; white-space: nowrap; }
.btn:hover { background: #343050; border-color: #5a5480; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.small { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn .price { font-weight: 700; background: rgba(0, 0, 0, .22); border-radius: 6px; padding: 1px 7px; font-size: 13px; }
.btn.google { background: #fff; color: #1f1f1f; border-color: #fff; font-weight: 600; padding: 12px 20px; }
.btn.google:hover { background: #f1f1f1; }
.btn.google svg { width: 18px; height: 18px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: rgba(22, 20, 31, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: .2px;
  color: var(--ink); text-decoration: none; }
.brand img { width: 28px; height: 28px; image-rendering: pixelated; }
.beta { font-size: 11px; font-weight: 700; color: var(--accent-2); border: 1px solid #6b2a52; border-radius: 999px; padding: 1px 8px; }
.spacer { flex: 1; }
.credits { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-weight: 700; cursor: pointer; }
.credits:hover { border-color: var(--line-2); }
.credits .coin { width: 12px; height: 12px; background: var(--gold); border-radius: 3px; box-shadow: inset -2px -2px 0 #b8900a; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; cursor: pointer; }
.menu { position: absolute; right: 24px; top: 58px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 240px; padding: 6px; z-index: 30; }
.menu .who { padding: 10px 12px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }

/* ---------- page ---------- */
main.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0; letter-spacing: -.2px; }
h2 { font-size: 18px; margin: 0; }
.sub { color: var(--muted); margin: 6px 0 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.back:hover { color: var(--ink); }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head .count { color: var(--faint); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }
.swatches { display: flex; flex-wrap: wrap; gap: 3px; }
.swatches i { width: 14px; height: 14px; border-radius: 3px; display: block; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.swatches.small i { width: 10px; height: 10px; border-radius: 2px; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #3a1d3a 0%, transparent 60%), var(--bg); }
.signin-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 36px 32px; text-align: center; box-shadow: var(--shadow); }
.signin-card .logo { width: 72px; height: 72px; image-rendering: pixelated; }
.signin-card h1 { margin-top: 14px; font-size: 30px; }
.signin-card .sub { font-size: 16px; margin-bottom: 26px; }
.signin-card .note { color: var(--faint); font-size: 13px; margin-top: 18px; }
.signin-card .brand { margin-bottom: 18px; }
.showcase { display: flex; justify-content: center; align-items: flex-end; gap: 4px; background: var(--stage); border-radius: 14px;
  padding: 10px; margin-bottom: 20px; border: 1px solid var(--line); }
.showcase.big { padding: 18px 28px; margin: 0; }
.hero-art { display: grid; gap: 10px; justify-items: center; }

/* ---------- welcome / empty ---------- */
.hero { background: linear-gradient(135deg, #2a1830 0%, #1f1d33 60%); border: 1px solid var(--line); border-radius: 18px;
  padding: 36px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: center; }
.hero h1 { font-size: 32px; }
.steps { display: grid; gap: 12px; margin: 22px 0 26px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step b { width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; }
.step span { color: var(--muted); }
.step strong { color: var(--ink); display: block; }
.empty { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; transition: border-color .12s, transform .12s; }
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.stage { height: 220px; background: var(--stage); display: grid; place-items: center; position: relative; }
.stage.light { background: #e7e5ef; }
.stage.checks { background-color: #d8d6e2; background-image: linear-gradient(45deg, #c3c0d0 25%, transparent 25%, transparent 75%, #c3c0d0 75%),
  linear-gradient(45deg, #c3c0d0 25%, transparent 25%, transparent 75%, #c3c0d0 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.stage .tag { position: absolute; top: 10px; left: 10px; font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: rgba(22, 20, 31, .75); padding: 2px 8px; border-radius: 999px; }
.stage .tag.new { color: #fff; background: var(--accent); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .title { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.game-card .stage { height: 170px; }
.new-card { border-style: dashed; border-width: 1.5px; align-items: center; justify-content: center; min-height: 260px; color: var(--muted); gap: 10px; }
.new-card .plus { width: 54px; height: 54px; border-radius: 14px; background: var(--panel-2); display: grid; place-items: center; font-size: 30px; color: var(--accent-2); }
.new-card:hover { color: var(--ink); }

.moves { display: flex; flex-wrap: wrap; gap: 6px; }
.move { font-size: 12.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.move:hover { color: var(--ink); border-color: var(--line-2); }
.move.on { color: #fff; background: #5b2149; border-color: var(--accent); }
.nudge { background: #2c1a2b; border: 1px solid #5b2149; color: #f9c7e1; border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* pending */
.pending .stage { background: linear-gradient(110deg, var(--stage) 30%, #3a3654 50%, var(--stage) 70%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--accent-2); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .8s linear; }
.failed { border-color: #6b2b33; }
.failed .stage { background: #2c1d24; color: var(--bad); font-weight: 700; }

/* toolbar on the game page */
.game-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.make-bar { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 7, 14, .66); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 100%; max-width: 600px; max-height: calc(100vh - 40px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.dialog.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.dialog header { padding: 20px 24px 6px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog header h2 { font-size: 21px; }
.dialog header p { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.dialog .x { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.dialog .x:hover { background: var(--panel-2); color: var(--ink); }
.dialog .content { padding: 12px 24px 8px; display: grid; gap: 18px; }
.dialog footer { position: sticky; bottom: 0; background: var(--bg-2); border-top: 1px solid var(--line); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog footer .total { color: var(--muted); font-size: 14px; }
.dialog footer .total b { color: var(--ink); }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.dots i.on { background: var(--accent); }

.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; justify-items: start; }
.field > input, .field > textarea, .field > select, .field > .choices, .field > .row, .field > .examples, .field > div { justify-self: stretch; }
.field > .seg { justify-self: start; }
.field small, .hint { color: var(--faint); font-weight: 500; font-size: 13px; }
input[type=text], textarea, select { width: 100%; background: var(--panel); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 12px; font: inherit; }
textarea { min-height: 84px; resize: vertical; }
input[type=text]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(236, 72, 153, .2); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.examples button:hover { color: var(--ink); border-color: var(--line-2); }

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.choice { background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left;
  display: grid; gap: 8px; transition: border-color .12s, background .12s; }
.choice:hover { border-color: var(--line-2); }
.choice.on { border-color: var(--accent); background: #2a1a2c; }
.choice strong { font-size: 14.5px; }
.choice span { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.choice svg { width: 100%; height: 64px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: 7px 13px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }
.checks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.check.on { border-color: var(--accent); background: #2a1a2c; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; }
.check .done { margin-left: auto; font-size: 11.5px; color: var(--good); font-weight: 700; }
.check .rec { margin-left: auto; font-size: 11.5px; color: var(--accent-2); font-weight: 700; }
.custom-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: start; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* detail viewer */
.viewer { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.viewer .stage { height: 360px; border-radius: 12px; }
.viewer .tools { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.facts { display: grid; gap: 4px; font-size: 14px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 7px 0; }
.facts div span:first-child { color: var(--muted); }
details.origin { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
details.origin summary { cursor: pointer; font-weight: 600; }
details.origin p { color: var(--muted); margin: 8px 0 0; word-break: break-word; }

/* history drawer */
.list { display: grid; gap: 2px; }
.list div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list .neg { color: var(--muted); }
.list .pos { color: var(--good); }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: grid; gap: 10px; }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 12px 16px; box-shadow: var(--shadow); max-width: 380px; animation: pop .16s ease-out; font-size: 14px; }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast b { display: block; margin-bottom: 2px; }

/* simple message page (sign-in errors) */
body.message { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.message-card { max-width: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; text-align: center; }
.message-card .brand { justify-content: center; margin-bottom: 14px; }
.message-card .brand img { width: 28px; height: 28px; }
.message-card p { color: var(--muted); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .topbar .beta, .credits .meta { display: none; }
  .make-bar { width: 100%; }
  .make-bar .btn { flex: 1 1 auto; }
  main.page { padding: 20px 16px 60px; }
  .hero { grid-template-columns: 1fr; padding: 24px; }
  .viewer { grid-template-columns: 1fr; }
  .checks-grid { grid-template-columns: 1fr; }
  .custom-row { grid-template-columns: 1fr; }
  .menu { right: 16px; }
}
