/* ============================================================
   派對遊戲 — 設計系統 (Apple 質感)
   - SF Pro 字體棧、系統色、大圓角、玻璃模糊、流暢轉場
   ============================================================ */

:root {
  /* 系統色 (Apple) */
  --blue:   #0A84FF;
  --green:  #30D158;
  --red:    #FF453A;
  --orange: #FF9F0A;
  --purple: #BF5AF2;
  --pink:   #FF375F;
  --yellow: #FFD60A;
  --teal:   #64D2FF;

  /* 中性 */
  --bg:        #f5f5f7;   /* Apple 經典淺灰底 */
  --bg-grad-1: #fbfbfd;
  --surface:   #ffffff;
  --label:     #1d1d1f;   /* Apple 近黑 */
  --label-2:   #6e6e73;   /* 次要灰 */
  --label-3:   #86868b;
  --separator: rgba(0,0,0,0.08);
  --hairline:  rgba(0,0,0,0.12);

  /* 圓角 */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 28px;
  --r-xl: 40px;

  /* 陰影 */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.12);
  --shadow-glow: 0 12px 40px rgba(10,132,255,0.25);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(10,132,255,0.10), transparent 60%),
    radial-gradient(1000px 500px at 0% 110%, rgba(191,90,242,0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---------- 版面 ---------- */
.app { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

.screen { display: none; animation: fadeUp 0.5s var(--ease) both; }
.screen.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- 頂部導覽 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; margin: 0 -20px 8px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.topbar .brand { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, #0A84FF, #BF5AF2); color: #fff; font-size: 17px; box-shadow: 0 5px 14px -4px rgba(10,132,255,.55), inset 0 1px 0 rgba(255,255,255,.4); }
.topbar .actions { display: flex; gap: 8px; }

/* ---------- 標題 ---------- */
.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 {
  font-size: clamp(34px, 6vw, 64px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  background: linear-gradient(120deg, #1d1d1f, #434348);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { margin-top: 14px; font-size: clamp(16px, 2.4vw, 21px); color: var(--label-2); font-weight: 400; }

/* ---------- 按鈕 ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 17px; cursor: pointer;
  border: none; border-radius: 980px; padding: 13px 26px;
  background: var(--blue); color: #fff;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.2s var(--ease), background 0.2s, opacity 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: scale(1.04); box-shadow: var(--shadow-glow); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary { background: rgba(0,0,0,0.05); color: var(--label); }
.btn.secondary:hover { background: rgba(0,0,0,0.08); box-shadow: var(--shadow-sm); }
.btn.ghost { background: transparent; color: var(--blue); box-shadow: none; padding: 10px 16px; }
.btn.ghost:hover { background: rgba(10,132,255,0.08); box-shadow: none; }
.btn.success { background: var(--green); }
.btn.success:hover { box-shadow: 0 12px 40px rgba(48,209,88,0.3); }
.btn.danger { background: var(--red); }
.btn.danger:hover { box-shadow: 0 12px 40px rgba(255,69,58,0.3); }
.btn.lg { font-size: 20px; padding: 17px 38px; }
.btn.xl { font-size: 24px; padding: 22px 48px; border-radius: 28px; }
.btn.block { display: flex; width: 100%; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); padding: 28px; border: 1px solid rgba(255,255,255,0.6);
}

/* ---------- 遊戲選擇格 ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 16px; }
.game-tile {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: var(--r-lg); padding: 30px 26px; min-height: 200px;
  background: var(--surface); box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,0.04);
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease);
  display: flex; flex-direction: column; justify-content: space-between;
}
.game-tile::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s var(--ease);
  background: radial-gradient(600px 200px at 50% 0%, var(--tile-color, var(--blue)), transparent 70%);
  filter: opacity(0.14);
}
.game-tile:hover { transform: translateY(-6px) scale(1.01); box-shadow: var(--shadow-lg); }
.game-tile:hover::before { opacity: 1; }
.game-tile .emoji { font-size: 52px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12)); }
/* 圖示徽章：漸層圓角方塊 + 光暈，Apple App icon 風格 */
.icon-badge {
  width: 68px; height: 68px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff;
  background: linear-gradient(145deg, var(--badge), color-mix(in srgb, var(--badge) 65%, #000));
  box-shadow: 0 8px 22px -6px var(--badge), inset 0 1px 0 rgba(255,255,255,0.4);
}
.game-tile:hover .icon-badge { transform: scale(1.06) rotate(-3deg); transition: transform 0.3s var(--ease-spring); }

/* ============ 橫向輪播 (首頁) ============ */
.hero-sm { padding: 28px 0 14px; }
.carousel-wrap { position: relative; }
.carousel {
  display: flex; gap: 22px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 44px max(20px, calc(50% - 150px)); scroll-padding: 0 max(20px, calc(50% - 150px));
  scrollbar-width: none; -ms-overflow-style: none; scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 15%, #000 85%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 15%, #000 85%, transparent 100%);
}
.carousel::-webkit-scrollbar { display: none; }
.cara-card {
  flex: 0 0 300px; height: 380px; scroll-snap-align: center; cursor: pointer;
  border-radius: 32px; position: relative; overflow: hidden; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 30px;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  box-shadow: 0 20px 50px -16px var(--c1);
  transform: scale(0.7); opacity: 0.4;
  transition: transform 0.5s var(--ease-spring), opacity 0.5s var(--ease), box-shadow 0.5s;
}
.cara-card.is-active { transform: scale(1); opacity: 1; box-shadow: 0 30px 70px -18px var(--c1); }
.cara-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.28), transparent 55%);
}
.cara-card .ghost-icon {
  position: absolute; top: -12px; right: -8px; font-size: 190px; opacity: 0.16;
  transform: rotate(-12deg); line-height: 1;
}
/* 懸停：光澤掃過 + 卡片微抬 + 圖示浮動 (Poki 風) */
.cara-card .shine {
  position: absolute; top: 0; left: -60%; width: 50%; height: 100%; z-index: 3; pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.45), transparent);
  transform: skewX(-18deg);
}
.cara-card:hover { transform: scale(1.04) translateY(-6px); }
.cara-card.is-active:hover { transform: scale(1.05) translateY(-8px); }
.cara-card:hover .shine { animation: shineSweep 0.85s var(--ease) forwards; }
@keyframes shineSweep { to { left: 130%; } }
.cara-card:hover .ghost-icon { animation: floatIcon 2.2s ease-in-out infinite; }
@keyframes floatIcon { 0%,100% { transform: rotate(-12deg) translateY(0); } 50% { transform: rotate(-8deg) translateY(-14px); } }
.cara-card:hover .badge2 { transform: scale(1.08) rotate(-4deg); transition: transform 0.3s var(--ease-spring); }

.cara-card .badge2 {
  width: 60px; height: 60px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: rgba(255,255,255,0.22); backdrop-filter: blur(6px); margin-bottom: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}
.cara-card h3 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; position: relative; }
.cara-card .mini { font-size: 14px; opacity: 0.9; margin-top: 6px; font-weight: 500; position: relative; }

/* 導覽箭頭 */
.cara-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 10;
  width: 50px; height: 50px; border-radius: 50%; border: none; cursor: pointer; font-size: 18px;
  background: rgba(255,255,255,0.8); backdrop-filter: blur(14px); color: var(--label);
  box-shadow: var(--shadow-md); transition: all 0.2s var(--ease-spring);
}
.cara-nav:hover { transform: translateY(-50%) scale(1.12); box-shadow: var(--shadow-lg); }
.cara-nav:active { transform: translateY(-50%) scale(0.95); }
.cara-nav.prev { left: 8px; } .cara-nav.next { right: 8px; }
@media (max-width: 700px) { .cara-nav { display: none; } }

/* 圓點 */
.dots { display: flex; gap: 9px; justify-content: center; margin: 6px 0 4px; }
.dots .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--hairline); cursor: pointer;
  transition: all 0.3s var(--ease-spring);
}
.dots .dot.on { width: 26px; border-radius: 4px; background: var(--dotc, var(--blue)); }

