/* Drawbox — a dusk-violet field lit by one magenta neon sign. Cards stack; the CA docks to the bottom edge. */
:root {
  --field: #5B4A86;
  --field-deep: #4C3E73;
  --sheet: #3A2F5A;
  --sheet-hi: #44386A;
  --ink: #F7F1FF;
  --ink-soft: #D9CCF4;
  --ink-mute: #B3A3D6;
  --neon: #FF4FD8;
  --neon-soft: rgba(255, 79, 216, .18);
  --tube: #B79CFF;
  --rule: rgba(247, 241, 255, .16);
  --glow: 0 0 6px rgba(255, 79, 216, .85), 0 0 18px rgba(255, 79, 216, .45);
  --display: 'Tilt Neon', 'Onest', system-ui, sans-serif;
  --body: 'Onest', system-ui, -apple-system, sans-serif;
  --mono: 'Fragment Mono', ui-monospace, Menlo, monospace;
  --strip-h: 64px;
}
* { box-sizing: border-box; }
html { background: var(--field); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--field); color: var(--ink); font: 400 15px/1.5 var(--body);
  padding: 0 0 calc(var(--strip-h) + 22px + env(safe-area-inset-bottom)); overflow-x: hidden;
}
a { color: inherit; }
code { font-family: var(--mono); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- the sign row (identity, small, not a bar) ---------- */
.signrow { display: flex; align-items: center; gap: 10px; padding: 10px 16px 0; max-width: 1180px; margin: 0 auto; height: 46px; }
.signrow-name { display: flex; align-items: center; gap: 8px; text-decoration: none; font: 400 22px/1 var(--display); color: var(--neon); text-shadow: var(--glow); }
.signrow-name img { border-radius: 7px; display: block; }
.signrow-tag { font: 400 11px/1 var(--mono); color: var(--ink-mute); letter-spacing: .04em; display: none; }
.signrow-plug { margin-left: auto; border: 1px solid var(--tube); background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--ink); }
.signrow-plug[data-on="1"] { border-color: var(--neon); color: var(--neon); font-family: var(--mono); }

/* ---------- the tale: the last draw, told first ---------- */
.tale { max-width: 1180px; margin: 14px auto 0; padding: 0 16px; font: 400 18px/1.55 var(--body); color: var(--ink-soft); }
.tale b { color: var(--ink); font-weight: 700; }
.tale em { font-style: normal; color: var(--neon); text-shadow: var(--glow); font-family: var(--mono); }
.tale[data-mode="won"] { color: var(--ink); }

/* ---------- the deck of sheets ---------- */
.deck { max-width: 1180px; margin: 18px auto 0; padding: 0 16px; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.sheet {
  position: relative; background: var(--sheet); border-radius: 18px; padding: 14px 14px 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 6px 0 -1px var(--field-deep), 0 12px 0 -3px rgba(58,47,90,.55), 0 18px 28px rgba(20,12,40,.35);
  min-width: 0;
}
.sheet-tab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font: 400 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); margin-bottom: 12px; }
.sheet-tab--sub { margin-top: 18px; }

