:root {
  --bg: #14362b;
  --card: #fffaf0;
  --ink: #22302a;
  --soft: #66746d;
  --line: #e3dccb;
  --red: #b3262e;
  --red-dark: #8e1b22;
  --gold: #e9b949;
  --ok: #1e7a4c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg) radial-gradient(circle at 50% -10%, #28604c, transparent 60%);
  color: var(--ink);
  font: 17px/1.6 "Noto Sans Thai", "Sarabun", "Leelawadee UI", Thonburi, system-ui, sans-serif;
}
main { max-width: 460px; margin: 0 auto; padding: 28px 16px 48px; }
main.wide { max-width: 860px; }
header { text-align: center; color: var(--card); margin-bottom: 20px; }
h1 { margin: 0; font-size: 30px; line-height: 1.3; }
header p { margin: 4px 0 0; color: var(--gold); }
h2 { margin: 0 0 8px; font-size: 21px; line-height: 1.4; }
.card { background: var(--card); border-radius: 18px; padding: 22px; margin-bottom: 14px; box-shadow: 0 8px 24px #0003; }
.note { color: var(--soft); margin: 0 0 14px; }
.warn { background: #fbe9c6; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
.error { color: var(--red); margin: 10px 0 0; min-height: 1.6em; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select {
  width: 100%; padding: 12px 14px; font: inherit; color: inherit; background: #fff;
  border: 1.5px solid var(--line); border-radius: 12px;
}
button {
  width: 100%; margin-top: 16px; padding: 13px 18px; font: inherit; font-weight: 700;
  color: #fff; background: var(--red); border: 0; border-radius: 12px; cursor: pointer;
}
button:hover { background: var(--red-dark); }
button:disabled { opacity: .5; cursor: default; }
a.button { display: block; text-align: center; text-decoration: none; padding: 13px 18px; font-weight: 700; color: #fff; background: var(--red); border-radius: 12px; }
a.button:hover { background: var(--red-dark); }
button.plain { background: none; color: var(--soft); font-weight: 500; text-decoration: underline; }
button.small { width: auto; margin: 0; padding: 6px 12px; font-size: 15px; background: #fff; color: var(--ink); border: 1.5px solid var(--line); font-weight: 500; }
button.small:hover { background: #f3ecdc; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Player */
.center { text-align: center; }
.big { margin: 0 0 8px; font-size: 32px; font-weight: 800; line-height: 1.3; color: var(--red); }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--soft); }
nav { text-align: center; }
nav a { color: var(--gold); }
nav button.plain { color: var(--card); margin-top: 6px; }
nav button.plain:hover { background: none; }

/* Wheel */
.wheel { display: block; width: 100%; max-width: 400px; margin: 0 auto; }
.wheel .rim { fill: var(--gold); }
.wheel .slice { stroke: var(--card); stroke-width: .6; }
.wheel .slice.c0 { fill: #b3262e; }
.wheel .slice.c1 { fill: #fff3d6; }
.wheel .slice.c2 { fill: #1e6b4a; }
.wheel .slice.c3 { fill: #f0c866; }
.wheel text { font-weight: 700; fill: #22302a; }
.wheel text.c0, .wheel text.c2 { fill: #fff; }
.wheel .hub { fill: var(--card); stroke: var(--gold); stroke-width: 3; }
.wheel .pointer { fill: var(--bg); stroke: var(--card); stroke-width: 1.5; }

.reveal { text-align: center; animation: pop .5s; }
.reveal .who { font-size: 36px; font-weight: 800; line-height: 1.3; color: var(--red); overflow-wrap: anywhere; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
dl { margin: 14px 0 0; text-align: left; }
dt { font-weight: 700; }
dd { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stats b { display: block; font-size: 30px; line-height: 1.2; }
ul.people { list-style: none; margin: 0; padding: 0; }
ul.people li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
ul.people .name { flex: 1 1 180px; overflow-wrap: anywhere; }
ul.people .mail { display: block; font-size: 14px; color: var(--soft); }
ul.people .out { opacity: .5; text-decoration: line-through; }
.tag { font-size: 14px; padding: 1px 10px; border-radius: 99px; background: #eee6d4; }
.tag.ok { background: #d9f0e2; color: var(--ok); }
ul.log { margin: 0; padding-left: 20px; font-size: 15px; color: var(--soft); }
.code { margin: 0 0 10px; font: 700 28px/1.4 ui-monospace, Consolas, monospace; letter-spacing: 2px; user-select: all; }

/* Circle of pairs */
.picked-text { text-align: center; font-size: 20px; font-weight: 700; min-height: 1.6em; }
.circle { display: block; width: 100%; max-width: 720px; margin: 0 auto; }
.circle .arc { fill: none; stroke: var(--gold); stroke-width: 2; }
.circle .head { fill: var(--gold); }
.circle .node { cursor: pointer; }
.circle .node circle { fill: var(--red); }
.circle .node text { fill: var(--ink); font-weight: 600; }
.circle .faded { opacity: .4; }
.circle.picked .node:not(.on), .circle.picked .arrow:not(.on) { opacity: .15; }
.circle.picked .node.on, .circle.picked .arrow.on { opacity: 1; }
.circle .on .arc { stroke: var(--ok); stroke-width: 3; }
.circle .on .head { fill: var(--ok); }
.circle .main text { fill: var(--red); font-weight: 800; }
