:root {
  --bg: #eeeaf5;
  --surface: #fbfaff;
  --fg: #1f1533;
  --muted: #655a7d;
  --line: #cfc7e0;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --plum: #4b2a78;
  --good: #1f7a4d;
  --bad: #b3261e;
  --glow: rgba(217, 72, 15, 0.16);
  --shadow: 0 1px 0 rgba(31, 21, 51, 0.04), 0 10px 30px -12px rgba(75, 42, 120, 0.28);
  --font-display: "Shrikhand", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #150f20;
    --surface: #211833;
    --fg: #f2ecfb;
    --muted: #b0a4c9;
    --line: #3c2f57;
    --accent: #ff8a3d;
    --accent-ink: #1a0f08;
    --plum: #c9a8ff;
    --good: #5fd49a;
    --bad: #ff8a80;
    --glow: rgba(255, 138, 61, 0.14);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 50% -120px, var(--glow), transparent 70%),
    radial-gradient(600px 360px at 100% 100%, rgba(75, 42, 120, 0.10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding: 36px max(16px, env(safe-area-inset-right)) 64px max(16px, env(safe-area-inset-left));
}
.wrap { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }

header { display: flex; flex-direction: column; gap: 10px; }
h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 11vw, 60px);
  line-height: 1.02;
  margin: 0;
  color: var(--accent);
  text-wrap: balance;
  text-shadow: 0 3px 0 rgba(75, 42, 120, 0.18);
}
.lede { margin: 0; color: var(--muted); max-width: 48ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.closed { margin: 0; font-weight: 700; }
form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label { font-weight: 700; font-size: 14px; }
.hint { font-weight: 400; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
}
input[type="text"]::placeholder { color: var(--muted); opacity: 0.8; }
input:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

button { font: inherit; cursor: pointer; }
button.primary {
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 10px;
  min-height: 50px;
  padding: 0 22px;
  box-shadow: 0 6px 18px -8px var(--accent);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.status { min-height: 1.5em; font-size: 14px; margin: 0; color: var(--muted); }
.ok { color: var(--good); font-weight: 700; }
.err { color: var(--bad); font-weight: 700; }

.ballot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; margin: 0; color: var(--plum); }
.count { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.vote-note { margin: 6px 0 12px; font-size: 14px; color: var(--muted); min-height: 1.5em; }

ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ticket {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ticket.mine { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-right: 2px dashed var(--line);
  color: var(--plum);
}
.stub small { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stub b { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.body { padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.costume { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.who { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 12px 10px 0; }
.votes { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.vote {
  font-weight: 700;
  font-size: 14px;
  min-height: 40px;
  min-width: 72px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
}
.ticket.mine .vote { background: var(--accent); color: var(--accent-ink); }
.empty {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 420px) {
  .ticket { grid-template-columns: 62px minmax(0, 1fr) auto; }
  .stub b { font-size: 26px; }
  .vote { min-width: 64px; padding: 0 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ticket.fresh { animation: pop 0.45s ease-out; }
  @keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Admin page */
.admin-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-row input { flex: 1 1 200px; }
.toggle { font-weight: 700; border: 1.5px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 10px; min-height: 44px; padding: 0 14px; }
.rm { font-size: 13px; color: var(--bad); background: transparent; border: 1px solid var(--bad); border-radius: 8px; padding: 6px 10px; }
.rm.arm { background: var(--bad); color: #fff; }
