:root {
  --bg: #17102e;
  --bg-2: #1f1640;
  --surface: #281d52;
  --line: #40337a;
  --text: #ffffff;
  --muted: #bdb4de;
  --accent: #ffd23f;
  --accent-ink: #2a1c00;
  --c0: #ff5a5f;
  --c1: #3a86ff;
  --c2: #ff9f1c;
  --c3: #2ec4b6;
  --glow-1: rgba(255, 90, 95, 0.22);
  --glow-2: rgba(58, 134, 255, 0.22);
  --dim: 0.45;
  --radius: 18px;
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 500px at 10% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; text-wrap: balance; }
p { margin: 0 0 1em; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }
main { flex: 1; }

/* 頁首 */
.site-header { padding: 16px 0; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand img { width: 30px; height: 30px; }
.site-nav { display: flex; gap: 18px; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }

/* 按鈕與表單 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 26px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1.05rem; text-decoration: none; cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 0.92rem; }
.btn.danger { background: var(--c0); color: #fff; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 4px; }
.input, select.input {
  width: 100%; min-height: 50px; padding: 0 16px;
  background: var(--bg-2); border: 2px solid var(--line); border-radius: 14px; color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); }
.input.code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; font-size: 1.4rem; text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 首頁 */
.hero { padding: 40px 0 28px; text-align: center; }
.hero h1 { font-size: clamp(2.1rem, 7vw, 3.8rem); font-weight: 900; letter-spacing: -0.01em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { max-width: 620px; margin: 0 auto 28px; color: var(--muted); font-size: 1.1rem; }
.start { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; max-width: 760px; margin: 0 auto; text-align: left; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card h2, .card h3 { font-size: 1.2rem; }
.card p { color: var(--muted); font-size: 0.97rem; }
.card > :last-child { margin-bottom: 0; }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; min-width: 0; }
.section { padding: 36px 0; }
.section > .wrap > h2 { font-size: 1.7rem; margin-bottom: 18px; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.game-card { border-top: 6px solid var(--tone, var(--accent)); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step); display: grid; place-items: center;
  width: 40px; height: 40px; margin-bottom: 12px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-weight: 900;
}
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { color: var(--muted); margin: 10px 0 0; }
.prose h1 { font-size: 2.1rem; margin-top: 24px; }
.prose h2 { font-size: 1.35rem; margin-top: 2em; }
.prose p, .prose li { color: #e3ddf6; }
.prose .updated { color: var(--muted); font-size: 0.92rem; }
.note { color: var(--muted); font-size: 0.9rem; }
.error-text { color: #ffb4b6; min-height: 1.5em; font-size: 0.92rem; margin: 8px 0 0; }

/* 頁尾 */
.site-footer { padding: 28px 20px 32px; text-align: center; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); margin-top: 32px; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-bottom: 10px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.footer-credit { margin: 0; }
.footer-credit .sep { margin: 0 0.5em; opacity: 0.55; }
.site-footer.compact { margin-top: 0; padding: 14px 16px 18px; font-size: 0.8rem; border-top: 0; }

/* 共用遊戲元件 */
.opt-0 { --tone: var(--c0); } .opt-1 { --tone: var(--c1); } .opt-2 { --tone: var(--c2); } .opt-3 { --tone: var(--c3); }
.timer { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 99px; transition: width 0.2s linear; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); font-size: 0.9rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6b6; }
.dot.off { background: var(--c0); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 20px; border-radius: 99px; z-index: 50; font-size: 0.95rem; }

/* ===== 主持人頁 ===== */
.host-body { background-attachment: scroll; }
.hostbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; flex-wrap: wrap; }
.hostbar .spacer { flex: 1; }
.hostbar .join-hint { font-size: clamp(0.95rem, 1.5vw, 1.3rem); color: var(--muted); }
.hostbar .join-hint b { color: var(--accent); letter-spacing: 0.12em; font-size: 1.25em; margin-left: 6px; }
.stage {
  min-height: calc(100vh - 70px); min-height: calc(100dvh - 70px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2vh 4vw 4vh; text-align: center; gap: 2.4vh;
}
.stage h1 { font-size: clamp(1.8rem, 4.6vw, 4.6rem); font-weight: 900; margin: 0; max-width: 22em; }
.stage .kicker { color: var(--accent); font-weight: 800; letter-spacing: 0.2em; font-size: clamp(0.9rem, 1.4vw, 1.3rem); }
.stage .big-num { font-size: clamp(3rem, 11vw, 10rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.stage .sub { color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.6rem); }
.stage .timer { width: min(900px, 90%); height: 14px; }
.lobby { display: grid; grid-template-columns: auto 1fr; gap: 5vw; align-items: center; width: min(1200px, 100%); text-align: left; }
.qr { background: #fff; border-radius: 24px; padding: 14px; width: min(42vh, 40vw, 440px); aspect-ratio: 1; }
.qr svg { display: block; width: 100%; height: 100%; }
.lobby .url { font-size: clamp(1.2rem, 2.6vw, 2.4rem); font-weight: 800; word-break: break-all; }
.lobby .code { font-size: clamp(3rem, 9vw, 8rem); font-weight: 900; letter-spacing: 0.14em; color: var(--accent); line-height: 1.1; }
.names { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; max-height: 5.5em; overflow: hidden; }
.names span { background: rgba(255, 255, 255, 0.1); border-radius: 99px; padding: 2px 14px; font-size: clamp(0.85rem, 1.3vw, 1.15rem); }
.bars { display: grid; gap: 1.6vh; width: min(1100px, 100%); }
.bar { position: relative; display: flex; align-items: center; gap: 16px; min-height: clamp(54px, 9vh, 96px); padding: 0 24px; border-radius: 16px; background: rgba(255, 255, 255, 0.08); overflow: hidden; text-align: left; font-size: clamp(1.1rem, 2.4vw, 2.2rem); font-weight: 800; }
.bar > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--tone); opacity: 0.9; transition: width 0.5s ease; }
.bar > * { position: relative; }
.bar .label { flex: 1; }
.bar .tag { display: grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 10px; background: var(--tone); box-shadow: inset 0 0 0 2px #fff5; flex: none; }
.bar.dim { opacity: 0.45; }
.bar.right { box-shadow: 0 0 0 4px #fff; }
.bar .mark { font-size: 0.6em; background: #fff; color: #111; padding: 2px 12px; border-radius: 99px; }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 0; width: min(1200px, 100%); border-radius: 24px; overflow: hidden; min-height: 34vh; }
.versus > div { display: flex; flex-direction: column; justify-content: center; padding: 3vh 2vw; background: var(--tone); }
.versus .name { font-size: clamp(1.4rem, 3.6vw, 3.6rem); font-weight: 900; }
.versus .pct { font-size: clamp(2.6rem, 8vw, 7.5rem); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tug { width: min(1100px, 100%); height: clamp(44px, 8vh, 80px); border-radius: 99px; overflow: hidden; display: flex; background: var(--c1); }
.tug > i { display: block; width: 50%; background: var(--c0); transition: width 0.4s ease; }
.tug-legend { display: flex; justify-content: space-between; width: min(1100px, 100%); font-weight: 800; font-size: clamp(1rem, 2vw, 1.8rem); font-variant-numeric: tabular-nums; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 1vh; width: min(900px, 100%); }
.rank li { display: flex; align-items: center; gap: 16px; padding: 0.5em 1em; border-radius: 14px; background: rgba(255, 255, 255, 0.08); font-size: clamp(1rem, 2.1vw, 1.9rem); font-weight: 700; text-align: left; }
.rank li:first-child { background: var(--accent); color: var(--accent-ink); }
.rank .pos { width: 1.8em; font-weight: 900; }
.rank .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .team { width: 0.7em; height: 0.7em; border-radius: 50%; flex: none; }
.team-0 { background: var(--c0); } .team-1 { background: var(--c1); }
.panel { background: var(--bg-2); border-top: 1px solid var(--line); padding: 20px; }
.panel-inner { max-width: 1040px; margin: 0 auto; }
.panel h2 { font-size: 1.1rem; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { min-height: 42px; padding: 0 18px; border-radius: 99px; border: 2px solid var(--line); background: transparent; cursor: pointer; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
.actions .spacer { flex: 1; }

/* ===== 玩家頁 ===== */
.play-body { background-attachment: scroll; overscroll-behavior: none; }
.playbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; font-size: 0.9rem; }
.play-main { flex: 1; display: flex; flex-direction: column; padding: 8px 16px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.screen { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; text-align: center; }
.screen h1 { font-size: 1.6rem; margin: 0; }
.screen .big { font-size: 4.2rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.screen .muted { color: var(--muted); margin: 0; }
.choices { display: grid; gap: 12px; flex: 1; max-height: 70vh; }
.choices.two { grid-template-rows: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 12px 18px;
  border: 0; border-radius: var(--radius); background: var(--tone); color: #fff;
  font-size: 1.25rem; font-weight: 800; text-align: left; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: transform 0.08s ease, opacity 0.2s ease;
}
.choice:active { transform: scale(0.97); }
.choice .tag { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #0003; flex: none; }
.choice.picked { box-shadow: 0 0 0 4px #fff; }
.choice.faded { opacity: 0.35; }
.choices.two .choice { justify-content: center; text-align: center; font-size: 1.7rem; }
.tap-zone {
  flex: 1; min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 28px; background: var(--tone, var(--c0)); color: #fff; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tap-zone.hit { filter: brightness(1.25); }
.tap-zone .big { font-size: 5.5rem; }
.tap-zone:disabled { opacity: 0.6; }
.verdict { font-size: 2rem; font-weight: 900; }
.verdict.good { color: #7df0a7; } .verdict.bad { color: #ffb4b6; }
.join-card { margin: auto 0; }

@media (max-width: 760px) {
  .start, .grid-3, .steps, .form-grid { grid-template-columns: 1fr; }
  .lobby { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .names { justify-content: center; }
  .site-nav { gap: 12px; font-size: 0.88rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 題庫 */
.deck { margin-bottom: 20px; padding: 18px 20px; }
.deck .note { margin: 10px 0 0; }
.deck .error-text { white-space: pre-line; }
.panel-sub { font-size: 1.05rem; margin: 0 0 12px; }
.deck-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 264px; overflow-y: auto; display: grid; gap: 6px; }
.deck-list button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); text-align: left; cursor: pointer; font-size: 0.95rem; }
.deck-list button:hover { border-color: var(--muted); }
.deck-list .num { width: 2em; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.deck-list .kind { flex: none; font-size: 0.78rem; padding: 1px 10px; border-radius: 99px; background: var(--c0); }
.deck-list .kind.sides { background: var(--c1); }
.deck-list .text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-list .played button { opacity: 0.45; }
.deck-list .up-next button { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.deck-list .up-next .num { color: var(--accent); font-weight: 800; }

/* 房間配色（主持人選擇後，來賓手機同步套用） */
[data-theme="wedding"] { --bg: #3a1528; --bg-2: #4a1c33; --surface: #5a2440; --line: #8a4a68; --muted: #f0cfdc; --glow-1: rgba(255, 210, 63, 0.25); --glow-2: rgba(255, 140, 170, 0.3); }
[data-theme="night"] { --bg: #05070f; --bg-2: #0d111f; --surface: #151b30; --line: #2b3555; --muted: #aab4d4; --glow-1: rgba(58, 134, 255, 0.18); --glow-2: rgba(46, 196, 182, 0.14); }
[data-theme="forest"] { --bg: #0c2a22; --bg-2: #11382d; --surface: #17483a; --line: #2f6f5b; --muted: #bfe3d6; --glow-1: rgba(255, 210, 63, 0.18); --glow-2: rgba(46, 196, 182, 0.25); }
[data-theme="sunset"] { --bg: #3b1436; --bg-2: #4c1a3c; --surface: #5e2344; --line: #94456a; --muted: #f3cfd9; --glow-1: rgba(255, 159, 28, 0.35); --glow-2: rgba(255, 90, 95, 0.3); }
[data-theme="ocean"] { --bg: #062a44; --bg-2: #0a3655; --surface: #104468; --line: #2a6c98; --muted: #c2def0; --glow-1: rgba(46, 196, 182, 0.3); --glow-2: rgba(58, 134, 255, 0.3); }

/* 主持人自訂背景圖（只存在主持人的裝置上） */
body.has-bg-image {
  background:
    linear-gradient(rgba(0, 0, 0, var(--dim)), rgba(0, 0, 0, var(--dim))),
    var(--bg-image) center / cover no-repeat fixed,
    var(--bg);
}
body.has-bg-image .stage h1, body.has-bg-image .stage .sub, body.has-bg-image .stage .kicker, body.has-bg-image .hostbar { text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
body.has-bg-image .stage .sub, body.has-bg-image .hostbar .join-hint { color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.swatches button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px 0 8px; border-radius: 99px; border: 2px solid var(--line); background: transparent; cursor: pointer; font-weight: 700; font-size: 0.92rem; }
.swatches button[aria-pressed="true"] { border-color: var(--accent); }
.swatches i { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--a), var(--b)); box-shadow: inset 0 0 0 1px #fff4; }
.bg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; }
.bg-row label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }

/* ===== 玩家頁：親切版 ===== */
.play-body { font-size: 18px; }
.net-banner { position: sticky; top: 0; z-index: 40; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.92rem; text-align: center; }
.me { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); font-size: 0.92rem; max-width: 62%; }
.me #me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me b { flex: none; color: var(--accent); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--tone, var(--c1)); color: #fff; font-style: normal; font-weight: 800; font-size: 0.95rem; line-height: 1; }
.avatar.xl { width: 92px; height: 92px; font-size: 2.6rem; margin: 0 auto; box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.14); }
.join-card { padding: 28px 22px; border-radius: 26px; }
.hello { text-align: center; margin-bottom: 18px; }
.hello h1 { font-size: 1.9rem; margin: 12px 0 6px; }
.hello .muted { color: var(--muted); margin: 0; font-size: 0.98rem; }
.room-chip { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 16px; padding: 8px 14px; border-radius: 14px; background: var(--bg-2); color: var(--muted); }
.room-chip b { color: var(--accent); letter-spacing: 0.18em; font-size: 1.2rem; }
.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); text-decoration: underline; font-size: 0.85rem; cursor: pointer; }
.btn.big { width: 100%; min-height: 60px; font-size: 1.2rem; }
.join-card .join-row .btn { flex: none; min-height: 50px; }
.bounce { display: flex; justify-content: center; gap: 8px; height: 22px; align-items: flex-end; }
.bounce i { width: 14px; height: 14px; border-radius: 50%; animation: bounce 1.2s ease-in-out infinite; }
.bounce i:nth-child(1) { background: var(--c0); }
.bounce i:nth-child(2) { background: var(--c1); animation-delay: 0.15s; }
.bounce i:nth-child(3) { background: var(--accent); animation-delay: 0.3s; }
.bounce i:nth-child(4) { background: var(--c3); animation-delay: 0.45s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-9px); } }
.screen p { margin: 0; }
.screen h1 { font-size: 1.65rem; }
.screen .kicker { color: var(--accent); font-weight: 800; letter-spacing: 0.16em; font-size: 0.9rem; }
.screen .tip { margin-top: 8px; padding: 12px 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); color: var(--muted); font-size: 0.88rem; }
.screen .hint { color: var(--muted); font-size: 0.98rem; }
.screen .hint.sent { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(125, 240, 167, 0.14); color: #fff; text-align: left; }
.screen .hint.sent .icon { width: 26px; height: 26px; flex: none; }
.icon { width: 76px; height: 76px; margin: 0 auto; }
.icon.ok circle { fill: #2fbf71; }
.icon.no circle { fill: rgba(255, 255, 255, 0.22); }
.screen .verdict { font-size: 1.9rem; }
.screen .verdict:not(.good):not(.bad) { color: #fff; }
.screen .answer { padding: 12px 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); }
.team-text-0 { color: var(--c0); margin: 0 4px; } .team-text-1 { color: #7fb0ff; margin: 0 4px; }
.tap-zone .tap-hint { font-size: 1.25rem; font-weight: 800; }
.tap-zone .tap-hint.count { font-size: 3.4rem; line-height: 1; }
.mini-bars { display: grid; gap: 10px; }
.mini-bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 0 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); overflow: hidden; font-weight: 800; text-align: left; }
.mini-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--tone); opacity: 0.85; }
.mini-bar > span, .mini-bar > b { position: relative; }
.mini-bar.mine { box-shadow: 0 0 0 3px #fff; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; background: var(--tone); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }
@media (prefers-reduced-motion: reduce) { .bounce i { animation: none; } }
.btn { white-space: nowrap; }

/* 全螢幕遙控列 */
.dock { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 30; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; max-width: calc(100vw - 24px); padding: 8px 14px; border-radius: 99px; background: rgba(0, 0, 0, 0.72); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.dock-on .dock, .dock:hover, .dock:focus-within { opacity: 1; pointer-events: auto; }
.dock .btn.ghost { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }
.dock-keys { color: #cfcfe6; font-size: 0.78rem; padding: 0 6px; }

/* 分組賽馬 */
.race-big { font-size: clamp(2rem, 6vw, 5rem) !important; min-height: 1em; }
.lanes { display: grid; gap: 0.8vh; width: min(1240px, 100%); }
.lane { display: grid; grid-template-columns: 5.2em 1fr 6em; align-items: center; gap: 12px; font-size: clamp(0.9rem, 1.7vw, 1.5rem); font-weight: 800; --tone: hsl(var(--hue) 85% 62%); }
.lane-name { text-align: right; color: var(--tone); white-space: nowrap; }
.lane-n { text-align: left; font-variant-numeric: tabular-nums; font-size: 0.8em; color: var(--muted); white-space: nowrap; }
.track { position: relative; height: 2.2em; border-radius: 99px; background: rgba(255, 255, 255, 0.09); border-right: 4px dashed #fff8; }
.horse { position: absolute; top: 50%; left: calc((100% - 2.6em) * var(--p, 0)); width: 2.6em; height: 1.95em; margin-top: -0.975em; color: var(--tone); transition: left 0.45s linear; }
.horse svg { display: block; width: 100%; height: 100%; }
.lane.running .horse svg { animation: gallop 0.36s ease-in-out infinite alternate; }
@keyframes gallop { from { transform: translateY(1px) rotate(-5deg); } to { transform: translateY(-3px) rotate(5deg); } }
.lane.winner .track { background: rgba(255, 210, 63, 0.3); box-shadow: 0 0 0 3px var(--accent); }
.lane.winner .lane-name { color: var(--accent); }
.lanes.dense { gap: 0.5vh; }
.lanes.dense .lane { font-size: clamp(0.8rem, 2.1vh, 1.3rem); }
.lanes.dense .track { height: 1.9em; }
.lanes.dense .horse { width: 2.2em; height: 1.65em; margin-top: -0.825em; left: calc((100% - 2.2em) * var(--p, 0)); }
body.has-bg-image .track { background: rgba(0, 0, 0, 0.45); }

/* 玩家選桌 */
.group-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.group-grid button { min-height: 54px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-weight: 800; font-size: 1.15rem; cursor: pointer; touch-action: manipulation; }
.group-grid button:active { transform: scale(0.95); }
.group-chip { display: inline-flex; align-items: center; gap: 8px; margin: 0 auto; padding: 8px 8px 8px 18px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); font-weight: 800; }
.waiting-title { font-size: 1.9rem !important; }
.toast { bottom: 110px; }

/* 分組開關、獎盃 */
.seg { display: inline-flex; border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); }
.seg button { min-height: 42px; padding: 0 20px; border: 0; background: transparent; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.trophy { display: block; width: 1.25em; height: 1.25em; }
.rank li:nth-child(1) .trophy { color: var(--accent-ink); }
.rank li:nth-child(2) .trophy { color: #d3dae8; }
.rank li:nth-child(3) .trophy { color: #e0975c; }
.medal { display: inline-block; vertical-align: -0.25em; margin-right: 4px; }
.medal.m1 { color: var(--accent); } .medal.m2 { color: #d3dae8; } .medal.m3 { color: #e0975c; }
.lane { grid-template-columns: 5.6em 1fr 8em; }
.screen .trophy { width: 84px; height: 84px; margin: 0 auto; }
.screen .trophy.t1 { color: var(--accent); } .screen .trophy.t2 { color: #d3dae8; } .screen .trophy.t3 { color: #e0975c; }
select.input.group-select { font-weight: 800; font-size: 1.1rem; }
.change-row { display: flex; gap: 10px; }
.change-row .input { flex: 1; min-width: 0; }

/* 像素風素材 */
.px { display: block; image-rendering: pixelated; overflow: visible; }
.px2 .pf1 { opacity: 0; }
.px2.run .pf0 { animation: pf-a 0.3s steps(1) infinite; }
.px2.run .pf1 { animation: pf-b 0.3s steps(1) infinite; }
@keyframes pf-a { 0%, 49.9% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pf-b { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
.trophy.t2 { color: #d3dae8; } .trophy.t3 { color: #e0975c; }

/* ===== 投影與遙控檢視 ===== */
.view-screen .panel { display: none; }
.view-remote .stage, .view-remote .dock, .view-remote #screen-tools, .view-remote #fullscreen, .view-remote .join-hint { display: none !important; }
.view-remote .panel { border-top: 0; }
.remote-status { position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.92rem; }
.remote-dialog { max-width: min(420px, 92vw); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; text-align: center; }
.remote-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.remote-dialog .qr { width: 100%; margin: 12px 0; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 0.95rem; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.deck-list .kind.survive { background: var(--c3); } .deck-list .kind.number { background: var(--c2); }

/* ===== 像素風舞台元件 ===== */
.small-title { font-size: clamp(1.2rem, 2.6vw, 2.4rem) !important; }
.answer-num small { font-size: 0.35em; margin-left: 0.3em; }
.names.center { justify-content: center; max-height: none; }
.rank .pos .px { width: 1.3em; }
.medal { display: inline-block; width: 1.3em; vertical-align: -0.25em; margin-right: 6px; }
.inline { display: inline-block; width: 1.4em; vertical-align: -0.2em; margin-right: 8px; }
.hands { display: flex; gap: 5vw; justify-content: center; align-items: end; font-size: clamp(1rem, 2vw, 1.8rem); }
.hand { width: clamp(90px, 14vw, 200px); margin: 0 auto 8px; }
.hand.big { width: clamp(140px, 22vw, 300px); }
.hand.shake { animation: shake 0.5s ease-in-out infinite alternate; }
.hands > div:nth-child(2) .hand { animation-delay: 0.15s; } .hands > div:nth-child(3) .hand { animation-delay: 0.3s; }
@keyframes shake { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-14px) rotate(6deg); } }
.chant { animation: pulse 0.5s steps(2) infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.survivors { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: clamp(1.3rem, 3.2vw, 3rem); }
.survivors small { font-size: 0.5em; color: var(--muted); }
.heart { display: inline-block; width: 1.1em; animation: beat 0.8s steps(2) infinite; }
@keyframes beat { 50% { transform: scale(1.18); } }
.tug-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: min(1240px, 100%); }
.tug-row .tug { width: auto; }
.puller { display: block; width: clamp(40px, 5vw, 76px); }
.puller.flip { transform: scaleX(-1); }
.herd { display: flex; gap: 3vw; justify-content: center; }
.herd span { width: clamp(70px, 10vw, 150px); }
.gift { width: clamp(120px, 16vw, 220px); }
.bounce-big { animation: hop 0.5s steps(3) infinite alternate; }
@keyframes hop { to { transform: translateY(-22px); } }
.roll { min-height: 1.3em; color: var(--accent); }
.rank.winners li { background: rgba(255, 210, 63, 0.16); color: #fff; box-shadow: inset 0 0 0 3px var(--accent); }
.rank.winners.few li { font-size: clamp(1.6rem, 4.4vw, 4rem); justify-content: center; }
.rank.winners.few .who { flex: none; }
.rank .star { width: 1.2em; flex: none; }
.rank .tagline { font-size: 0.6em; color: var(--muted); }
.bingo-stage { display: grid; grid-template-columns: 1.15fr 1fr; gap: 4vw; width: min(1280px, 100%); align-items: start; }
.bingo-left { display: grid; justify-items: center; gap: 1.6vh; }
.ball { display: grid; place-items: center; width: clamp(120px, 17vw, 240px); aspect-ratio: 1; background: var(--accent); color: var(--accent-ink); font-size: clamp(3rem, 9vw, 8rem); font-weight: 900; box-shadow: 0 0 0 8px #fff, 0 0 0 16px var(--accent-ink), 10px 10px 0 16px rgba(0, 0, 0, 0.35); }
.ball.pop { animation: pop 0.35s steps(4); }
@keyframes pop { from { transform: scale(0.3); } }
.bingo-board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; width: 100%; }
.bingo-board i { display: grid; place-items: center; aspect-ratio: 1.25; font-style: normal; font-weight: 800; font-size: clamp(0.8rem, 1.5vw, 1.4rem); background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.bingo-board i.on { background: var(--accent); color: var(--accent-ink); }
.bingo-right .rank li { font-size: clamp(0.95rem, 1.7vw, 1.5rem); }
.lanes .horse .px { width: 100%; height: 100%; }
.track { border-radius: 6px; border-right: 6px dashed #fff; background-image: repeating-linear-gradient(90deg, transparent 0 48px, rgba(255, 255, 255, 0.06) 48px 52px); }
@media (max-width: 900px) { .bingo-stage { grid-template-columns: 1fr; } }

/* ===== 來賓頁的像素風元件 ===== */
.screen .px { margin: 0 auto; }
.screen .sprite-lg { width: 120px; }
.screen .sprite-md { width: 84px; }
.screen .trophy { width: 96px !important; height: auto !important; }
.choice, .tap-zone, .num-form .input, .bcard i { border-radius: 10px; }
.choice, .tap-zone { box-shadow: 0 6px 0 rgba(0, 0, 0, 0.32); }
.choice:active, .tap-zone:active { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.32); translate: 0 4px; }
.choices.three { grid-template-columns: repeat(3, 1fr); grid-template-rows: none; flex: none; }
.choices.three .choice { flex-direction: column; justify-content: center; text-align: center; gap: 8px; padding: 16px 6px; font-size: 1.05rem; background: var(--surface); border: 3px solid var(--line); }
.choices.three .choice .px { width: 72px; }
.choices.three .choice.picked { border-color: var(--accent); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.32); }
.num-form { display: grid; gap: 12px; }
.num-form .input { min-height: 72px; font-size: 2rem; font-weight: 900; text-align: center; }
.tap-zone .px { width: 46%; max-width: 190px; color: #fff; }
.status-row { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; }
.status-row .px { width: 34px; margin: 0; }
.bcard { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; max-width: 380px; margin: 0 auto; }
.bcard i { display: grid; place-items: center; aspect-ratio: 1; font-style: normal; font-weight: 900; font-size: 1.3rem; background: var(--surface); border: 2px solid var(--line); }
.bcard i.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bcard i.free { font-size: 0.8rem; }
.bcard i.last { animation: pop 0.35s steps(4); box-shadow: 0 0 0 3px #fff; }
.ball-sm { display: inline-grid; place-items: center; min-width: 2.2em; height: 2.2em; margin: 0 6px; background: var(--accent); color: var(--accent-ink); font-weight: 900; box-shadow: 0 0 0 3px #fff; }
.px2.alt .pf0 { opacity: 0; } .px2.alt .pf1 { opacity: 1; }
.rank li:first-child { background: rgba(255, 210, 63, 0.2); color: #fff; box-shadow: inset 0 0 0 3px var(--accent); }
.ball { width: clamp(96px, 11vw, 170px); font-size: clamp(2.4rem, 6vw, 5.5rem); }
.bingo-board i { aspect-ratio: 1.7; }
.tap-zone .px { color: #fff; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.25)); }

/* 搖搖火箭 */
.pads { display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 2vw, 28px); width: min(1240px, 100%); }
.pad { flex: 1; max-width: 130px; display: grid; justify-items: center; gap: 4px; font-size: clamp(0.8rem, 1.5vw, 1.3rem); font-weight: 800; --tone: hsl(var(--hue) 85% 62%); }
.pad b { color: var(--tone); white-space: nowrap; }
.pad span { min-height: 1.5em; font-size: 0.85em; color: var(--muted); white-space: nowrap; }
.sky { position: relative; width: 100%; height: clamp(180px, 40vh, 420px); border-bottom: 6px solid var(--tone); background: linear-gradient(to top, rgba(255, 255, 255, 0.1), transparent); }
.rocket { position: absolute; left: 50%; bottom: calc((100% - 5.2em) * var(--p, 0)); width: 3.4em; margin-left: -1.7em; color: var(--tone); transition: bottom 0.9s linear; }
.pad.winner .sky { box-shadow: inset 0 0 0 3px var(--accent); background: rgba(255, 210, 63, 0.18); }
.pad.winner b { color: var(--accent); }
.tap-zone.shake-on { animation: wiggle 0.25s steps(2) infinite alternate; }
@keyframes wiggle { from { rotate: -3deg; } to { rotate: 3deg; } }
