/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f2f5f7;
  --surface: #ffffff;
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #d5dbe3;
  --cell: #dde3ea;
  --gold: #c2a633;      /* Dogecoin gold: normal entries */
  --gold-ink: #7a6514;  /* gold as readable text color */
  --gold-wash: #f7efcf;
  --hl: #ef6a1f;        /* highlight orange: 5 DOGE entries */
  --hl-ink: #a8430c;
  --hl-wash: #fde6d6;
  --bad: #b3261e;
  --ok: #2f8a50;
  --px-sky: #9fd0ee; --px-o: #de8730; --px-d: #aa5c1c; --px-c: #f8e9cc; --px-s: #fff4b4;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* Dark theme: follows the system unless "Light" is chosen, or forced with "Dark" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10151d; --surface: #182030; --ink: #e7ebf1; --muted: #98a2b3; --line: #2a3445; --cell: #222b3a;
    --gold: #d6b94a; --gold-ink: #e6cc66; --gold-wash: #2a2617;
    --hl: #ff7f36; --hl-ink: #ffa16b; --hl-wash: #36210f;
    --bad: #ff8a80; --ok: #5fd08a;
    --px-sky: #22395a; --px-o: #e08a33; --px-d: #b5662a; --px-c: #f3e3c3; --px-s: #ffe98a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151d; --surface: #182030; --ink: #e7ebf1; --muted: #98a2b3; --line: #2a3445; --cell: #222b3a;
  --gold: #d6b94a; --gold-ink: #e6cc66; --gold-wash: #2a2617;
  --hl: #ff7f36; --hl-ink: #ffa16b; --hl-wash: #36210f;
  --bad: #ff8a80; --ok: #5fd08a;
  --px-sky: #22395a; --px-o: #e08a33; --px-d: #b5662a; --px-c: #f3e3c3; --px-s: #ffe98a;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
