:root {
  --bg: #f6f5fa;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #5d6b63;
  --line: #c9cfc7;
  --line-strong: #2b3a32;
  --accent: #5b3fa8;
  --accent-soft: #e8e1f7;
  --same: #c6e0d1;
  --peer: #eef3ee;
  --given: #1f2a24;
  --entered: #2a5db0;
  --error: #c0392b;
  --error-soft: #f8dcd8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a17;
    --surface: #1c2420;
    --ink: #e6ece8;
    --muted: #9fb0a6;
    --line: #3a4740;
    --line-strong: #a9bbb0;
    --accent: #b39cf0;
    --accent-soft: #2e2545;
    --same: #2d4a3a;
    --peer: #1f2a25;
    --given: #e6ece8;
    --entered: #8fb6ff;
    --error: #ff7a6b;
    --error-soft: #4a2420;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0 4px; }
h2 { font-size: 1.25rem; margin: 28px 0 8px; }
h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.lede { color: var(--muted); margin-top: 0; }
.prose { max-width: 680px; }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; border-top: 1px solid var(--line); margin-top: 40px; }
.site-footer p { margin: 4px 0; }
.ai-note { font-style: italic; }
.ad { margin: 24px 0; min-height: 100px; }
.ad-label { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 16px 0; }
.links-grid a { display: block; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); }
.links-grid a strong { display: block; color: var(--accent); }
.links-grid a span { font-size: .85rem; color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Tools ---- */
.tool { display: grid; gap: 20px; margin: 12px 0 8px; }
@media (min-width: 760px) { .tool[data-tool="wheel"] { grid-template-columns: 1.2fr 1fr; align-items: start; } main.wide, body.wide main { max-width: 1000px; } }
body.wide main { max-width: 1000px; }
.wheel-wrap { display: grid; justify-items: center; gap: 12px; }
.wheel-stage { position: relative; width: min(92vw, 480px); aspect-ratio: 1; }
.wheel-stage canvas { width: 100%; height: 100%; cursor: pointer; border-radius: 50%; box-shadow: 0 6px 24px rgba(0,0,0,.15); }
.pointer { position: absolute; top: -10px; left: 50%; width: 0; height: 0; transform: translateX(-50%); transform-origin: 50% 0;
  border-left: 20px solid transparent; border-right: 20px solid transparent; border-top: 40px solid #e0663a;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); z-index: 2; }
.pointer.tick { animation: tick .12s ease-out; }
@keyframes tick { 0% { transform: translateX(-50%) rotate(0); } 40% { transform: translateX(-50%) rotate(-18deg); } 100% { transform: translateX(-50%) rotate(0); } }
.spin-btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 16%; aspect-ratio: 1; border-radius: 50%;
  border: 0; background: radial-gradient(circle at 35% 30%, #ff9a5c, #e0663a 60%, #b8441f); color: #fff;
  font: 900 clamp(.8rem, 2.6vw, 1.15rem) system-ui, sans-serif; letter-spacing: .04em; cursor: pointer;
  box-shadow: 0 4px 14px rgba(224,102,58,.55); animation: pulse 1.6s ease-in-out infinite; }
.spin-btn:disabled { animation: none; opacity: .85; cursor: default; }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.08); } }
.sound-btn { position: absolute; right: 0; bottom: 0; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); font-size: 1.1rem; cursor: pointer; }
.wheel-stage canvas { transition: filter .3s; }
.is-spinning .wheel-stage canvas { filter: saturate(1.25); }
.win-modal { position: fixed; inset: 0; background: rgba(20,12,40,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.win-modal[hidden] { display: none; }
.win-card { background: var(--surface); border-radius: 18px; padding: 26px 28px; text-align: center; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-kicker { margin: 0; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
.win-name { margin: 8px 0 18px; font-size: clamp(1.8rem, 7vw, 2.8rem); font-weight: 900; color: var(--accent); line-height: 1.15; word-break: break-word; }
.win-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.result { min-height: 2.4em; text-align: center; font-size: 1.1rem; }
.result.big { font-size: 1.3rem; }
.winner { display: inline-block; padding: 6px 14px; margin: 3px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; font-size: 1.25rem; }
.editor { display: grid; gap: 10px; }
.editor textarea { width: 100%; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); resize: vertical; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.editor-actions input[type=number], .editor-actions select { font: inherit; width: 5em; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.editor-actions select { width: auto; }
.check-row { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.count { color: var(--muted); font-weight: 400; }
.history { color: var(--muted); font-size: .9rem; margin: 0; padding-left: 1.4em; }
.history:empty { display: none; }
.teams-out { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.team { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface); }
.team h3 { margin: 0 0 4px; color: var(--accent); }
.team ul { margin: 0; padding-left: 1.2em; }
.draw-out h3 { margin: 12px 0 4px; }
.draw-meta { color: var(--muted); font-size: .85rem; }
.wheel-options { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .9rem; color: var(--muted); }
.wheel-options select { font: inherit; margin-left: 4px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
