/* CQ 學員手機版面。顏色一律用 theme.css 的變數；手機跟著系統深淺色，也可以手動切換。 */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--font-body); font-weight: 500; line-height: 1.5; min-height: 100dvh; padding-inline: 16px; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden], .hidden { display: none !important; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.shell { max-width: 480px; min-height: 100dvh; margin-inline: auto; padding-block: 14px 22px; display: flex; flex-direction: column; gap: 12px; }
#root { flex: 1; display: flex; flex-direction: column; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-num); font-weight: 900; font-size: 28px; color: var(--ink); text-decoration: none; }
.dots { display: flex; gap: 5px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.pills { display: flex; gap: 6px; align-items: center; min-width: 0; }
.pill { background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; box-shadow: var(--shadow); }
.pill.bad { color: var(--bad); }
button.pill { border: 0; cursor: pointer; }

.card { background: var(--surface); border-radius: 28px; padding: 24px; display: grid; gap: 16px; text-align: center; box-shadow: var(--shadow); }
.card h1 { font-size: 30px; font-weight: 900; line-height: 1.25; text-wrap: balance; }
.card h2 { font-size: 22px; font-weight: 900; line-height: 1.3; text-wrap: balance; }
.sub { color: var(--muted); font-size: 16px; font-weight: 700; }
.nick { justify-self: center; max-width: 100%; overflow-wrap: anywhere; background: var(--surface2); border-radius: 999px; padding: 10px 20px; font-size: 26px; font-weight: 900; }

/* 加入 */
.field { width: 100%; min-width: 0; background: var(--surface2); color: var(--ink); border: 2px solid transparent; border-radius: 999px; padding: 14px 20px; font-size: 20px; font-weight: 700; text-align: center; }
.field::placeholder { color: var(--muted); font-weight: 500; }
.field:focus { outline: none; border-color: var(--accent); }
.field.pin { font-family: var(--font-num); font-size: 32px; font-weight: 900; letter-spacing: 0.14em; }
.nick-row { display: flex; gap: 8px; }
.dice { flex: none; border: 0; border-radius: 999px; background: var(--surface2); color: var(--ink); padding: 0 16px; font-size: 16px; font-weight: 900; cursor: pointer; }
.go { appearance: none; display: block; width: 100%; border: 0; border-radius: 999px; background: var(--accent); color: var(--onaccent); padding: 16px; font-size: 21px; font-weight: 900; text-align: center; text-decoration: none; cursor: pointer; box-shadow: var(--press); }
.go:disabled { opacity: 0.4; cursor: not-allowed; }
.hint { font-size: 15px; font-weight: 700; color: var(--muted); text-align: center; }
.err { color: var(--bad); font-weight: 700; min-height: 1.3em; }
.foot { text-align: center; font-size: 15px; }
.foot a { color: var(--muted); font-weight: 700; }

/* 作答提示 */
.tip { align-self: center; justify-self: center; background: var(--accent); color: var(--onaccent); border-radius: 999px; padding: 6px 16px; font-size: 16px; font-weight: 900; text-align: center; }

/* 讀題 */
.ring { width: 132px; aspect-ratio: 1; border-radius: 50%; justify-self: center; display: grid; place-items: center; background: var(--surface2); border: 10px solid var(--accent); }
.ring b { font-family: var(--font-num); font-weight: 900; font-size: 56px; line-height: 1; }

/* 作答 */
.play { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.qbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 16px; font-weight: 900; }
.countdown { font-family: var(--font-num); font-weight: 900; font-size: 30px; line-height: 1; min-width: 2ch; text-align: right; }
.qtext { background: var(--surface); border-radius: 22px; padding: 16px 18px; font-size: 21px; font-weight: 900; line-height: 1.35; text-align: center; text-wrap: balance; box-shadow: var(--shadow); }
.choices { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 12px; min-height: 280px; }
.choice { appearance: none; border: 0; border-radius: 26px; background: var(--c); color: var(--cink); display: grid; place-items: center; align-content: center; gap: 10px; padding: 14px 10px; min-height: 120px; font-size: 21px; font-weight: 900; line-height: 1.3; cursor: pointer; box-shadow: var(--press); touch-action: manipulation; }
.choice:active { transform: translateY(3px); }
.choice svg { width: 50px; height: 50px; }
.play.pad .choice svg { width: 68px; height: 68px; }
.choice:disabled { opacity: 0.35; cursor: default; }
.choice.picked { opacity: 1; outline: 5px solid var(--ink); outline-offset: 3px; }
.picked-shape { width: 96px; height: 96px; justify-self: center; border-radius: 28px; background: var(--c); color: var(--cink); display: grid; place-items: center; box-shadow: var(--press); }
.picked-shape svg { width: 60%; height: 60%; }

.conf { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.conf button { border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 700; cursor: pointer; }
.conf button.on { background: var(--accent); border-color: var(--accent); color: var(--onaccent); }
.order { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order li { display: flex; align-items: center; gap: 8px; background: var(--surface2); border-radius: 18px; padding: 10px 12px; text-align: left; font-weight: 900; }
.order li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.order button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); font-size: 18px; cursor: pointer; }
.slider-value { font-family: var(--font-num); font-weight: 900; font-size: 56px; line-height: 1; color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.teams button { border: 0; border-top: 6px solid var(--c); background: var(--surface2); color: var(--ink); border-radius: 18px; padding: 12px 10px; display: grid; gap: 4px; font-size: 17px; font-weight: 900; cursor: pointer; }
.teams button small { font-family: var(--font-num); font-weight: 800; color: var(--muted); }
.teams button.mine { background: var(--accent); color: var(--onaccent); }
.teams button.mine small { color: var(--onaccent); }
.teams button:disabled { opacity: 0.35; cursor: not-allowed; }

/* 結果：整張卡片變色，一眼看出對錯 */
.result { flex: 1; border-radius: 28px; padding: 28px 22px; display: grid; align-content: center; justify-items: center; gap: 14px; text-align: center; box-shadow: var(--press); animation: pop 0.35s ease-out; }
.result.good { background: var(--good); color: var(--ongood); }
.result.bad { background: var(--bad); color: var(--onbad); }
.result.neutral { background: var(--accent); color: var(--onaccent); }
.result h1 { font-size: 38px; font-weight: 900; line-height: 1.2; }
.result .step-no { font-size: 15px; font-weight: 700; }
.points { font-family: var(--font-num); font-weight: 900; font-size: 60px; line-height: 1; background: rgba(0, 0, 0, 0.14); border-radius: 22px; padding: 10px 22px; }
.streak { background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 16px; font-weight: 900; }
.rank-line { font-size: 22px; font-weight: 900; }
.rank-line b { font-family: var(--font-num); font-size: 34px; }
.gap { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.total { font-size: 16px; font-weight: 700; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }

/* 結束 */
.medal { width: 120px; aspect-ratio: 1; border-radius: 50%; justify-self: center; display: grid; place-items: center; font-family: var(--font-num); font-weight: 900; font-size: 56px; color: var(--medal-ink); box-shadow: var(--press); animation: pop 0.6s ease-out; }
.medal.m1 { background: var(--gold); }
.medal.m2 { background: var(--silver); }
.medal.m3 { background: var(--bronze); }
.big-number { font-family: var(--font-num); font-weight: 900; font-size: 56px; line-height: 1; color: var(--accent); }

.wait { display: flex; justify-content: center; gap: 8px; }
.wait i { width: 12px; height: 12px; border-radius: 50%; display: block; animation: bounce 1.2s ease-in-out infinite; }
.wait i:nth-child(2) { animation-delay: 0.15s; }
.wait i:nth-child(3) { animation-delay: 0.3s; }
.wait i:nth-child(4) { animation-delay: 0.45s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- 開場說明 ---------- */
.intro-phone { text-align: left; }
.intro-phone h1, .intro-phone > .sub { text-align: center; }
.type-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.type-list li { display: flex; gap: 12px; align-items: center; }
.type-list b { display: block; font-size: 17px; font-weight: 900; }
.type-list span:not(.type-badge) { display: block; font-size: 14px; font-weight: 700; color: var(--muted); }
.type-badge { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--c); color: var(--cink); display: grid; place-items: center; }
.type-badge svg { width: 60%; height: 60%; }
.rule-list { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; font-size: 16px; font-weight: 700; text-align: left; }
.rule-list li::marker { color: var(--accent); font-weight: 900; }

/* ---------- 隊伍取名 ---------- */
.team-form { display: grid; gap: 10px; border-top: 2px dashed var(--line); padding-top: 14px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon { border: 2px solid transparent; background: var(--surface2); border-radius: 12px; aspect-ratio: 1; font-size: 22px; cursor: pointer; padding: 0; }
.icon.on { border-color: var(--accent); background: var(--surface); }

/* ---------- 手機遙控 ---------- */
.remote { gap: 18px; }
.remote-actions { display: grid; gap: 12px; }
.go.secondary { background: var(--surface2); color: var(--ink); box-shadow: none; }
.stat-big { display: grid; justify-items: center; gap: 2px; }
.stat-big b { font-size: 52px; font-weight: 900; color: var(--accent); line-height: 1; }
.stat-big span { font-weight: 700; color: var(--muted); }
.answer-line { font-size: 20px; font-weight: 700; }
.answer-line b { color: var(--good); }
.end-game { justify-self: center; color: var(--bad); }

/* ---------- 結束畫面（2026-09-15 改版） ---------- */
.finale-phone { flex: 1; position: relative; isolation: isolate; overflow: hidden; background: var(--surface); border-radius: 32px; padding: 32px 22px 24px; display: grid; align-content: center; justify-items: center; gap: 16px; text-align: center; box-shadow: var(--shadow); }
.finale-phone::before { content: ""; position: absolute; inset: -30% -30% auto; height: 70%; background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--medal, var(--accent)) 34%, transparent), transparent 68%); z-index: -1; }
.finale-phone.podium-1 { --medal: var(--gold); }
.finale-phone.podium-2 { --medal: var(--silver); }
.finale-phone.podium-3 { --medal: var(--bronze); }
.finale-phone .kicker { font-size: 14px; font-weight: 900; letter-spacing: 0.16em; color: var(--muted); }
.finale-phone h1 { font-size: 32px; font-weight: 900; line-height: 1.2; text-wrap: balance; }
.finale-phone .medal { position: relative; width: 132px; font-size: 60px; background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--medal, var(--accent)) 55%, #FFFFFF), var(--medal, var(--accent)) 58%, color-mix(in srgb, var(--medal, var(--accent)) 80%, #000000)); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.6), inset 0 -8px 0 rgba(0, 0, 0, 0.12), 0 16px 34px color-mix(in srgb, var(--medal, var(--accent)) 45%, transparent); }
.finale-phone .medal::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.45); }
.finale-phone .medal.thanks { --medal: var(--accent); color: var(--onaccent); font-size: 54px; }
.finale-phone .hush-medal { --medal: var(--track); color: var(--muted); animation: breathe 1.8s ease-in-out infinite; }
.final-stats { display: flex; justify-content: center; gap: 10px; width: 100%; flex-wrap: wrap; }
.final-stats div { flex: 1; min-width: 88px; background: var(--surface2); border-radius: 20px; padding: 12px 8px; display: grid; gap: 2px; }
.final-stats b { font-size: 34px; font-weight: 900; line-height: 1; color: var(--accent); }
.final-stats span { font-size: 13px; font-weight: 700; color: var(--muted); }
@keyframes breathe { 50% { transform: scale(0.94); opacity: 0.7; } }
/* 光暈鋪滿整張卡片、柔和淡出，不留硬邊 */
.finale-phone::before { inset: 0; height: auto; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--medal, var(--accent)) 30%, transparent) 0%, transparent 62%); }

