:root {
  --purple: #3d2572;
  --purple-dark: #2b1954;
  --purple-soft: #eee8f8;
  --orange: #d85f26;
  --cream: #fbfaf7;
  --ink: #202127;
  --muted: #676a73;
  --line: #d8d5df;
  --success: #246c4a;
  --danger: #a52d2d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: var(--purple); }
button, input { font: inherit; }
button, .button-link {
  min-height: 44px;
  border: 1px solid var(--purple);
  border-radius: 0.55rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(216, 95, 38, 0.45);
  outline-offset: 2px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--purple); color: white; }
.primary:hover { background: var(--purple-dark); }
.secondary, .button-link { background: white; color: var(--purple); }
.button-link.primary { background: var(--purple); color: white; }

.site-header {
  background: var(--purple);
  color: white;
  padding: 0.8rem max(1rem, calc((100vw - 70rem) / 2));
}
.brand { color: white; text-decoration: none; font-weight: 800; letter-spacing: 0.01em; }
.page-shell { width: min(70rem, calc(100% - 2rem)); margin: 1.25rem auto 3rem; }
.site-footer { color: var(--muted); text-align: center; padding: 1.5rem 1rem 2rem; font-size: 0.85rem; }
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1.1rem, 3vw, 2rem);
  margin-bottom: 1rem;
  box-shadow: 0 0.35rem 1.2rem rgba(42, 28, 72, 0.06);
}
.narrow { max-width: 42rem; margin-left: auto; margin-right: auto; }
h1, h2 { color: var(--purple-dark); line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin: 0.25rem 0 1rem; }
h2 { font-size: clamp(1.25rem, 3.5vw, 1.75rem); }
p { line-height: 1.55; }
.eyebrow { color: var(--orange); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; margin: 0; }
.ratio-key { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1rem; }
.ratio-key span { background: var(--purple-soft); border-radius: 99rem; padding: 0.4rem 0.7rem; font-size: 0.88rem; }

.unlock-form { display: grid; gap: 0.7rem; }
.unlock-form input { min-height: 48px; border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.6rem; }
.error { color: var(--danger); font-weight: 700; }
.status-panel { text-align: center; }

.progress-row { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-weight: 700; margin-bottom: 1rem; }
.question h2 { margin-bottom: 0.35rem; }
.question-prompt { color: var(--muted); margin-top: 0; }
.roulette-note { font-size: 0.9rem; color: var(--muted); }
.roulette-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(36px, 1fr);
  align-items: end;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 1rem 0 0.5rem;
  min-height: 18rem;
}
.bin-button {
  min-width: 36px;
  height: 15rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  background: #faf9fc;
  color: var(--ink);
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 0.35rem;
}
.bin-button:hover { border-color: var(--orange); }
.chip-stack { display: flex; flex-direction: column-reverse; gap: 2px; width: 100%; align-items: center; }
.chip { width: min(1.25rem, 85%); height: 0.42rem; border-radius: 99rem; background: var(--orange); }
.bin-count { font-weight: 800; color: var(--purple); }
.bin-label { font-size: 0.7rem; writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 auto; }
.controls { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1rem; }
.form-message { min-height: 1.5rem; color: var(--muted); font-weight: 700; }
.storage-warning { border-left: 4px solid var(--orange); background: #fff6ec; padding: 0.75rem; }
.prior-receipt { border-left: 4px solid var(--success); background: #eef8f2; padding: 0.75rem; font-weight: 700; }
.confirmation { text-align: center; }
.confirmation-code { font-size: 2rem; color: var(--success); letter-spacing: 0.08em; font-weight: 900; }

.result-card { break-inside: avoid; }
.result-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(30px, 1fr); gap: 0.35rem; overflow-x: auto; align-items: end; min-height: 14rem; }
.result-bin { min-width: 30px; height: 12rem; display: grid; grid-template-rows: auto 1fr auto; gap: 0.25rem; align-items: end; text-align: center; }
.result-count { font-size: 0.75rem; color: var(--muted); }
.result-bin progress { width: 100%; height: 8rem; writing-mode: vertical-lr; direction: rtl; accent-color: var(--orange); }
.result-label { font-size: 0.68rem; writing-mode: vertical-rl; transform: rotate(180deg); margin: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.status { border-radius: 99rem; padding: 0.25rem 0.6rem; font-weight: 700; }
.status-open { background: #dff2e8; color: var(--success); }
.status-closed, .status-archived { background: #eee; }
.status-draft { background: #fff0d8; color: #795100; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; }
dt { font-weight: 800; } dd { margin: 0; }
.admin-actions, .admin-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
code { overflow-wrap: anywhere; }

@media (max-width: 620px) {
  .page-shell { width: min(100% - 1rem, 70rem); margin-top: 0.5rem; }
  .card { border-radius: 0.75rem; }
  .progress-row { align-items: flex-start; font-size: 0.85rem; }
  .controls { justify-content: stretch; }
  .controls button { flex: 1 1 42%; }
  .bin-button { height: 13rem; }
}
