/* 色票：夜色底、奶油字，珊瑚色只用在「我的勇者」與主要按鈕。 */
:root {
  --night: #1f1226;
  --panel: #2a1a33;
  --card: #372340;
  --button: #4a3052;
  --cream: #fbf1ea;
  --muted: #b9a6bd;
  --ink: #3a2626;
  --outline: #3d0f1e;
  --coral: #ff8280;
  --hp: #f2b84b;
  --dream: #ffd9d4;
  --mp: #8fb8ff;
  --poison: #c9e06a;
  --bad: #e8607a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--night);
  color: var(--cream);
  font: 16px/1.5 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.page { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--muted); font-weight: 500; }

/* ───── 場景 ─────
   場景圖（256px）放大約 2.8 倍置中成正方形；角色圖（128px）佔場景寬的 17.8%，
   兩者像素密度不同，跟 RO 一樣。左右兩側留給名牌、數值、排行榜和廣播。 */
.scene {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  border: 3px solid var(--outline);
  background: #1b1730;
  container-type: inline-size;
  font-size: clamp(9px, 1.5cqw, 16px);
}
.map {
  position: absolute; top: 0; bottom: 0; left: 50%; translate: -50% 0;
  aspect-ratio: 1; height: 100%;
  background: url("/assets/art/scene_garden_night.png") center / 100% 100% no-repeat;
  image-rendering: pixelated;
  container-type: size;
}
.sprite { display: block; width: 100%; image-rendering: pixelated; user-select: none; -webkit-user-drag: none; }
.scene.quake .map { animation: quake 0.18s linear 14; }
@keyframes quake { 25% { transform: translate(-0.4%, 0.3%); } 75% { transform: translate(0.4%, -0.3%); } }

.plate {
  position: absolute;
  background: rgb(42 26 51 / 0.88);
  border: 2px solid var(--outline);
  border-radius: 8px;
  padding: 0.5em 0.8em;
  z-index: 4;
}
.title-plate { top: 2%; left: 1.2%; width: 19.5%; display: grid; }
.title-plate span { color: var(--muted); font-size: 0.85em; }
.beauty-plate { top: 17%; left: 1.2%; width: 19.5%; display: grid; gap: 0.4em; }
.beauty-plate .gauges { width: 100%; }
.board { top: 2%; right: 1.2%; width: 19.5%; }
.board-row { display: flex; justify-content: space-between; gap: 1em; font-size: 0.9em; }
.url-plate { bottom: 2%; right: 1.2%; width: 19.5%; font-size: 0.85em; display: none; }
.display .url-plate { display: flex; align-items: center; gap: 0.8em; }
.url-plate .qr { width: 42%; height: auto; aspect-ratio: 1; border-radius: 4px; flex: none; }
.url-plate div { display: grid; gap: 0.2em; }
.url-plate strong { font-size: 1.15em; }
.url-plate span { color: var(--muted); overflow-wrap: anywhere; }
.howto-plate { display: none; }
.display .howto-plate { display: block; top: 38%; left: 1.2%; width: 19.5%; font-size: 1.3em; line-height: 1.35; }
.howto-plate strong { font-size: 1.1em; }
.howto-plate ol { margin: 0.4em 0 0; padding-left: 1.3em; display: grid; gap: 0.35em; }
.howto-plate li { white-space: pre-line; }

.banner {
  position: absolute; top: 3%; left: 50%; transform: translateX(-50%);
  max-width: 50%; text-align: center; z-index: 6;
  background: var(--cream); color: var(--ink);
  border: 3px solid var(--outline); border-radius: 999px; padding: 0.5em 1.4em; font-weight: 700;
}
/* 廣播：寬螢幕放在場景左側欄的下半部，手機放在場景下方，免得蓋住角色。 */
.stage { position: relative; }
.feed { position: absolute; left: 1.2%; bottom: 2%; width: 19.5%; display: grid; gap: 3px; z-index: 4; font-size: clamp(10px, 0.95vw, 14px); }
.feed-line { background: rgb(31 18 38 / 0.85); border-radius: 6px; padding: 1px 8px; }
/* 手機直式：場景改成滿版正方形，名牌和睡美人數值縮小疊在天空那一條，廣播放到場景下方。 */
@media (max-width: 700px) {
  body:not(.display) .page { padding: 8px; gap: 10px; }
  body:not(.display) .scene { aspect-ratio: 1; font-size: 11px; border-width: 2px; }
  body:not(.display) .map { left: 0; translate: none; width: 100%; height: 100%; }
  body:not(.display) .plate { padding: 0.25em 0.5em; border-width: 1px; background: rgb(31 18 38 / 0.8); }
  body:not(.display) .title-plate { top: 1.5%; left: 1.5%; width: 34%; font-size: 10px; }
  body:not(.display) .beauty-plate { top: 1.5%; left: auto; right: 1.5%; width: 34%; gap: 0.2em; }
  body:not(.display) .beauty-plate .gauge span { width: 2.4em; }
  body:not(.display) .board { display: none; }
  body:not(.display) .banner { top: auto; bottom: 2%; max-width: 92%; font-size: 12px; }
  body:not(.display) .feed { position: static; width: auto; margin-top: 8px; font-size: 13px; }
  body:not(.display) .monster .gauges { width: 8em; bottom: auto; top: 92%; }
  /* 打開手機最常做的是行動，排在自己的勇者資料前面。 */
  body:not(.display) #notice { order: -3; }
  body:not(.display) #install { order: -2; }
  body:not(.display) #actions { order: -1; }
}

.gauges { display: grid; gap: 0.25em; justify-items: center; align-content: start; width: 12em; }
/* 狀態標籤（深眠、醒著倒數）不跟著格子撐大，維持一顆小膠囊。 */
.gauges > .tag { align-self: start; justify-self: center; }
.gauge { display: flex; align-items: center; gap: 0.4em; width: 100%; font-size: 0.8em; }
.gauge span { width: 3em; text-align: right; }
.gauge-track { flex: 1; height: 0.8em; background: var(--night); border: 2px solid var(--outline); border-radius: 999px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--hp); transition: width 0.6s; }
.gauge.dream .gauge-fill { background: var(--dream); }
.gauge.mp .gauge-fill { background: var(--mp); }
.gauge.xp .gauge-fill { background: #b9e27a; }
.gauge.poison .gauge-fill { background: var(--poison); }

.tag { background: var(--card); border: 2px solid var(--outline); border-radius: 999px; padding: 0 0.7em; font-size: 0.8em; }
.tag.bad { background: var(--bad); color: var(--ink); font-weight: 700; }
.tag.buff { background: var(--dream); color: var(--ink); }
.aura { display: flex; flex-wrap: wrap; gap: 0.3em; }
.aura:empty { display: none; }

.bubble {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--cream); color: var(--ink); border: 2px solid var(--outline);
  border-radius: 10px; padding: 0.2em 0.7em; white-space: nowrap; font-size: 0.85em; z-index: 3;
}

