:root {
  --bg: #0d0b1a;
  --panel: #18142e;
  --panel2: #221c40;
  --well: #0a0816;
  --edge: #3a3166;
  --edge-hi: #4b4180;
  --ink: #f4f1ff;
  --dim: #a19bbf;
  --gold: #ffd23f;
  --gold-dk: #8a6d00;
  --ok: #3ee07a;
  --ok-bg: #16351f;
  --bad: #ff5c7a;
  --hatch-a: #3a3358;
  --hatch-b: #2a2442;
  --hatch: repeating-linear-gradient(45deg, var(--hatch-a) 0 3px, var(--hatch-b) 3px 6px);
  --px: 'Silkscreen', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 16px;
  background: var(--bg) radial-gradient(#ffffff12 1px, transparent 1px) 0 0 / 6px 6px;
  color: var(--ink);
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 22px;
  line-height: 1.4;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- frame ---------- */
.phone {
  width: 100%;
  max-width: 420px;
  min-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  padding: 18px 16px 22px;
  background: var(--panel);
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000, inset 0 0 0 3px var(--edge);
}

.top { margin-bottom: 20px; }
.party-title {
  margin: 0 0 12px;
  font-family: var(--px);
  font-size: 14px;
  line-height: 1.6;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
}

.stepper { display: flex; gap: 6px; }
.stepper span { flex: 1; height: 12px; background: #2e2752; border: 2px solid #000; }
.stepper span.on { background: var(--gold); }
.stepper span.done { background: var(--ok); }

.screen, .grow { flex: 1; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

.title {
  margin: 0 0 14px;
  font-family: var(--px);
  font-size: 21px;
  font-weight: normal;
  line-height: 1.4;
  text-shadow: 2px 2px 0 #000;
}
.title:focus { outline: none; }

.hint { margin: 0 0 14px; color: var(--dim); font-size: 20px; }

.loading {
  margin: auto;
  font-family: var(--px);
  font-size: 16px;
  color: var(--dim);
  text-align: center;
}

.sprite { margin: 4px 0 10px; font-size: 48px; text-align: center; }

/* ---------- controls ---------- */
#nome {
  width: 100%;
  margin: 4px 0 14px;
  padding: 14px 12px;
  background: var(--well);
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: inset 0 0 0 2px var(--edge-hi);
  font-family: var(--px);
  font-size: 20px; /* 16px+ keeps iOS from zooming */
  caret-color: var(--gold);
  outline: none;
}
#nome:focus { box-shadow: inset 0 0 0 2px var(--gold); }

.btn {
  width: 100%;
  margin-top: auto;
  margin-bottom: 5px;
  padding: 16px 10px;
  background: var(--gold);
  color: #1a1400;
  border: 3px solid #000;
  border-radius: 0;
  box-shadow: 0 5px 0 var(--gold-dk), 0 5px 0 3px #000;
  font-family: var(--px);
  font-size: 18px; font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-dk), 0 1px 0 3px #000; }
.btn:disabled { background: #4a4466; color: #9c96b6; box-shadow: 0 5px 0 #2b2640, 0 5px 0 3px #000; cursor: not-allowed; }

.link {
  display: block;
  margin: 6px auto 14px;
  padding: 8px;
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 20px;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  cursor: pointer;
}
.link:hover { color: var(--ink); }
.link[hidden] { display: none; }

.btn:focus-visible, .link:focus-visible, .tile:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* ---------- dates ---------- */
.tiles { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: var(--panel2);
  color: var(--ink);
  border: 3px solid #000;
  border-radius: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tile .box {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: var(--well);
  border: 3px solid #000;
  color: #000;
  font-family: var(--px);
  font-size: 14px;
}
.tile .d { flex: 1; line-height: 1.2; }
.tile .d small { display: block; color: var(--dim); font-size: 18px; }
.tile .count { color: var(--gold); }
.tile .count.zero { color: var(--dim); }
.tile .tag { font-family: var(--px); font-size: 13px; color: var(--dim); }
.tile[aria-pressed="true"] { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
.tile[aria-pressed="true"] .box { background: var(--ok); }
.tile[aria-pressed="true"] .tag { color: var(--ok); }

/* ---------- results ---------- */
.mine {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--well);
  border: 3px solid #000;
  box-shadow: inset 0 0 0 2px var(--edge-hi);
}
.mine[hidden] { display: none; }
.mine .big { flex: none; width: 46px; height: 46px; border: 3px solid #000; }
.mine-name { display: block; font-family: var(--px); font-size: 16px; line-height: 1.6; }
.mine small { display: block; color: var(--dim); font-size: 18px; }

.night { margin-bottom: 10px; padding: 10px 12px; background: var(--panel2); border: 3px solid #000; }
.night h2 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  font-family: var(--px);
  font-size: 15px;
  font-weight: normal;
  line-height: 1.5;
}
.night h2 em { font-style: normal; color: var(--ok); white-space: nowrap; }
.who { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; }
.who li { display: inline-flex; align-items: center; gap: 6px; }
.who .me { color: var(--gold); }
.q { flex: none; width: 14px; height: 14px; border: 2px solid #000; background: var(--hatch); }
.empty { margin: 0; color: var(--dim); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 14px;
  transform: translateX(-50%);
  background: var(--bad);
  color: #1a0006;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  font-size: 20px;
}
.toast[hidden] { display: none; }

/* ---------- color wheel ---------- */
.center { text-align: center; }
.legend { display: flex; justify-content: center; gap: 18px; margin: 0 0 8px; color: var(--dim); font-size: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.wheel { position: relative; width: min(290px, 100%); aspect-ratio: 1; margin: 0 auto 12px; }
.wheel svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wheel path { cursor: pointer; outline: none; }
.wheel path.taken { cursor: not-allowed; }
.wheel path:focus-visible { stroke: var(--gold); stroke-width: 5; }

.hub {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-content: center;
  width: 40%;
  aspect-ratio: 1;
  padding: 6px;
  transform: translate(-50%, -50%);
  background: var(--well);
  border: 4px solid #000;
  border-radius: 50%;
  text-align: center;
  pointer-events: none;
}
.hub-swatch { width: 26px; height: 26px; margin: 0 auto 4px; background: var(--hatch); border: 3px solid #000; }
.hub-name { font-family: var(--px); font-size: 13px; font-weight: 700; line-height: 1.2; }
.hub-tag { font-family: var(--px); font-size: 11px; color: var(--bad); }

/* ---------- too slow ---------- */
.slow {
  margin: auto 0;
  padding: 22px 14px;
  background: var(--bad);
  color: #1a0006;
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  text-align: center;
}
.slow-title { margin-bottom: 10px; font-size: 26px; font-weight: 700; text-shadow: none; }
.slow p { margin: 0; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .screen.enter { animation: pop .5s steps(5) both; }
  .sprite { animation: bob 1.2s steps(2) infinite; }
  .loading { animation: blink 1s steps(1) infinite; }
  .wheel path { transition: transform .2s steps(3); }
  .enter .slow { animation: shake .12s steps(2) 8 alternate; }
}
@keyframes shake { from { transform: translateX(-4px); } to { transform: translateX(4px); } }
@keyframes pop { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes blink { 50% { opacity: 0; } }