main, .top, .foot { width: min(100% - 32px, 1040px); margin-inline: auto; }
a { color: var(--gold-ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 18px 0; font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.theme { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.theme button { font: 500 13px/1 var(--body); color: var(--muted); background: transparent; border: 0; border-radius: 999px; padding: 6px 11px; cursor: pointer; }
.theme button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.brand { font-family: var(--display); font-weight: 700; font-size: 17px; white-space: nowrap; }
.indexer { text-align: right; }
@media (max-width: 560px) { .indexer { font-size: 12px; } }
.indexer { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.indexer .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.indexer.ok .dot { background: var(--ok); }
.indexer.warn .dot { background: var(--bad); }

/* ---------- Hero with pixel picture ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  gap: 40px;
  align-items: center;
  padding: 24px 0 48px;
}
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 24px; } }
h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(48px, 8vw, 104px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  margin: 0 0 18px;
  font-variant-numeric: tabular-nums;
}
.lede { max-width: 48ch; color: var(--muted); font-size: 18px; margin: 0 0 12px; }
.lede.small { font-size: 15px; }
.picture { margin: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(40, 1fr);
  gap: 1px;
  width: 100%;
  max-width: 440px;
  padding: 6px;
  border-radius: 10px;
  background: var(--surface);
  border: 1.5px solid var(--line);
}
@media (max-width: 820px) { .grid { max-width: 520px; } }
.cell { aspect-ratio: 1; border-radius: 1px; background: var(--cell); }
.cell.on { cursor: pointer; }
.cell.p { background: transparent; box-shadow: inset 0 0 0 1px var(--gold); }
.cell.x { background: repeating-linear-gradient(45deg, var(--cell) 0 1px, transparent 1px 3px); }
.cell.new { animation: pop 900ms ease-out both; }
@keyframes pop { from { transform: scale(2.4); filter: brightness(1.6); } }
@media (prefers-reduced-motion: reduce) { .cell.new { animation: none; } }

/* Pixel palette */
.px-\. { background: var(--px-sky); }
.px-o { background: var(--px-o); }
.px-d { background: var(--px-d); }
.px-c { background: var(--px-c); }
.px-k { background: #1e1e22; }
.px-w { background: #ffffff; }
.px-p { background: #ec8c96; }
.px-r { background: #f0a08c; }
.px-s { background: var(--px-s); }

.legend { margin: 18px 0 0; color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Write ---------- */
.write {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 48px;
  padding: 48px 0;
  border-top: 1px solid var(--line);
}
@media (max-width: 820px) { .write { grid-template-columns: 1fr; gap: 32px; } .rules { order: -1; padding-bottom: 24px; border-bottom: 1px solid var(--line); } }
h2 { font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 20px; }
.rules h2 { font-size: 22px; }
.rules { color: var(--muted); font-size: 15px; }
.rules p { margin: 0 0 12px; }
.rules strong { color: var(--ink); }

fieldset.tiers { border: 0; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset.tiers legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.tier {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.tier input { position: absolute; opacity: 0; pointer-events: none; }
.tier:has(input:checked) { border-color: var(--gold); background: var(--gold-wash); }
.tier-hl .tier-price { color: var(--hl-ink); }
.tier-hl:has(input:checked) { border-color: var(--hl); background: var(--hl-wash); }
.tier:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 3px; }
.tier-price { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; }
.tier-name { font-weight: 600; }
.tier-desc { color: var(--muted); font-size: 13px; line-height: 1.35; }

.field { display: grid; gap: 6px; margin-bottom: 16px; font-weight: 600; }
.field input, .field textarea {
  font: 400 16px/1.5 var(--body);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); outline: none; }
.field [aria-invalid="true"] { border-color: var(--bad); }
.count { justify-self: end; font-weight: 400; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-top: -2px; }
.count.over { color: var(--bad); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  font: 600 16px/1 var(--body);
  color: #1d2433;
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  padding: 13px 20px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--gold); }
.btn.small { font-size: 14px; padding: 8px 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.error { color: var(--bad); min-height: 0; margin: 0 0 12px; font-weight: 500; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 14px; }
.hint a { word-break: break-all; }
.turnstile { margin: 16px 0; min-height: 65px; }

/* ---------- Payment ---------- */
.pay-box { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; padding: 20px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); }
@media (max-width: 520px) { .pay-box { grid-template-columns: 1fr; } }
.qr { background: #fff; padding: 10px; border-radius: 8px; line-height: 0; width: max-content; }
.qr:empty { display: none; }
.pay-amount { margin: 0 0 4px; font-size: 18px; }
.pay-amount strong { font-family: var(--display); font-size: 26px; }
.addr { margin: 0 0 10px; overflow-x: auto; }
.addr code { font-family: var(--mono); font-size: 14px; word-break: break-all; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 16px 0 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 400ms ease; }
.pay-status { margin: 0; font-weight: 600; }
.pay-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Entries ---------- */
.entries { padding: 48px 0; border-top: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.entry { display: grid; grid-template-columns: 4.2em 1fr; gap: 4px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.entry .no { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; padding-top: 2px; }
.entry .who { font-weight: 600; }
.entry .msg { margin: 0; overflow-wrap: anywhere; }
.entry .meta { grid-column: 2; color: var(--muted); font-size: 13px; }
.entry .meta a { color: inherit; }
.badge { display: inline-block; font-size: 12px; font-weight: 500; color: var(--gold-ink); border: 1px solid var(--gold); border-radius: 999px; padding: 0 8px; margin-left: 8px; vertical-align: 1px; }

.entry.highlight {
  grid-template-columns: 1fr;
  margin: 18px 0;
  padding: 24px 26px;
  background: var(--hl-wash);
  border: 0;
  border-left: 6px solid var(--hl);
  border-radius: 4px 12px 12px 4px;
}
.entry.highlight .no { color: var(--hl-ink); font-weight: 600; }
.entry.highlight .msg { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; letter-spacing: -0.015em; white-space: pre-line; }
.entry.highlight .who { font-size: 17px; margin-top: 10px; }
.entry.highlight .meta { grid-column: 1; }
.entry.flash { outline: 2px solid var(--gold); outline-offset: 4px; }
.entry.highlight.flash { outline-color: var(--hl); }
.entry.highlight .badge { color: var(--hl-ink); border-color: var(--hl); }
.empty { color: var(--muted); }

.foot { padding: 24px 0 48px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* ---------- Open reservation banner ---------- */
.resume { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 20px; padding: 12px 14px; border-radius: 8px; background: var(--gold-wash); border: 1.5px solid var(--gold); font-size: 15px; }
.linkbtn { font: 600 15px/1.4 var(--body); color: var(--gold-ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Entries paused (indexer down) ---------- */
.paused { margin: 0 0 20px; padding: 12px 14px; border-radius: 8px; border: 1.5px solid var(--bad); color: var(--ink); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); font-size: 15px; }
.paused strong { color: var(--bad); }
form.is-paused { opacity: 0.55; }