/* 下方絢麗介紹面板 */
.intro-panel {
  max-width: 720px; margin: 22px auto 0; padding: 34px; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-md); text-align: center; position: relative; overflow: hidden;
  border: 1px solid rgba(0,0,0,0.04);
}
.intro-panel::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--ic1), var(--ic2));
}
.intro-panel .glow {
  position: absolute; top: -80px; left: 50%; transform: translateX(-50%);
  width: 360px; height: 200px; background: radial-gradient(closest-side, var(--ic1), transparent);
  opacity: 0.18; pointer-events: none; filter: blur(10px);
}
.intro-anim { animation: introIn 0.45s var(--ease) both; }
@keyframes introIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.intro-panel h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 12px; }
.intro-panel h2 i { font-size: 26px; }
.intro-panel .desc { color: var(--label-2); font-size: 17px; line-height: 1.6; margin: 12px auto 18px; max-width: 540px; }
.intro-tags { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.intro-tags .tag2 {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 980px;
  background: rgba(0,0,0,0.04); font-size: 14px; font-weight: 600; color: var(--label-2);
}
.intro-tags .tag2 i { color: var(--ic1); }

/* 首頁遊戲預覽 */
.home-preview { overflow: hidden; max-width: 760px; margin: 0 auto; padding: 6px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.hp-track { display: flex; gap: 30px; width: max-content; animation: hpScroll 26s linear infinite; }
.hp-track:hover { animation-play-state: paused; }
@keyframes hpScroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.hp-item { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 92px; flex-shrink: 0; }
.hp-badge { width: 58px; height: 58px; border-radius: 17px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 25px; box-shadow: 0 8px 20px -6px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.4); }
.hp-item span { font-size: 14px; font-weight: 600; color: var(--label-2); }

.game-tile h3 { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; margin-top: 14px; }
.game-tile p { color: var(--label-2); font-size: 15px; line-height: 1.5; margin-top: 8px; }
.game-tile .go {
  margin-top: 16px; align-self: flex-start; font-weight: 600; color: var(--tile-color, var(--blue));
  font-size: 15px; display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- 區段標題 ---------- */
.section-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 36px 0 4px; }
.section-sub { color: var(--label-2); margin-bottom: 18px; }

/* ---------- 表單 ---------- */
.field { margin-bottom: 22px; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 10px; color: var(--label); }
.field .hint { color: var(--label-3); font-size: 13px; font-weight: 400; }
input[type="text"], input[type="number"], select {
  font: inherit; font-size: 17px; width: 100%; padding: 14px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--hairline); background: var(--surface);
  color: var(--label); transition: border 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10,132,255,0.15); }

