/* TV / host screen. Layout mode comes from one ResizeObserver: body[data-mode=tv|tablet|phone]. */
#app { position: fixed; inset: 0; }
.host .screen { padding: clamp(16px, 2.6vw, 44px); gap: clamp(12px, 2vh, 24px); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar .right { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; font-size: 22px;
  background: #fff; box-shadow: 0 0 0 2px var(--line), 0 4px 0 var(--lip);
  transition: transform var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 2px var(--line), 0 0 0 var(--lip); }

/* ---------- lobby ---------- */
.lobby-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 30%) 1fr; gap: clamp(16px, 2.4vw, 36px); }
.join { padding: clamp(18px, 2.4vw, 32px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.join .qr-wrap { width: min(100%, 34vh); aspect-ratio: 1; padding: 12px; border-radius: 24px; background: #fff; box-shadow: 0 0 0 3px var(--ink); }
.join .qr-wrap img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.code { display: flex; gap: 10px; justify-content: center; }
.code span {
  width: clamp(48px, 5vw, 76px); height: clamp(58px, 6vw, 92px); border-radius: 18px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: clamp(34px, 4vw, 60px); color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.18);
  animation: popIn var(--t4) var(--pop) backwards; animation-delay: var(--d);
}
.code span:nth-child(1) { background: var(--tomato); }
.code span:nth-child(2) { background: var(--ocean); }
.code span:nth-child(3) { background: var(--sun); }
.code span:nth-child(4) { background: var(--mint); }
.howto { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.howto span { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 26px; }
.howto small { font-size: 12px; font-weight: 800; color: var(--ink-3); letter-spacing: .04em; }
.howto i { font-style: normal; color: var(--dot); font-size: 22px; font-weight: 900; }
.join .url { font-size: clamp(15px, 1.3vw, 20px); color: var(--ink-2); word-break: break-all; }
.join .url b { color: var(--ink); }

.setup { display: flex; flex-direction: column; gap: clamp(12px, 1.8vh, 22px); min-height: 0; }
.setup-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.setup-head h2 { font-size: clamp(28px, 2.8vw, 46px); margin-top: 4px; }
.cats { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; padding: 4px 4px 12px; align-content: start; }
.cat {
  --cc: var(--ocean);
  position: relative; text-align: left; padding: 16px; border-radius: var(--r-m);
  background: #fff; box-shadow: 0 0 0 2px var(--line), 0 6px 0 var(--lip);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center;
  transition: transform var(--t1) var(--ease), box-shadow var(--t3) var(--ease), background var(--t1) ease;
  animation: popIn var(--t4) var(--pop) backwards; animation-delay: var(--d);
}
.cat:active { transform: translateY(5px) scale(.98); box-shadow: 0 0 0 2px var(--line), 0 1px 0 var(--lip); }
.cat .bubble { grid-row: span 2; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; background: var(--cc); box-shadow: inset 0 -5px 0 rgba(0,0,0,.15); }
.cat .name { font-family: var(--display); font-weight: 600; font-size: 22px; line-height: 1.1; }
.cat .blurb { font-size: 14px; color: var(--ink-3); line-height: 1.25; }
.cat .stats { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.cat .stats span { background: var(--paper); padding: 3px 9px; border-radius: 999px; }
.cat .tick { position: absolute; top: -8px; right: -8px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--cc); color: #fff; font-size: 18px; transform: scale(0); transition: transform var(--t3) var(--pop); box-shadow: 0 0 0 3px #fff; }
.cat.on { box-shadow: 0 0 0 4px var(--cc), 0 6px 0 var(--cc); }
.cat.on .tick { transform: scale(1); }

.presets { display: flex; gap: 10px; flex-wrap: wrap; }
.preset {
  height: 40px; padding: 0 16px; border-radius: 999px; background: #fff; font-weight: 800; font-size: 15px; color: var(--ink-2);
  box-shadow: 0 0 0 2px var(--line), 0 4px 0 var(--lip);
  transition: transform var(--t1) var(--ease), box-shadow var(--t1) var(--ease), background var(--t1) ease, color var(--t1) ease;
}
.preset:active { transform: translateY(4px); box-shadow: 0 0 0 2px var(--line), 0 0 0 var(--lip); }
.preset.on { background: var(--grape); color: #fff; box-shadow: 0 0 0 2px var(--grape), 0 4px 0 var(--grape-lip); }
.cat-group {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; justify-self: start;
  margin-top: 6px; padding: 6px 14px 6px 8px; border-radius: 999px;
  font-family: var(--display); font-weight: 600; font-size: 20px; color: var(--ink-2);
  transition: background var(--t1) ease, color var(--t1) ease, transform var(--t1) var(--ease);
}
.cat-group:first-child { margin-top: 0; }
.cat-group span { font-size: 22px; }
.cat-group small { font-family: var(--body); font-size: 13px; font-weight: 900; color: var(--ink-3); background: #fff; border-radius: 999px; padding: 2px 9px; box-shadow: 0 0 0 2px var(--line); }
.cat-group:hover { background: rgba(255,255,255,.7); }
.cat-group:active { transform: scale(.97); }
.cat-group.on { background: var(--ink); color: #fff; }
.cat .stats .diff-dots { background: none; padding: 3px 4px; color: var(--cc); }
.setup-row { display: flex; gap: clamp(16px, 3vw, 48px); flex-wrap: wrap; align-items: flex-end; }
.setup-row .eyebrow { margin-bottom: 8px; }
.setup-row .hint { margin-top: 6px; font-size: 12px; color: var(--ink-3); max-width: 240px; line-height: 1.3; }

.lobby-foot { display: flex; align-items: center; gap: 20px; }
.players-strip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 10px 18px; border-radius: var(--r-l); background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 2px var(--line); overflow: hidden; }
.players-strip .count { font-family: var(--display); font-weight: 600; font-size: 22px; white-space: nowrap; }
.players-strip .faces { display: flex; gap: 10px; overflow: hidden; flex-wrap: nowrap; }
.face { display: flex; flex-direction: column; align-items: center; gap: 2px; animation: popIn var(--t4) var(--pop) backwards; position: relative; }
.face .avatar { width: 50px; height: 50px; font-size: 26px; }
.face small { font-size: 12px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.face.off { opacity: .35; }
.face.seen { animation: none; }
.btn.ghost.on-mix { --bg: var(--ink); color: #fff; box-shadow: 0 0 0 2px var(--ink), 0 4px 0 #0B0E22; }
.face button.kick { position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; opacity: 0; transition: opacity var(--t1) ease; }
.face:hover button.kick { opacity: 1; }
.waiting { color: var(--ink-3); font-weight: 800; display: flex; align-items: center; gap: 10px; }
.waiting i { width: 10px; height: 10px; border-radius: 50%; background: var(--sun); animation: pulse 1.2s var(--ease) infinite; }
.go { display: flex; align-items: center; gap: 18px; }
.estimate { text-align: right; }
.estimate b { display: block; font-family: var(--display); font-weight: 600; font-size: 26px; }

/* ---------- intro ---------- */
.intro { flex: 1; display: grid; place-items: center; }
.intro-card { --cc: var(--ocean); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; animation: popIn var(--t4) var(--pop) backwards; }
.intro-card .bubble { width: clamp(120px, 18vh, 200px); height: clamp(120px, 18vh, 200px); border-radius: 30%; display: grid; place-items: center; font-size: clamp(64px, 10vh, 120px); background: var(--cc); box-shadow: inset 0 -12px 0 rgba(0,0,0,.15), 0 12px 0 rgba(0,0,0,.08); animation: squish .7s var(--ease) .25s both; }
.intro-card h1 { font-size: clamp(44px, 6vw, 96px); }
.intro-card .meta { display: flex; gap: 12px; }
.intro-bar { width: min(420px, 70vw); height: 12px; border-radius: 99px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); overflow: hidden; }
.intro-bar i { display: block; height: 100%; background: var(--cc); transform-origin: left; animation: drain var(--dur) linear both; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- question ---------- */
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.q-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill.cat-pill { background: var(--cc); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.pill.join-pill b { color: var(--ink); letter-spacing: .08em; }
.q-right { display: flex; align-items: center; gap: 14px; }
.answered { font-size: 18px; }
.answered b { font-family: var(--display); font-size: 22px; color: var(--ink); }
.q-prompt { text-align: center; font-size: clamp(30px, 4.2vw, 64px); animation: popIn var(--t4) var(--pop) backwards; }
.q-prompt.memo { color: var(--grape); }
.stage { flex: 1; min-height: 0; }
.host .tiles { gap: clamp(10px, 1.4vw, 20px); }
.host .tile { min-height: clamp(76px, 12vh, 130px); }
.host .tile .opt { font-size: clamp(36px, 5.2vh, 64px); }
.host .tile .slot-ico { width: clamp(30px, 4vh, 46px); height: clamp(30px, 4vh, 46px); }
.reveal-strip { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; min-height: 44px; }
.reveal-strip .pill { animation: popIn var(--t4) var(--pop) backwards; animation-delay: var(--d); }
.reveal-strip .explain { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #0B0E22; height: auto; min-height: 44px; padding: 8px 18px; white-space: normal; font-size: clamp(16px, 1.5vw, 22px); }
.reveal-strip .fast { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 var(--sun-lip); }

/* ---------- leaderboard ---------- */
.board { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: 0; }
.board h1 { font-size: clamp(40px, 5vw, 72px); }
.ranks { list-style: none; width: min(900px, 100%); display: flex; flex-direction: column; gap: 12px; }
.rank-row {
  height: clamp(60px, 7.6vh, 78px); display: flex; align-items: center; gap: 16px; padding: 0 22px 0 14px; border-radius: var(--r-m);
  background: #fff; box-shadow: 0 0 0 2px var(--line), 0 6px 0 var(--lip);
  transition: transform .7s var(--ease);
}
.rank-row .pos { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 22px; background: var(--paper); }
.rank-row:nth-child(1) .pos { background: var(--sun); color: #fff; }
.rank-row:nth-child(2) .pos { background: #B8C2D6; color: #fff; }
.rank-row:nth-child(3) .pos { background: #E09A5C; color: #fff; }
.rank-row .avatar { width: 48px; height: 48px; font-size: 26px; }
.rank-row .nm { flex: 1; font-family: var(--display); font-weight: 600; font-size: clamp(20px, 2vw, 28px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .streak { font-size: 18px; color: var(--tomato); }
.rank-row .gain { padding: 4px 12px; border-radius: 999px; background: var(--mint); color: #fff; font-weight: 900; animation: popIn var(--t4) var(--pop) .5s backwards; }
.rank-row .gain.zero { background: var(--paper); color: var(--ink-3); }
.rank-row .score { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 2.2vw, 32px); min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.rank-row .move { width: 22px; font-size: 16px; text-align: center; }
.rank-row .move.up { color: var(--mint); }
.rank-row .move.down { color: var(--tomato); }

/* ---------- final ---------- */
.final { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(14px, 2.4vh, 28px); }
.final h1 { font-size: clamp(44px, 6vw, 92px); }
.podium { display: flex; align-items: flex-end; gap: clamp(12px, 2vw, 28px); }
.pod { display: flex; flex-direction: column; align-items: center; gap: 10px; width: clamp(140px, 16vw, 230px); }
.pod .avatar { width: clamp(70px, 9vh, 110px); height: clamp(70px, 9vh, 110px); font-size: clamp(38px, 5vh, 60px); animation: popIn var(--t4) var(--pop) backwards; animation-delay: var(--d); }
.pod .nm { font-family: var(--display); font-weight: 600; font-size: clamp(20px, 2vw, 30px); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pts { color: var(--ink-2); }
.pod .block { width: 100%; border-radius: 22px 22px 10px 10px; display: grid; place-items: start center; padding-top: 14px; font-family: var(--display); font-weight: 700; font-size: clamp(36px, 5vh, 64px); color: #fff; box-shadow: inset 0 -10px 0 rgba(0,0,0,.12); transform-origin: bottom; animation: barGrow .7s var(--ease) both; animation-delay: var(--d); }
.pod.p1 .block { height: clamp(150px, 26vh, 300px); background: var(--sun); }
.pod.p2 .block { height: clamp(110px, 18vh, 210px); background: var(--ocean); }
.pod.p3 .block { height: clamp(80px, 12vh, 150px); background: var(--tomato); }
.pod.p1 .avatar { animation: popIn var(--t4) var(--pop) backwards, bob 2.4s var(--ease) 1.2s infinite; }
.rest { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.final-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ---------- host controls (quiet, bottom-right) ---------- */
.host .screen:has(.hud) { padding-bottom: 86px; }
.ring.done .bar { stroke: var(--mint); }
.ring.done .num { color: var(--mint); font-size: 40px; animation: popIn var(--t4) var(--pop) backwards; }
.hud { position: fixed; right: 18px; bottom: 18px; display: flex; gap: 10px; z-index: 20; }
.hud .icon-btn { width: auto; padding: 0 16px; gap: 8px; display: inline-flex; align-items: center; font-weight: 800; font-size: 16px; }

/* ---------- phone-as-host & small screens ---------- */
body[data-mode="phone"] { overflow: auto; }
body[data-mode="phone"] #app { position: relative; min-height: 100%; }
body[data-mode="phone"] .screen { position: relative; min-height: 100vh; }
body[data-mode="phone"] .lobby-grid { grid-template-columns: 1fr; }
body[data-mode="phone"] .cats { overflow: visible; grid-template-columns: 1fr 1fr; }
body[data-mode="phone"] .cat { grid-template-columns: 1fr; padding: 12px; }
body[data-mode="phone"] .cat .bubble { grid-row: auto; width: 46px; height: 46px; font-size: 26px; }
body[data-mode="phone"] .cat .blurb { display: none; }
body[data-mode="phone"] .lobby-foot { flex-direction: column; align-items: stretch; position: sticky; bottom: 0; background: var(--paper); padding-top: 10px; }
body[data-mode="phone"] .go { justify-content: space-between; }
body[data-mode="phone"] .tiles { grid-template-columns: 1fr; }
body[data-mode="phone"] .hud { bottom: 10px; right: 10px; }
body[data-mode="phone"] .q-top { align-items: flex-start; }
body[data-mode="phone"] .q-meta .pill:nth-child(n+3) { display: none; }
body[data-mode="phone"] .ring { width: 64px; height: 64px; }
body[data-mode="phone"] .ring .num { font-size: 26px; }
body[data-mode="tablet"] .lobby-grid { grid-template-columns: minmax(260px, 34%) 1fr; }
