:root {
  --bg: #f6f5f1;
  --fg: #1f1f1f;
  --muted: #6b6b6b;
  --card: #ffffff;
  --line: #dddad2;
  --a: #2f7d4f;
  --a-hover: #276a43;
  --b: #b4423a;
  --err: #b4423a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --fg: #ececec;
    --muted: #a0a0a0;
    --card: #222226;
    --line: #38383e;
    --a: #47a56d;
    --a-hover: #3c8f5e;
    --b: #d25a51;
    --err: #ef7a71;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  line-height: 1.6;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 16px;
  text-align: center;
}
.lead { color: var(--muted); margin: 0 0 8px; }
h1 { font-size: clamp(1.3rem, 4.5vw, 1.8rem); margin: 0 0 24px; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; }

.arena {
  position: relative;
  height: 300px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
  touch-action: manipulation;
}
.vote-btn {
  --scale: 1;
  position: absolute;
  width: 96px;
  height: 96px;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 2.4rem;
  font-weight: 700;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(var(--scale));
  transition: left .18s ease-out, top .18s ease-out, transform .25s;
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  user-select: none;
}
.vote-btn:active { box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.vote-btn.a { background: var(--a); z-index: 1; }
.vote-btn.a:hover { background: var(--a-hover); }
.vote-btn.b { background: var(--b); z-index: 2; }
.vote-btn.b.tired { animation: pant 1.2s ease-in-out infinite; }
@keyframes pant {
  50% { transform: translate(-50%, -50%) scale(calc(var(--scale) * 0.92)) rotate(-6deg); }
}
.taunt { min-height: 1.6em; color: var(--muted); margin-top: 16px; }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
}
.modal[hidden] { display: none; }
.dialog {
  background: var(--card);
  border-radius: 14px;
  padding: 24px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.q { font-size: 1.05rem; margin: 0 0 16px; }
.choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.sub-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 1rem;
  cursor: pointer;
}
.sub-btn:hover { border-color: var(--muted); }
.sub-btn.primary { background: var(--a); border-color: var(--a); color: #fff; }
.sub-btn.primary:hover { background: var(--a-hover); }
.err { color: var(--err); min-height: 1.4em; margin: 8px 0 0; }

.progress { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.pfill { height: 100%; width: 0; background: var(--b); }
.ptext { font-variant-numeric: tabular-nums; margin: 6px 0 0; color: var(--muted); }

.captcha { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile {
  aspect-ratio: 1;
  border: 3px solid transparent;
  border-radius: 6px;
  background: var(--bg);
  font-size: 2.2rem;
  font-weight: 700;
  cursor: pointer;
}
.tile.on { border-color: #3b82f6; }
.tile .tiny { font-size: .55rem; opacity: .7; }

/* results */
.thanks { font-size: 1.15rem; font-weight: 600; min-height: 1.6em; }
.bars { display: grid; gap: 10px; text-align: left; }
.bar-row { display: grid; grid-template-columns: 1.5em 1fr auto; gap: 10px; align-items: center; }
.label { font-weight: 700; }
.bar { height: 22px; background: var(--line); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: 0; transition: width .8s ease-out; }
.fill.a { background: var(--a); }
.fill.b { background: var(--b); }
.count { font-variant-numeric: tabular-nums; min-width: 8em; text-align: right; }
.stats { display: grid; gap: 8px; margin: 24px 0; }
.stats div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 6px 0; text-align: left; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: .85rem; }
.credit { margin-top: 40px; color: var(--muted); font-size: .75rem; opacity: .8; }
.credit a { color: inherit; }
.credit a:hover { color: var(--fg); }
@media (max-width: 480px) {
  main { padding: 28px 16px; }
  .arena { height: 340px; }
  .vote-btn { width: 80px; height: 80px; font-size: 2rem; }
}
