:root {
  --show-ink: #1f1f1d;
  --show-muted: rgba(0, 0, 0, .55);
  --show-line: rgba(0, 0, 0, .08);
  --show-accent: #2a6f97;
  --show-paper: #f7f6f3;
  --show-amber: #b86e12;
  --show-red: #a33;
  --show-ok: #2a7a4b;
}

* { box-sizing: border-box; }

html:has(body.show-body) {
  height: 100dvh;
  overflow: hidden;
}

body.show-body {
  margin: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  font-family: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  background: var(--show-paper);
  color: var(--show-ink);
}

body.show-body #live {
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

body.show-body #live > .show-panel:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}

body.show-body .host-bar {
  position: static;
  flex: 0 0 auto;
}

.hidden { display: none !important; }

.show-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 0;
  position: relative;
  z-index: 2;
}

.show-header-url {
  font-size: .85rem;
  letter-spacing: .02em;
  color: var(--show-muted);
}

.show-code { font-weight: 700; letter-spacing: .08em; color: var(--show-ink); margin-left: 6px; }

.show-header-meta { display: flex; align-items: center; gap: 8px; margin-right: 72px; }

.show-round, .show-badge, .show-mult {
  border: 1px solid var(--show-line);
  background: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .85rem;
}

.header-qr {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 64px;
  height: 64px;
  background: #fff;
  border-radius: 8px;
  object-fit: contain;
}

.show-stage { position: relative; min-height: 0; flex: 1 1 auto; }

.media-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.show-panel { position: relative; z-index: 1; padding: 12px 16px; }

.panel-center, .panel-countdown {
  min-height: 0;
  display: grid;
  place-items: center;
  text-align: center;
  align-content: center;
}

.join-banner { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 6px; margin: 8px 0; }
.join-host { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 650; }
.join-sep { color: var(--show-muted); font-size: 1.6rem; }
.code { font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: .12em; font-weight: 700; margin: 0; }
#qr, .lobby-qr, .hushuo-qr {
  width: min(220px, 26vh);
  height: auto;
  max-height: 26vh;
  background: #fff;
  border-radius: 8px;
}

.term { font-size: min(12vw, 20vh); margin: 0 0 4px; line-height: 1.05; }
.pinyin { color: var(--show-muted); font-size: 1.05rem; margin: 0 0 8px; }

.dial {
  width: min(28vh, 28vw);
  margin: 8px auto;
  position: relative;
  flex: 0 1 auto;
}
.dial svg { width: 100%; height: auto; display: block; }
.dial-track, .dial-arc { fill: none; stroke-width: 8; }
.dial-track { stroke: rgba(0, 0, 0, .08); }
.dial-arc {
  stroke: var(--show-accent);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}
.dial-amber .dial-arc { stroke: var(--show-amber); }
.dial-red .dial-arc { stroke: var(--show-red); }
.dial .timer, .timer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: clamp(1.4rem, 4vh, 2.4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timer.urgent, .dial-red .timer { color: var(--show-red); }
.dial-amber .timer { color: var(--show-amber); }

.countdown-num {
  font-size: clamp(4rem, 18vw, 8rem);
  font-weight: 700;
  line-height: 1;
  margin: 0;
}

.roster-chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; justify-content: center; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--show-line);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  background: #fff;
}
.chip.disconnected { opacity: .45; }
.chip.pop { animation: esw-pop .35s ease; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--show-accent); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}
.check { color: var(--show-ok); font-weight: 700; }

.show-reconnect {
  border: 1px solid var(--show-amber);
  color: var(--show-amber);
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .8rem;
}

@media (max-height: 820px) {
  .dial { width: min(16vh, 20vw); }
  .arena-lead, .lede, .show-desc { display: none !important; }
  .header-qr { width: 40px; height: 40px; }
  #qr, .lobby-qr, .hushuo-qr { width: min(120px, 16vh); max-height: 16vh; }
  .term { font-size: min(9vw, 14vh); }
  .show-header { padding-top: 6px; }
  .host-bar { padding: 8px 12px; }
  .roster-chips { margin-top: 8px; gap: 6px; }
}

.host-bar {
  position: static;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(247, 246, 243, .94);
  border-top: 1px solid var(--show-line);
  z-index: 3;
  width: 100%;
}

button {
  background: var(--show-accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}
button.secondary { background: #fff; color: var(--show-ink); border: 1px solid var(--show-line); }
button:disabled { opacity: .45; cursor: not-allowed; }

.hint, .muted, .stat { color: var(--show-muted); }
.err { color: var(--show-red); }
.setup { padding: 20px 20px 0; }
.tts-caption { min-height: 1.4em; font-size: 1.15rem; margin: 8px 0; }

.options { display: grid; gap: 10px; margin-top: 16px; text-align: left; width: min(720px, 100%); max-height: min(36vh, 420px); overflow: auto; }
body.show-body textarea.copy { width: min(720px, 100%); min-height: 0; height: 12vh; max-height: 14vh; }
body.show-body .roster-chips { max-height: 16vh; overflow: hidden; }
.option { border: 1px solid var(--show-line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.option.canonical { outline: 2px solid var(--show-accent); }
.house { font-size: .9rem; font-weight: 600; }
.option.flip { animation: hushuo-flip .55s ease; }
.option .house.in { animation: hushuo-in .35s ease both; }
.winner { margin-top: 16px; text-align: center; }
.winner h2 { margin: 8px 0; font-size: 2rem; }
.winner-name { display: flex; align-items: center; justify-content: center; gap: 12px; }
textarea.copy { width: min(720px, 100%); min-height: 72px; font: inherit; }

@keyframes esw-pop { from { transform: scale(.86); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hushuo-flip { from { transform: rotateX(80deg); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes hushuo-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .chip.pop, .option.flip, .option .house.in, .countdown-num, .winner { animation: none !important; }
  .dial-arc { transition: none; }
}
