:root {
  --c0: #e2384d;
  --c1: #2a6fdb;
  --c2: #d99a00;
  --c3: #21995a;
  --bg1: #5c0a1a;
  --bg2: #a3132f;
  --gold: #f6c453;
  --ink: #1d1d27;
  --ok: #1f9d55;
  --bad: #d23a3a;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  color: #fff;
  background: radial-gradient(circle at 20% 10%, var(--bg2), var(--bg1) 70%) fixed;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; border: 0; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.btn {
  background: #fff; color: var(--ink); padding: .7em 1.4em; border-radius: 10px; font-weight: 800;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn.gold { background: var(--gold); }
.btn.dark { background: #2b2b38; color: #fff; }
.btn.ghost { background: rgba(255,255,255,.15); color: #fff; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); }
.shape { flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 99;
  background: #fff; color: var(--bad); padding: 12px 18px; border-radius: 10px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw;
}
.offline {
  position: fixed; bottom: 0; left: 0; right: 0; background: #000c; text-align: center; padding: 6px; font-size: 14px; z-index: 98;
}

/* ---------- 彩帶 ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg); } }

/* =================================================================== */
/*  玩家手機                                                           */
/* =================================================================== */
body.player { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.p-top, .p-bottom {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: rgba(0,0,0,.25); font-weight: 700;
}
.p-bottom { background: #fff; color: var(--ink); }
.p-bottom .score { background: #2b2b38; color: #fff; padding: 4px 12px; border-radius: 6px; }
.p-main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; text-align: center; }
.logo { font-size: 38px; font-weight: 900; letter-spacing: 2px; margin-bottom: 18px; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.logo small { display: block; font-size: 15px; color: var(--gold); letter-spacing: 6px; }
.card {
  background: #fff; color: var(--ink); border-radius: 12px; padding: 16px; width: min(340px, 92vw);
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.card input {
  padding: 14px; border: 2px solid #ccc; border-radius: 8px; text-align: center; font-size: 20px; font-weight: 800;
}
.card input:focus { outline: none; border-color: var(--bg2); }
.card .btn { background: #2b2b38; color: #fff; font-size: 18px; }
.big { font-size: 30px; font-weight: 900; margin: 6px 0; }
.sub { opacity: .85; font-size: 17px; }
.spinner { width: 54px; height: 54px; border: 6px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-question { font-size: 18px; font-weight: 700; background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; width: 100%; }

.answers { flex: 1; width: 100%; display: grid; gap: 10px; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; min-height: 0; }
.answers.n2 { grid-template-columns: 1fr; }
.ans {
  position: relative; border-radius: 10px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 34px 8px 8px; min-height: 0; overflow: hidden; box-shadow: 0 5px 0 rgba(0,0,0,.25); font-weight: 800;
}
.ans:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.ans .shape { position: absolute; left: 8px; top: 8px; }
.ans .img { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.ans .img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; }
.ans .txt { line-height: 1.25; word-break: break-word; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.ans .img + .txt { margin-top: 6px; font-size: 15px; }
.timebar { width: 100%; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; margin-bottom: 10px; overflow: hidden; }
.timebar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }

.picked { width: 140px; height: 120px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 14px auto; }
body.player.res-ok { background: var(--ok); }
body.player.res-bad { background: var(--bad); }
.mark { width: 92px; height: 92px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 56px; margin: 10px auto; font-weight: 900; }
.res-ok .mark { color: var(--ok); } .res-bad .mark { color: var(--bad); }
.pts { display: inline-block; background: rgba(0,0,0,.3); padding: 8px 22px; border-radius: 8px; font-size: 26px; font-weight: 900; margin: 8px 0; }
.rankpill { background: rgba(0,0,0,.3); border-radius: 10px; padding: 12px 18px; margin-top: 18px; font-size: 18px; font-weight: 700; }
.medal { font-size: 90px; }

/* =================================================================== */
/*  主持人：編輯器                                                      */
/* =================================================================== */
body.host-edit { background: #f3f0ee; color: var(--ink); }
.ed-bar {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 20px; background: var(--bg1); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.ed-bar h1 { font-size: 20px; margin: 0 10px 0 0; white-space: nowrap; }
.ed-bar input.title { flex: 1; min-width: 200px; padding: 9px 12px; border-radius: 8px; border: 0; font-size: 17px; font-weight: 700; }
.ed-bar .btn { padding: .55em 1em; }
.ed-wrap { max-width: 980px; margin: 0 auto; padding: 20px; }
.resume { background: #fff7df; border: 2px solid var(--gold); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; }
.qcard { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.qhead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.qhead b { font-size: 18px; margin-right: auto; }
.icon-btn { background: #eee; border-radius: 6px; padding: 5px 10px; font-size: 14px; }
.icon-btn:hover { background: #ddd; }
.icon-btn.danger:hover { background: #fdd; }
.qrow { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.qrow textarea { flex: 1; min-width: 260px; min-height: 64px; padding: 10px; font-size: 17px; font-weight: 700; border: 2px solid #ddd; border-radius: 8px; resize: vertical; }
.qrow select { padding: 8px; border-radius: 8px; border: 2px solid #ddd; }
.meta { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.meta label { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.imgslot { width: 150px; height: 100px; border: 2px dashed #ccc; border-radius: 8px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; color: #888; font-size: 13px; cursor: pointer; text-align: center; background: #fafafa; flex: none; }
.imgslot img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.imgslot .x { position: absolute; top: 3px; right: 3px; background: #000a; color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: 13px; line-height: 22px; padding: 0; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.opt { border-radius: 10px; padding: 8px; display: flex; gap: 8px; align-items: center; color: #fff; }
.opt input[type=text] { flex: 1; min-width: 0; padding: 9px; border-radius: 6px; border: 0; font-size: 15px; font-weight: 700; }
.opt .imgslot { width: 64px; height: 50px; border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.15); color: #fff; font-size: 11px; }
.correct { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; background: transparent; color: transparent; font-weight: 900; font-size: 18px; flex: none; padding: 0; }
.correct.on { background: #fff; color: var(--ok); }
.opt-add { border: 2px dashed #bbb; border-radius: 10px; background: transparent; color: #777; min-height: 50px; }
.err { color: var(--bad); font-weight: 700; font-size: 14px; margin-top: 6px; }
.hint { color: #666; font-size: 14px; line-height: 1.6; }

/* =================================================================== */
/*  主持人：大螢幕                                                      */
/* =================================================================== */
body.host-game { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.hg-bar { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 1.2vh 1.5vw; gap: 10px; font-weight: 800; font-size: 2vh; }
.hg-bar .ctrl { display: flex; gap: 8px; }
.hg-bar .btn { padding: .5em 1em; }
.hg-main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 2vw 2vh; }

.lobby-top { display: flex; gap: 2vw; align-items: stretch; justify-content: center; }
.joinbox { background: #fff; color: var(--ink); border-radius: 14px; padding: 2vh 2.5vw; display: flex; flex-direction: column; justify-content: center; }
.joinbox .url { font-size: 2.6vh; font-weight: 700; }
.joinbox .pinlabel { font-size: 2.4vh; margin-top: 1vh; color: #555; font-weight: 700; }
.joinbox .pin { font-size: 11vh; font-weight: 900; letter-spacing: .5vw; line-height: 1; }
.qrbox { background: #fff; border-radius: 14px; padding: 1vh; }
.qrbox img { height: 28vh; width: 28vh; display: block; }
.lobby-mid { display: flex; justify-content: space-between; align-items: center; margin: 2vh 0 1.5vh; }
.count { background: rgba(0,0,0,.3); padding: .6vh 1.2vw; border-radius: 10px; font-size: 3vh; font-weight: 900; }
.lobby-title { font-size: 4.5vh; font-weight: 900; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.names { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; gap: 1.2vh; align-content: flex-start; justify-content: center; }
.names button { background: rgba(255,255,255,.95); color: var(--ink); padding: 1vh 1.4vw; border-radius: 8px; font-size: 2.8vh; font-weight: 800; animation: pop .3s; }
.names button:hover { text-decoration: line-through; background: #fdd; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.toggles { display: flex; gap: 14px; font-size: 1.8vh; align-items: center; }
.toggles label { display: flex; gap: 5px; align-items: center; cursor: pointer; }

.qtitle { background: #fff; color: var(--ink); border-radius: 12px; padding: 2vh 2vw; font-size: 4.4vh; font-weight: 900; text-align: center; line-height: 1.3; flex: none; }
.intro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh; }
.intro .qtitle { font-size: 6vh; max-width: 85vw; padding: 4vh 4vw; animation: pop .4s; }
.introbar { width: 60vw; height: 1.4vh; background: rgba(255,255,255,.2); border-radius: 1vh; overflow: hidden; }
.introbar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.badge { display: inline-block; background: var(--gold); color: var(--ink); padding: .5vh 1.2vw; border-radius: 30px; font-weight: 900; font-size: 2.6vh; }

.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: space-between; gap: 2vw; padding: 2vh 0; }
.timer { width: 15vh; height: 15vh; border-radius: 50%; background: var(--gold); color: var(--ink); display: flex; align-items: center; justify-content: center; font-size: 7vh; font-weight: 900; flex: none; box-shadow: 0 .6vh 0 rgba(0,0,0,.25); }
.timer.low { background: #fff; color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.qimg { flex: 1; height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
.qimg img { max-height: 100%; max-width: 100%; border-radius: 10px; object-fit: contain; background: #fff; }
.acount { text-align: center; font-size: 2.6vh; font-weight: 800; flex: none; width: 15vh; }
.acount b { display: block; font-size: 8vh; line-height: 1; }

.hopts { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vh; height: 34vh; }
.hopt { border-radius: 10px; display: flex; align-items: center; gap: 1.5vw; padding: 1vh 1.5vw; font-size: 3.6vh; font-weight: 800; min-height: 0; overflow: hidden; box-shadow: 0 .5vh 0 rgba(0,0,0,.25); position: relative; }
.hopt img { height: 100%; max-width: 45%; object-fit: contain; background: #fff; border-radius: 6px; }
.hopt .t { flex: 1; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.hopt .ok { font-size: 5vh; }
.hopt.dim { opacity: .3; }

.chart { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: center; gap: 2vw; padding: 2vh 0; }
.bar { width: 12vw; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar .col { width: 100%; border-radius: 8px 8px 0 0; min-height: 1vh; transition: height .8s cubic-bezier(.2,.9,.3,1.2); }
.bar .lbl { width: 100%; display: flex; align-items: center; justify-content: center; gap: .6vw; padding: 1vh 0; font-size: 3.6vh; font-weight: 900; border-radius: 0 0 8px 8px; }
.bar.dim { opacity: .35; }

.board { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1.6vh; padding-top: 2vh; }
.board h2 { font-size: 6vh; margin: 0 0 1vh; background: #fff; color: var(--ink); padding: 1vh 4vw; border-radius: 12px; }
.row { width: min(70vw, 1000px); background: #fff; color: var(--ink); border-radius: 10px; display: flex; align-items: center; padding: 1.6vh 2vw; font-size: 3.6vh; font-weight: 900; gap: 1.5vw; animation: slidein .5s backwards; }
.row:first-of-type { background: var(--gold); }
.row .nm { flex: 1; } .row .up { color: var(--ok); font-size: 2.6vh; }
@keyframes slidein { from { transform: translateX(-40px); opacity: 0; } }

.podium { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 1.5vw; }
.pcol { width: 22vw; display: flex; flex-direction: column; align-items: center; opacity: 0; transform: translateY(40px); transition: all .7s cubic-bezier(.2,.9,.3,1.3); }
.pcol.show { opacity: 1; transform: none; }
.pcol .pname { font-size: 4.4vh; font-weight: 900; background: #fff; color: var(--ink); padding: 1vh 1.5vw; border-radius: 10px; margin-bottom: 1.5vh; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcol .pscore { font-size: 2.8vh; font-weight: 800; margin-bottom: 1vh; }
.pcol .block { width: 100%; background: linear-gradient(#ffe08a, #d49b12); color: var(--bg1); border-radius: 10px 10px 0 0; display: flex; justify-content: center; padding-top: 2vh; font-size: 10vh; font-weight: 900; }
.pcol.p2 .block { background: linear-gradient(#f0f0f0, #a9aeb6); }
.pcol.p3 .block { background: linear-gradient(#f3c49a, #b06a33); }
.hopt .shape { width: 5vh; height: 5vh; }
.bar .lbl .shape { width: 3.4vh; height: 3.4vh; }
body.host-game #app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dlg-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.dlg { background: #fff; color: var(--ink); border-radius: 14px; padding: 22px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.4); font-size: 18px; }
.dlg-msg { font-weight: 700; line-height: 1.5; white-space: pre-line; }
.dlg-in { padding: 12px; border: 2px solid #ccc; border-radius: 8px; font-size: 18px; }
.dlg-in:focus { outline: none; border-color: var(--bg2); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 10px; }
.btn.ghost-dark { background: #eee; color: var(--ink); box-shadow: none; }
