/* Mobile-first. System fonts only, no images, and margins instead of flex
   `gap` so older iOS Safari lays things out the same. */

:root {
  --bg: #f7f3ec;
  --card: #fff;
  --ink: #1d1b26;
  --muted: #6b6779;
  --line: #e4ddd0;
  --chip: #eee8dd;
  --accent: #ff5a36;
  --accent-ink: #fff;
  --accent-soft: #ffe4dc;
  --ok: #1b7f45;
  --ok-soft: #dcf1e3;
  --bad: #c03a3a;
  --bad-soft: #f9e0e0;
  --star-soft: #fff1cc;
  --star-ink: #7d5400;
  --bar: #1d1b26;
  --bar-ink: #fff;
  --bar-h: 56px;
  --r: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121119;
    --card: #1c1b25;
    --ink: #efedf6;
    --muted: #a3a0b3;
    --line: #2e2c3a;
    --chip: #282633;
    --accent-soft: #3f241d;
    --ok: #55c487;
    --ok-soft: #173424;
    --bad: #f07a7a;
    --bad-soft: #3a1d20;
    --star-soft: #3a2f12;
    --star-ink: #ffd36b;
    --bar: #0b0a10;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 76px 0 32px;
  padding: calc(76px + env(safe-area-inset-top)) 0 calc(32px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

main, .ad-dock {
  display: block;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

h1, h2 { line-height: 1.2; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint { margin: 12px 0 0; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.h { font-size: 18px; margin: 28px 0 10px; }
.h0 { font-size: 26px; margin: 4px 0 12px; }

/* --- header ------------------------------------------------------------- */

#bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--bar);
  color: var(--bar-ink);
  padding-top: env(safe-area-inset-top);
}

.bar-in {
  display: flex;
  align-items: center;
  max-width: 560px;
  height: var(--bar-h);
  margin: 0 auto;
  padding: 0 16px;
}

.bar-l, .bar-r { flex: 0 0 auto; }
.bar-m {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 12px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .85;
}
.bar-r {
  min-width: 3.4em;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bar-r.timer { font-size: 30px; letter-spacing: .5px; }
.bar-r.low { color: #ff7d61; animation: blink 1s steps(2, start) infinite; }

@keyframes blink { to { opacity: .55; } }

.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand b { color: var(--accent); }

.code-chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  font-weight: 800;
  letter-spacing: 2px;
}

.tile {
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 40px;
  text-align: center;
}

.tbar { height: 4px; background: rgba(255, 255, 255, .12); visibility: hidden; }
.tbar.on { visibility: visible; }
.tfill {
  height: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transition: transform .2s linear;
}
.tbar.low .tfill { background: #ff3b3b; }

.net { padding: 4px; background: #b83232; color: #fff; font-size: 13px; text-align: center; }

/* --- basics ------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}

.btn {
  display: inline-block;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 44px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; }
.btn.big { min-height: 54px; font-size: 18px; line-height: 52px; }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn.big, .card + .btn, .board + .btn { margin-top: 20px; }

.link {
  display: block;
  margin: 18px auto 0;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

.field {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  -webkit-appearance: none;
  appearance: none;
}
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.av {
  display: inline-block;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 32px;
  text-align: center;
}
.av.sm { width: 20px; height: 20px; font-size: 11px; line-height: 20px; }

.chip {
  display: inline-flex;
  align-items: center;
  margin: 3px;
  padding: 4px 10px 4px 4px;
  border-radius: 99px;
  background: var(--chip);
  font-size: 13px;
}
.chip .av { margin-right: 6px; }
.chip b { margin-left: 4px; }
.chip.done { background: var(--ok-soft); }
.chip.off { opacity: .5; }

/* --- home --------------------------------------------------------------- */

.home { text-align: center; }
.home .card { text-align: left; }
.logo { margin: 12px 0 10px; font-size: 40px; line-height: 1.05; letter-spacing: -1px; }
.logo b { color: var(--accent); }
.tag { margin: 0 0 20px; color: var(--muted); }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.lbl { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.home .btn.big { margin-top: 12px; }
.or { margin: 18px 0 10px; color: var(--muted); font-size: 13px; text-align: center; }
.row { display: flex; }
.row .field { flex: 1 1 auto; min-width: 0; margin-right: 8px; }
.field.code { font-weight: 700; letter-spacing: 4px; text-align: center; text-transform: uppercase; }
.how { margin-top: 16px; text-align: left; }
.how summary { font-weight: 600; cursor: pointer; }
.how ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.how li + li { margin-top: 6px; }
.foot-links { margin: 24px 0 0; font-size: 13px; text-align: center; }
.foot-links a { color: var(--muted); }

/* --- text pages (privacy) ---------------------------------------------- */

a.brand { color: inherit; text-decoration: none; }
.doc { line-height: 1.6; }
.doc h1 { margin: 8px 0 2px; font-size: 30px; }
.doc h1 + .muted { margin-top: 0; }
.doc h2 { margin: 28px 0 8px; font-size: 19px; }
.doc ul { padding-left: 20px; }
.doc li + li { margin-top: 6px; }
.doc a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 2px; }

/* --- lobby -------------------------------------------------------------- */

.big-code { margin: 4px 0 12px; font-size: 48px; font-weight: 800; letter-spacing: 8px; }

.plist, .board, .elist, .alist { list-style: none; margin: 0; padding: 0; }
.plist, .board {
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.plist li, .board li { display: flex; align-items: center; min-height: 54px; padding: 10px 12px; }
.plist li + li, .board li + li { border-top: 1px solid var(--line); }
.plist li > * + *, .board li > * + * { margin-left: 10px; }
.plist li.off { opacity: .55; }

.pname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.mini {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.x {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 20px;
  line-height: 36px;
  cursor: pointer;
}

.set + .set { margin-top: 14px; }
.host-note { margin: 0 0 14px; }
.set.flash .seg { animation: flash 1.6s ease-out; }
@keyframes flash {
  from { box-shadow: 0 0 0 3px var(--accent); }
  to { box-shadow: 0 0 0 3px transparent; }
}
.set-l { margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.seg { display: flex; padding: 3px; border-radius: 10px; background: var(--chip); }
.seg button {
  flex: 1 1 0;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.seg button + button { margin-left: 3px; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.seg button[disabled] { color: var(--muted); cursor: default; }
.seg button.on[disabled] { color: var(--ink); }

/* --- round -------------------------------------------------------------- */

.alist li {
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.alist li + li { margin-top: 10px; }
.alist label { display: flex; align-items: center; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}
.ans { scroll-margin-top: 110px; }
.ans:disabled { opacity: .6; -webkit-text-fill-color: var(--ink); }

.prog, .live { margin-top: 14px; text-align: center; }
.live { margin-top: 6px; }
.review .hint { margin-bottom: 18px; }

.cd {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bar);
  color: #fff;
}
.cd-in { text-align: center; }
.cd-l {
  width: 150px;
  height: 150px;
  margin: 0 auto;
  border-radius: 32px;
  background: var(--accent);
  font-size: 100px;
  font-weight: 800;
  line-height: 150px;
}
.cd-n { margin-top: 22px; font-size: 22px; opacity: .85; }

/* --- review ------------------------------------------------------------- */

.cat { margin: 4px 0 14px; font-size: 26px; }

.entry {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.entry + .entry { margin-top: 8px; }
.entry.blank { opacity: .6; }
.entry.bad .e-ans { color: var(--muted); text-decoration: line-through; }
/* Answers you still need to vote on get an accent edge. */
.entry.todo { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.e-top { display: flex; align-items: center; }
.e-main { flex: 1 1 auto; min-width: 0; margin: 0 10px; }
.e-who { color: var(--muted); font-size: 12px; }
.e-ans { font-size: 18px; font-weight: 600; word-wrap: break-word; overflow-wrap: break-word; }

.pill {
  flex: 0 0 auto;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.blank { background: var(--chip); color: var(--muted); }

/* Vote buttons sit on their own row: ask bot, star, thumbs down, thumbs up. */
.votes { display: flex; margin-top: 8px; }
.vote {
  flex: 1 1 0;
  min-width: 0;
  max-width: 96px;
  height: 40px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 38px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.vote + .vote { margin-left: 6px; }
.vote.on { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.vote.yes.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.vote.star.on { background: var(--star-soft); border-color: #e0a200; color: var(--star-ink); }
.vote.ro { border-style: dashed; cursor: default; }
.vote.bot { flex: 2 1 0; max-width: 192px; font-size: 14px; }
.vote.wait { color: var(--muted); cursor: default; }
.vote.verdict {
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  cursor: default;
}
.vote.verdict small { font-size: 10px; font-weight: 600; opacity: .8; }
.vote.verdict.yes2 { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.vote.verdict.yes1 { border-color: var(--ok); color: var(--ok); }
.vote.verdict.mid { color: var(--muted); }
.vote.verdict.no1 { border-color: var(--bad); color: var(--bad); }
.vote.verdict.no2 { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.vote.zero { opacity: .45; }

.rv-foot {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  padding: 10px 0 12px;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.rv-foot > p { margin: 0 0 8px; }
.rv-foot > p:last-child { margin-bottom: 0; }
.waiting { font-size: 14px; font-weight: 600; text-align: center; }
.waiting.done { color: var(--ok); }
.navrow { display: flex; }
.picker { margin-top: 16px; }
.picker .pick { margin-top: 8px; text-align: left; }
.picker .pick .av { margin-right: 6px; vertical-align: middle; }

/* End-game vote, shown in the header so it's visible on every screen. */
.endpill {
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.endpill.on { background: #b83232; border-color: #b83232; }
.navrow .btn + .btn { margin-left: 8px; }
.navrow .grow { flex: 1 1 auto; }

/* --- results ------------------------------------------------------------ */

.board li.me { background: var(--accent-soft); }
.rank { width: 20px; color: var(--muted); font-weight: 800; text-align: center; }
.delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.plus { min-width: 30px; color: var(--ok); font-size: 13px; font-weight: 700; text-align: right; }
.meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.total { min-width: 34px; font-size: 20px; font-variant-numeric: tabular-nums; text-align: right; }

.award {
  display: flex;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.award + .award { margin-top: 8px; }
.a-ic { flex: 0 0 auto; margin-right: 12px; font-size: 26px; line-height: 1.1; }
.a-t { font-weight: 700; }
.a-x { color: var(--muted); font-size: 14px; }

.winner .trophy { font-size: 56px; line-height: 1.1; }
.w-name { margin: 4px 0; font-size: 30px; font-weight: 800; word-wrap: break-word; }

/* --- ads ---------------------------------------------------------------- */

.ad-dock { margin-top: 28px; }
/* The review slot runs full-bleed, so responsive ads can use the whole width
   of the phone, and it keeps clear space above and below. */
.ad-inline { margin: 24px -16px 20px; text-align: center; }
.ad-inline .ad-house { margin: 0 16px; }
.ad-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
}
/* Google marks a unit "unfilled" when it has no ad; don't leave a gap. */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-ph {
  height: 100px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 96px;
  text-align: center;
}
.ad-ph.lg { max-width: 300px; height: 250px; margin: 0 auto; line-height: 246px; }
.ad-house {
  display: block;
  min-height: 100px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}
.ad-house b { display: block; font-size: 16px; }
.ad-house span { display: block; color: var(--muted); font-size: 14px; }
.ad-house .ad-tag { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.ad-house .ad-cta { margin-top: 4px; color: var(--accent); font-weight: 600; }

/* --- toast -------------------------------------------------------------- */

/* Toasts drop in under the header, clear of the sticky buttons at the bottom. */
.toast {
  position: fixed;
  left: 50%;
  top: 68px;
  top: calc(68px + env(safe-area-inset-top));
  z-index: 40;
  max-width: 90%;
  padding: 10px 16px;
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