/* 段控 (segmented control) */
.segment { display: inline-flex; background: rgba(0,0,0,0.05); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.segment button {
  font: inherit; font-weight: 600; font-size: 15px; border: none; cursor: pointer;
  background: transparent; color: var(--label); padding: 9px 18px; border-radius: 9px;
  transition: all 0.2s var(--ease);
}
.segment button.on { background: var(--surface); color: var(--label); box-shadow: var(--shadow-sm); }

/* 步進器 */
.stepper { display: inline-flex; align-items: center; gap: 16px; }
.stepper button {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; background: rgba(0,0,0,0.05); color: var(--label);
  transition: all 0.15s var(--ease-spring); display: flex; align-items: center; justify-content: center;
}
.stepper button:hover { background: rgba(0,0,0,0.1); transform: scale(1.08); }
.stepper button:active { transform: scale(0.92); }
.stepper .val { font-size: 32px; font-weight: 700; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

/* 隊伍輸入列 */
.team-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; animation: pop 0.3s var(--ease-spring) both; }
.team-dot { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 3px rgba(255,255,255,0.5); }
.team-row input { flex: 1; }

/* ---------- 遊玩畫面 ---------- */
.play-stage {
  text-align: center; min-height: calc(100vh - 200px); display: flex; flex-direction: column;
  align-items: center; justify-content: safe center; gap: 24px; padding: 16px 0 40px;
}
.word-card {
  background: var(--surface); border-radius: var(--r-xl); padding: 56px 48px;
  box-shadow: var(--shadow-lg); min-width: min(560px, 90vw); animation: pop 0.4s var(--ease-spring) both;
  border: 1px solid rgba(0,0,0,0.04);
}
.word-card .word { font-size: clamp(42px, 9vw, 88px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.word-card .label { font-size: 15px; font-weight: 600; color: var(--label-3); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 18px; }
.word-card .sub { font-size: 22px; color: var(--label-2); margin-top: 18px; }

/* 計時器圈 */
.timer-wrap { position: relative; width: 160px; height: 160px; }
.timer-wrap svg { transform: rotate(-90deg); }
.timer-wrap .ring-bg { fill: none; stroke: rgba(0,0,0,0.07); stroke-width: 12; }
.timer-wrap .ring-fg { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.4s; }
.timer-wrap .time-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* 分數列 */
.scorebar { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 8px 0 24px; }
.score-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 980px;
  background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; font-size: 17px;
  border: 1px solid var(--separator); transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}
.score-chip.active { transform: scale(1.06); box-shadow: var(--shadow-md); }
.score-chip .dot { width: 14px; height: 14px; border-radius: 50%; }
.score-chip .n { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 22px; text-align: center; }

/* 選項按鈕 (二選一) */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; width: min(720px, 92vw); }
.choice {
  font: inherit; cursor: pointer; border: 2px solid var(--hairline); background: var(--surface);
  border-radius: var(--r-lg); padding: 36px 24px; font-size: 30px; font-weight: 700;
  transition: all 0.2s var(--ease-spring); box-shadow: var(--shadow-sm);
}
.choice:hover { transform: translateY(-4px); border-color: var(--blue); box-shadow: var(--shadow-md); }
.choice .tag { display: block; font-size: 15px; color: var(--label-3); font-weight: 600; margin-bottom: 8px; }
.choice.correct { border-color: var(--green); background: rgba(48,209,88,0.08); }
.choice.wrong { border-color: var(--red); background: rgba(255,69,58,0.08); opacity: 0.7; }

/* 隊伍搶答按鈕格 */
.buzz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; width: min(760px,92vw); }
.buzz-btn {
  font: inherit; cursor: pointer; border: none; border-radius: var(--r-lg); padding: 28px 18px;
  font-size: 24px; font-weight: 800; color: #fff; box-shadow: var(--shadow-md);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.2s, filter 0.2s;
}
.buzz-btn:hover { transform: translateY(-4px) scale(1.02); }
.buzz-btn:active { transform: scale(0.96); }

/* ---------- 規則 / SOP ---------- */
.rules-card { max-width: 720px; margin: 0 auto; }
.rules-card ol { margin: 8px 0 0; padding-left: 0; list-style: none; counter-reset: step; }
.rules-card ol li {
  counter-increment: step; position: relative; padding: 14px 0 14px 52px; font-size: 17px; line-height: 1.5;
  border-bottom: 1px solid var(--separator); color: var(--label);
}
.rules-card ol li:last-child { border-bottom: none; }
.rules-card ol li::before {
  content: counter(step); position: absolute; left: 0; top: 12px;
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}

/* ---------- 結算 ---------- */
.result-podium { display: flex; align-items: flex-end; justify-content: center; gap: 18px; margin: 30px 0; flex-wrap: wrap; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: fadeUp 0.6s var(--ease) both; }
.podium-bar { width: 120px; border-radius: 18px 18px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 14px; color: #fff; font-weight: 800; font-size: 22px; box-shadow: var(--shadow-md); }
.podium-col .name { font-weight: 700; font-size: 18px; }
.podium-col .medal { font-size: 38px; }

/* ---------- 浮層 / Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; animation: fadeUp 0.3s var(--ease); }
.modal {
  background: var(--surface); border-radius: var(--r-lg); padding: 32px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-lg); text-align: center; animation: pop 0.35s var(--ease-spring);
}
.modal h3 { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.modal p { color: var(--label-2); line-height: 1.6; margin-bottom: 20px; }
#qrImg { border-radius: var(--r-sm); box-shadow: var(--shadow-sm); margin: 0 auto 16px; display: block; }

/* ---------- 工具列 ---------- */
.toolbar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 24px; }
.center { text-align: center; }
.muted { color: var(--label-2); }
.pill { display: inline-block; padding: 6px 14px; border-radius: 980px; background: rgba(0,0,0,0.05); font-size: 14px; font-weight: 600; color: var(--label-2); }

