:root {
  --bg: #0d1020;
  --bg2: #151a33;
  --surface: rgba(255,255,255,.05);
  --surface-hi: rgba(255,255,255,.09);
  --text: #f2f3fa;
  --muted: #9aa0bf;
  --accent: #8fb0ff;
  --border: rgba(255,255,255,.10);
  --glow: rgba(110,120,255,.45);
  --honey: #ffb703;
  --honey2: #ffd45e;
  --leaf: #4caf50;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(47,111,228,.35), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(123,63,228,.30), transparent 60%),
    var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

.back {
  position: fixed; top: 10px; left: 12px; z-index: 50;
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: 8px 12px; border-radius: 999px; background: rgba(13,16,32,.6); border: 1px solid var(--border);
  min-height: 44px; display: inline-flex; align-items: center;
}
.back:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.view { position: fixed; inset: 0; }
.page { display: grid; place-items: center; padding: 70px 16px 24px; overflow-y: auto; }

/* ---------- buttons ---------- */
.btn {
  border-radius: 999px; padding: 10px 18px; min-height: 44px; font-weight: 700; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover, .btn:focus-visible { background: var(--surface-hi); transform: translateY(-2px); }
.btn:focus-visible, .btn:focus { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn.primary { background: linear-gradient(135deg, #8fd8ff, #a98bff); color: #0d1020; border: 0; box-shadow: 0 10px 30px -12px var(--glow); }
.btn.big { padding: 14px 26px; font-size: 1.1rem; min-height: 54px; }
.btn.icon { padding: 6px 10px; min-width: 44px; font-size: 1.1rem; }
.btn.sel { border-color: rgba(255,212,94,.85); background: rgba(255,183,3,.2); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- home ---------- */
.attract { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .75; }
.logo {
  margin: 0; font-size: clamp(3.2rem, 15vw, 7rem); font-weight: 900; letter-spacing: .04em; line-height: .95;
  background: linear-gradient(#fff6c8 0%, #ffd45e 40%, #ff9f1c 70%, #c75b00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(60,30,0,.65)) drop-shadow(0 0 24px rgba(255,183,3,.45));
}
.logo span { display: block; font-size: .62em; letter-spacing: .22em;
  background: linear-gradient(#e8ffd6, #8be36a 55%, #2f8f3a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.small { font-size: 2.6rem; }
.home-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 560px;
  background: radial-gradient(closest-side, rgba(13,16,32,.78), rgba(13,16,32,.45) 70%, transparent); padding: 40px 30px; border-radius: 40px; }
.tag { margin: 0; font-size: 1.15rem; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(13,16,32,.95); }
.home-buttons { display: flex; flex-direction: column; gap: 12px; width: min(100%, 360px); margin-top: 10px; }
.hint { color: #c9cde6; font-size: .92rem; margin: 6px 0 0; text-shadow: 0 1px 6px #0d1020; }

.card { background: rgba(21,26,51,.92); border: 1px solid var(--border); border-radius: 22px; padding: 22px; backdrop-filter: blur(8px); }
.join-card { width: min(100%, 380px); display: flex; flex-direction: column; gap: 14px; }
.join-card h2 { margin: 0; letter-spacing: -.02em; }
.join-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--muted); font-size: .9rem; }
.join-card input {
  background: rgba(0,0,0,.3); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; font-size: 1.2rem; color: var(--text); min-height: 50px;
}
.join-card input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
#codeIn { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.swatch { aspect-ratio: 1; min-height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; box-shadow: 0 0 12px currentColor; }
.swatch[aria-checked="true"] { border-color: #fff; transform: scale(1.12); }
.swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.err { color: #ff8fa3; margin: 0; min-height: 1.2em; }

/* ---------- screen (TV) ---------- */
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 12px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 24px; }
.timer {
  font-weight: 900; font-size: 2.2rem; letter-spacing: .06em; font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 2px 0 rgba(60,30,0,.7), 0 0 16px rgba(255,183,3,.8);
}
.timer.hot { color: #fff0c0; text-shadow: 0 0 18px #ff6b1a, 0 0 2px #fff; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.hivebar { display: flex; align-items: center; gap: 12px; background: rgba(13,16,32,.6); border: 1px solid rgba(255,183,3,.4); border-radius: 999px; padding: 6px 16px; font-weight: 800; }
.hivebar .hp { width: 200px; height: 14px; border-radius: 999px; background: rgba(0,0,0,.45); overflow: hidden; }
.hivebar .hp i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff4d4d, #ffd45e 40%, #7dff8a); transition: width .3s; }
.board {
  position: absolute; top: 70px; right: 14px; width: 260px; display: flex; flex-direction: column; gap: 3px;
  background: rgba(13,16,32,.55); border: 1px solid var(--border); border-radius: 18px; padding: 10px 12px;
}
.board:empty { display: none; }
.brow { display: grid; grid-template-columns: 14px 1fr auto; column-gap: 8px; align-items: center; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.brow .dot { width: 14px; height: 14px; border-radius: 50%; }
.brow .nm { overflow: hidden; text-overflow: ellipsis; }
.brow .sc { font-variant-numeric: tabular-nums; }
.brow .bar { grid-column: 2 / 4; display: flex; height: 4px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,.08); }
.brow .bar i { display: block; height: 100%; }
.brow.bot { opacity: .62; font-weight: 500; }
.brow.dead { opacity: .4; }
.feed { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 4px; }
.feed div { background: rgba(13,16,32,.68); border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: .95rem; animation: fadeout 6s forwards; }
@keyframes fadeout { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
.banner {
  position: absolute; left: 0; right: 0; top: 28%; text-align: center; font-weight: 900;
  font-size: 4.5rem; letter-spacing: .05em; color: #fff6c8; opacity: 0; transform: scale(.8);
  text-shadow: 0 4px 0 rgba(90,45,0,.8), 0 0 30px rgba(255,159,28,.9); transition: opacity .2s, transform .2s;
}
.banner.on { opacity: 1; transform: scale(1); }
.banner small { display: block; font-size: 1.6rem; letter-spacing: 0; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.9); }
.roomtag { position: absolute; left: 16px; top: 62px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.panel {
  position: absolute; left: 3vw; top: 50%; transform: translateY(-50%); width: min(520px, 92vw);
  background: rgba(13,16,32,.93); border: 1px solid rgba(255,183,3,.35); border-radius: 26px; padding: 24px; backdrop-filter: blur(6px);
  box-shadow: 0 0 60px -10px rgba(255,183,3,.35), inset 0 0 40px rgba(76,175,80,.07);
  display: flex; flex-direction: column; gap: 14px; max-height: 94vh; overflow: auto;
}
.results-panel { left: 50%; transform: translate(-50%, -50%); }
.panel h2 { margin: 0; font-size: 2rem; letter-spacing: -.02em; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .9rem; }
.joinbox { display: flex; gap: 18px; align-items: center; }
.qr { width: 150px; height: 150px; border-radius: 14px; background: #fff; padding: 6px; flex: none; }
.joinurl { margin: 0; font-weight: 700; color: var(--accent); word-break: break-all; }
.code { margin: 0; font-size: 3rem; font-weight: 900; letter-spacing: .18em; color: var(--honey2); text-shadow: 0 0 14px rgba(255,183,3,.6); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; }
.chip .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #0d1020; font-weight: 900; font-size: .85rem; }
.chip.off { opacity: .45; }
.settings { display: flex; flex-direction: column; gap: 8px; }
.setting { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setting > span { min-width: 150px; color: var(--muted); font-weight: 600; }
.howto { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: .92rem; color: #d7dbef; }
.howto img { width: 34px; height: 34px; }
.howto b { color: #fff; }
.results { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.results li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 14px; background: var(--surface); font-weight: 700; }
.results li.first { background: linear-gradient(90deg, rgba(255,212,94,.28), rgba(76,175,80,.15)); border: 1px solid rgba(255,212,94,.5); }
.results .pl { width: 2em; font-size: 1.2rem; color: var(--muted); }
.results .nm { flex: 1; }
.results .k { color: var(--muted); font-weight: 600; font-size: .9rem; }
.results li.bot { opacity: .6; }
.mute { position: absolute; right: 16px; bottom: 16px; }
.soundgate { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); }

/* ---------- TV scale ---------- */
html.tv body { font-size: 26px; }
html.tv .back { top: 4vh; left: 3vw; font-size: 22px; }
html.tv .panel { left: 4vw; width: 780px; padding: 30px 34px; top: 54%; max-height: 86vh; }
html.tv .results-panel { left: 50%; }
html.tv .qr { width: 220px; height: 220px; }
html.tv .code { font-size: 4rem; }
html.tv .board { top: 10vh; right: 3vw; width: 380px; }
html.tv .brow { font-size: 1.05rem; grid-template-columns: 20px 1fr auto; }
html.tv .brow .dot { width: 20px; height: 20px; }
html.tv .timer { font-size: 3rem; }
html.tv .hud-top { top: 3.5vh; }
html.tv .hivebar .hp { width: 300px; height: 20px; }
html.tv .feed { left: 3vw; bottom: 5vh; }
html.tv .roomtag { left: 3vw; top: 11vh; }
html.tv .mute { right: 3vw; bottom: 5vh; }
html.tv .howto img { width: 48px; height: 48px; }
html.tv .btn:focus { box-shadow: 0 0 0 6px rgba(143,176,255,.35); transform: scale(1.05); }
html.tv #playHereBtn { display: none; }

/* ---------- phone controller ---------- */
#phone { display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(120% 70% at 50% 100%, rgba(76,175,80,.22), transparent 60%), radial-gradient(90% 50% at 50% 0%, rgba(255,183,3,.12), transparent 70%), var(--bg); }
#phone .status { display: flex; align-items: center; gap: 10px; padding: 62px 14px 6px; }
.me-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; }
.me-name { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 44px; }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }
.mix { display: flex; gap: 8px; padding: 0 14px; min-height: 40px; flex-wrap: wrap; align-items: center; }
.mix span { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px 2px 4px; background: var(--surface); border: 1px solid var(--border); font-weight: 800; font-variant-numeric: tabular-nums; }
.mix img { width: 28px; height: 28px; }
.mix .tagx { padding: 2px 10px; color: #0d1020; background: var(--honey2); }
.pad { flex: 1; position: relative; margin: 6px 12px; border-radius: 26px; border: 1px solid rgba(255,183,3,.25);
  background:
    radial-gradient(circle at 50% 50%, rgba(76,175,80,.14), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='48' viewBox='0 0 56 48'%3E%3Cpath d='M14 0h28l14 24-14 24H14L0 24z' fill='none' stroke='%23ffb703' stroke-opacity='.10' stroke-width='2'/%3E%3C/svg%3E") 0 0 / 56px 48px,
    rgba(0,0,0,.2);
  overflow: hidden; }
.pad-ring { position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; left: 50%; top: 50%; border-radius: 50%;
  border: 2px solid rgba(255,212,94,.5); box-shadow: 0 0 24px rgba(255,183,3,.25), inset 0 0 24px rgba(76,175,80,.2); }
.pad-knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--knob, #ffd45e) 45%, #2a1a05 100%); box-shadow: 0 0 24px var(--knob, #ffd45e); }
.pad-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: var(--muted); margin: 0; font-size: .9rem; }
.split {
  position: relative; overflow: hidden;
  margin: 4px 12px calc(14px + env(safe-area-inset-bottom)); min-height: 88px; border-radius: 24px; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
  color: #2a1400; cursor: pointer; touch-action: none;
  background: linear-gradient(135deg, #fff1a8, #ffb703 55%, #ff7a00); box-shadow: 0 10px 40px -10px rgba(255,159,28,.8);
}
.split .lbl { position: relative; font-weight: 900; font-size: 1.7rem; letter-spacing: .2em; }
.split small { position: relative; font-weight: 700; opacity: .75; }
.split .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(42,20,0,.35); }
.split.on { filter: brightness(1.25); transform: scale(.98); }
.split:disabled { filter: grayscale(.7); opacity: .55; }
.phone-card, .dead {
  position: absolute; left: 12px; right: 12px; top: 120px; padding: 18px; border-radius: 22px;
  background: rgba(21,26,51,.95); border: 1px solid rgba(255,183,3,.35); display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px -20px rgba(255,183,3,.4); max-height: calc(100% - 240px); overflow: auto;
}
.phone-card h2, .dead h2 { margin: 0; font-size: 1.4rem; }
.phone-card p, .dead p { margin: 0; color: var(--muted); }
.phone-card .setting > span { min-width: 0; width: 100%; }
.phone-card.peek { pointer-events: none; opacity: .92; top: auto; bottom: 116px; }
.dead { text-align: center; align-items: center; pointer-events: none; }
.dead .big { font-size: 3rem; font-weight: 900; color: #fff; text-shadow: 0 0 20px #ff6b1a; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #151a33; border: 1px solid var(--border); padding: 10px 16px; border-radius: 999px; font-weight: 600; opacity: 0; transition: opacity .2s; z-index: 60; pointer-events: none; white-space: nowrap; }
.toast.on { opacity: 1; }

@media (max-width: 700px) {
  .panel { left: 50%; transform: translate(-50%, -50%); }
  .board { width: 180px; font-size: .85rem; }
  .banner { font-size: 2.6rem; }
  .hivebar .hp { width: 110px; }
}

/* In a party, party.js draws its Party button top-right. */
html.party #phone .status { padding-top: 66px; }
html.party .board { top: 82px; }
html.party.tv .board { top: 13vh; }