/* 手機卡片裡的格線不能把卡片撐寬 */
.card > * { min-width: 0; }
.teams { grid-template-columns: repeat(auto-fill, minmax(min(132px, 100%), 1fr)); }
.icon-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.icon { min-width: 0; font-size: clamp(16px, 5vw, 22px); }
.nick-row .field { min-width: 0; }

/* ---------- 翻牌看正確答案 ---------- */
.flip { flex: 1; display: flex; perspective: 1400px; cursor: pointer; min-height: 520px; -webkit-tap-highlight-color: transparent; }
.flip:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 28px; }
.flip-inner { position: relative; flex: 1; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; animation: none; }
.face.back { transform: rotateY(180deg); }
.flip-hint { font-size: 15px; font-weight: 900; background: rgba(0, 0, 0, 0.16); border-radius: 999px; padding: 6px 16px; }
.answer-face { background: var(--surface); color: var(--ink); border: 3px solid var(--good); }
.answer-face .flip-hint { background: var(--surface2); color: var(--muted); }
.answer-kicker { font-size: 14px; font-weight: 900; letter-spacing: 0.14em; color: var(--good); }
.answer-face h2 { font-size: 20px; font-weight: 900; line-height: 1.35; text-wrap: balance; }
.answer-chip { display: flex; align-items: center; gap: 12px; background: var(--c); color: var(--cink); border-radius: 22px; padding: 14px 22px; font-size: 26px; font-weight: 900; box-shadow: var(--press); max-width: 100%; }
.answer-chip svg { width: 40px; height: 40px; flex: none; }
.answer-chip span { overflow-wrap: anywhere; }
.answer-order { margin: 0; padding-left: 1.6em; text-align: left; display: grid; gap: 6px; font-size: 20px; font-weight: 900; }
.answer-order li::marker { color: var(--good); }
.answer-number { font-size: 64px; font-weight: 900; line-height: 1; color: var(--good); }
.answer-note { font-size: 15px; font-weight: 700; color: var(--muted); }
.your-answer { font-size: 17px; font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.your-answer b { color: var(--bad); }

/* ---------- 題目圖片 ---------- */
.q-image { display: block; width: 100%; max-height: 30vh; object-fit: contain; background: #FFFFFF; border-radius: 18px; box-shadow: var(--shadow); }

/* Logo：四格色塊（2026-09-15 Miles 選定 B） */
.brand .logo { width: 1.15em; height: 1.15em; flex: none; }
.ver { font-family: var(--font-num); font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: 0.02em; }

/* 雙倍分數：出題前全螢幕「2×」，不擋作答 */
.double-splash { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 6px; pointer-events: none; background: var(--accent); color: var(--onaccent); animation: splash-fade 2.6s ease both; }
.double-splash b { font-family: var(--font-num); font-weight: 900; font-size: clamp(120px, 22vw, 320px); line-height: 1; text-shadow: 0 8px 0 rgba(0, 0, 0, 0.18); animation: splash-pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.double-splash span { font-weight: 900; font-size: clamp(28px, 4vw, 64px); animation: splash-pop 0.7s 0.12s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes splash-pop { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splash-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .double-splash, .double-splash b, .double-splash span { animation-duration: 0.01s; } .double-splash { animation: splash-fade 2.6s steps(1, end) both; } }
.foot .ver { margin-left: 10px; }
.gap.small { font-size: 14px; opacity: 0.85; }
.points.soft { font-size: 34px; }
