/* v0.4 手機版改版：底部分頁、RPG 視窗感的卡片、技能格、橫向全螢幕、勇者走動、睡美人翻身。
   疊在 style.css 後面，只改玩家頁；直播畫面（.display）只用到「走動」「翻身」兩段。
   設計稿：〈睡美人不想上班 手機版改版〉。 */

:root {
  --gold: #e9c27a;
  --gold-deep: #4a3420;
  --line: #6b4a52;
  --deep: #120a18;
  --skill: #43284c;
  --tabbar: 76px;
}

/* ───── 共用：勇者走動、睡美人翻身（直播畫面也用）───── */
.hero { transition: left 0.8s, top 0.8s, transform var(--walk-seconds, 1s) linear; }
.hero[data-face="left"] .figure { transform: scaleX(-1); }
.hero[data-walking]:not(.down) .figure { animation: walk-bob 0.36s steps(2) infinite; }
@keyframes walk-bob { 50% { translate: 0 -0.25em; } }
.hero .bubble.idle { background: var(--dream); font-size: 0.75em; }

.beauty.turning .sleeper { animation: turn-over 0.9s ease-in-out; transform-origin: 50% 80%; }
@keyframes turn-over {
  0% { translate: 0 0; scale: 1; }
  25% { translate: 0 -0.4em; scale: 1.04 0.96; }
  50% { translate: 0 0; scale: 0.97 1.03; }
  75% { translate: 0 -0.15em; scale: 1.02 0.98; }
  100% { translate: 0 0; scale: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hero, .hero .figure, .beauty.turning .sleeper { animation: none !important; transition: none !important; }
}

/* ───── 直播畫面不顯示的東西 ───── */
.display .player-only,
.display .landscape-dock,
.admin-view .player-only { display: none !important; }

/* ───── 卡片：RPG 視窗感（深底、細金框）───── */
body:not(.display) .card {
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgb(233 194 122 / 0.16), 0 0 0 2px #0e0712;
}
body:not(.display) .card h2 { font-size: 17px; font-weight: 900; letter-spacing: 0.04em; margin: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-head .muted { margin: 0; font-size: 12px; }
.action-goal { margin: -2px 0 2px; font-size: 12px; }
body:not(.display) .notice { border-color: var(--cream); }

/* ───── 底部分頁 ───── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(var(--tabbar) - 14px); padding-bottom: max(14px, env(safe-area-inset-bottom));
  box-sizing: content-box;
  background: var(--deep); border-top: 1px solid #3d2443;
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; padding: 0; border: 0; border-radius: 0; background: none;
  color: var(--muted); font-size: 11px; text-align: center;
}
.tabs button[aria-current="page"] { color: var(--coral); font-weight: 700; }
.tabs svg, .tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

body:not(.display):not(.admin-view) .page { padding-bottom: calc(var(--tabbar) + 24px); }

/* 分頁切換：卡片標 data-tab，沒標的（提示訊息）每頁都看得到。 */
body:not(.display):not(.admin-view)[data-tab="home"] #panel > [data-tab]:not([data-tab~="home"]),
body:not(.display):not(.admin-view)[data-tab="shop"] #panel > [data-tab]:not([data-tab~="shop"]),
body:not(.display):not(.admin-view)[data-tab="hero"] #panel > [data-tab]:not([data-tab~="hero"]),
body:not(.display):not(.admin-view)[data-tab="settings"] #panel > [data-tab]:not([data-tab~="settings"]) { display: none !important; }
body:not(.display):not(.admin-view):not([data-tab="home"]) .stage { display: none; }
body:not(.display):not(.admin-view) .panel { grid-template-columns: minmax(0, 1fr); max-width: 640px; margin: 0 auto; width: 100%; }
.event-card[data-portal="true"] {
  position: sticky; top: 0; left: auto; translate: none; width: 100%; margin: 0 0 10px;
  z-index: 20; font-size: 14px; animation: none;
}

/* ───── 場景上的按鈕：聲音、全螢幕 ───── */
.scene-tools { position: absolute; right: 2%; bottom: 2.5%; z-index: 7; display: flex; gap: 8px; }
.tool {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border-radius: 12px; border: 1px solid rgb(233 194 122 / 0.45);
  background: rgb(26 15 34 / 0.85); color: var(--cream); font-size: 13px; text-align: center;
}
.tool.wide { padding: 0 12px; }
#sound-toggle .icon-on { display: none; }
#sound-toggle[aria-pressed="true"] .icon-on { display: block; }
#sound-toggle[aria-pressed="true"] .icon-off { display: none; }
@media (max-width: 700px) {
  /* 手機上廣播條在場景下方，按鈕不會擋到它；橫幅移到上方避開按鈕。 */
  body:not(.display) .banner { bottom: auto; top: 16%; }
}

/* ───── 小場景條（商店／勇者／設定分頁）───── */
.mini-scene {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 60px; padding: 8px 12px; border-radius: 10px;
  background: var(--deep); border: 1px solid #3d2443; color: var(--cream); text-align: left;
}
.mini-thumb { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex: none; background: url("/assets/art/scene_garden_night.png") 40% 30% / 340% no-repeat; image-rendering: pixelated; }
.mini-thumb img { width: 100%; }
.mini-text { flex: 1; display: grid; gap: 5px; font-size: 13px; }
.mini-track { height: 6px; background: #0e0712; border-radius: 3px; overflow: hidden; }
.mini-fill { display: block; height: 100%; background: var(--dream); transition: width 0.6s; }
.mini-back { color: var(--gold); font-size: 12px; white-space: nowrap; }

/* ───── 首頁：我的勇者小卡 ───── */
.me-strip { display: flex !important; align-items: center; gap: 12px; text-align: left; color: var(--cream); background: var(--panel); padding: 10px 12px; }
.me-strip[hidden] { display: none !important; }
.strip-face { width: 52px; height: 52px; flex: none; border-radius: 10px; overflow: hidden; background: var(--night); display: flex; justify-content: center; }
.strip-face img { width: 92px; max-width: none; margin-top: -4px; }
.strip-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.strip-name { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); }
.strip-name strong { font-size: 15px; color: var(--cream); }
.strip-name .lv { color: var(--gold); font-weight: 700; }
.strip-body .gauge { font-size: 11px; }
.strip-body .gauge span { width: 2em; text-align: left; }
.strip-go { color: var(--muted); font-size: 22px; }

/* ───── 首頁：你不在時 ───── */
.away { background: #2f1d38; }
.away .close { min-width: 44px; min-height: 44px; margin: -10px -8px -10px 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 22px; text-align: center; }
.away-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.away-tile { display: grid; justify-items: center; background: var(--night); border-radius: 8px; padding: 8px 4px; }
.away-tile strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.away-tile span { font-size: 11px; color: var(--muted); }
.away-tile.dream strong { color: #ffb3c1; }
.away-tile.bad strong { color: var(--bad); }
.away-tile.mp strong { color: var(--mp); }
.away p { margin: 0; font-size: 13px; line-height: 1.7; }

/* ───── 行動：技能格 ───── */
body:not(.display) #action-buttons,
body:not(.display) #greeting-buttons,
body:not(.display) #potion-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body:not(.display) #actions button { background: var(--skill); border: 1px solid var(--line); min-height: 64px; display: grid; align-content: center; gap: 2px; }
.action-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; width: 100%; }
.action-top strong { font-size: 15px; }
.mp-cost { font-size: 11px; color: var(--mp); font-variant-numeric: tabular-nums; white-space: nowrap; }
body:not(.display) #actions button.signature { grid-column: 1 / -1; background: var(--gold-deep); border-color: var(--gold); }
body:not(.display) #actions button.signature small { color: #e6d0a8; }
body:not(.display) #actions select { min-height: 44px; }

/* 直播畫面在 PRISM 擷取時越省越好：勇者超過 16 位就不做走路彈跳和閒聊泡泡以外的動畫。 */
.display.crowded .hero .figure { animation: none !important; }
/* 她睡著時打招呼整段收起來（11/18 版行為），醒著才出現。 */

/* ───── 商店 ───── */
body:not(.display) #job-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body:not(.display) #job-choices .choice { flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 6px 8px 10px; overflow: hidden; }
body:not(.display) #job-choices .choice input { position: absolute; opacity: 0; pointer-events: none; }
body:not(.display) #job-choices .choice:has(input:checked) { background: var(--gold-deep); border-color: var(--gold); }
body:not(.display) #job-choices .choice:has(input:focus-visible) { outline: 2px solid var(--cream); outline-offset: 2px; }
.job-sprite { width: 84px; margin: -8px 0 -4px; }
body:not(.display) #job-choices .choice span strong { font-size: 15px; }
body:not(.display) #job-choices .choice small { font-size: 11px; line-height: 1.4; }
body:not(.display) #shop h3 { color: var(--cream); font-size: 16px; font-weight: 900; margin: 8px 0 6px; }

/* ───── 設定：聲音 ───── */
.switch-list { display: grid; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 1px solid #3d2443; color: var(--cream); }
.switch span { display: grid; }
.switch strong { font-size: 15px; }
.switch small { color: var(--muted); font-size: 12px; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 52px; height: 32px; border-radius: 16px; background: var(--button); position: relative; cursor: pointer; margin: 0;
}
.switch input::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--cream); transition: left 0.2s; }
.switch input:checked { background: var(--coral); }
.switch input:checked::after { left: 24px; }
.switch input:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }
.volume input { accent-color: var(--coral); width: 100%; min-height: 32px; }
.sound-list { display: grid; }
.sound-row { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid #3d2443; }
.sound-row span { display: grid; }
.sound-row small { color: var(--muted); font-size: 11px; }
.sound-row .play { width: 44px; height: 44px; min-height: 44px; padding: 0; flex: none; border-radius: 50%; text-align: center; background: var(--skill); }

/* ───── 管理後台：台詞錄音 ───── */
.admin-voice { grid-column: 1 / -1; }
.admin-voice summary { cursor: pointer; }
.admin-voice summary h3 { display: inline; }
.voice-groups { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.voice-groups button { min-height: 40px; padding: 0 12px; border-radius: 20px; }
.voice-groups button[aria-pressed="true"] { background: var(--coral); color: var(--ink); font-weight: 700; }
.voice-list { display: grid; gap: 0; }
.voice-line { padding: 10px 0; border-bottom: 1px solid #3d2443; display: grid; gap: 8px; }
.voice-line p { margin: 0; }
.voice-line.done p::after { content: "　已上線"; color: var(--poison); font-size: 12px; }
.voice-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.voice-buttons button { min-height: 40px; padding: 0 14px; border-radius: 20px; display: inline-flex; align-items: center; gap: 6px; }
.voice-buttons .rec { border-color: var(--coral); color: #ffb3b2; background: transparent; }
.voice-buttons .rec.on { background: var(--bad); color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.voice-buttons .ghost { background: transparent; color: var(--muted); }
.rec-dot { width: 10px; height: 10px; border-radius: 2px; background: var(--ink); }

/* ───── 橫向全螢幕（陪她上班）─────
   排版借用直播畫面：中間正方形場景，兩側名牌、數值、廣播；右下角換成快速行動。 */
.landscape-dock { display: none; }
body.landscape { overflow: hidden; }
body.landscape .tabs,
body.landscape .panel,
body.landscape .mini-scene,
body.landscape .scene-tools,
body.landscape .admin-tabs { display: none !important; }
body.landscape .stage { display: block !important; position: fixed; inset: 0; z-index: 60; background: #0b0610; }
body.landscape .page { padding: 0; }
body.landscape .scene {
  width: 100vw; height: 100dvh; aspect-ratio: auto; border: 0; border-radius: 0;
  font-size: clamp(9px, 1.5cqw, 16px);
}
body.landscape .map { left: 50%; translate: -50% 0; width: auto; height: 100%; }
body.landscape .plate { padding: 0.5em 0.8em; border-width: 2px; background: rgb(42 26 51 / 0.88); }
body.landscape .title-plate { top: 2%; left: 1.2%; width: 22%; font-size: inherit; }
body.landscape .beauty-plate { top: 17%; left: 1.2%; right: auto; width: 22%; }
body.landscape .board { display: none; }
body.landscape .banner { top: 3%; bottom: auto; max-width: 50%; font-size: inherit; }
body.landscape .feed { position: absolute; left: 1.2%; bottom: 2%; width: 22%; margin: 0; font-size: clamp(10px, 1.3cqw, 14px); z-index: 4; }
body.landscape .feed .feed-line:nth-last-of-type(n+4) { display: none; } /* 11/21：用 of-type，最後面的「↓ 最新」按鈕不算一則 */
body.landscape .landscape-dock {
  display: flex; flex-direction: column; gap: 8px;
  position: absolute; right: 1.2%; top: 3%; bottom: 3%; width: 22%; z-index: 7;
}
.dock-timer { display: flex; justify-content: space-between; align-items: center; background: rgb(26 15 34 / 0.86); border: 1px solid rgb(233 194 122 / 0.35); border-radius: 10px; padding: 6px 10px; font-size: 11px; color: var(--muted); }
.dock-timer strong { color: var(--gold); font-size: 15px; font-variant-numeric: tabular-nums; }
.dock-actions { display: grid; gap: 8px; }
.dock-actions button { min-height: 48px; background: rgb(67 40 76 / 0.95); border: 1px solid var(--line); }
.dock-actions button small { display: none; }
.dock-mp { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.dock-tools { margin-top: auto; display: flex; gap: 8px; }
.dock-tools .wide { flex: 1; }
#dock-sound[aria-pressed="false"] { opacity: 0.6; }
body.landscape.hud-hidden .plate,
body.landscape.hud-hidden .feed,
body.landscape.hud-hidden .dock-timer,
body.landscape.hud-hidden .dock-actions,
body.landscape.hud-hidden .dock-mp { visibility: hidden; }

/* 手機直拿時把整個畫面轉 90 度：觀眾把手機轉橫就是正的，開了直向鎖定也一樣。 */
@media (orientation: portrait) {
  body.landscape .stage {
    inset: auto; top: 0; left: 0;
    width: 100dvh; height: 100vw;
    transform: rotate(90deg) translateY(-100%);
    transform-origin: top left;
  }
  body.landscape .scene { width: 100dvh; height: 100vw; }
}

/* ───── 首頁卡片順序：提示 → 你不在時 → 我的勇者 → 加到主畫面 → 行動 ───── */
body:not(.display) #notice { order: -6; }
body:not(.display) #away { order: -5; }
body:not(.display) #me-strip { order: -4; }
body:not(.display) #install { order: -3; }
/* 11/21：已經有勇者的人，「加到主畫面」排在行動後面、預設收合，不擋操作。 */
body:not(.display) #install.has-hero { order: 0; }
body:not(.display) #restore { order: -1; }
body:not(.display) #guest-card { order: -2; }
body:not(.display) #actions { order: -1; }

/* 手機：廣播是場景下方的一條跑馬燈，最多三則。 */
@media (max-width: 700px) {
  body:not(.display):not(.landscape) .feed {
    background: var(--deep); border: 1px solid #3d2443; border-radius: 10px;
    padding: 6px 10px; gap: 2px; font-size: 12px;
  }
  body:not(.display):not(.landscape) .feed-line { background: none; padding: 1px 0; }
  body:not(.display):not(.landscape) .feed-line:nth-last-of-type(n+3) { display: none; }
  /* 11/18 的固定場景把廣播限高 3.6em，加上內距會切到第一行；改成只顯示兩則、不限高。 */
  body:not(.display):not(.landscape) .feed { max-height: none; overflow: visible; }
  body:not(.display):not(.landscape) .feed-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* 11/21 Louisa：新訊息要完整看得到。最新那則可以換行，舊的那則維持一行。 */
  body:not(.display):not(.landscape) .feed-line:last-of-type { white-space: normal; }
  body:not(.display):not(.landscape) .feed-jump { display: none; }
  /* 場景縮到 40svh 後，44px 的按鈕會蓋到勇者名牌：手機直式改成小圖示、貼角落。 */
  body:not(.display):not(.landscape) .scene-tools { right: 1.5%; bottom: 1.5%; gap: 4px; }
  body:not(.display):not(.landscape) .scene .tool { min-width: 30px; min-height: 30px; padding: 0 6px; border-radius: 8px; }
  body:not(.display):not(.landscape) .scene .tool svg { width: 16px; height: 16px; }
  body:not(.display):not(.landscape) .scene .tool-label { display: none; }
  /* 名牌：不要從「內湖三｜吉彩花」中間斷行。 */
  body:not(.display):not(.landscape) .title-plate { word-break: keep-all; line-height: 1.3; }
  /* 數值條：空的時候也看得出是一條。 */
  body:not(.display):not(.landscape) .beauty-plate .gauge-track { background: rgb(255 255 255 / 0.12); border-width: 1px; }
}

/* 電腦上分頁列不要拉滿整個寬度。 */
.tabs { padding-inline: max(0px, calc((100% - 640px) / 2)); }

/* ───── 勇者分頁：大張展示 ───── */
.hero-show {
  position: relative; display: grid; justify-items: center; gap: 6px;
  margin: -16px -16px 4px; padding: 18px 16px 14px; border-radius: 10px 10px 0 0; overflow: hidden;
  background: linear-gradient(180deg, rgb(26 15 34 / 0.2), var(--panel)), url("/assets/art/scene_garden_night.png") center 70% / 160% no-repeat;
  image-rendering: pixelated;
}
.hero-show > img.sprite { width: 168px; margin-bottom: -16px; }
.hero-plate { display: flex; align-items: center; gap: 6px; background: rgb(31 18 38 / 0.92); border: 1px solid var(--gold); border-radius: 8px; padding: 3px 12px; }
.hero-plate strong { font-size: 17px; }
.hero-plate .lv { color: var(--gold); font-weight: 700; }

/* 勇者私人活動：固定時間、材料與日記，只出現在「我的勇者」分頁。 */
.activity-card { border-color: rgb(233 194 122 / 0.42); }
.activity-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.activity-actions > button, .activity-help > button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 54px; }
.activity-actions button span { color: var(--muted); font-size: 0.82em; }
.activity-help { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.activity-help select { grid-column: 1; }
.activity-help button { grid-column: 2; grid-row: 1 / span 3; }
.activity-help > small, .activity-help > span { grid-column: 1; }
.activity-status { min-height: 42px; }
.activity-status:empty { display: none; }
.activity-running { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: rgb(19 11 28 / 0.55); }
.activity-materials { display: flex; flex-wrap: wrap; gap: 6px; }
.activity-material { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--cream); font-size: 0.88em; }
.activity-diary { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.activity-diary li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid rgb(255 255 255 / 0.08); }
.activity-diary time { flex: 0 0 auto; color: var(--muted); font-size: 0.82em; }
@media (max-width: 430px) { .activity-actions { grid-template-columns: 1fr 1fr; } .activity-actions > button { min-height: 48px; padding: 8px 12px; } }
.hero-plate .badge { width: 18px; height: 18px; margin: 0; flex: none; }
.hero-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.hero-chips span { font-size: 11px; background: var(--card); border: 1px solid #5b3a63; border-radius: 10px; padding: 2px 9px; }
body:not(.display) #me > h2 { display: none; }

/* 橫向全螢幕：兩側用場景圖放大模糊延伸，不留黑邊。 */
body.landscape .scene::before {
  content: ""; position: absolute; inset: -24px; z-index: 0;
  background: url("/assets/art/scene_garden_night.png") center / cover no-repeat;
  filter: blur(8px) brightness(0.42);
}
body.landscape .map { z-index: 1; box-shadow: 0 0 40px rgb(0 0 0 / 0.6); }

/* ───── 11/18 修正：style.css 的按鈕、輸入框通用樣式（格線排版、靠左、內距、44px 高、粗框）
   蓋過了 v0.4 的圓形按鈕和開關，圖示沒置中、開關的圓點跑位。這裡把它們歸位。 ───── */
.switch input {
  padding: 0; min-height: 0; border: 0; box-sizing: border-box;
  height: 32px; width: 52px; border-radius: 16px;
}
.switch input::after { top: 4px; left: 4px; }
.switch input:checked::after { left: 24px; }
.notice-close, .sound-row .play {
  display: grid; place-items: center; text-align: center; padding: 0; line-height: 1;
}
.notice-close { width: 32px; height: 32px; border-width: 1px; }
.sound-row .play { border-width: 1px; font-size: 16px; padding-left: 3px; }

/* 11/18 修正：通用的 .sprite（寬 100%）蓋過了小卡大頭照的裁切，整隻勇者被縮進小框；改回只放臉。 */
.strip-face { align-items: flex-start; }
.strip-face img.sprite { width: 80px; height: 80px; max-width: none; margin-top: -2px; flex: none; }
/* 小場景條的縮圖：原本是場景圖再疊一張床的圖，擠在一起；改成只放睡美人的臉。 */
.mini-thumb { position: relative; background: #3a2340; }
.mini-thumb img.sprite { position: absolute; width: 80px; max-width: none; left: -15px; top: -13px; }

/* ───── 補 HP、護盾的對象：點頭像 ───── */
.target-picker { display: grid; gap: 10px; background: var(--card); border: 1px solid #3d2443; border-radius: 12px; padding: 12px; }
.target-title { margin: 0; font-weight: 700; color: var(--cream); }
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.target-tile { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; min-height: 0; text-align: center; border-width: 1px; }
.target-tile strong { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-tile small { font-size: 11px; }
.target-face { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--night); display: flex; justify-content: center; align-items: flex-start; }
.target-face img.sprite { width: 80px; height: 80px; max-width: none; margin-top: -2px; flex: none; }
.target-face img.sprite.princess { width: 96px; height: 96px; margin: -12px 0 0 6px; }
.target-cancel { justify-self: start; min-height: 36px; padding: 4px 14px; border-width: 1px; text-align: center; }

/* ───── 管理員：底部分頁多兩格（後台、數據）───── */
.display .tabs { display: none !important; }
body.is-admin .tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tabs .admin-tab[hidden] { display: none; }
/* 後台頁也要留底部分頁列的空間。 */
body.admin-view .page { padding-bottom: calc(var(--tabbar) + 16px); }

/* 11/18 修正：錄音分類和按鈕的字被通用按鈕樣式擠到左上角。 */
.voice-groups button, .voice-buttons button {
  display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; border-width: 1px;
}
.voice-buttons .send { background: var(--coral); color: var(--ink); font-weight: 700; border-color: var(--coral); }

/* ───── 加入：髮型（頭像點選）───── */
.style-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.style-pick { position: relative; display: block; cursor: pointer; border-radius: 50%; }
.style-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.style-pick .target-face { width: 48px; height: 48px; border: 2px solid transparent; box-sizing: border-box; }
.style-pick .target-face img.sprite { width: 74px; height: 74px; }
.style-pick input:checked + .target-face { border-color: var(--coral); }
.style-pick input:focus-visible + .target-face { outline: 2px solid var(--cream); outline-offset: 2px; }

/* ───── 後台改版：一頁只做一件事 ───── */
#admin { display: block; }
#admin[hidden] { display: none; }
.admin-page { display: grid; gap: 12px; }
.admin-page[hidden] { display: none; }
.admin-page h3 { margin: 8px 0 0; font-size: 15px; }
.admin-top { display: flex; align-items: center; gap: 8px; }
.admin-top h2 { flex: 1; margin: 0; }
.admin-back { min-width: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; font-size: 22px; border-width: 1px; }
.admin-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.admin-tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.admin-tile span, .admin-tile small { font-size: 12px; color: var(--muted); }
.admin-tile strong { font-size: 18px; }
.admin-todo { display: grid; gap: 8px; }
.admin-todo-row, .admin-nav-row, .admin-hero-row {
  display: flex !important; align-items: center; gap: 12px; width: 100%; text-align: left; border-width: 1px;
}
.admin-todo-row { min-height: 64px; padding: 10px 14px; border-radius: 12px; background: var(--card); }
.admin-todo-row.hot { border-color: var(--coral); }
.admin-count { width: 36px; height: 36px; border-radius: 50%; background: var(--button); display: grid; place-items: center; font-weight: 900; flex: none; }
.admin-todo-row.hot .admin-count { background: var(--coral); color: var(--ink); }
.admin-todo-text { flex: 1; display: grid; gap: 2px; }
.admin-todo-text small, .admin-nav-row small { color: var(--muted); font-size: 12px; }
.admin-go { color: var(--muted); font-size: 20px; }
.admin-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-quick > * { min-height: 56px; text-align: center; display: grid !important; place-items: center; font-weight: 700; }
.admin-nav { display: grid; }
.admin-nav-row { min-height: 52px; padding: 0 4px; background: none; border: 0; border-bottom: 1px solid #3d2443; border-radius: 0; }
.admin-nav-label { flex: 1; font-size: 15px; }
.admin-logout { justify-self: start; background: none; border: 0; color: var(--muted); padding: 0; }
.admin-world { font-size: 12px; margin: 0; }
.admin-review-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 12px; }
.admin-review-text { margin: 0; font-size: 24px; font-weight: 900; line-height: 1.4; }
.admin-chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.admin-chips span { background: var(--panel); border-radius: 999px; padding: 4px 10px; }
.admin-review-buttons { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.admin-review-buttons button { min-height: 56px; display: grid; place-items: center; text-align: center; font-size: 16px; font-weight: 700; }
.admin-next { background: var(--panel); border-radius: 12px; padding: 10px 14px; display: flex; gap: 10px; align-items: baseline; }
.admin-next span { flex: 1; }
.admin-next small { color: var(--muted); }
.admin-empty { border: 1px dashed var(--line); border-radius: 16px; padding: 24px; text-align: center; display: grid; gap: 6px; justify-items: center; }
.admin-empty small { color: var(--muted); }
.admin-search { font-size: 13px; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-filters button { min-height: 36px; padding: 0 14px; border-radius: 999px; border-width: 1px; display: inline-flex; align-items: center; font-size: 13px; }
.admin-filters button[aria-pressed="true"] { background: var(--coral); color: var(--ink); font-weight: 700; }
.admin-hero-list { list-style: none; margin: 0; padding: 0; display: grid; }
.admin-hero-row { min-height: 60px; padding: 4px; background: none; border: 0; border-bottom: 1px solid #3d2443; border-radius: 0; }
.admin-hero-row .target-face { width: 40px; height: 40px; flex: none; }
.admin-hero-row .target-face img.sprite { width: 62px; height: 62px; }
.admin-hero-row.frozen { opacity: 0.55; }
.admin-hero-text { flex: 1; display: grid; gap: 2px; }
.admin-hero-text small { color: var(--muted); font-size: 12px; font-weight: 400; }
.admin-hero-text small.online { color: var(--poison); }
.admin-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar); z-index: 45; max-width: 640px; margin: 0 auto;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px;
  display: grid; gap: 12px; box-shadow: 0 -12px 30px rgb(0 0 0 / 0.45);
}
.admin-sheet[hidden] { display: none; }
.admin-sheet-head { display: flex; align-items: center; gap: 12px; }
.admin-sheet-head > div { flex: 1; display: grid; gap: 2px; }
.admin-sheet-head small { color: var(--muted); font-size: 12px; }
.admin-sheet-head .target-face { width: 52px; height: 52px; }
.admin-sheet-close { min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 18px; border-width: 1px; }
.admin-sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-sheet-buttons button { min-height: 52px; display: grid; place-items: center; text-align: center; font-weight: 700; }
.admin-freeze { min-height: 44px; border: 1px solid var(--bad); background: transparent; color: #ffb3b2; text-align: center; display: grid; place-items: center; }
#admin { max-width: 640px; width: 100%; margin-inline: auto; box-sizing: border-box; }

/* ───── 數據：先看三個數字 ───── */
.stats-headline { display: grid; gap: 8px; }
.stats-big { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; align-items: baseline; gap: 10px; }
.stats-big span { flex: 1; font-size: 14px; color: var(--muted); }
.stats-big strong { font-size: 30px; font-weight: 900; }
.stats-big small { font-size: 12px; color: var(--muted); min-width: 5em; text-align: right; }
details.stats-more > summary { min-height: 48px; display: flex; align-items: center; font-size: 15px; font-weight: 700; cursor: pointer; }
details.stats-more[open] > summary { margin-bottom: 8px; }
.stats-note { font-size: 12px; }
#stats { max-width: 640px; width: 100%; margin-inline: auto; box-sizing: border-box; }
details.stats-more > summary::before { content: "▸"; margin-right: 8px; color: var(--muted); }
details.stats-more[open] > summary::before { content: "▾"; }
details.stats-more { border-bottom: 1px solid #3d2443; }

/* 補 HP 選對象：每格血條，血少於一半標紅 */
.target-hp { display: block; width: 80%; height: 5px; border-radius: 999px; background: var(--night); overflow: hidden; }
.target-hp span { display: block; height: 100%; background: var(--hp); }
.target-tile.low .target-hp span { background: #e8615e; }
.target-tile.low small { color: #ff9b98; }

/* 改暱稱 */
.hero-chips .rename-open { min-height: 0; padding: 2px 10px; font-size: 12px; border-radius: 999px; }
.rename-box { display: grid; gap: 8px; margin: 10px 0; padding: 12px; border: 1px solid var(--line, rgb(255 255 255 / 0.15)); border-radius: 10px; }
.rename-box label { display: grid; gap: 4px; }
.rename-box .error { color: #ff9b98; }
.rename-actions { display: flex; gap: 8px; }

/* 實況主個人頁連結 */
.site-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.site-link[hidden] { display: none; }
.site-face { width: 44px; height: 44px; object-fit: cover; object-position: top; border-radius: 50%; background: var(--night); flex: none; }
.site-link strong { display: block; }
.site-link small { color: var(--muted); }
.site-arrow { margin-left: auto; color: var(--muted); font-size: 18px; }

/* Twitch 聊天室 */

/* ───── 電腦版（11/19 改版）─────
   1100px 以上：像 Twitch 一樣兩欄、整頁不捲動、兩欄各自捲。
   左欄＝遊戲：場景（含兩側名牌、排行、廣播）＋下面的行動；右欄＝分頁列＋內容（守夜分頁是聊天室，像 Twitch 的聊天在右邊）。
   管理後台、數據也改成吃滿寬度的多欄。 */
.left-col { display: contents; }
.stage-below:empty { display: none; }
@media (min-width: 1100px) {
  body:not(.display):not(.admin-view):not(.landscape) .page {
    max-width: none; height: 100dvh; box-sizing: border-box; overflow: hidden;
    padding: 14px 18px; margin: 0;
    grid-template-columns: minmax(0, 1fr) clamp(340px, 26vw, 440px);
    grid-template-areas: "left tabs" "left panel";
    grid-template-rows: auto minmax(0, 1fr); column-gap: 16px; row-gap: 10px;
  }
  body:not(.display):not(.admin-view):not(.landscape) .left-col {
    grid-area: left; display: grid; gap: 12px; align-content: start; min-height: 0; overflow-y: auto; scrollbar-width: thin;
  }
  body:not(.display):not(.admin-view):not(.landscape) .stage { display: block !important; position: relative; top: auto; }
  body:not(.display):not(.admin-view):not(.landscape) .stage-below { display: grid; gap: 12px; }
  /* 行動在場景下面：技能格排成一列多格。 */
  body:not(.display):not(.admin-view):not(.landscape) .stage-below #actions .buttons { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  /* 招牌技在電腦上跟其他技能一樣寬，只靠金色區分（手機上才整列）。 */
  body:not(.display):not(.admin-view):not(.landscape) .stage-below #actions button.signature { grid-column: auto; }
  body:not(.display):not(.admin-view):not(.landscape) .mini-scene { display: none !important; }
  body:not(.display):not(.admin-view):not(.landscape) .panel {
    grid-area: panel; max-width: none; margin: 0; gap: 12px; min-height: 0; overflow-y: auto; align-content: start; scrollbar-width: thin;
    grid-auto-rows: max-content;
  }
  /* 場景：3:2，高度不超過視窗的 70%，下面留給行動。 */
  body:not(.display):not(.admin-view):not(.landscape) .scene { aspect-ratio: 3 / 2; max-height: 70dvh; margin-inline: auto; font-size: clamp(9px, 1.15cqw, 15px); }
  body:not(.display):not(.admin-view):not(.landscape) .title-plate,
  body:not(.display):not(.admin-view):not(.landscape) .beauty-plate,
  body:not(.display):not(.admin-view):not(.landscape) .board,
  body:not(.display):not(.admin-view):not(.landscape) .feed { width: 15.4%; }
  body:not(.display):not(.admin-view):not(.landscape) .title-plate,
  body:not(.display):not(.admin-view):not(.landscape) .beauty-plate,
  body:not(.display):not(.admin-view):not(.landscape) .feed { left: 0.8%; }
  body:not(.display):not(.admin-view):not(.landscape) .board { right: 0.8%; }
  /* 聊天室：守夜分頁預設打開、拉高，像 Twitch 右邊那條。 */
  body:not(.display):not(.admin-view):not(.landscape) .chat-panel .chat-lines { height: calc(100dvh - 330px); min-height: 360px; }

  /* 分頁列：在右欄最上面，一行放得下（管理員多兩格時拿掉圖示）。 */
  body:not(.display):not(.landscape) .tabs {
    grid-area: tabs; position: relative; z-index: 20;
    height: auto; padding: 4px; box-sizing: border-box;
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    border: 1px solid var(--line); border-radius: 12px; background: var(--deep);
  }
  body:not(.display):not(.landscape) .tabs button { flex-direction: row; gap: 6px; min-height: 40px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
  body:not(.display):not(.landscape) .tabs button[aria-current="page"] { background: rgb(255 130 128 / 0.12); }
  body:not(.display):not(.landscape) .tabs svg { width: 18px; height: 18px; flex: none; }
  body.is-admin:not(.display):not(.landscape) .tabs svg { display: none; }
  body.is-admin:not(.display):not(.landscape) .tabs button { font-size: 13px; }

  /* ───── 管理後台（電腦版）：三欄同時看：後台首頁｜勇者名單｜第三欄（留言審核、訂單、送藥水…）───── */
  body.admin-view:not(.display) .page { max-width: 1680px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "tabs" "panel"; padding: 14px 20px 24px; }
  body.admin-view:not(.display) .left-col { display: none; }
  body.admin-view:not(.display) .tabs { width: min(100%, 760px); justify-self: center; position: sticky; top: 10px; }
  body.admin-view:not(.display) .panel { grid-area: panel; max-width: none; }
  body.admin-view:not(.display) #admin, body.admin-view:not(.display) #stats { max-width: none; }
  body.admin-view:not(.stats-view):not(.display) #admin:not([hidden]) {
    display: grid; grid-template-areas: none; align-items: start; gap: 20px;
    grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.25fr) minmax(320px, 1fr);
  }
  body.admin-view:not(.display) #admin .admin-page[data-page="home"] { grid-column: 1; }
  body.admin-view:not(.display) #admin .admin-page[data-page="heroes"] { grid-column: 2; }
  body.admin-view:not(.display) #admin .admin-page:not([data-page="home"]):not([data-page="heroes"]) { grid-column: 3; }
  body.admin-view:not(.display) #admin .admin-page { grid-row: 1; min-width: 0; }
  body.admin-view:not(.display) #admin .admin-page[data-page="home"] .admin-back,
  body.admin-view:not(.display) #admin .admin-page[data-page="heroes"] .admin-back { display: none; }
  /* 勇者詳細：右下角浮出來的小視窗，不蓋住整排。 */
  body.admin-view:not(.display) .admin-sheet { left: auto; right: 24px; bottom: 24px; width: 420px; border-radius: 16px; border: 1px solid var(--line); }

  /* ───── 數據（電腦版）：上面三個大數字一排，下面多欄、預設全部展開 ───── */
  body.stats-view:not(.display) .stats-headline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.stats-view:not(.display) .stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; align-items: start; }
  body.stats-view:not(.display) .stats-grid > .stats-wide { grid-column: 1 / -1; }
  body.stats-view:not(.display) details.stats-more { border: 1px solid #3d2443; border-radius: 12px; padding: 4px 14px 12px; }
}

/* 派勇者去找 */
.search-card { border-color: var(--gold) !important; }
.search-status { color: var(--gold); font-size: 14px; }
.search-actions { display: grid; gap: 8px; }

/* HiveBee 贊助付款卡片 */
.pay-sheet-backdrop { position: fixed; inset: 0; z-index: 100; background: rgb(15 8 20 / 0.72); display: grid; place-items: center; padding: 16px; }
.pay-sheet { width: min(100%, 440px); max-height: calc(100dvh - 32px); overflow-y: auto; display: grid; gap: 10px; }
.pay-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 12px; }
.pay-code-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.pay-code { font-size: 30px; letter-spacing: 0.18em; font-family: ui-monospace, Menlo, monospace; color: var(--gold); }
.pay-phrase { flex: 1; font-size: 15px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.06); color: var(--gold); user-select: all; -webkit-user-select: all; word-break: break-all; }
.pay-copied { display: block; font-size: 13px; margin-top: 4px; min-height: 1em; }
.pay-go { display: inline-flex; justify-content: center; text-decoration: none; padding: 10px 14px; border-radius: 10px; }
.pay-status { color: var(--muted); }
.pay-status.paid { color: #9fe59a; font-weight: 700; }
.pay-note { font-size: 12px; }
.pay-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pay-go { background: var(--coral); color: var(--ink); font-weight: 700; }

/* 後台：沒配到的贊助 */
.admin-donation { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid #3d2443; }
.admin-donation p { margin: 0; }
.admin-donation-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.admin-donation-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.admin-donation-actions select { min-width: 0; }

/* 11/20：訪客勇者與 Twitch／Google 登入 */
.login-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.login-buttons .google-login { min-height: 40px; }
.twitch-login { background: #9146ff; color: #fff; border-color: #9146ff; border-radius: 999px; padding: 9px 18px; font-weight: 700; }
.guest-bar { border-left: 3px solid var(--gold); padding: 4px 0 4px 12px; }
.guest-bar.expired, .guest-card { border-color: #ff8280; }
.guest-bar p { margin: 0 0 6px; }
.restore h2 { margin-bottom: 4px; }
.restore details { margin-top: 6px; }

/* 11/20：紀錄區像線上遊戲對話框：時間、誰說的、分類顏色；最新在最下面。 */
.feed-line { display: block; line-height: 1.45; overflow-wrap: anywhere; }
.feed-time { color: var(--muted); font-size: 0.82em; margin-right: 0.45em; font-variant-numeric: tabular-nums; opacity: 0.75; }
.feed-speaker { color: #ff9e9c; font-weight: 700; }
.feed-line.dream { color: #cdbcff; font-style: italic; }
.feed-line.dream .feed-speaker { color: #b9a3ff; }
.feed-line.kind-battle { color: #ff8a80; }
.feed-line.kind-gift { color: #ffc96b; }
.feed-line.kind-hero { color: #8fe3b0; }
.feed-line.kind-beauty { color: #9fd0ff; }
.feed-line.kind-action { color: var(--cream); opacity: 0.9; }
/* 直播畫面和中尺寸：只露最後 6 行，不捲（電腦版的場景左欄可以捲）。 */
.feed-line:nth-last-child(n+7) { display: none; }
.scene > .feed .feed-line { display: block; }
.display .feed-line:nth-last-child(n+7) { display: none; }
.board-gap { border: 0; border-top: 1px solid rgb(233 194 122 / 0.25); margin: 0.5em 0; }
.support-heart { font-size: 26px; color: #ff8280; width: 44px; text-align: center; }

@media (min-width: 1100px) {
  /* 場景改成三欄：左＝名牌、睡美人數值、紀錄；中＝正方形花園；右＝排行榜。兩側欄至少 240px。 */
  body:not(.display):not(.admin-view):not(.landscape) .stage { container: stage / inline-size; }
  body:not(.display):not(.admin-view):not(.landscape) .scene {
    --scene-h: min(72dvh, calc(100cqw - 480px), 820px);
    aspect-ratio: auto; max-height: none; width: 100%; height: var(--scene-h);
    display: grid; grid-template-columns: minmax(240px, 1fr) var(--scene-h) minmax(240px, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr); column-gap: 0;
    font-size: clamp(12px, 0.95vw, 15px);
  }
  body:not(.display):not(.admin-view):not(.landscape) .map {
    position: relative; left: auto; translate: none; grid-column: 2; grid-row: 1 / -1; width: 100%; height: 100%;
  }
  body:not(.display):not(.admin-view):not(.landscape) .title-plate,
  body:not(.display):not(.admin-view):not(.landscape) .beauty-plate,
  body:not(.display):not(.admin-view):not(.landscape) .board,
  body:not(.display):not(.admin-view):not(.landscape) .scene > .feed {
    position: static; width: auto; inset: auto; margin: 10px 10px 0; box-sizing: border-box;
  }
  body:not(.display):not(.admin-view):not(.landscape) .title-plate { grid-column: 1; grid-row: 1; }
  body:not(.display):not(.admin-view):not(.landscape) .beauty-plate { grid-column: 1; grid-row: 2; }
  /* 11/25：排行榜（兩個榜各 5 名）比名牌＋數值高，以前只跨前兩列，會把左邊名牌和數值框撐高、深眠標籤變成大圓。
     改成跨整欄，多出來的高度交給最下面的紀錄。 */
  body:not(.display):not(.admin-view):not(.landscape) .board { grid-column: 3; grid-row: 1 / -1; align-self: start; }
  body:not(.display):not(.admin-view):not(.landscape) .title-plate,
  body:not(.display):not(.admin-view):not(.landscape) .beauty-plate { align-self: start; }
  body:not(.display):not(.admin-view):not(.landscape) .scene > .feed {
    grid-column: 1; grid-row: 3; margin-bottom: 10px; min-height: 0; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px; padding: 8px 10px;
    background: rgb(20 12 28 / 0.6); border: 1px solid var(--line); border-radius: 8px;
    font-size: 13px; scrollbar-width: thin;
  }
  body:not(.display):not(.admin-view):not(.landscape) .scene > .feed > :first-child { margin-top: auto; }
  body:not(.display):not(.admin-view):not(.landscape) .scene > .feed .feed-line { background: none; padding: 0; white-space: normal; }
  /* 左欄比較窄（例如筆電把視窗拉小）：花園在左，名牌、數值、排行、紀錄全部疊在右邊一欄。 */
  @container stage (max-width: 999px) {
    body:not(.display):not(.admin-view):not(.landscape) .scene {
      --scene-h: min(72dvh, calc(100cqw - 250px));
      grid-template-columns: var(--scene-h) minmax(240px, 1fr);
      grid-template-rows: auto auto auto minmax(0, 1fr);
    }
    body:not(.display):not(.admin-view):not(.landscape) .map { grid-column: 1; }
    body:not(.display):not(.admin-view):not(.landscape) .title-plate { grid-column: 2; grid-row: 1; }
    body:not(.display):not(.admin-view):not(.landscape) .beauty-plate { grid-column: 2; grid-row: 2; }
    body:not(.display):not(.admin-view):not(.landscape) .board { grid-column: 2; grid-row: 3; }
    body:not(.display):not(.admin-view):not(.landscape) .scene > .feed { grid-column: 2; grid-row: 4; margin-bottom: 64px; }
  }
}
.pay-warning { color: #ff9e9c; font-weight: 700; margin: 8px 0; }
.feed-line.kind-card { color: #e0b3ff; }

/* 11/21 遊戲頁聊天室：大家都看得到，登入 Twitch 就能發言 */
.chat-panel[hidden] { display: none; }
.chat-panel .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-popout { font-size: 13px; }
.chat-lines { height: 260px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; margin: 8px 0; border-radius: 8px; background: rgb(0 0 0 / 0.22); font-size: 14px; line-height: 1.45; }
.chat-line { overflow-wrap: anywhere; }
.chat-name { margin-right: 0.35em; }
.chat-name::after { content: "："; color: var(--muted, #b9a8bf); font-weight: 400; }
.chat-emote { height: 1.6em; vertical-align: middle; margin: 0 1px; }
.chat-empty { margin: auto 0; text-align: center; font-size: 13px; }
.chat-form { display: grid; gap: 6px; }
.chat-row { display: flex; gap: 8px; }
.chat-input { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; }
.chat-send, .chat-login { min-height: 44px; }
.chat-login { width: 100%; }
.chat-logout { background: none; border: 0; padding: 0; min-height: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; }

/* 11/21 數據收進後台：標題左邊的「‹」回後台 */
#stats .admin-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; }

/* 11/21 商店改版：商品卡片＋結帳視窗 */
.shop-intro { margin-top: -4px; }
.shop-group-title { margin: 18px 0 8px; font-size: 15px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-card { display: grid; grid-template-rows: auto 1fr auto; justify-items: start; gap: 6px; text-align: left; padding: 12px; min-height: 150px;
  border-radius: 12px; border: 1px solid var(--line, #5b3a63); background: var(--card, #2a1832); color: var(--cream, #fff4e8); cursor: pointer; }
.shop-card:hover, .shop-card:focus-visible { border-color: var(--gold, #e9c27a); }
.shop-card .shop-text { display: grid; gap: 3px; }
.shop-card .shop-text small { color: var(--muted, #b9a8bf); font-size: 12px; line-height: 1.4; }
.shop-card .shop-price { font-weight: 700; color: var(--gold, #e9c27a); }
.shop-card.grand { grid-column: 1 / -1; min-height: 0; grid-template-columns: auto 1fr auto; grid-template-rows: auto; align-items: center;
  border-color: rgb(233 194 122 / 0.6); background: linear-gradient(135deg, rgb(233 194 122 / 0.12), transparent); }
.shop-icon { font-size: 28px; line-height: 1; }
.checkout { max-height: 90dvh; overflow-y: auto; }
.checkout-head { display: flex; gap: 12px; align-items: flex-start; }
.checkout-head h2 { margin: 0 0 4px; }
.checkout-head p { margin: 0; }
.checkout-label { margin: 12px 0 6px; font-weight: 700; }
.checkout-field { display: grid; gap: 6px; margin-top: 12px; font-size: 14px; }
.checkout-field input, .checkout-field select { min-height: 44px; font-size: 16px; }
.checkout-error { color: #ff9b9b; margin: 8px 0 0; }
.checkout #job-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 11/21 勇者日記、CG 收藏、皇家贊助人 */
.diary-tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.diary-tabs button { flex: 1; min-height: 40px; border-radius: 999px; }
.diary-tabs button[aria-selected="true"] { border-color: var(--gold, #e9c27a); color: var(--gold, #e9c27a); }
.diary-list { list-style: none; margin: 0; padding: 0; display: grid; max-height: 420px; overflow-y: auto; }
.diary-list[hidden] { display: none; }
.diary-list li { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgb(255 255 255 / 0.08); align-items: baseline; }
.diary-list time { color: var(--muted, #b9a8bf); font-size: 12px; white-space: nowrap; }
.diary-list .diary-empty { display: block; border: 0; }
.cg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.cg-grid[hidden] { display: none; }
.cg-tile { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 6px; border-radius: 12px; border: 1px dashed var(--line, #5b3a63); text-align: center; }
.cg-tile.unlocked { border-style: solid; border-color: var(--gold, #e9c27a); }
.cg-thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; background: rgb(0 0 0 / 0.3); font-size: 28px; color: var(--muted, #b9a8bf); }
.cg-tile small { color: var(--muted, #b9a8bf); }
.sponsor-board { margin-top: 18px; }
.sponsor-board[hidden] { display: none; }
.sponsor-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.sponsor-list li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: rgb(0 0 0 / 0.2); }
.sponsor-list li.mine { outline: 1px solid var(--gold, #e9c27a); }
.sponsor-rank { width: 1.6em; text-align: center; font-weight: 700; color: var(--gold, #e9c27a); }

/* 11/21 字少一點：按鈕用圖示 */
.action-button .action-top { justify-content: flex-start; }
.action-button .action-top .mp-cost { margin-left: auto; }
.action-icon { font-size: 18px; line-height: 1; }
#action-buttons .action-button, #potion-buttons .action-button, #greeting-buttons .action-button { min-height: 48px; }
.auto-rules { margin-top: 2px; }
.auto-rules summary { cursor: pointer; font-size: 12px; color: var(--muted, #b9a8bf); }
.shop-card { min-height: 128px; }
@media (max-width: 700px) {
  body:not(.display):not(.admin-view):not(.landscape) .chat-panel .chat-lines { height: 240px; min-height: 0; }
}

/* 11/21 夢晶 */
.activity-material.crystal { display: inline-flex; gap: 8px; align-items: baseline; font-weight: 700; border-color: rgba(150, 200, 255, 0.45); }
.activity-material.crystal small { font-weight: 400; opacity: 0.75; }
.shop-price .shop-crystal { display: block; font-size: 0.78em; opacity: 0.8; font-weight: 400; }
.pay-actions:has(.crystal-pay) { flex-wrap: wrap; }
.pay-actions:has(.crystal-pay) > .primary { flex: 1 1 0; }
.pay-actions .crystal-pay { order: -1; flex: 1 1 100%; border: 1px solid rgba(150, 200, 255, 0.5); }
/* 11/25：只能用夢晶換的商品，夢晶按鈕就是主要按鈕：跟其他結帳一樣「先不買」在左、主要按鈕在右。 */
.pay-actions .crystal-pay.primary { order: 0; flex: 1 1 0; }

/* 11/21：CG 收藏分組、縮圖、全螢幕看圖 */
.cg-group { grid-column: 1 / -1; margin: 8px 0 0; font-size: 0.95em; color: var(--cream, #f6e7d8); }
.cg-group:first-child { margin-top: 0; }
button.cg-tile { font: inherit; color: inherit; background: none; cursor: pointer; }
.cg-thumb { position: relative; overflow: hidden; }
.cg-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cg-tile strong { font-size: 0.85em; }
.cg-group small { margin-left: 8px; font-weight: 400; color: var(--muted, #b9a8bf); }
.cg-viewer { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; gap: 10px; padding: 16px; background: rgb(10 6 16 / 0.88); text-align: center; color: #fff; cursor: zoom-out; }
.cg-viewer img { max-width: min(96vw, 1200px); max-height: 80vh; border-radius: 12px; }
.crystal-icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; image-rendering: pixelated; }

/* 11/21 跑版檢查：手機上事件卡縮小，只蓋住場景上半部（說明最多兩行、拿掉小提示），不擋聲音／全螢幕鍵。 */
@media (max-width: 700px), (max-height: 500px) {
  body:not(.display) .event-card:not([data-portal="true"]) { top: 2%; width: 92%; font-size: 12px; gap: 0.35em; padding: 0.5em 0.7em; }
  body:not(.display) .event-card:not([data-portal="true"]) .card-head img { width: 2.4em; height: 2.4em; }
  body:not(.display) .event-card:not([data-portal="true"]) p {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body:not(.display) .event-card:not([data-portal="true"]) .card-hint { display: none; }
  body:not(.display) .event-card:not([data-portal="true"]) .card-option { padding: 0.45em 0.6em; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body:not(.display) .event-card:not([data-portal="true"]) { width: 70%; }
}
/* 很窄的手機（≤360）：行動按鈕字不要斷成兩行。 */
@media (max-width: 360px) {
  .action-button { padding-left: 10px; padding-right: 10px; }
  .action-button strong { white-space: nowrap; font-size: 14px; }
  .action-button .mp-cost { font-size: 10px; }
  .card-option span, .card-option b { white-space: nowrap; }
  .card-option { gap: 0.3em; }
}

/* 11/22 更新日誌 */
.changelog-entry { border-top: 1px solid var(--line, #5b3a63); padding: 8px 0; }
.changelog-entry:first-child { border-top: 0; }
.changelog-entry summary { display: flex; gap: 10px; align-items: baseline; cursor: pointer; list-style: none; }
.changelog-entry summary::-webkit-details-marker { display: none; }
.changelog-entry summary::after { content: "▾"; margin-left: auto; color: var(--muted, #b9a8bf); transition: transform 0.15s; }
.changelog-entry[open] summary::after { transform: rotate(180deg); }
.changelog-entry summary strong { color: var(--gold, #e9c27a); font-variant-numeric: tabular-nums; }
.changelog-entry ul { margin: 8px 0 2px; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.changelog-entry li { line-height: 1.5; }
