:root {
  --bg: #1b1036; --bg2: #2a1957; --card: #2f1d62; --line: #4a3590; --text: #fff; --muted: #b9a9ef;
  --yellow: #ffcf3f; --pink: #ff5da2; --teal: #3fe0c5; --red: #ff6b6b; --green: #4fe08a;
  --teamA: #ff8a3d; --teamB: #3fa8ff;
  --r: 18px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text);
  font: 17px/1.4 ui-rounded, -apple-system, "SF Pro Rounded", "Segoe UI", Roboto, system-ui, sans-serif; min-height: 100%; }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 50% -200px, #3a2380, var(--bg)) no-repeat, var(--bg); padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px); -webkit-tap-highlight-color: transparent; }
a { color: var(--yellow); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; max-width: 640px; margin: 0 auto; }
.logo { font-weight: 900; font-size: 24px; letter-spacing: 1px; color: #fff; text-decoration: none; }
.flip { display: inline-block; transform: scaleX(-1); color: var(--yellow); }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 30px; margin: 8px 0 6px; line-height: 1.1; }
h2 { font-size: 22px; margin: 4px 0 10px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 0 8px; }
p { margin: 6px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 12px 0; }
.hero { text-align: center; padding: 26px 18px; }
.hero .big { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.phrase { font-size: 28px; font-weight: 800; color: var(--yellow); line-height: 1.15; margin: 8px 0; word-break: break-word; }
.btn { appearance: none; border: 0; border-radius: 14px; padding: 15px 18px; font: inherit; font-weight: 800; color: var(--bg);
  background: #fff; cursor: pointer; width: 100%; margin: 6px 0; display: block; text-align: center; text-decoration: none; transition: transform .05s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.primary { background: var(--yellow); }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); }
.btn.ghost { background: transparent; color: #fff; border: 2px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 2px solid #6b2b4b; }
.btn.small { padding: 10px 12px; font-size: 15px; width: auto; display: inline-block; margin: 4px 4px 4px 0; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; padding: 6px; }
input[type=text], input[type=email], input[inputmode=numeric] { width: 100%; font: inherit; font-size: 20px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg2); color: #fff; margin: 6px 0; outline: none; }
input:focus { border-color: var(--yellow); }
input.code { letter-spacing: 10px; text-align: center; font-size: 30px; font-weight: 800; }
input.roomcode { text-transform: uppercase; letter-spacing: 8px; text-align: center; font-weight: 800; font-size: 26px; }
.seg { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; gap: 4px; margin: 6px 0; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; padding: 10px 6px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.seg button.on { background: var(--yellow); color: var(--bg); }
.seg[aria-disabled=true] button { cursor: default; }
.code-big { font-size: 44px; font-weight: 900; letter-spacing: 10px; color: var(--yellow); }
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.players li:last-child { border-bottom: 0; }
.players .nm { flex: 1; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6c5aa8; flex: none; }
.dot.on { background: var(--green); }
.tag { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); }
.tag.A { background: var(--teamA); color: #2a1200; }
.tag.B { background: var(--teamB); color: #001a33; }
.tag.role { background: var(--pink); color: #fff; }
.score { font-weight: 900; font-size: 20px; min-width: 32px; text-align: right; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.teambox { border-radius: var(--r); padding: 12px; background: var(--bg2); border: 2px solid var(--line); }
.teambox.A { border-color: var(--teamA); } .teambox.B { border-color: var(--teamB); }
.teambox .tot { font-size: 32px; font-weight: 900; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.strip .chip { flex: none; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.strip .chip b { color: var(--yellow); margin-left: 4px; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cats button { border: 2px solid var(--line); background: var(--bg2); color: #fff; border-radius: 14px; padding: 14px 8px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.cats button:active { border-color: var(--yellow); }
.cats .e { font-size: 24px; display: block; }
.rec { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0; }
.recbtn { width: 118px; height: 118px; border-radius: 50%; border: 6px solid #fff; background: var(--pink); color: #fff; font: inherit; font-weight: 900; font-size: 17px; cursor: pointer;
  box-shadow: 0 0 0 0 rgba(255,93,162,.6); }
.recbtn.on { background: var(--red); animation: pulse 1.1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,107,107,.6); } 100% { box-shadow: 0 0 0 26px rgba(255,107,107,0); } }
.meter { width: 220px; height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--yellow), var(--pink)); transition: width .06s; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.player { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.player .pb { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--teal); color: var(--bg); font-size: 22px; cursor: pointer; flex: none; }
.player.rev .pb { background: var(--yellow); }
.player .lbl { flex: 1; font-weight: 700; line-height: 1.2; }
.player .lbl small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.player .spd { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 10px; padding: 8px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.player .spd.on { color: var(--bg); background: var(--muted); }
.player progress { width: 100%; height: 4px; display: block; margin-top: 6px; accent-color: var(--yellow); }
.verdict { font-size: 54px; line-height: 1; }
.pass { background: linear-gradient(135deg, var(--pink), #8a4dff); border-radius: var(--r); padding: 14px 16px; margin: 12px 0; font-weight: 800; }
.hidden-phrase { filter: blur(12px); user-select: none; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist .q { font-weight: 800; }
.ok { color: var(--green); } .no { color: var(--red); }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%) translateY(120px); background: #fff; color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-weight: 700; transition: transform .25s, opacity .25s; opacity: 0; pointer-events: none; max-width: 90vw; z-index: 10; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.err { background: var(--red); color: #fff; }
dialog { background: var(--card); color: #fff; border: 1px solid var(--line); border-radius: var(--r); max-width: 520px; width: calc(100% - 32px); padding: 22px; }
dialog::backdrop { background: rgba(10,4,30,.7); }
.how li { margin-bottom: 8px; }
.waiting { display: inline-block; animation: bob 1.2s infinite ease-in-out; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.bars { display: inline-flex; gap: 3px; height: 18px; align-items: end; vertical-align: middle; margin-left: 6px; }
.bars i { width: 4px; background: var(--yellow); border-radius: 2px; animation: bars .9s infinite ease-in-out; }
.bars i:nth-child(2) { animation-delay: .15s } .bars i:nth-child(3) { animation-delay: .3s } .bars i:nth-child(4) { animation-delay: .45s }
@keyframes bars { 0%,100% { height: 4px } 50% { height: 18px } }
.foot { text-align: center; margin-top: 26px; }
