:root {
  --paper: #f5ede0;
  --card: #fbf6ee;
  --ink: #2e1d12;
  --muted: #7d6655;
  --line: #e2d4bf;
  --cherry: #9e2a2b;
  --gold: #b97a22;
  --ok: #3f6b3a;
  --shadow: 0 1px 0 rgba(46, 29, 18, 0.04), 0 8px 24px -12px rgba(46, 29, 18, 0.18);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15100c;
    --card: #1d1611;
    --ink: #f0e4d3;
    --muted: #a8927d;
    --line: #33271e;
    --cherry: #e06a62;
    --gold: #dba650;
    --ok: #8fbf7f;
    --shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--serif);
  font-optical-sizing: auto;
}
a { color: var(--cherry); text-underline-offset: 3px; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 6vw, 3.3rem); font-weight: 800; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 36em; }
.note { color: var(--muted); font-size: 0.95rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}

input, button { font: inherit; }
input {
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
button {
  padding: 11px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--cherry);
  color: #fff8ef;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; }
button.quiet { background: transparent; color: var(--muted); padding: 0; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 10px; }
.stack { display: grid; gap: 8px; max-width: 420px; }
.stack label { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.stack button { justify-self: start; margin-top: 10px; }
.note.error { color: var(--cherry); }
@media (max-width: 480px) { .row { flex-direction: column; } }

/* Home */
.hero { padding: 56px 0 20px; }
@media (max-width: 640px) { .hero { padding-top: 36px; } }
section { margin: 0 0 28px; }
.ticket { font-family: var(--mono); background: var(--paper); border: 1px dashed var(--gold); border-radius: 8px; padding: 8px 12px; display: inline-block; word-break: break-all; }

.pies { list-style: none; margin: 0; padding: 0; }
.pies li {
  display: grid;
  grid-template-columns: 3em 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.pies li:last-child { border-bottom: 0; }
.pies .num { font-size: 0.9rem; color: var(--muted); }
.pies .name { font-weight: 600; }
.pies .word { display: block; font: 500 0.85rem var(--mono); color: var(--ok); }
.pill { font-size: 0.9rem; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.open { border-color: var(--cherry); color: var(--cherry); text-decoration: none; }
.pill.solved { border-color: var(--ok); color: var(--ok); }

.board { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.board th { text-align: left; font-weight: 400; font-size: 0.9rem; color: var(--muted); padding: 0 8px 8px 0; }
.board td { padding: 9px 8px 9px 0; border-top: 1px solid var(--line); }
.board td:first-child { font-family: var(--mono); color: var(--muted); width: 2.5em; }
.board .done { color: var(--ok); font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }
.board-wrap { overflow-x: auto; }

footer { padding: 24px 0 48px; color: var(--muted); font-size: 0.9rem; }

/* Pie pages */
.top { max-width: 900px; margin: 0 auto; padding: 22px 16px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.back { text-decoration: none; font-family: var(--mono); font-size: 0.9rem; }
.stage { max-width: 900px; margin: 0 auto; padding: 28px 16px 64px; }
.answer { margin-top: 36px; max-width: 520px; }
.answer label { display: block; color: var(--muted); margin-bottom: 8px; }
.answer .note { margin-top: 10px; min-height: 1.6em; }
.answer .note.good { color: var(--ok); }
.answer .note.bad { color: var(--cherry); }

/* Motion: short and cheap (opacity and transform only). */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes pop { 50% { transform: scale(1.04); } }
.wrap > *, .stage > * { animation: rise 0.35s cubic-bezier(.2, .7, .2, 1) both; }
.wrap > :nth-child(2), .stage > :nth-child(2) { animation-delay: 40ms; }
.wrap > :nth-child(3), .stage > :nth-child(3) { animation-delay: 80ms; }
.wrap > :nth-child(4), .stage > :nth-child(4) { animation-delay: 120ms; }
.wrap > :nth-child(n+5), .stage > :nth-child(n+5) { animation-delay: 160ms; }
.note.bad, .note.error:not(:empty) { animation: shake 0.3s ease; }
.note.good { animation: pop 0.35s ease; }
button { transition: transform 0.1s ease, filter 0.15s ease, background-color 0.15s ease; }
button:active:not(:disabled) { transform: scale(0.97); }
a, .pill { transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease; }
.pill.open:hover { background: var(--cherry); color: #fff8ef; }
input { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.board tbody tr { animation: rise 0.3s ease both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
