:root {
  --bg: #fbf6ee;
  --card: #ffffff;
  --ink: #2b2620;
  --muted: #7a6f63;
  --line: #eadfce;
  --you: #e8664a;        /* coral: you */
  --you-soft: #fde6df;
  --pal: #2a9d8f;        /* teal: your partner */
  --pal-soft: #dcf1ee;
  --good: #2f9e44;
  --good-soft: #e3f6e6;
  --gold: #d29b0c;       /* the correct answer (not a player color) */
  --gold-soft: #fdf1cc;
  --gold-ink: #9a6b00;
  --bad: #d64545;
  --bad-soft: #fbe4e4;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(43, 38, 32, .06), 0 8px 24px rgba(43, 38, 32, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1915; --card: #26221d; --ink: #f3ece2; --muted: #a99d8f; --line: #3a342c;
    --you-soft: #4a2a22; --pal-soft: #1c3b37; --good-soft: #1f3a24; --bad-soft: #452222;
    --gold: #e0b030; --gold-soft: #3a2f10; --gold-ink: #f0c24b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; }
.wrap.wide { max-width: 900px; }

.brand { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; }
.brand .dots { display: flex; }
.brand .dots span { width: 22px; height: 22px; border-radius: 50%; display: block; }
.brand .dots span:first-child { background: var(--you); }
.brand .dots span:last-child { background: var(--pal); margin-left: -8px; mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .brand .dots span:last-child { mix-blend-mode: screen; } }
.brand b { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }

h1 { font-size: 30px; line-height: 1.15; margin: 0 0 8px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 10px; font-weight: 800; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=email], input[type=password] {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
input:focus { outline: none; border-color: var(--pal); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; color: var(--muted); }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }

button, .btn {
  font: inherit; font-weight: 800; border: 0; cursor: pointer;
  border-radius: 999px; padding: 14px 22px; background: var(--you); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .06s ease, opacity .15s;
}
a.btn { text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary, a.btn.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
button.block { width: 100%; margin-top: 18px; }
.err { color: var(--bad); font-weight: 700; margin-top: 12px; min-height: 1.5em; }
.ok { color: var(--good); font-weight: 700; }

/* ---------- play ---------- */
.status { text-align: center; padding: 36px 20px; }
.status .big { font-size: 46px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pulse { width: 64px; height: 64px; margin: 0 auto 16px; position: relative; }
.pulse span { position: absolute; inset: 0; border-radius: 50%; }
.pulse span:first-child { background: var(--you); animation: orbit 1.6s ease-in-out infinite; }
.pulse span:last-child { background: var(--pal); animation: orbit 1.6s ease-in-out infinite reverse; opacity: .85; }
@keyframes orbit {
  0%, 100% { transform: translateX(-14px) scale(.7); }
  50% { transform: translateX(14px) scale(.7); }
}

.game { display: grid; gap: 16px; }
@media (min-width: 820px) { .game { grid-template-columns: 1fr 320px; align-items: start; } }

.topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; font-weight: 700; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.timer { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 18px; }
.timer i { display: block; height: 100%; background: var(--pal); width: 100%; transition: width .2s linear; }
.timer.low i { background: var(--you); }
.question { font-size: 22px; font-weight: 800; line-height: 1.3; margin-bottom: 18px; }
.choices { display: grid; gap: 10px; }
.choice {
  text-align: left; justify-content: flex-start; border-radius: 14px; padding: 14px 16px;
  background: var(--bg); color: var(--ink); border: 2px solid var(--line); font-weight: 700; width: 100%;
  position: relative;
}
.choice { flex-wrap: wrap; row-gap: 6px; }
.badges { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.who { white-space: nowrap; }
.who { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; }
.who.me { background: var(--you); }
.who.them { background: var(--pal); }
.who.team { background: var(--ink); color: var(--bg); }
.choice.byme { border-color: var(--you); background: var(--you-soft); }
.choice.bythem { border-color: var(--pal); background: var(--pal-soft); }
.choice.byme.bythem { border-color: var(--pal); background: linear-gradient(90deg, var(--you-soft), var(--pal-soft)); }
.choice.agreed { animation: agree 1s ease-in-out infinite; }
@keyframes agree { 50% { box-shadow: 0 0 0 4px var(--pal-soft); } }
/* Reveal: the correct answer is gold (never a player's color). */
.choice.right { border-color: var(--gold); border-width: 3px; background: var(--gold-soft); }
/* One gentle pop when the correct answer is revealed (not a continuous pulse). */
.choice.pop { animation: pop .45s ease-out 1; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.04); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .choice.pop { animation: none; } }
.who.correct { background: var(--gold); color: #fff; }
.choice:disabled { opacity: 1; cursor: default; }
.choices.closed .choice { pointer-events: none; opacity: .75; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--muted); }
.badgelist { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 14px; font-weight: 700; }
.badge.new { border-color: var(--pal); background: var(--pal-soft); }
.badge i, .newtag { font-style: normal; font-size: 11px; font-weight: 800; color: var(--you); text-transform: uppercase; }
.news { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.news li { display: flex; gap: 10px; align-items: flex-start; }
.newsemoji { font-size: 20px; line-height: 1.2; flex: none; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); font-weight: 700; padding: 12px 18px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.lockin { margin-top: 14px; text-align: center; font-weight: 800; padding: 10px; border-radius: 12px; background: var(--pal-soft); }
.lockin .muted { font-weight: 400; font-size: 14px; }
.readybar { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.readybar .small { line-height: 1.4; }
.how { text-align: left; max-width: 420px; margin: 8px auto 0; padding-left: 20px; color: var(--muted); font-size: 15px; }
.how li { margin-bottom: 4px; }
.verdict { margin-top: 14px; font-weight: 800; text-align: center; }

.chat { display: flex; flex-direction: column; height: 340px; padding: 0; overflow: hidden; }
.chat h2 { padding: 16px 16px 0; margin-bottom: 6px; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 8px; }
button.iconbtn { background: none; border: none; box-shadow: none; padding: 4px 6px; min-height: 0; font-size: 20px; line-height: 1; }
.chathead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chathead h2 { min-width: 0; }
button.linkbtn { background: none; border: none; box-shadow: none; color: var(--muted); font-size: 13px; font-weight: 700;
  text-decoration: underline; padding: 16px 16px 0; min-height: 0; flex: none; }
.notice { background: var(--bad-soft); border-radius: 12px; padding: 12px 14px; font-weight: 700; margin-bottom: 14px; }
.msgs { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--pal-soft); align-self: flex-start; word-wrap: break-word; }
.msg.mine { background: var(--you-soft); align-self: flex-end; }
.msg small { display: block; font-size: 11px; font-weight: 800; color: var(--muted); }
.msg.sending { opacity: .6; }
.msg.typing { padding: 8px 14px 10px; }
.dots3 { display: inline-flex; gap: 4px; }
.dots3 i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.dots3 i:nth-child(2) { animation-delay: .15s; }
.dots3 i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .dots3 i { animation: none; opacity: .6; } }
.chatbar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chatbar input { padding: 10px 12px; }
.chatbar button { padding: 10px 16px; }

.board { width: 100%; border-collapse: collapse; }
.board td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
.board td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.board tr.mine td { color: var(--you); font-weight: 800; }

/* ---------- admin ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list td, table.list th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
@media (min-width: 820px) { .chat { height: 460px; } }

.invited { background: var(--pal-soft); color: var(--ink); font-weight: 800; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; }
.invited.bad { background: var(--bad-soft); }
.invitecard { display: flex; flex-direction: column; gap: 10px; }
.invitecard .linkrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invitecard input { flex: 1; min-width: 200px; font-size: 14px; }
.invitecard button { padding: 10px 16px; }
.tree, .tree ul { list-style: none; padding-left: 18px; margin: 4px 0; }
.tree > li { padding-left: 0; }
.tree li { position: relative; margin: 4px 0; }
.tree ul li::before { content: "└"; position: absolute; left: -16px; color: var(--muted); }