/* 睡美人：躺在床上；醒來時換成站姿圖，站在床前。床是場景圖的一部分。 */
.beauty { position: absolute; left: 41.1%; top: 25%; width: 17.8%; z-index: 2; transition: top 0.6s; }
.beauty .bubble { bottom: auto; top: -1.6em; }
/* 夢話：雲朵感、淡一點，跟醒著說話分開 */
.beauty .bubble.dreaming { background: var(--dream); border-style: dashed; border-radius: 999px; font-style: italic; opacity: 0.92; }
.beauty[data-state="awake"] { top: 24%; }
.beauty[data-state="deep"] .sleeper { filter: brightness(0.55) saturate(0.6); }
.beauty.dizzy .sleeper { animation: sway 2s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes sway { 50% { rotate: 6deg; } }
.zzz { position: absolute; left: 78%; top: 2%; color: var(--cream); font-weight: 700; pointer-events: none; }
.zzz span { position: absolute; animation: drift-up 3.6s ease-in infinite; opacity: 0; }
.zzz span:nth-child(1) { font-size: 0.8em; }
.zzz span:nth-child(2) { font-size: 1em; animation-delay: 1.2s; left: 0.5em; }
.zzz span:nth-child(3) { font-size: 1.25em; animation-delay: 2.4s; left: 1em; }
@keyframes drift-up { 0% { opacity: 0; translate: 0 1em; } 20% { opacity: 1; } 100% { opacity: 0; translate: 0.8em -2.2em; } }
.beauty[data-state="awake"] .zzz { display: none; }
@keyframes drift { 50% { transform: translateY(-0.5em); } }

.monster { position: absolute; left: 70%; top: 36%; width: 17.8%; display: grid; justify-items: center; gap: 0.3em; z-index: 2; }
.monster .gauges { width: 10em; position: absolute; bottom: 100%; }
.blob { animation: drift 2.4s ease-in-out infinite; }

/* 勇者：只站在草地上，左右各留一點給樹叢。初心者站後排，轉職者站前排。 */
.heroes { position: absolute; inset: 0 9%; pointer-events: none; z-index: 3; }
.hero { position: absolute; width: 17.8cqw; translate: -50% 0; display: grid; justify-items: center; transition: left 0.8s, top 0.8s; }
.hero.back { top: 58%; scale: 0.85; }
.hero.front { top: 70%; }
/* 相鄰的勇者前後錯開，名牌才不會疊在一起。 */
.hero.stagger { margin-top: 7cqh; }
.figure { transition: rotate 0.4s; }
/* 11/21：圖固定寬度。原本 width:100% 會被名牌撐開，名字越長（或多一行「近身守衛」）圖就越大。 */
.hero > .figure { width: 21cqw; max-width: none; }
.hero.down .figure { rotate: 90deg; translate: 0 25%; filter: grayscale(0.7); }
.hero.shielded .figure { filter: drop-shadow(0 0 0.4em rgb(143 184 255 / 0.9)); }
.hero.gifted .nameplate::after { content: "✿"; margin-left: 0.3em; color: var(--dream); }
.nameplate { margin-top: -0.6em; display: flex; align-items: center; gap: 0.25em; background: rgb(31 18 38 / 0.85); border: 2px solid var(--outline); border-radius: 6px; padding: 0 0.5em; font-size: 0.75em; white-space: nowrap; }
.nameplate span { color: var(--muted); margin-left: 0.25em; }
.nameplate .badge { width: 1.3em; height: 1.3em; margin-left: -0.2em; }
/* 自己的勇者：名牌外加一圈奶油色光暈。訂閱者：依等級換底框（只有外觀，不影響數值）。 */
.hero.mine .nameplate { box-shadow: 0 0 0 2px var(--cream); }
.hero[data-sub="1"] .nameplate { border-color: var(--coral); }
.hero[data-sub="2"] .nameplate { border-color: var(--coral); background: rgb(110 40 62 / 0.92); }
.hero[data-sub="3"] .nameplate { border-color: var(--hp); background: rgb(96 62 22 / 0.92); }

/* 個性：平常的小動作 */
.hero[data-personality="brave_fool"] .figure { animation: swing 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
.hero[data-personality="coward"] .figure { animation: shiver 2.5s steps(2) infinite; }
.hero[data-personality="sleepy"] .figure { animation: nod 3.5s ease-in-out infinite; transform-origin: 50% 90%; }
.hero[data-personality="showoff"] .figure { animation: hop 1.6s ease-in-out infinite; }
.hero[data-personality="worker"] .figure { animation: sigh 5s ease-in-out infinite; transform-origin: 50% 100%; }
.hero.down .figure { animation: none; }
@keyframes swing { 50% { rotate: 6deg; } }
@keyframes shiver { 50% { translate: 0.12em 0; } }
@keyframes nod { 60% { rotate: 8deg; translate: 0 0.2em; } }
@keyframes hop { 50% { translate: 0 -0.5em; } }
@keyframes sigh { 90% { scale: 1; } 95% { scale: 1.06 0.94; } }

/* 個性：地面搖晃時的反應 */
.hero[data-move="front"] { top: 70%; }
.hero[data-move="panic"] { animation: panic 0.9s ease-in-out infinite; }
.hero[data-move="late"] { transition-delay: 2.5s; top: 66%; }
.hero[data-move="tumble"] .figure { animation: tumble 1.2s ease-in-out 2; }
.hero[data-move="trudge"] { transition-duration: 4s; top: 67%; }
@keyframes panic { 25% { translate: calc(-50% - 3em) 0; } 75% { translate: calc(-50% + 3em) 0; } }
@keyframes tumble { 50% { rotate: 360deg; translate: 0 0.6em; } }

/* ───── 操作區 ───── */
.display .panel { display: none; }
.display .page { max-width: none; padding: 0; }
.display .scene { border-radius: 0; border: 0; height: 100vh; width: 100vw; aspect-ratio: auto; }
/* 12/03：直播畫面整體跟著視窗等比例縮放（以 1920×1080 為準，字 16px）。
   以前字有 16px 上限、不會跟著縮，視窗小於 1920（例如 1280×720）時「怎麼玩」會壓到下面的紀錄。 */
.display .scene { font-size: min(100vw / 120, 100vh / 67.5); }
.display .feed { font-size: min(0.73vw, 1.3vh); }

.panel { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.card { background: var(--panel); border: 2px solid var(--outline); border-radius: 12px; padding: 16px; display: grid; gap: 8px; }
.card .gauge { font-size: 14px; }
.notice { grid-column: 1 / -1; background: var(--cream); color: var(--ink); font-weight: 700; }

label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input:not([type="radio"]), select {
  font: inherit; color: var(--cream); background: var(--card);
  border: 2px solid var(--outline); border-radius: 8px; padding: 8px 10px; min-height: 44px;
}
button {
  font: inherit; color: var(--cream); background: var(--button);
  border: 2px solid var(--outline); border-radius: 10px; padding: 8px 14px; min-height: 44px;
  cursor: pointer; display: grid; text-align: left;
}
button small { color: var(--muted); font-size: 12px; }
button.primary { background: var(--coral); color: var(--ink); font-weight: 700; text-align: center; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:is(button, input, select):focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.buttons { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
form { display: grid; gap: 8px; }
.look { display: flex; gap: 12px; align-items: center; }
.look-preview { width: 112px; flex: none; background: var(--card); border: 2px solid var(--outline); border-radius: 10px; }
.look-fields { display: grid; gap: 8px; flex: 1; }
.twitch-row { display: grid; gap: 6px; }
.install p { margin: 0; }

/* ───── 管理後台 ───── */
.admin-tabs { display: flex; gap: 8px; }
.admin-tabs button { flex: none; text-align: center; }
.admin-tabs button[aria-pressed="true"] { background: var(--coral); color: var(--ink); font-weight: 700; }
/* 管理後台畫面：藏起遊戲場景和玩家的卡片，只留後台 */
.admin-view .stage { display: none !important; }
body:not(.admin-view) #admin { display: none !important; }
.admin-view .page { max-width: 1400px; }
.admin { grid-column: 1 / -1; border-color: var(--coral); }
.admin-col { display: grid; gap: 8px; align-content: start; }
.admin-col h3 { margin: 4px 0 0; }
/* 電腦上兩欄：左邊現況與送藥水、右邊勇者名單；訂單在左下 */
@media (min-width: 900px) {
  .admin-view .admin {
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr);
    grid-template-areas: "head head" "status heroes" "orders heroes";
    column-gap: 24px;
  }
  .admin-view .admin > .admin-head { grid-area: head; }
  .admin-view .admin-col-status { grid-area: status; }
  .admin-view .admin-col-heroes { grid-area: heroes; }
  .admin-view .admin-col-orders { grid-area: orders; }
  .admin-view .admin-col-heroes .admin-list { max-height: 70vh; }
  .admin-view .admin-row { grid-template-columns: 1fr auto; align-items: center; }
}
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.admin-head h2 { margin: 0; }
.admin-head-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.button-link { display: grid; place-items: center; min-height: 44px; padding: 8px 14px; border-radius: 10px; background: var(--coral); color: var(--ink); font-weight: 700; text-decoration: none; border: 2px solid var(--outline); }
.admin-message { margin: 0; color: var(--dream); min-height: 1.5em; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-link { flex: 1; min-width: 220px; }
.admin-potions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.admin-potions button { grid-column: 1 / -1; text-align: center; }
.admin-list { display: grid; gap: 6px; max-height: 420px; overflow: auto; }
.admin-row { display: grid; gap: 6px; background: var(--card); border: 2px solid var(--outline); border-radius: 10px; padding: 8px 10px; }
.admin-row small { color: var(--muted); }
.admin-row.frozen { opacity: 0.6; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-actions button { min-height: 36px; padding: 4px 10px; }
.admin-order { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; background: var(--card); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.admin-order small { grid-column: 1 / -1; color: var(--muted); }
.order-paid { color: var(--poison); }
.order-failed, .order-mismatch { color: var(--bad); }
.admin-test summary { cursor: pointer; color: var(--muted); }
.admin-test .buttons { margin-top: 8px; }
.choices { display: grid; gap: 6px; }
.choice { display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--outline); border-radius: 10px; padding: 8px 10px; color: var(--cream); cursor: pointer; }
.choice span { display: grid; }
.choice small { color: var(--muted); }
.choice:has(input:checked) { border-color: var(--cream); }

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

/* ───── 找回連結 ───── */
/* 新玩家先看到「加入」；從主畫面打開（大多是已經有勇者的人）時先看到「找回」 */
#restore { order: -1; }
.keep summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.keep[open] summary { margin-bottom: 4px; }
.keep p { margin: 0; }
.keep input { font-size: 13px; }

/* ───── 數據 ───── */
.stats { grid-column: 1 / -1; border-color: var(--coral); }
body:not(.stats-view) #stats { display: none !important; }
.stats-view #admin { display: none !important; }
.admin-view #panel > .card:not(.admin-only) { display: none !important; }
.stats p { margin: 0; }
.stat-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-tile { display: grid; gap: 2px; background: var(--card); border: 2px solid var(--outline); border-radius: 10px; padding: 10px 12px; }
.stat-tile strong { font-size: 24px; color: var(--cream); font-variant-numeric: tabular-nums; }
.stat-tile small { color: var(--muted); }
.stats-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats-wide { grid-column: 1 / -1; }
.stats-block { display: grid; gap: 8px; align-content: start; }
.stats-block h3 { margin: 0; }
.stats-block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { min-height: 32px; padding: 2px 10px; font-size: 13px; text-align: center; }
.seg button[aria-pressed="true"] { background: var(--coral); color: var(--ink); font-weight: 700; }
/* 長條圖：只有一個數列，用一個顏色；格線與軸線都很淡 */
.bars {
  display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); gap: 2px;
  height: 180px; align-items: end; padding-top: 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
}
.bars-hours { height: 140px; }
.bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; cursor: default; }
.bar-fill { width: min(70%, 28px); background: var(--dream); border-radius: 4px 4px 0 0; min-height: 0; transition: filter 0.15s; }
.bar.now .bar-fill { background: var(--coral); }
.bar:hover .bar-fill, .bar:focus-visible .bar-fill { filter: brightness(1.15); outline: 2px solid var(--cream); outline-offset: 1px; }
.bar-value { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.bar-label { position: absolute; top: 100%; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars + details { margin-top: 20px; }
.bars-hours { margin-bottom: 24px; }
.stats-table-wrap { overflow-x: auto; }
.stats-table { border-collapse: collapse; font-size: 13px; width: 100%; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 4px 8px; text-align: right; border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); white-space: nowrap; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.stats-dl dt { color: var(--muted); }
.stats-dl dd { margin: 0; }
.stats-dl .stats-note { grid-column: 1 / -1; font-size: 13px; }
@media (max-width: 700px) {
  /* 手機上日期太擠，隔一天標一次（保留今天） */
  .bars:not(.bars-hours) .bar:nth-child(odd) .bar-label { visibility: hidden; }
  .bar-value { font-size: 9px; }
}

/* ───── 購買留言 ───── */
.message-field { display: grid; gap: 4px; }
.message-hint { font-size: 13px; color: var(--muted); }
.message-row strong { color: var(--cream); }

/* ───── 加到主畫面：還沒有勇者時不用講找回連結 ───── */
.install:not(.has-hero) .install-recovery { display: none; }
.install.has-hero .install-first { display: none; }
.install-recovery { display: grid; gap: 6px; }

/* ───── 髮色、眼睛色塊 ───── */
.swatch-field { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.swatch-field legend { padding: 0; font-size: 14px; }
.swatch-name { color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; width: 34px; height: 34px; cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch-dot { display: block; width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--outline); box-sizing: border-box; }
.swatch input:checked + .swatch-dot { outline: 3px solid var(--cream); outline-offset: 2px; }
.swatch input:focus-visible + .swatch-dot { outline: 3px solid var(--coral); outline-offset: 2px; }

/* ───── 商店各項可收合 ───── */
.shop-item > summary { cursor: pointer; font-weight: 700; font-size: 1.05em; min-height: 36px; display: flex; align-items: center; }
.shop-item[open] > summary { margin-bottom: 6px; }
.shop-item > * + * { margin-top: 8px; }
.shop-item > summary + * { margin-top: 0; }
#shop form { border-top: 1px solid color-mix(in srgb, var(--muted) 30%, transparent); padding-top: 4px; }

/* ───── 提示可以關掉 ───── */
.notice { display: flex; align-items: flex-start; gap: 8px; }
.notice-text { flex: 1; }
.notice-close { flex: none; min-height: 32px; min-width: 32px; padding: 0; font-size: 20px; line-height: 1; border-radius: 50%; }

/* ───── 加到主畫面：收起來後移到最下面 ───── */
.install > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.install > summary::-webkit-details-marker { display: none; }
.install > summary h2 { margin: 0; font-size: inherit; }
.install > summary::after { content: "▾"; color: var(--muted); }
.install:not([open]) > summary::after { content: "▸"; }
.install > * + * { margin-top: 8px; }
.install.tucked .install-tucked-hint, .install.tucked #install-later { display: none; }
/* 收起來的引導：縮成一行、放在行動下面（11/20：原本排到最底，被 Twitch 聊天室擠到看不到）。 */
body:not(.display) #install.tucked { order: 0; }

/* ───── 手機：遊戲畫面固定在上方，往下捲動操作時還看得到她 ───── */
@media (max-width: 700px) {
  body:not(.display):not(.admin-view) .stage {
    position: sticky; top: 0; z-index: 20;
    background: var(--night); padding-bottom: 4px;
    box-shadow: 0 6px 12px -6px rgb(0 0 0 / 0.6);
  }
  body:not(.display):not(.admin-view) .scene { width: min(100%, 40svh); margin-inline: auto; }
  body:not(.display):not(.admin-view) .feed { max-height: 3.6em; overflow: hidden; margin-top: 4px; display: flex; flex-direction: column; justify-content: flex-end; }
}

/* 稱號：名字下一行，金色小字，像遊戲裡的稱號。 */
.streamer-title { font-style: normal; color: var(--gold); font-size: 0.85em; font-weight: 700; letter-spacing: 0.02em; }

/* ───── 施法、打怪特效（fx.js）───── */
.fx { position: absolute; pointer-events: none; z-index: 30; translate: -50% -50%; }
.fx-bolt { width: 3.2cqw; height: 3.2cqw; border-radius: 50%; animation: fx-bolt 0.45s ease-in forwards; box-shadow: 0 0 2cqw 0.6cqw currentColor; background: #fff; }
@keyframes fx-bolt { from { transform: translate(0, 0) scale(0.6); } to { transform: translate(var(--dx), var(--dy)) scale(1.1); } }
.fx-spark { width: 1.6cqw; height: 1.6cqw; border-radius: 50%; background: currentColor; box-shadow: 0 0 1.2cqw currentColor;
  animation: fx-spark 0.75s ease-out var(--delay, 0ms) forwards; opacity: 0; }
@keyframes fx-spark { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); } }
.fx-ring { width: 4cqw; height: 4cqw; border-radius: 50%; border: 0.6cqw solid currentColor; animation: fx-ring 0.6s ease-out forwards; }
@keyframes fx-ring { from { opacity: 1; transform: scale(0.4); } to { opacity: 0; transform: scale(4); } }
.fx-float { font-size: 5cqw; font-weight: 900; color: currentColor; text-shadow: 0 0 1cqw #000; animation: fx-float 1.1s ease-out forwards; }
@keyframes fx-float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-9cqh); } }
.fx-slash { width: 16cqw; height: 1.4cqw; border-radius: 1cqw; background: linear-gradient(90deg, transparent, #fff, transparent);
  rotate: -35deg; animation: fx-slash 0.38s ease-out forwards; box-shadow: 0 0 2cqw #ffd2a8; }
@keyframes fx-slash { from { opacity: 0; transform: scaleX(0.2); } 30% { opacity: 1; } to { opacity: 0; transform: scaleX(1.4); } }
.fx-dome { width: 14cqw; height: 14cqw; border-radius: 50%; border: 0.5cqw solid #ffe28a; background: radial-gradient(circle, rgb(255 226 138 / 0.05), rgb(255 226 138 / 0.35));
  animation: fx-dome 1.2s ease-out forwards; }
@keyframes fx-dome { 0% { opacity: 0; transform: scale(0.5); } 25% { opacity: 1; transform: scale(1.05); } 100% { opacity: 0; transform: scale(1); } }
.fx-flash { inset: 0; width: 100%; height: 100%; translate: none; left: 0 !important; top: 0 !important; background: radial-gradient(circle, rgb(255 236 170 / 0.75), transparent 70%); animation: fx-flash 0.6s ease-out forwards; }
@keyframes fx-flash { from { opacity: 1; } to { opacity: 0; } }
.fx-dream { color: #ffb3d9; }
.fx-attack { color: #ffb070; }
.fx-heal { color: #8dffa8; }
.fx-purify { color: #9fe6ff; }
.fx-shield { color: #ffe28a; }
.fx-signature { color: #ffd76a; }
.fx-shake { animation: fx-shake 0.4s ease-in-out; }
@keyframes fx-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-2cqw); } 40% { transform: translateX(2cqw); } 60% { transform: translateX(-1.2cqw); } 80% { transform: translateX(1.2cqw); } }
@media (prefers-reduced-motion: reduce) { .fx-shake { animation: none; } }

/* ───── v0.5：一波好幾隻的怪（紅點史萊姆）───── */
.monster-pack { display: grid; justify-items: center; }
.monster-pack.swarm { grid-template-columns: repeat(3, 1fr); width: 150%; gap: 0 4%; }
.monster-pack.swarm .blob { width: 100%; animation-delay: calc(var(--i) * -0.4s); }
.monster-pack.swarm .blob:nth-child(n+4) { margin-top: -30%; }

/* ───── v0.5：天亮天黑（台北時間）。夜景是 .map 的底圖，白天圖疊在上面用透明度淡入淡出 ───── */
.sky-day, .sky-tint { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.sky-day { background: url("/assets/art/scene_garden_day.png") center / 100% 100% no-repeat; image-rendering: pixelated;
  opacity: var(--day, 0); transition: opacity var(--sky-fade, 60s) linear; }
.sky-tint { background: var(--tint, transparent); mix-blend-mode: soft-light; transition: background 60s linear; }
.map > .beauty, .map > .monster, .map > .heroes { z-index: 1; }

/* ───── 稀有訪客 ───── */
.visitor { position: absolute; z-index: 3; pointer-events: none; }
.visitor[hidden] { display: none; }
/* 11/20：花精靈在右邊大樹附近繞小圈（不飛到涼亭那邊，免得擋到本週第一名的勇者），圖上下輕飄、灑亮粉。 */
.visitor-fairy { left: 74%; top: 40%; width: 14%; animation: fairy-tour 14s ease-in-out infinite; filter: drop-shadow(0 0 1.2cqw rgb(255 240 160 / 0.9)); }
.visitor-fairy img { animation: fairy-float 1.6s ease-in-out infinite; }
.visitor-fairy::after { content: "✦"; position: absolute; left: 30%; bottom: 0; color: #fff3b0; font-size: 2.4cqw; animation: fairy-dust 1.2s ease-out infinite; }
@keyframes fairy-float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-3cqh) rotate(4deg); } }
@keyframes fairy-dust { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(-2cqw, 4cqh) scale(0.4); } }
@keyframes fairy-tour {
  0%, 100% { left: 74%; top: 40%; }
  25% { left: 82%; top: 50%; }
  50% { left: 78%; top: 62%; }
  75% { left: 68%; top: 52%; }
}

.visitor-dragon { top: 6%; width: 20%; left: -25%; animation: dragon-fly 9s linear infinite; }
@keyframes dragon-fly { from { transform: translateX(0) translateY(0); } 50% { transform: translateX(65cqw) translateY(4cqh); } to { transform: translateX(130cqw) translateY(0); } }
@media (prefers-reduced-motion: reduce) { .visitor-fairy, .visitor-fairy img, .visitor-dragon { animation: none; } .visitor-dragon { left: 40%; } }
#actions .visitor-catch, .visitor-catch {
  width: 100%; min-height: 52px; margin-bottom: 10px; border-radius: 12px; font-weight: 700; text-align: center;
  display: grid; place-items: center; background: #ffe28a; color: #3a2626; border-color: #e9c27a;
  animation: catch-glow 1.6s ease-in-out infinite;
}
.visitor-catch[hidden] { display: none; }
@keyframes catch-glow { 0%, 100% { box-shadow: 0 0 0 0 rgb(255 226 138 / 0.6); } 50% { box-shadow: 0 0 0 8px rgb(255 226 138 / 0); } }
#actions .visitor-catch { background: #ffe28a !important; color: #3a2626 !important; font-size: 15px; }

/* ───── 節日裝扮：活動期間每位勇者頭上自動戴一頂（免費的場景裝飾）───── */
body[data-festive] .hero::before {
  content: ""; position: absolute; z-index: 2; top: -1%; left: 50%; width: 42%; aspect-ratio: 1;
  translate: -50% 0; rotate: 12deg; background: var(--festive-hat) center / contain no-repeat; image-rendering: pixelated;
  pointer-events: none;
}
body[data-festive="birthday"] { --festive-hat: url("/assets/art/hat_party.png"); }
body[data-festive="christmas"] { --festive-hat: url("/assets/art/hat_santa.png"); }

/* ───── 點勇者看狀態的小卡 ───── */
body:not(.display) .hero .figure, body:not(.display) .hero .nameplate { pointer-events: auto; cursor: pointer; }
.hero-card { position: absolute; z-index: 20; width: max(190px, 34cqw); max-width: 260px; display: grid; gap: 6px; padding: 10px 12px;
  background: rgb(31 18 38 / 0.94); border: 2px solid var(--outline); border-radius: 10px; color: var(--cream); font-size: 13px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); }
.hero-card[hidden] { display: none; }
.hero-card-head { display: flex; align-items: center; gap: 8px; }
.hero-card-head .target-face { width: 40px; height: 40px; flex: none; border-radius: 50%; overflow: hidden; background: var(--night); display: flex; justify-content: center; align-items: flex-start; }
.hero-card-head .target-face img.sprite { width: 62px; height: 62px; max-width: none; flex: none; }
.hero-card-head strong { display: block; font-size: 15px; }
.hero-card-head small { color: var(--muted); }
.hero-card .gauge { font-size: 12px; }
.hero-card .gauge span { width: 2.6em; text-align: left; }
.hero-card .stat-value { font-style: normal; color: var(--muted); min-width: 5.2em; text-align: right; font-size: 11px; }
.hero-card .gauge.xp .gauge-fill { background: #b9e27a; }
.hero-card-note { margin: 0; color: var(--muted); font-size: 12px; }

/* Twitch 聊天泡泡：比閒聊泡泡明顯一點 */
.bubble.chat { background: var(--cream); color: #2a1630; border-color: #9146ff; font-weight: 700; width: max-content; max-width: 30cqw; white-space: normal; text-align: center; line-height: 1.3; }

/* 近衛：有訂閱的勇者站在涼亭兩側，比花園裡的人小一點（比較遠） */
.hero.guard { scale: 0.8; z-index: 1; }
.streamer-title[hidden] { display: none !important; }

/* 武器：疊在勇者右手邊，跟著轉身；躺平時收起來 */
.hero::after { content: ""; position: absolute; left: 0; top: 0; width: 100%; aspect-ratio: 1; pointer-events: none; z-index: 1;
  background: var(--weapon, none) 80% 74% / 36% no-repeat; image-rendering: pixelated; }
.hero[data-face="left"]::after { transform: scaleX(-1); }
.hero.down::after { display: none; }

/* 近身守衛稱號：名牌上方的小金字 */
.nameplate { position: relative; }
.hero.guard .nameplate::before { content: attr(data-guard); position: absolute; left: 50%; top: 100%; translate: -50% 2px;
  background: #f2c94c; color: #3d0f1e; font-weight: 700; font-size: 0.85em; white-space: nowrap; padding: 0 0.5em; border-radius: 999px; z-index: 2; }

/* ───── 城牆：怪探頭、跳下來；本週第一名當城牆哨兵 ───── */
.wall-peek { position: absolute; z-index: 1; pointer-events: none; transform-origin: 50% 100%; animation: wall-peek 1.8s ease-in-out infinite; }
@keyframes wall-peek { 0%, 100% { translate: 0 0.6cqh; } 40% { translate: 0 -0.8cqh; } 60% { translate: -0.6cqw -0.4cqh; } }
.monster.wall-jump { animation: wall-jump 0.9s cubic-bezier(.3,.6,.4,1); }
@keyframes wall-jump { from { translate: 6cqw -33cqh; scale: 0.62; } 45% { translate: 4cqw -38cqh; scale: 0.75; } to { translate: 0 0; scale: 1; } }
/* 本週第一：站在涼亭裡床邊，跟近身守衛一樣大。 */
.hero.guard.sentry { scale: 0.8; }
@media (prefers-reduced-motion: reduce) { .wall-peek, .monster.wall-jump { animation: none; } }

/* 11/20：直播畫面右欄的 Twitch 聊天室（排行榜下面）。 */
.stream-chat { display: none; }
.display .stream-chat:not([hidden]) {
  display: flex; flex-direction: column; top: 45%; bottom: 23%; right: 1.2%; width: 19.5%; overflow: hidden;
}
.display .stream-chat strong { flex: none; margin-bottom: 0.3em; }
.stream-chat-lines { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.25em; overflow: hidden; }
.stream-chat-line { line-height: 1.4; overflow-wrap: anywhere; }
.stream-chat-line b { font-weight: 700; color: #ff9e9c; }

/* 11/20：睡美人醒著時的小動作（app.js 的 beautyAct）。只動圖，不動對話泡泡。 */
.beauty[data-state="awake"] .sleeper { transform-origin: 50% 90%; }
.beauty[data-state="awake"].act-walk-left .sleeper { animation: beauty-walk-left 4s ease-in-out; }
.beauty[data-state="awake"].act-walk-right .sleeper { animation: beauty-walk-right 4s ease-in-out; }
.beauty[data-state="awake"].act-hop .sleeper { animation: beauty-hop 0.9s ease-out 2; }
.beauty[data-state="awake"].act-sit .sleeper { animation: beauty-sit 4s ease-in-out; }
.beauty[data-state="awake"].act-yawn .sleeper { animation: beauty-yawn 3s ease-in-out; }
.beauty[data-state="awake"].act-turn .sleeper { animation: beauty-turn 4s ease-in-out; }
.beauty[data-state="awake"].act-look .sleeper { animation: beauty-look 3.5s ease-in-out; }
.beauty[data-state="awake"].act-stretch .sleeper { animation: beauty-stretch 3.6s ease-in-out; }
.beauty[data-state="awake"].act-twirl .sleeper { animation: beauty-twirl 3.4s ease-in-out; }
.beauty[data-state="awake"].act-curtsy .sleeper { animation: beauty-curtsy 3.2s ease-in-out; }
.beauty[data-state="awake"].act-peek .sleeper { animation: beauty-peek 3.5s ease-in-out; }
.beauty[data-state="awake"].act-cheer .sleeper { animation: beauty-cheer 2.8s ease-in-out; }
.beauty[data-state="awake"].act-listen .sleeper { animation: beauty-listen 3.2s ease-in-out; }
.beauty[data-state="awake"].act-ponder .sleeper { animation: beauty-ponder 3.5s ease-in-out; }
.beauty[data-state="awake"][data-reaction="cry"] .sleeper { animation: beauty-fright-cry 0.55s ease-in-out 4; }
.beauty[data-state="awake"][data-reaction="run"] .sleeper { animation: beauty-fright-run 0.7s ease-in-out 3; }
.beauty[data-state="awake"][data-reaction="hide"] .sleeper { animation: beauty-fright-hide 1.1s ease-in-out 2; }
@keyframes beauty-fright-cry { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-2%) rotate(-4deg); } 75% { transform: translateX(2%) rotate(4deg); } }
@keyframes beauty-fright-run { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-9%, -4%); } 50% { transform: translate(8%, -2%); } 80% { transform: translate(-4%, 0); } }
@keyframes beauty-fright-hide { 0%, 100% { transform: translateY(0) scale(1); opacity: 1; } 45%, 70% { transform: translateY(14%) scale(0.78); opacity: 0.65; } }
.beauty[data-state="awake"].act-yawn::after {
  content: "～"; position: absolute; left: 62%; top: 8%; font-size: 1.4em; color: var(--cream);
  animation: beauty-emote 3s ease-out forwards; pointer-events: none;
}
.beauty[data-state="awake"].act-sit::after {
  content: "♪"; position: absolute; left: 66%; top: 12%; font-size: 1.3em; color: #ffd27a;
  animation: beauty-emote 4s ease-out forwards; pointer-events: none;
}
.beauty[data-state="awake"].act-stretch::after,
.beauty[data-state="awake"].act-twirl::after { content: "✧"; color: #ffe49a; }
.beauty[data-state="awake"].act-curtsy::after { content: "♡"; color: #ffb6d8; }
.beauty[data-state="awake"].act-peek::after { content: "?"; color: #d8c5ff; }
.beauty[data-state="awake"].act-cheer::after { content: "✦"; color: #ffe49a; }
.beauty[data-state="awake"].act-listen::after { content: "♫"; color: #b8e6ff; }
.beauty[data-state="awake"].act-ponder::after { content: "…"; color: #e8d8ff; }
.beauty[data-state="awake"].act-stretch::after,
.beauty[data-state="awake"].act-twirl::after,
.beauty[data-state="awake"].act-curtsy::after,
.beauty[data-state="awake"].act-peek::after,
.beauty[data-state="awake"].act-cheer::after,
.beauty[data-state="awake"].act-listen::after,
.beauty[data-state="awake"].act-ponder::after {
  position: absolute; left: 66%; top: 10%; font-size: 1.4em;
  animation: beauty-emote 3.2s ease-out forwards; pointer-events: none;
}
/* 不左右鏡像：鏡像後淚痣和側分會跑到另一邊（11/17 定案）。 */
@keyframes beauty-walk-left {
  0%, 100% { transform: translateX(0); }
  15%, 35%, 55% { transform: translateX(-12%) translateY(0); }
  25%, 45% { transform: translateX(-22%) translateY(-3%); }
  65% { transform: translateX(-30%); }
}
@keyframes beauty-walk-right {
  0%, 100% { transform: translateX(0); }
  15%, 35%, 55% { transform: translateX(12%) translateY(0); }
  25%, 45% { transform: translateX(22%) translateY(-3%); }
  65% { transform: translateX(30%); }
}
@keyframes beauty-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.06, 0.92); }
  45% { transform: translateY(-14%) scale(0.96, 1.05); }
  75% { transform: translateY(0) scale(1.04, 0.95); }
}
@keyframes beauty-sit {
  0%, 100% { transform: translateY(0) scaleY(1); }
  15%, 85% { transform: translateY(8%) scaleY(0.9); }
  30%, 50%, 70% { transform: translateY(8%) scaleY(0.9) rotate(-3deg); }
  40%, 60% { transform: translateY(8%) scaleY(0.9) rotate(3deg); }
}
@keyframes beauty-yawn {
  0%, 100% { transform: scale(1, 1); }
  30%, 60% { transform: scale(1.04, 1.06) translateY(-2%); }
  75% { transform: scale(0.98, 0.96); }
}
@keyframes beauty-turn {
  0%, 100% { transform: rotate(0) translateY(0); }
  20% { transform: rotate(-8deg) translateY(-2%); }
  40% { transform: rotate(8deg) translateY(-2%); }
  60% { transform: rotate(-8deg) translateY(-2%); }
  80% { transform: rotate(0) translateY(0); }
}
@keyframes beauty-look {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  50% { transform: rotate(0); }
  75% { transform: rotate(6deg); }
}
@keyframes beauty-stretch {
  0%, 100% { transform: scale(1, 1) translateY(0); }
  20%, 65% { transform: scale(0.98, 1.04) translateY(-2%); }
  42% { transform: scale(0.96, 1.09) translateY(-5%); }
}
@keyframes beauty-twirl {
  0%, 100% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-9deg) translateY(-3%); }
  50% { transform: rotate(0) translateY(-6%); }
  75% { transform: rotate(9deg) translateY(-3%); }
}
@keyframes beauty-curtsy {
  0%, 100% { transform: translateY(0) scale(1); }
  28%, 65% { transform: translateY(7%) scale(0.94, 0.91) rotate(-4deg); }
  45% { transform: translateY(4%) scale(0.97, 0.95) rotate(3deg); }
}
@keyframes beauty-peek {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%, 45% { transform: translateX(-8%) rotate(-5deg); }
  70% { transform: translateX(4%) rotate(3deg); }
}
@keyframes beauty-cheer {
  0%, 100% { transform: translateY(0) scale(1); }
  20%, 55% { transform: translateY(-9%) scale(1.04, 0.96); }
  38%, 73% { transform: translateY(0) scale(0.97, 1.05); }
}
@keyframes beauty-listen {
  0%, 100% { transform: rotate(0) translateY(0); }
  30%, 70% { transform: rotate(7deg) translateY(-2%); }
  50% { transform: rotate(-3deg) translateY(0); }
}
@keyframes beauty-ponder {
  0%, 100% { transform: rotate(0) translateY(0); }
  25%, 70% { transform: rotate(-5deg) translateY(-2%); }
  45% { transform: rotate(3deg) translateY(1%); }
}
@keyframes beauty-emote {
  0% { opacity: 0; transform: translateY(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60%); }
}
@media (prefers-reduced-motion: reduce) {
  .beauty[data-state="awake"] .sleeper { animation: none !important; }
}

/* 11/20：小彩花走下涼亭找勇者（app.js 的 beautyVisit）。走路時上下彈、面向要去的方向。 */
.beauty.visiting { transition: left 2.4s ease-in-out, top 2.4s ease-in-out; z-index: 3; }
.beauty.visiting .zzz { display: none; }
.beauty.visiting.walking .sleeper { animation: beauty-step 0.45s ease-in-out infinite alternate; }
@keyframes beauty-step { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-3%) rotate(2deg); } }
.hero.greeted .figure { animation: hero-greeted 0.6s ease-out 2; }
@keyframes hero-greeted { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12%); } }

/* 11/20：怪攻擊睡美人的特效。 */
.fx-monster { color: #c58bff; }
.fx-float.fx-monster { color: #ff6b6b; }
.fx-claw { width: 12cqw; height: 12cqw; translate: -50% -50%;
  background: repeating-linear-gradient(120deg, transparent 0 22%, #ffd1f0 22% 27%, transparent 27% 38%);
  animation: fx-claw 0.45s ease-out forwards; }
@keyframes fx-claw { from { opacity: 0; scale: 0.6; } 30% { opacity: 1; } to { opacity: 0; scale: 1.15; } }
.fx-lunge { animation: fx-lunge 0.6s ease-in-out; }
@keyframes fx-lunge { 0%, 100% { translate: 0 0; } 40% { translate: -6cqw 1cqh; } }
.fx-hurt .sleeper { filter: brightness(1.6) sepia(1) hue-rotate(-30deg) saturate(4); }

/* 11/20：事件卡投票。疊在場景上方中間；直播畫面放在花園上方，玩家頁蓋在花園上（可以按）。 */
.event-card {
  position: absolute; z-index: 6; left: 50%; top: 4%; translate: -50% 0; width: min(46%, 520px);
  background: rgb(42 26 51 / 0.94); border: 2px solid #c58bff; border-radius: 12px; padding: 0.7em 0.9em;
  display: grid; gap: 0.5em; box-shadow: 0 0 2em rgb(197 139 255 / 0.35); animation: card-in 0.4s ease-out;
}
@keyframes card-in { from { opacity: 0; transform: translateY(-12%) rotateX(60deg); } to { opacity: 1; transform: none; } }
.event-card .card-head { display: flex; align-items: center; gap: 0.6em; }
.event-card .card-head img { width: 3.2em; height: 3.2em; object-fit: contain; }
.event-card .card-head small { color: #e0b3ff; display: block; font-size: 0.8em; }
.event-card .card-head strong { font-size: 1.15em; }
.event-card p { margin: 0; color: var(--cream); }
.card-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5em; }
.card-option {
  position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; gap: 0.5em;
  padding: 0.6em 0.8em; border-radius: 8px; border: 2px solid var(--line); background: rgb(255 255 255 / 0.06);
  color: var(--cream); font: inherit; font-weight: 700; cursor: pointer;
}
.card-option::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--share, 0%); background: rgb(197 139 255 / 0.28); transition: width 0.4s; }
.card-option > * { position: relative; }
.card-option b { color: #ffd27a; font-size: 0.9em; white-space: nowrap; }
.card-option.mine { border-color: #ffd27a; }
.card-option:disabled { cursor: default; opacity: 1; }
.card-timer { height: 1.3em; border-radius: 999px; background: rgb(255 255 255 / 0.08); overflow: hidden; }
.card-timer span { display: block; height: 100%; background: linear-gradient(90deg, #c58bff, #ff8280); color: #1f1226; font-size: 0.75em; font-weight: 800; text-align: right; padding-right: 0.5em; line-height: 1.75; transition: width 0.25s linear; white-space: nowrap; }
.card-hint { color: var(--muted); font-size: 0.8em; }
@media (max-width: 1099px) {
  body:not(.display) .event-card { width: 88%; top: 3%; font-size: 13px; }
}
.event-card .card-head > div { flex: 1; text-align: left; }

/* 11/20：花園小動物（critters.js）。 */
.critters { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.critter { position: absolute; image-rendering: pixelated; translate: -50% -50%; }
.critter.bird { width: 8.5cqw; transition: left 3.2s ease-in-out, top 3.2s ease-in-out; }
.critter.bird.flying { animation: bird-flight 0.34s steps(2, end) infinite alternate; }
.critter.bird.face-left { transform: scaleX(-1); }
.critter.bird.perched { animation: bird-hop 1.4s ease-in-out infinite; }
@keyframes bird-flight {
  from { translate: -50% -50%; rotate: -2deg; }
  to { translate: -50% calc(-50% - 0.7cqw); rotate: 2deg; }
}
@keyframes bird-hop { 0%, 60%, 100% { translate: -50% -50%; } 70% { translate: -50% -70%; } 80% { translate: -50% -50%; } }
.critter-chirp { position: absolute; translate: -50% -50%; font-size: 1.6cqw; font-weight: 800; color: var(--cream); text-shadow: 0 0 0.6cqw #000; animation: fx-float 1.5s ease-out forwards; }
.critter.flutter { width: 5cqw; transition: left var(--flutter-seconds, 6s) ease-in-out, top var(--flutter-seconds, 6s) ease-in-out; animation: flutter 0.5s ease-in-out infinite alternate; }
@keyframes flutter { from { transform: scaleX(1) translateY(0); } to { transform: scaleX(0.55) translateY(-0.6cqh); } }
.critter.flutter.firefly { width: 1cqw; height: 1cqw; border-radius: 50%; background: #fff7a8; box-shadow: 0 0 1.4cqw 0.5cqw rgb(255 240 120 / 0.8); animation: firefly 2.2s ease-in-out infinite; }
@keyframes firefly { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* 睡美人睡著時：呼吸起伏、冒夢泡泡。 */
.beauty:not([data-state="awake"]) .sleeper { animation: beauty-breathe 4.5s ease-in-out infinite; transform-origin: 50% 85%; }
@keyframes beauty-breathe { 0%, 100% { scale: 1 1; } 50% { scale: 1.015 1.03; } }
.beauty.dizzy .sleeper { animation: sway 2s ease-in-out infinite; }
.dream-puff {
  position: absolute; left: 30%; top: 0; font-size: 1.3em; font-weight: 800; color: #ffd6ec;
  background: rgb(255 255 255 / 0.85); color: #c2569b; border-radius: 999px; width: 1.7em; height: 1.7em;
  display: grid; place-items: center; pointer-events: none; animation: dream-puff 4s ease-out forwards;
}
@keyframes dream-puff {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15% { opacity: 1; transform: translate(0, -20%) scale(1); }
  100% { opacity: 0; transform: translate(var(--drift, 0), -180%) scale(0.9); }
}
@media (prefers-reduced-motion: reduce) { .beauty .sleeper, .dream-puff { animation: none !important; } }

/* 11/20 自動戰鬥（掛機） */
.hero.auto .nameplate::before { content: "💤"; margin-right: 0.2em; font-size: 0.85em; }
.auto-battle { margin-top: 0.8rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line, rgb(255 255 255 / 0.12)); border-radius: 10px; display: grid; gap: 0.4rem; }
.auto-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.auto-status { margin: 0; font-size: 0.85em; }
.auto-toggle { width: 100%; }
.auto-toggle.on { background: transparent; border: 1px solid currentColor; }

/* 11/21 紀錄欄：往上看舊紀錄時出現「↓ 最新」 */
.feed-jump { position: sticky; bottom: 2px; justify-self: end; align-self: flex-end; margin-left: auto; width: max-content;
  padding: 2px 10px; min-height: 0; border-radius: 999px; font-size: 0.85em; background: var(--card, #2a1832); border: 1px solid var(--line, #5b3a63); color: var(--cream, #fff4e8); cursor: pointer; z-index: 2; }
.feed-jump[hidden] { display: none; }
.display .feed-jump { display: none; }

/* 11/21 部署後提示更新 */
.update-bar { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); translate: -50% 0; z-index: 100;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--gold, #e9c27a); background: #2a1832; color: var(--cream, #fff4e8);
  font-weight: 700; box-shadow: 0 4px 16px rgb(0 0 0 / 0.4); cursor: pointer; }

/* 11/21：事件卡的來客（女巫、工程師）站在床右邊；開票後離開 */
.card-guest { position: absolute; z-index: 3; left: 81%; top: 41%; width: 12%; pointer-events: none; filter: drop-shadow(0 0.6cqw 0.8cqw rgb(0 0 0 / 0.45)); }
.card-guest[hidden] { display: none; }
.card-guest.arrive { animation: guest-arrive 0.9s ease-out, guest-bob 2.2s ease-in-out 0.9s infinite; }
@keyframes guest-arrive { from { translate: 30cqw 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@keyframes guest-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -0.8cqh; } }
.card-guest.leave { animation: guest-fly 1.7s ease-in forwards; }
.card-guest.leave-slack, .card-guest.leave-help { animation-name: guest-run; }
@keyframes guest-fly { 0% { translate: 0 0; rotate: 0deg; } 30% { translate: -2cqw 1cqh; } 100% { translate: 40cqw -40cqh; rotate: 25deg; opacity: 0; } }
@keyframes guest-run { to { translate: 45cqw 0; opacity: 0; } }

/* 11/21：回憶碎片 */
.cg-shard { position: absolute; z-index: 4; width: 7%; aspect-ratio: 1; translate: -50% -50%; padding: 0; border: 0; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 250 220 / 0.95) 0 25%, rgb(255 200 230 / 0.55) 45%, transparent 70%);
  color: #fff6d6; font-size: 3.4cqw; line-height: 1; cursor: pointer; animation: shard-glow 1.6s ease-in-out infinite; }
.cg-shard[hidden] { display: none; }
.cg-shard:disabled { cursor: default; }
@keyframes shard-glow { 0%, 100% { scale: 0.9; filter: drop-shadow(0 0 0.6cqw rgb(255 230 160 / 0.7)); } 50% { scale: 1.12; filter: drop-shadow(0 0 1.6cqw rgb(255 210 240 / 0.95)); } }
@media (prefers-reduced-motion: reduce) { .card-guest.arrive, .cg-shard { animation: none; } }

/* 11/21：直播畫面聲音被瀏覽器擋住時的小提示（左下角、很小） */
.sound-blocked { position: fixed; left: 8px; bottom: 8px; z-index: 50; padding: 4px 10px; border-radius: 999px;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 12px; pointer-events: none; }
.sound-blocked[hidden] { display: none; }
/* 11/21：直播畫面兩個榜一起列（各 5 名），行距縮一點，聊天室移到榜的下面。 */
.display .board .board-row { line-height: 1.35; }
.display .board .board-gap { margin: 0.4em 0; }

/* 12/02：服務資訊連結（商品與價格、條款、隱私權、退費、客服）。 */
.legal-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; padding: 12px 16px; }
.legal-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