/* 翻牌 (傳手機) */
.reveal-card {
  cursor: pointer; user-select: none; min-width: min(420px,88vw); min-height: 280px;
  border-radius: var(--r-xl); display: flex; align-items: center; justify-content: center; flex-direction: column;
  box-shadow: var(--shadow-lg); transition: transform 0.4s var(--ease-spring); position: relative;
}
.reveal-card.hidden-face { background: linear-gradient(135deg, #1d1d1f, #3a3a3c); color: #fff; }
.reveal-card.shown-face { background: var(--surface); }
.reveal-card .big { font-size: clamp(40px, 8vw, 72px); font-weight: 800; }
.reveal-card .small { font-size: 18px; opacity: 0.8; margin-top: 8px; }

/* YouTube 播放器 */
.yt-frame { width: min(640px, 92vw); aspect-ratio: 16/9; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-md); background:#000; }
.yt-frame.audio-mode { aspect-ratio: auto; height: 0; }

/* RWD */
@media (max-width: 640px) {
  .app { padding: 16px 14px 60px; }
  .choices { grid-template-columns: 1fr; }
  .game-tile { min-height: 170px; }
  .word-card { padding: 40px 28px; }
}

/* ============ Notion 風頭像選擇 / 聊天 / 語音 ============ */
.av-preview { margin: 10px auto 6px; width: 96px; height: 96px; }
.av-preview img { width: 96px; height: 96px; border-radius: 50%; box-shadow: var(--shadow-md); background: #fff; }
.av-section-label { font-size: 13px; font-weight: 600; color: var(--label-3); text-align: left; margin: 12px 0 6px; }
.av-bgrow { display: flex; flex-wrap: wrap; gap: 8px; }
.av-bg { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .15s var(--ease-spring); }
.av-bg:hover { transform: scale(1.12); }
.av-bg.on { border-color: var(--blue); transform: scale(1.1); }
.av-seedgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-seed { padding: 3px; border-radius: 14px; border: 2px solid transparent; background: rgba(0,0,0,0.03); cursor: pointer; transition: all .15s var(--ease-spring); }
.av-seed img { width: 100%; display: block; border-radius: 10px; }
.av-seed:hover { transform: scale(1.06); }
.av-seed.on { border-color: var(--blue); background: rgba(10,132,255,0.12); transform: scale(1.04); }

/* 各處插畫頭像尺寸 */
.av-img, .av-emoji { display: inline-block; vertical-align: middle; border-radius: 50%; object-fit: cover; background: #fff; }
.p-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 0 0 3px var(--pc, var(--blue)); }
.chat-av { width: 26px !important; height: 26px; border-radius: 50%; object-fit: cover; background: #fff; }
.cp-av { width: 22px; height: 22px; border-radius: 50%; vertical-align: middle; background: #fff; }
.ww-av { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #fff; }
.av-emoji { font-size: 22px; box-shadow: none; }

/* DIY 頭像編輯器（◀▶ 切換器式，完整角色只在上方預覽）*/
.av-preview { margin: 8px auto 4px; width: 128px; height: 128px; }
.av-preview img { width: 128px; height: 128px; }
.av-preview img.bounce { animation: avBounce .5s var(--ease-spring); }
@keyframes avBounce { 0% { transform: scale(.7) rotate(-8deg); } 55% { transform: scale(1.14) rotate(5deg); } 100% { transform: scale(1) rotate(0); } }
.av-random { margin: 2px auto 12px !important; display: inline-flex !important; width: auto !important; }
.av-editor { text-align: left; margin: 6px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.av-cat { grid-column: 1 / -1; }
.av-cat-label { font-size: 13px; font-weight: 700; color: var(--label-2); margin-bottom: 6px; }
.av-bgrow { display: flex; flex-wrap: wrap; gap: 8px; }
.av-bg { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .15s var(--ease-spring); }
.av-bg:hover { transform: scale(1.1); } .av-bg.on { border-color: var(--blue); transform: scale(1.08); }
.av-step { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: rgba(0,0,0,.04); border-radius: 12px; padding: 6px 8px; }
.av-step-label { font-size: 14px; font-weight: 700; flex: 1; text-align: center; }
.av-arrow { width: 34px; height: 34px; border-radius: 9px; border: none; background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer; font-size: 13px; color: var(--blue); transition: all .12s var(--ease-spring); flex-shrink: 0; }
.av-arrow:hover { transform: scale(1.08); } .av-arrow:active { transform: scale(.9); }

/* 大廳泡泡舞台 */
.lobby-stage-card { min-height: 480px; }
.bubble-stage { position: relative; height: 440px; margin-top: 12px; border-radius: 18px; overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, rgba(10,132,255,.06), transparent 70%), rgba(0,0,0,.02); }
.stage-empty { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; text-align: center; color: var(--label-3); font-size: 14px; line-height: 1.7; padding: 0 20px 18px; pointer-events: none; }
/* QR 在正中央，當作障礙物 */
.stage-qr { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; text-align: center;
  background: var(--surface); border-radius: 22px; padding: 14px 14px 10px; box-shadow: var(--shadow-lg); }
.stage-qr .qr-frame { background: #fff; border-radius: 12px; padding: 6px; }
.stage-qr .qr-frame img { display: block; border-radius: 8px; }
.stage-qr .room-code { font-size: 13px; margin-top: 6px; color: var(--label-2); }
.stage-qr .room-code b { font-size: 22px; letter-spacing: 4px; color: var(--blue); }
/* 物理泡泡：transform 由 JS 每幀控制，不要 transition */
.float-av { position: absolute; top: 0; left: 0; width: 80px; display: flex; flex-direction: column; align-items: center; gap: 4px; will-change: transform; z-index: 3; }
.fa-imgwrap { animation: bob 3s ease-in-out infinite; position: relative; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.fa-img { width: 60px; height: 60px; border-radius: 50%; background: #fff; box-shadow: 0 8px 18px -5px var(--pc, #0A84FF), 0 0 0 3px var(--pc, #0A84FF); object-fit: cover; }
.fa-name { font-size: 13px; font-weight: 700; background: var(--surface); padding: 2px 10px; border-radius: 980px; box-shadow: var(--shadow-sm); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 對話泡泡：在頭像「上方」(不蓋住)，往上疊最多3個 */
.speech-slot { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 5px; z-index: 6; pointer-events: none; }
.speech { background: #fff; color: var(--label); padding: 8px 14px; border-radius: 16px; font-size: 14px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-md); position: relative; animation: speechPop .3s var(--ease-spring) both; }
.speech::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
.speech.fade { opacity: 0; transform: translateY(-14px) scale(1.15) rotate(-2deg); transition: all .55s ease; }   /* 像泡泡破掉/飄走 */
@keyframes speechPop { 0% { opacity: 0; transform: scale(.5); } 70% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }   /* 冒出來帶一點回彈 */

/* 手機開嗆預設 */
.greet-title { font-size: 13px; font-weight: 600; color: var(--label-2); margin: 16px 0 8px; text-align: left; }
.greet-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.greet-btn { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 980px; border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; transition: all .15s var(--ease-spring); }
.greet-btn:active { transform: scale(.94); background: rgba(10,132,255,.1); border-color: var(--blue); }

/* 等待室玩家列 */
.client-players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.cp-chip { background: rgba(0,0,0,0.05); padding: 6px 12px; border-radius: 980px; font-size: 14px; font-weight: 600; }

/* 聊天室 */
.lobby-chat .chat-feed { margin-top: 12px; }
.chat-feed { height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.client-chat { margin-top: 18px; text-align: left; }
.client-chat .chat-feed { height: 32vh; background: rgba(0,0,0,0.03); border-radius: 14px; padding: 10px; }
.chat-line { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.4; animation: pop .25s var(--ease-spring) both; }
.chat-av { font-size: 20px; flex-shrink: 0; }
.chat-line b { color: var(--blue); }
.chat-sys { text-align: center; font-size: 13px; color: var(--label-3); font-style: italic; }
.chat-empty { text-align: center; color: var(--label-3); font-size: 14px; padding: 30px 0; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; margin-top: 0 !important; padding: 12px 14px !important; }
.chat-input .btn { padding: 12px 18px; }

/* 語音按鈕 */
.voice-toggle { position: fixed; right: 18px; bottom: 18px; z-index: 60; border: none; cursor: pointer;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(14px); box-shadow: var(--shadow-md);
  border-radius: 980px; padding: 12px 18px; font-size: 16px; font-weight: 700; transition: all .2s var(--ease-spring); }
.voice-toggle:hover { transform: scale(1.06); box-shadow: var(--shadow-lg); }
.voice-toggle.off { opacity: 0.6; }
.ww-av { font-size: 22px; }

/* ============ 手機端遊戲互動 ============ */
.buzz-big {
  width: 220px; height: 220px; border-radius: 50%; border: none; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 50% 35%, #FF6961, #FF453A 60%, #c0271d);
  box-shadow: 0 16px 40px -8px rgba(255,69,58,0.6), inset 0 -6px 14px rgba(0,0,0,0.25), inset 0 4px 10px rgba(255,255,255,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-size: 30px; font-weight: 900; margin: 10px auto; transition: transform .08s; -webkit-tap-highlight-color: transparent;
}
.buzz-big i { font-size: 48px; }
.buzz-big:active { transform: scale(0.93); }
.buzz-big.pressed { background: #8e8e93; box-shadow: none; transform: scale(0.9); }
.buzz-big:disabled { cursor: default; }

.choice-big {
  display: block; width: 100%; margin: 10px 0; padding: 22px 18px; border-radius: 20px; border: 2px solid var(--hairline);
  background: var(--surface); font-size: 20px; font-weight: 700; cursor: pointer; text-align: left; transition: all .15s var(--ease-spring); box-shadow: var(--shadow-sm);
}
.choice-big b { display: inline-flex; width: 32px; height: 32px; border-radius: 8px; background: var(--blue); color: #fff; align-items: center; justify-content: center; margin-right: 10px; }
.choice-big:active { transform: scale(0.98); }
.choice-big.picked { border-color: var(--blue); background: rgba(10,132,255,0.1); }
.choice-big:disabled { opacity: 0.6; }

.word-reveal { border-radius: 26px; padding: 30px 24px; color: #fff; text-align: center; margin: 10px 0;
  background: linear-gradient(160deg, var(--rc), color-mix(in srgb, var(--rc) 55%, #000)); box-shadow: 0 16px 40px -12px var(--rc); animation: pop .4s var(--ease-spring) both; }
.word-reveal .role-top { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.word-big { font-size: clamp(38px, 12vw, 60px); font-weight: 900; letter-spacing: -.02em; margin-top: 8px; }
.word-sub { font-size: 15px; opacity: .9; margin-top: 12px; }

.vote-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.vote-btn { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--hairline);
  background: var(--surface); font-size: 18px; font-weight: 700; cursor: pointer; transition: all .15s var(--ease-spring); }
.vote-btn:active { transform: scale(0.98); }
.vote-btn.picked { border-color: var(--red); background: rgba(255,69,58,0.1); }
.vote-btn:disabled { opacity: 0.55; }
.vote-av { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; }

.vote-count { font-size: 14px; color: var(--label-2); font-weight: 600; margin-top: 8px; }
.choice.correct .vote-count { color: var(--green); }
.sc-av { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: #fff; }
.po-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; background: #fff; }

/* 四選一 — 主機大螢幕 */
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(720px, 92vw); }
.quiz-opt { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); border: 2px solid var(--separator); font-size: 19px; font-weight: 700; }
.qo-key { width: 30px; height: 30px; border-radius: 8px; background: rgba(0,0,0,.06); display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.qo-text { flex: 1; }
.qo-count { font-size: 14px; font-weight: 800; color: var(--blue); min-width: 40px; text-align: right; }
.quiz-opt.correct { border-color: var(--green); background: rgba(48,209,88,.12); }
.quiz-opt.correct .qo-key { background: var(--green); color: #fff; }

/* 倒數數字 */
.big-count { display: inline-block; font-size: 68px; font-weight: 900; color: var(--blue); animation: avBounce .4s var(--ease-spring); }
.q4-timer { font-size: 50px; font-weight: 900; color: var(--blue); font-variant-numeric: tabular-nums; line-height: 1; }
.q4-timer.urgent { color: var(--red); animation: pulse2 .5s infinite; }
@keyframes pulse2 { 0%,100% { transform: scale(1); } 50% { transform: scale(1.16); } }

/* 大一點的遊戲按鈕 */
.play-stage .btn.xl { font-size: 27px; padding: 25px 54px; }
.play-stage .btn.lg { font-size: 22px; padding: 18px 38px; }

/* 比手畫腳 3 角色 */
.char-roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: min(640px, 92vw); margin: 8px 0; }
.char-role { background: var(--surface); border-radius: 18px; padding: 16px 12px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.char-role b { font-size: 17px; }
.char-role small { color: var(--label-3); font-size: 12px; }
.cr-av { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #fff; }
.cr-tag { font-size: 13px; font-weight: 800; padding: 3px 12px; border-radius: 980px; color: #fff; }
.cr-tag.opp { background: var(--blue); } .cr-tag.perf { background: var(--orange); } .cr-tag.guess { background: var(--green); }
.btn.block { display: flex; width: 100%; }

/* 成功/失敗橫幅 */
.result-banner { font-size: 30px; font-weight: 900; padding: 16px 30px; border-radius: 18px; box-shadow: var(--shadow-md); display: inline-flex; align-items: center; gap: 12px; margin-bottom: 6px; animation: pop .45s var(--ease-spring); }
.result-banner.good { background: rgba(48,209,88,.16); color: #1a7a33; }
.result-banner.bad { background: rgba(255,69,58,.16); color: #c0271d; }
.vote-btn.self { opacity: .5; }

/* 二選一 — 手機左右各一半 */
.lr-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.lr-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 38vh; padding: 18px 12px; border-radius: 20px; border: 2px solid var(--hairline); background: var(--surface); font-size: 22px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s var(--ease-spring); }
.lr-choice .lr-key { width: 40px; height: 40px; border-radius: 12px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.lr-choice.A .lr-key { background: var(--blue); } .lr-choice.B .lr-key { background: var(--purple); }
.lr-choice:active { transform: scale(.97); }
.lr-choice.picked { border-color: var(--blue); background: rgba(10,132,255,.1); }
.lr-choice:disabled { opacity: .55; }

/* 四選一 — 手機 2×2 (左上/右上/左下/右下) */
.quiz4-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.quiz4-btn { min-height: 19vh; flex-direction: column; justify-content: center; }
.quiz4-btn { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 18px 16px; border-radius: 16px; border: 2px solid var(--hairline); background: var(--surface); font-size: 17px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s var(--ease-spring); }
.quiz4-btn:active { transform: scale(.98); }
.quiz4-btn.picked { border-color: var(--blue); background: rgba(10,132,255,.1); }
.quiz4-btn:disabled { opacity: .55; }
.q4-key { width: 30px; height: 30px; border-radius: 8px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
/* 提前結束遊戲：各遊戲畫面左上角，回到選遊戲 */
.end-game-btn { position: fixed; top: 12px; left: 12px; z-index: 70; font: inherit; font-size: 14px; font-weight: 700;
  padding: 9px 15px; border-radius: 980px; border: 1.5px solid var(--red); background: rgba(255,69,58,.10); color: var(--red);
  cursor: pointer; transition: all .15s var(--ease-spring); box-shadow: var(--shadow-sm); }
.end-game-btn:hover { background: var(--red); color: #fff; }
.end-game-btn:active { transform: scale(.93); }
/* 遊戲教學彈窗：大字、白話、8~88 歲都好讀 */
.tut-modal { max-width: min(580px, 92vw); text-align: left; }
.tut-modal h3 { font-size: 25px; text-align: center; margin-bottom: 4px; }
.tut-desc { font-size: 16px; color: var(--label-2); text-align: center; margin: 6px 0 18px; line-height: 1.65; }
.tut-steps { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 14px; }
.tut-steps li { display: flex; gap: 13px; align-items: flex-start; font-size: 18px; line-height: 1.65; font-weight: 600; color: var(--label); }
.tut-n { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; margin-top: 1px; }
/* 輸入搶答：手機的答案輸入框 */
.ans-input { width: 100%; font: inherit; font-size: 22px; font-weight: 700; text-align: center; padding: 16px 14px; border-radius: 16px; border: 2px solid var(--hairline); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .15s; }
.ans-input:focus { outline: none; border-color: var(--blue); }
.ans-input:disabled { opacity: .55; }
/* 開始前倒數：每台手機同步顯示的大數字 */
.count-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 0 20px; }
.count-num { font-size: 130px; font-weight: 900; color: var(--blue); line-height: 1; font-variant-numeric: tabular-nums; animation: q4pop .5s var(--ease-spring) both; }
.count-tip { margin-top: 14px; font-size: 17px; font-weight: 700; color: var(--label-2); }
/* 作答完成：彈跳確認（不顯示選了哪個）*/
.q4-done { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 0; }
.q4-done-ic { font-size: 84px; color: var(--green); animation: q4pop .6s var(--ease-spring) both; }
.q4-done h2 { margin: 8px 0 2px; }
@keyframes q4pop { 0% { transform: scale(0) rotate(-12deg); opacity: 0; } 60% { transform: scale(1.28) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }

/* 房主遙控列（固定底部，鏡射大螢幕控制鈕，不含答案）*/
#hostRemote { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: linear-gradient(180deg, rgba(30,30,40,.97), rgba(16,16,22,.99)); backdrop-filter: blur(18px);
  color: #fff; padding: 8px 14px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 34px rgba(0,0,0,.34);
  border-top-left-radius: 24px; border-top-right-radius: 24px; max-height: 48vh; overflow-y: auto; }
body:not(.client-mode) #hostRemote { display: none; }
.hr-grip { width: 42px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 2px auto 11px; }
.hr-title { font-size: 13px; font-weight: 700; opacity: .95; margin-bottom: 13px; text-align: center; }
.hr-title .hr-sub { opacity: .5; font-weight: 500; }
.hr-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; max-width: 500px; margin: 0 auto; }
.hr-btn { font: inherit; font-size: 16px; font-weight: 800; border: none; border-radius: 16px; padding: 15px 14px;
  background: #3a3a48; color: #fff; cursor: pointer; min-height: 56px; line-height: 1.2;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transition: transform .08s var(--ease-spring), filter .15s; box-shadow: 0 4px 12px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08); }
.hr-btn:active { transform: scale(.94); filter: brightness(1.12); }
.hr-btn:disabled { opacity: .32; box-shadow: none; }
.hr-norm { background: #3a3a48; }
.hr-sec  { background: #2f2f3a; color: #cfd2dc; }
.hr-go   { background: linear-gradient(160deg, #34d35e, #1a9e42); }
.hr-danger { background: linear-gradient(160deg, #ff5a52, #d23a32); }
.hr-game { background: linear-gradient(160deg, var(--blue), #0768d6); font-size: 17px; }
.hr-on   { background: linear-gradient(160deg, #34d35e, #1a9e42); }
.hr-off  { background: #2f2f3a; color: #aeb2bd; }
.hr-active { background: linear-gradient(160deg, var(--blue), #0768d6); }
.hr-cell { background: #3a3a48; }
.hr-empty { text-align: center; opacity: .72; font-size: 14px; padding: 16px 8px; line-height: 1.7; }
body.has-remote #clientRoot { padding-bottom: 200px; }

/* 手機靜音鈕 */
.client-mute { position: fixed; top: 14px; right: 14px; z-index: 70; width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer; background: var(--surface); box-shadow: var(--shadow-md); color: var(--blue); font-size: 16px; }
.client-mute.off { color: var(--label-3); }
body:not(.client-mode) .client-mute { display: none; }

/* 背景音樂控制(主機) */
.bgm-ctl { position: fixed; left: 18px; bottom: 18px; z-index: 60; display: flex; gap: 6px; }
.bgm-ctl button { border: none; cursor: pointer; background: rgba(255,255,255,.85); backdrop-filter: blur(14px); box-shadow: var(--shadow-md); border-radius: 980px; padding: 10px 16px; font-size: 14px; font-weight: 700; color: var(--label); transition: all .2s var(--ease-spring); }
.bgm-ctl button:hover { transform: scale(1.05); }
.bgm-ctl #bgmToggle.off { opacity: .5; }
body.client-mode .bgm-ctl { display: none; }

/* 黑膠唱片 (猜歌) */
#ytHost { position: fixed; bottom: 0; right: 0; width: 1px; height: 1px; opacity: 0.01; pointer-events: none; z-index: -1; }
.disc {
  width: 180px; height: 180px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 56px; color: #fff; position: relative;
  background: radial-gradient(circle at 50% 50%, #444 0 18%, #1a1a1a 19% 100%);
  box-shadow: var(--shadow-lg), inset 0 0 0 22px rgba(255,255,255,0.04), inset 0 0 0 23px rgba(255,255,255,0.08);
}
.disc::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 4px #888; }
.disc i { position: relative; z-index: 2; opacity: 0.9; }
.disc.spin { animation: discSpin 2.6s linear infinite; }
@keyframes discSpin { to { transform: rotate(360deg); } }

/* ============ 大廳 ============ */
.lobby-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.lobby-right { display: flex; flex-direction: column; gap: 18px; }

/* 兩步驟大廳：泡泡在上、QR 在下 */
.lobby-joinrow { display: flex; justify-content: center; margin-top: 18px; }
.lobby-joinrow .join-panel { max-width: 300px; width: 100%; }
.arrange-empty { padding: 36px; font-size: 16px; }

/* QR 加入面板 — 深色質感卡 */
.join-panel {
  position: relative; overflow: hidden; text-align: center; color: #fff; border-radius: var(--r-lg); padding: 28px 24px;
  background: linear-gradient(165deg, #2b2b3d, #16161f);
  box-shadow: var(--shadow-lg);
}
.join-glow { position: absolute; top: -60px; left: 50%; transform: translateX(-50%); width: 260px; height: 160px;
  background: radial-gradient(closest-side, var(--blue), transparent); opacity: 0.45; filter: blur(20px); pointer-events: none; }
.join-label { position: relative; font-weight: 700; font-size: 15px; opacity: 0.85; margin-bottom: 16px; letter-spacing: 0.02em; }
.qr-frame { position: relative; background: #fff; border-radius: 18px; padding: 12px; width: fit-content; margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.qr-frame img { display: block; border-radius: 8px; }
.room-code { position: relative; font-size: 15px; margin-top: 16px; opacity: 0.85; }
.room-code b { display: block; font-size: 40px; letter-spacing: 8px; color: #fff; font-variant-numeric: tabular-nums; margin-top: 2px;
  text-shadow: 0 2px 12px rgba(10,132,255,0.6); }
.lobby-warn { position: relative; margin-top: 14px; padding: 12px; border-radius: 12px; background: rgba(255,159,10,0.18); color: #FFD08A; font-size: 12.5px; line-height: 1.5; text-align: left; }

/* 玩家頭像 */
.player-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; min-height: 80px; align-content: flex-start; }
.player-list .empty-hint { color: var(--label-3); font-size: 15px; padding: 22px; width: 100%; text-align: center; }
.player-chip { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; animation: pop 0.35s var(--ease-spring) both; }
.player-chip .avatar { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff; background: var(--pc, var(--blue)); box-shadow: 0 6px 16px -4px var(--pc, var(--blue)); }
.player-chip .pname { font-size: 13px; font-weight: 600; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip.off { opacity: 0.4; }

/* 配置面板 */
.lobby-config .cfg-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.cfg-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--separator); }
.cfg-row:last-child { border-bottom: none; }
.cfg-ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px; flex-shrink: 0; }
.cfg-name { font-weight: 600; flex: 1; }
.cfg-name small { display: block; color: var(--label-3); font-weight: 400; font-size: 12px; }
.cfg-stepper { display: flex; align-items: center; gap: 10px; }
.cfg-stepper button { width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(0,0,0,0.06); font-size: 18px; cursor: pointer; transition: all .15s var(--ease-spring); }
.cfg-stepper button:hover { background: rgba(0,0,0,0.12); transform: scale(1.1); }
.cfg-stepper .cnum { font-weight: 800; font-size: 18px; min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.cfg-toggle { width: 52px; height: 30px; border-radius: 980px; border: none; cursor: pointer; background: rgba(0,0,0,0.12); position: relative; transition: background .2s; }
.cfg-toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease-spring); }
.cfg-toggle.on { background: var(--green); }
.cfg-toggle.on::after { transform: translateX(22px); }
.cfg-summary { margin-top: 14px; padding: 12px; border-radius: 12px; background: rgba(10,132,255,0.08); font-weight: 600; text-align: center; font-size: 14px; }
.cfg-summary.bad { background: rgba(255,69,58,0.1); color: var(--red); }

@media (max-width: 700px) { .lobby-wrap { grid-template-columns: 1fr; } }

/* ============ 手機端 ============ */
body.client-mode .topbar, body.client-mode .app { display: none !important; }
#clientRoot { display: none; }
body.client-mode #clientRoot {
  display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; padding: 24px 16px 60px;
}
.client-card { width: 100%; max-width: 440px; text-align: center; }
.client-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0; }
.client-logo { font-size: 40px; margin-bottom: 8px; font-weight: 800; letter-spacing: -0.02em; }
.client-logo i { color: var(--blue); }
.client-card input, .client-card textarea {
  font: inherit; font-size: 18px; width: 100%; padding: 16px; border-radius: 14px;
  border: 1px solid var(--hairline); background: var(--surface); margin-top: 8px;
}
.pulse-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--green); margin: 24px auto 0; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(48,209,88,0.5); } 50% { box-shadow: 0 0 0 16px rgba(48,209,88,0); } }

/* 身分卡 */
.role-card {
  border-radius: 28px; padding: 32px 24px; color: #fff; text-align: center; position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--rc), color-mix(in srgb, var(--rc) 55%, #000));
  box-shadow: 0 20px 50px -16px var(--rc); animation: pop 0.5s var(--ease-spring) both;
}
.role-top { font-size: 14px; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.85; }
.role-ic { font-size: 64px; margin: 14px 0 6px; }
.role-name { font-size: 38px; font-weight: 900; letter-spacing: -0.02em; }
.role-faction { font-size: 16px; opacity: 0.92; margin-top: 4px; font-weight: 600; }
.role-ability { font-size: 15px; line-height: 1.6; margin-top: 16px; background: rgba(255,255,255,0.16); padding: 14px; border-radius: 14px; text-align: left; }
.mates { margin-top: 12px; font-size: 15px; background: rgba(0,0,0,0.22); padding: 12px; border-radius: 12px; }
.note-wrap { margin-top: 18px; text-align: left; }
.note-wrap label { font-weight: 600; font-size: 14px; color: var(--label-2); }
.note-wrap textarea { min-height: 110px; resize: vertical; }
.seer-result { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-weight: 600; text-align: left; animation: pop 0.3s var(--ease-spring) both; }
.seer-result.good { background: rgba(48,209,88,0.14); color: #1a7a33; }
.seer-result.wolf { background: rgba(255,69,58,0.14); color: #c0271d; }
.seer-result.lover { background: rgba(255,55,95,0.14); color: #c01a4a; }

/* ============ 狼人殺 上帝面板 ============ */
.ww-board { max-width: 520px; margin: 0 auto; }
.ww-narration { max-width: 640px; margin: 0 auto 18px; padding: 28px; border-radius: 24px; text-align: center;
  background: linear-gradient(160deg, #2a2a3e, #1a1a28); color: #fff; box-shadow: var(--shadow-lg); }
.ww-narration.day { background: linear-gradient(160deg, #ffd66b, #ff9f43); color: #3a2600; }
.ww-phase { font-weight: 700; font-size: 15px; opacity: 0.85; margin-bottom: 10px; }
.ww-narration p { font-size: 20px; line-height: 1.5; }
.ww-hint { text-align: center; color: var(--label-2); font-weight: 600; margin: 6px 0 12px; }
.ww-ok { text-align: center; font-weight: 700; background: rgba(10,132,255,0.1); color: var(--blue); padding: 12px; border-radius: 12px; max-width: 520px; margin: 0 auto 12px; animation: pop 0.3s var(--ease-spring); }
.ww-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; max-width: 760px; margin: 16px auto 0; }
.ww-cell { background: var(--surface); border-radius: 16px; padding: 16px 10px; text-align: center; cursor: pointer; box-shadow: var(--shadow-sm); border: 2px solid transparent; transition: all 0.18s var(--ease-spring); position: relative; }
.ww-cell:hover { transform: translateY(-3px); border-color: var(--blue); box-shadow: var(--shadow-md); }
.ww-cell.dead { opacity: 0.5; cursor: default; }
.ww-cell.dead:hover { transform: none; border-color: transparent; }
.ww-rolehide { height: 22px; color: var(--red); font-size: 20px; }
.ww-name { font-weight: 700; font-size: 17px; }
.ww-role { font-size: 12px; color: var(--label-3); margin-top: 6px; padding: 4px; border-radius: 8px; background: rgba(0,0,0,0.04); }
.reveal-list { margin-top: 10px; }
.reveal-row { display: flex; justify-content: space-between; padding: 10px 4px; border-bottom: 1px solid var(--separator); }
.reveal-row.dead { opacity: 0.55; }

/* 彩帶 */
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 200; pointer-events: none; border-radius: 2px; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

/* 大螢幕暫時斷線提示（手機端） */
.host-away{position:fixed;left:12px;right:12px;top:10px;z-index:9999;background:#FF9F0A;color:#1d1d1f;font-weight:700;text-align:center;padding:10px 12px;border-radius:12px;box-shadow:0 6px 20px rgba(0,0,0,.18)}
.host-key{display:inline-block;margin-top:6px;font-size:14px;opacity:.85}
.host-key b{letter-spacing:3px;font-size:18px}

/* ===== 新遊戲（games2.js） ===== */
.ml-ranks{display:flex;flex-direction:column;gap:10px;width:min(560px,92%);margin:6px auto}
.ml-rank{display:flex;align-items:center;gap:12px;background:var(--card,#fff);border-radius:16px;padding:10px 16px;font-size:22px;box-shadow:0 4px 14px rgba(0,0,0,.06)}
.ml-rank .ml-medal{font-size:30px}.ml-rank .ml-cnt{margin-left:auto;font-weight:800;color:var(--orange)}
.bn-range{display:flex;align-items:center;justify-content:center;gap:22px;font-size:clamp(46px,9vw,110px);font-weight:900;color:var(--red);margin:6px 0}
.bn-range i{font-size:.55em;color:var(--label-2,#555)}.bn-range.sm{font-size:44px;gap:14px}
.bg-last{font-size:clamp(70px,12vw,150px);font-weight:900;color:var(--blue);line-height:1}
.bg-board{display:grid;grid-template-columns:repeat(12,1fr);gap:6px;width:min(760px,96%);margin:10px auto}
.bg-n{padding:6px 0;border-radius:8px;background:rgba(120,120,128,.12);font-weight:700;text-align:center;color:var(--label-3,#999)}
.bg-n.on{background:var(--blue);color:#fff}
.bc-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:6px;margin:12px 0}
.bc{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border-radius:12px;background:rgba(120,120,128,.12);font-size:22px;font-weight:800}
.bc.on{background:var(--blue);color:#fff}.bc.last{outline:3px solid var(--orange)}.bc.free{background:var(--yellow,#FFD60A);color:#1d1d1f}
.td-wheel{font-size:clamp(40px,7vw,72px);font-weight:900;min-height:1.6em;display:flex;align-items:center;justify-content:center;gap:12px}
.dg-wrap{width:min(960px,96%);margin:0 auto}.dg-wrap canvas{width:100%;height:auto;background:#fff;border-radius:16px;box-shadow:0 6px 24px rgba(0,0,0,.12);border:2px solid rgba(0,0,0,.06)}
.dg-side{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:14px;margin:8px 0}
.dg-guesses{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;max-width:720px}
.dg-guess{background:rgba(120,120,128,.14);border-radius:999px;padding:4px 10px;font-size:14px}
.dg-pad{width:100%;height:auto;background:#fff;border-radius:14px;border:2px solid rgba(0,0,0,.12);touch-action:none;margin-top:8px}
.dg-tools{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;margin-top:8px}
.dg-col{width:34px;height:34px;border-radius:50%;border:3px solid transparent}.dg-col.on{border-color:var(--orange)}
.dg-w{min-width:44px;height:34px;border-radius:10px;border:2px solid rgba(0,0,0,.15);background:#fff;font-weight:700}.dg-w.on{border-color:var(--orange)}