/* ---------- the box ---------- */
.crate-clock { text-transform: none; letter-spacing: 0; display: flex; gap: 6px; align-items: baseline; }
.crate-clock i { font-style: normal; color: var(--ink-mute); }
.crate-clock b { font: 400 24px/1 var(--display); color: var(--ink); }
.crate-clock[data-hot="1"] b { color: var(--neon); text-shadow: var(--glow); }
.crate { position: relative; border: 2px solid var(--tube); border-radius: 14px; padding: 26px 10px 12px; box-shadow: 0 0 10px rgba(183,156,255,.35), inset 0 0 14px rgba(183,156,255,.18); }
.crate-slot { position: absolute; left: 50%; top: -2px; width: 42%; transform: translateX(-50%); height: 12px; }
.crate-slot span { display: block; height: 4px; margin: 4px 0 0; border-radius: 4px; background: var(--neon); box-shadow: var(--glow); }
.crate-well { display: flex; flex-wrap: wrap; align-content: flex-end; gap: 6px; min-height: 132px; }
.stub {
  position: relative; width: 44px; height: 56px; border-radius: 6px; background: var(--sheet-hi); border: 1.5px solid var(--tube);
  display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(var(--tilt, 0deg));
}
.stub::before { content: ''; position: absolute; top: -1.5px; left: 50%; width: 12px; height: 7px; margin-left: -6px; background: var(--sheet); border: 1.5px solid var(--tube); border-top: 0; border-radius: 0 0 8px 8px; }
.stub b { font: 400 13px/1 var(--mono); color: var(--ink); }
.stub i { font: 400 9px/1.1 var(--body); font-style: normal; color: var(--ink-mute); text-align: center; margin-top: 3px; }
.stub--me { border-color: var(--neon); box-shadow: var(--glow); }
.stub--me::before { border-color: var(--neon); }
.stub--new { animation: fall .7s cubic-bezier(.2,.9,.3,1.2); }
.stub--more { border-style: dashed; }
.stub--ghost { width: 92px; border-style: dashed; border-color: var(--neon); background: var(--neon-soft); animation: beckon 1.8s ease-in-out infinite; }
.stub--ghost::before { border-color: var(--neon); border-style: dashed; border-top: 0; }
.stub--ghost b { color: var(--neon); text-shadow: var(--glow); }
@keyframes fall { from { transform: translateY(-80px) rotate(-14deg); opacity: 0; } to { transform: rotate(var(--tilt, 0deg)); opacity: 1; } }
@keyframes beckon { 0%, 100% { box-shadow: 0 0 0 rgba(255,79,216,0); } 50% { box-shadow: 0 0 16px rgba(255,79,216,.6); } }
.crate-meter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.crate-meter div { background: var(--field-deep); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.crate-meter span { display: block; font: 400 10px/1.2 var(--mono); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; }
.crate-meter b { display: block; font: 400 19px/1.2 var(--display); color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
.liveline { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.liveline b { color: var(--ink); }

/* ---------- the drawn ticket ---------- */
.pull { display: flex; gap: 14px; align-items: center; }
.pull-stub {
  flex: none; width: 104px; height: 128px; border-radius: 10px; border: 2px solid var(--neon); background: var(--neon-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--glow); transform: rotate(-4deg);
}
.pull-stub b { font: 400 34px/1 var(--display); color: var(--neon); text-shadow: var(--glow); }
.pull-stub span { font: 400 11px/1.2 var(--mono); color: var(--ink); text-align: center; padding: 0 6px; }
.pull[data-mode="none"] .pull-stub { border-style: dashed; box-shadow: none; transform: none; }
.pull[data-mode="sealed"] .pull-stub { animation: beckon 1.2s ease-in-out infinite; }
.pull-who { font-size: 14px; color: var(--ink-soft); min-width: 0; overflow-wrap: anywhere; }
.pull-who b { color: var(--ink); }
.pull-who code { font-size: 12px; color: var(--ink); }
.payers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }
.payer { font: 400 11px/1 var(--mono); padding: 6px 8px; border-radius: 999px; background: var(--field-deep); color: var(--ink-soft); }
.payer--ghost { border: 1px dashed var(--tube); background: transparent; }

/* ---------- the ticket form ---------- */
.ticketform-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper { display: flex; align-items: center; background: var(--field-deep); border-radius: 999px; padding: 4px; }
.stepper-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--sheet-hi); font-size: 22px; line-height: 1; }
.stepper-btn:active { background: var(--neon); color: var(--sheet); }
.stepper-n { min-width: 52px; text-align: center; font: 400 28px/1 var(--display); }
.ticketform-sum { text-align: right; }
.ticketform-sum span { display: block; font: 400 10px/1 var(--mono); text-transform: uppercase; color: var(--ink-mute); letter-spacing: .06em; }
.ticketform-sum b { font: 400 24px/1.2 var(--display); }
.dropbtn {
  display: block; width: 100%; margin-top: 14px; border: 2px solid var(--neon); background: var(--neon); color: #2A1238;
  border-radius: 14px; padding: 15px 16px; font: 700 17px/1 var(--body); box-shadow: var(--glow);
}
.dropbtn:disabled { background: transparent; color: var(--ink-mute); border-color: var(--tube); box-shadow: none; cursor: default; }
.ticketform-fine { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-mute); }
.fetchbtn { display: block; width: 100%; margin-top: 10px; border: 1px solid var(--tube); background: transparent; border-radius: 12px; padding: 11px; font-weight: 700; }

/* ---------- rulebook ---------- */
.book { margin: 0; padding: 0 0 0 0; list-style: none; display: grid; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.book b { color: var(--ink); }
.worked { margin-top: 14px; border-left: 3px solid var(--neon); padding: 4px 0 4px 12px; }
.worked-k { font: 400 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--neon); }
.worked p { margin: 6px 0 0; font-size: 14px; }

/* ---------- tape ---------- */
.tape, .past { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tape li { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--rule); font-size: 13px; align-items: baseline; }
.tape li.tape-quiet, .past li.tape-quiet { display: block; color: var(--ink-mute); border: 0; font-size: 13px; padding: 4px; }
.tape .tk { font: 400 10px/1.4 var(--mono); text-transform: uppercase; color: var(--tube); }
.tape li[data-k="drawn"] .tk { color: var(--neon); }
.tape .tt { min-width: 0; overflow-wrap: anywhere; }
.tape .tw { font: 400 11px/1.4 var(--mono); color: var(--ink-mute); }
.tape li.is-new { animation: print .9s ease-out; }
@keyframes print { from { background: var(--neon-soft); clip-path: inset(0 100% 0 0); } to { background: transparent; clip-path: inset(0 0 0 0); } }
.past li { padding: 8px 4px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.past .pt { display: flex; justify-content: space-between; gap: 8px; }
.past .pi { font: 400 11px/1.5 var(--mono); color: var(--ink-mute); overflow-wrap: anywhere; margin-top: 3px; }
.minebox { margin-top: 14px; font-size: 13px; display: grid; gap: 4px; overflow-wrap: anywhere; }

/* ---------- colophon ---------- */
.colophon { padding: 8px 2px 4px; font-size: 12px; color: var(--ink-mute); }
.colophon-row { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; min-width: 0; }
.colophon-row span { flex: none; width: 92px; text-transform: uppercase; font: 400 10px/1.4 var(--mono); letter-spacing: .06em; }
.colophon-row code { font-size: 11.5px; color: var(--ink-soft); overflow-wrap: anywhere; min-width: 0; }
.colophon-links { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0; }
.colophon-links a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.colophon-links a.is-off { display: none; }
.colophon-note { margin: 0; }

/* ---------- the CA dock (bottom edge, every width) ---------- */
.castrip {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; min-height: var(--strip-h);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "k gm" "ca copy"; align-items: center; column-gap: 10px; row-gap: 2px;
  padding: 8px 8px 8px 14px; border-radius: 16px; background: #241B3D; border: 1.5px solid var(--neon);
  box-shadow: 0 0 14px rgba(255,79,216,.35), 0 10px 30px rgba(10,6,24,.5);
}
.castrip-k { grid-area: k; font: 400 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--neon); }
.castrip-ca { grid-area: ca; font-size: 11.5px; line-height: 1.3; color: var(--ink); user-select: all; overflow-wrap: anywhere; min-width: 0; }
.castrip-ca.is-blank { color: var(--ink-mute); user-select: none; }
.castrip-copy { grid-area: copy; border: 0; background: var(--neon); color: #2A1238; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; }
.castrip-copy[data-done="1"] { background: var(--ink); }
.castrip-gm { grid-area: gm; justify-self: end; font: 400 10px/1 var(--mono); color: var(--ink-mute); text-decoration: none; }

.toasts { position: fixed; left: 50%; bottom: calc(var(--strip-h) + 30px); transform: translateX(-50%); z-index: 30; display: grid; gap: 6px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #2A1238; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

/* ---------- tablet: wider measure, bigger object ---------- */
@media (min-width: 720px) {
  body { font-size: 16px; }
  .signrow { padding: 14px 28px 0; }
  .signrow-tag { display: inline; }
  .tale { padding: 0 28px; font-size: 19px; max-width: 900px; margin-left: auto; margin-right: auto; }
  .deck { padding: 0 28px; max-width: 900px; gap: 22px; }
  .sheet { padding: 18px 20px 20px; }
  .stub { width: 52px; height: 66px; }
  .stub--ghost { width: 110px; }
  .crate-well { min-height: 170px; gap: 8px; }
  .pull-stub { width: 130px; height: 160px; }
  .pull-stub b { font-size: 44px; }
  .castrip { left: 50%; right: auto; transform: translateX(-50%); width: min(860px, calc(100vw - 40px)); grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "k ca copy gm"; padding: 8px 10px 8px 18px; }
  .castrip-ca { font-size: 14px; }
}

/* ---------- desktop: the deck recomposes into two columns ---------- */
@media (min-width: 1000px) {
  .signrow, .tale { max-width: 1180px; }
  .tale { font-size: 19px; padding: 0 32px; columns: 1; max-width: 1180px; }
  .deck {
    max-width: 1180px; padding: 0 32px; gap: 24px 28px;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-areas: "crate pull" "crate slip" "book tape" "foot tape";
    align-items: start;
  }
  .sheet--crate { grid-area: crate; }
  .sheet--pull { grid-area: pull; }
  .sheet--slip { grid-area: slip; }
  .sheet--book { grid-area: book; }
  .sheet--tape { grid-area: tape; position: sticky; top: 16px; }
  .colophon { grid-area: foot; }
  .stub { width: 58px; height: 74px; }
  .stub b { font-size: 15px; }
  .crate { padding: 34px 16px 16px; }
  .crate-well { min-height: 300px; gap: 10px; }
  .crate-meter b { font-size: 26px; }
  .crate-clock b { font-size: 32px; }
  .castrip { width: min(1116px, calc(100vw - 64px)); }
}
