/* ===== 彩虹泡泡砲 — 可愛、明亮、圓潤；手機／平板／桌機、直橫向皆可用 ===== */
:root {
  --ink: #3b2a5a; --ink2: #6b5a8a; --ink3: #9a8cb8;
  --paper: #fff9ef; --card: #ffffff; --line: #eadff7;
  --pink: #ff7eb6; --pink-d: #d3438a;
  --sky: #5cc4ff; --sky-d: #2a8ed6;
  --mint: #4fd6a8; --mint-d: #23a67b;
  --sun: #ffd24d; --sun-d: #e0a014;
  --grape: #9b7bff; --grape-d: #6a49d4;
  --red: #ff6b6b; --red-d: #d93d4a;
  --r: 22px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
  --font: "Baloo 2", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); font-size: 16px; line-height: 1.45;
  background: radial-gradient(circle at 12% 18%, #ffe0ef 0, transparent 38%), radial-gradient(circle at 88% 12%, #d7efff 0, transparent 40%), radial-gradient(circle at 70% 92%, #fff0c4 0, transparent 40%), #fff4fa;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
.app { position: fixed; inset: 0; overflow: hidden; }
h1, h2, h3, p { margin: 0; }
.ico { display: block; flex: none; }
:focus-visible { outline: 4px solid var(--grape-d); outline-offset: 2px; border-radius: 12px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 按鈕 ---------- */
.btn {
  --c: var(--sky); --cd: var(--sky-d);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .55em 1.4em; border: 0; border-radius: 999px;
  font: inherit; font-weight: 800; font-size: 1.05rem; color: #fff; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 82%, #fff) 0, var(--c) 100%);
  box-shadow: 0 5px 0 var(--cd), 0 9px 16px rgba(80, 40, 120, .18), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .18); transition: transform .08s, box-shadow .08s, filter .15s;
  position: relative; top: 0;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd), 0 3px 6px rgba(80, 40, 120, .18), inset 0 2px 0 rgba(255, 255, 255, .35); }
.btn:disabled { filter: grayscale(.7) opacity(.55); cursor: not-allowed; transform: none; box-shadow: 0 5px 0 #b9b0c9; }
.btn-sky { --c: var(--sky); --cd: var(--sky-d); }
.btn-pink { --c: var(--pink); --cd: var(--pink-d); }
.btn-mint { --c: var(--mint); --cd: var(--mint-d); }
.btn-sun { --c: var(--sun); --cd: var(--sun-d); color: #5a3a00; text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.btn-grape { --c: var(--grape); --cd: var(--grape-d); }
.btn-ghost { --c: #fff; --cd: #cdbfe6; color: var(--ink); text-shadow: none; }
.btn-lg { min-height: 64px; font-size: 1.3rem; padding: .6em 1.8em; }
.btn-sm { min-height: 40px; font-size: .95rem; padding: .35em 1em; box-shadow: 0 4px 0 var(--cd), 0 6px 10px rgba(80, 40, 120, .14), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn-block { display: flex; width: 100%; }
.btn-ico { display: inline-flex; }
.icon-btn {
  width: 48px; height: 48px; display: inline-grid; place-items: center; border: 0; border-radius: 50%;
  background: #fff; color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 #cdbfe6, 0 8px 14px rgba(80, 40, 120, .16);
  transition: transform .08s, box-shadow .08s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #cdbfe6; }
.icon-btn.sm { width: 40px; height: 40px; }
.gear {
  position: fixed; z-index: 60; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r));
}
/* 首頁左上角的「← 回遊戲大廳」，外觀跟右上角的設定鈕一致；display 寫死會蓋掉 [hidden]，所以要留下面那條 */
.lobby-home-link {
  position: fixed; z-index: 60; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l));
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px;
  background: #ffe03d; color: #5a3d8a; border: 3px solid #5a3d8a; border-radius: 14px; box-shadow: 0 4px 0 #5a3d8a;
  font-weight: 900; font-size: .92rem; text-decoration: none; white-space: nowrap; transition: transform .08s, box-shadow .08s;
}
.lobby-home-link[hidden] { display: none; }
.lobby-home-link:active { transform: translateY(3px); box-shadow: 0 1px 0 #5a3d8a; }
.lobby-home-link:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---------- 版面共通 ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l)); -webkit-overflow-scrolling: touch; }
.screen.center { align-items: center; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 52px; padding-right: 58px; }
.topbar h2 { font-size: clamp(1.3rem, 3.2vw, 1.8rem); font-weight: 900; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: 0 6px 0 var(--line), 0 14px 26px rgba(90, 50, 140, .12); border: 3px solid #fff; }
.card h3 { font-size: 1.1rem; font-weight: 900; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--ink2); }
.small { font-size: .88rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.gap-lg { gap: 18px; }
.grow { flex: 1 1 auto; min-width: 0; }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 0; border-bottom: 2px dashed var(--line); }
.field:last-child { border-bottom: 0; }
.field > .label { font-weight: 800; min-width: 7.5em; display: flex; align-items: center; gap: 6px; }
.field > .ctl { flex: 1 1 220px; min-width: 0; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.text-input {
  width: 100%; min-height: 48px; border: 3px solid var(--line); border-radius: 16px; padding: 8px 14px; font: inherit; font-weight: 700; color: var(--ink);
  background: #fff9ff; outline: none; box-shadow: inset 0 3px 0 rgba(120, 80, 180, .06);
}
.text-input:focus { border-color: var(--grape); box-shadow: 0 0 0 4px rgba(155, 123, 255, .22); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; background: #f4ecff; color: var(--grape-d); font-weight: 800; font-size: .85rem; }
.pill.mint { background: #dcf8ee; color: var(--mint-d); }
.pill.sun { background: #fff0c4; color: #a86f00; }
.pill.pink { background: #ffe1ef; color: var(--pink-d); }
.pill.gray { background: #eee9f5; color: var(--ink2); }
.hint { background: #fff6d8; border-radius: 14px; padding: 8px 12px; color: #7a5a00; font-weight: 700; font-size: .92rem; }

/* ---------- 分段選項／步進器／開關／音量 ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #f3ebff; border-radius: 999px; }
.seg-btn {
  border: 0; background: transparent; color: var(--ink2); font: inherit; font-weight: 800; min-height: 40px; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, color .12s;
}
.seg-btn[aria-checked="true"] { background: var(--grape); color: #fff; box-shadow: 0 3px 0 var(--grape-d); }
.seg-btn:disabled { opacity: .45; cursor: not-allowed; }
.seg.small .seg-btn { min-height: 34px; padding: 2px 10px; font-size: .9rem; }
.seg.lvl .seg-btn[aria-checked="true"] { background: var(--mint); box-shadow: 0 3px 0 var(--mint-d); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.step-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--sun); color: #5a3a00; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 var(--sun-d); }
.step-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--sun-d); }
.step-btn:disabled { opacity: .4; cursor: not-allowed; }
.stepper-val { min-width: 3.4em; text-align: center; font-weight: 900; font-size: 1.2rem; }
.sw { width: 66px; height: 38px; border: 0; border-radius: 999px; background: #d8cfe8; position: relative; cursor: pointer; box-shadow: inset 0 3px 0 rgba(0, 0, 0, .12); transition: background .15s; flex: none; }
.sw[aria-checked="true"] { background: var(--mint); }
.sw-knob { position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); transition: transform .15s; }
.sw[aria-checked="true"] .sw-knob { transform: translateX(28px); }
.sw:disabled { opacity: .5; cursor: not-allowed; }
.vol { position: relative; width: min(220px, 100%); height: 38px; cursor: pointer; touch-action: none; }
.vol::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 12px; border-radius: 999px; background: #e6dcf5; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .08); }
.vol-fill { position: absolute; left: 0; top: 13px; height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--pink), var(--sun)); }
.vol-thumb { position: absolute; top: 3px; width: 32px; height: 32px; margin-left: -16px; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 #cdbfe6, 0 6px 10px rgba(80, 40, 120, .2); }
.vol.is-off { opacity: .45; }
.key {
  display: inline-grid; place-items: center; min-width: 2.1em; height: 2.1em; padding: 0 .5em; border-radius: 9px; font: inherit; font-weight: 900; font-size: .95rem; color: var(--ink);
  background: linear-gradient(180deg, #fff, #f3ecff); border: 2px solid #d9cdef; box-shadow: 0 3px 0 #b9a8d9; margin: 0 2px;
}
.key.wide { min-width: 5.5em; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 35% 25%, #fff, #f1e8ff); flex: none; overflow: hidden; box-shadow: inset 0 0 0 3px #fff, 0 3px 0 #e1d5f3; }
.avatar-img { width: 92%; height: 92%; object-fit: contain; pointer-events: none; }

/* ---------- 首頁 ---------- */
.home { justify-content: center; align-items: center; text-align: center; gap: 18px; }
.hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero-title { font-size: clamp(2.6rem, 9vw, 5rem); font-weight: 900; letter-spacing: .04em; color: #fff; -webkit-text-stroke: 0; text-shadow: 0 5px 0 var(--pink-d), 0 9px 0 rgba(90, 40, 120, .25), 0 0 20px rgba(255, 126, 182, .5); line-height: 1.05; }
.hero-title span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.hero-title span:nth-child(2) { animation-delay: .15s; } .hero-title span:nth-child(3) { animation-delay: .3s; } .hero-title span:nth-child(4) { animation-delay: .45s; }
.hero-sub { font-weight: 800; color: var(--ink2); font-size: clamp(1rem, 2.4vw, 1.3rem); }
.hero-cast { display: flex; justify-content: center; align-items: flex-end; gap: 0; margin-top: 8px; flex-wrap: nowrap; max-width: 100%; }
.hero-cast .avatar { box-shadow: none; background: transparent; width: clamp(44px, 9vw, 78px) !important; height: clamp(44px, 9vw, 78px) !important; margin: 0 -4px; animation: hop 1.8s ease-in-out infinite; }
.hero-cast .avatar:nth-child(2n) { animation-delay: .25s; } .hero-cast .avatar:nth-child(3n) { animation-delay: .5s; }
.hero-bomb { width: clamp(70px, 14vw, 120px); height: clamp(70px, 14vw, 120px); animation: pulse 1.1s ease-in-out infinite; }
.home-menu { display: flex; flex-direction: column; gap: 14px; width: min(420px, 100%); }
.home-foot { color: var(--ink2); font-weight: 700; font-size: .92rem; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
body.calm *, body.calm *::before, body.calm *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .hero-title span, .hero-cast .avatar, .hero-bomb { animation: none; } }

/* ---------- 教學 ---------- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.help-fig { width: 100%; max-width: 360px; margin: 6px auto 0; display: block; }
.item-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 14px; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.item-row img { width: 46px; height: 46px; flex: none; }
.item-row b { display: block; }
.steps { padding-left: 1.2em; margin: 6px 0 0; display: grid; gap: 6px; font-weight: 700; }

/* ---------- 單機設定／選角色 ---------- */
.animal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.animal-opt { border: 3px solid transparent; background: #faf5ff; border-radius: 20px; padding: 6px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-weight: 800; color: var(--ink2); }
.animal-opt[aria-checked="true"] { border-color: var(--grape); background: #efe6ff; color: var(--grape-d); box-shadow: 0 4px 0 var(--grape); }
.animal-opt[aria-disabled="true"] { opacity: .35; cursor: not-allowed; }
.ai-rows { display: grid; gap: 8px; }
.ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 10px; background: #faf5ff; border-radius: 18px; }
.ai-row .name { font-weight: 800; min-width: 5em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 大廳 ---------- */
.room-list { display: grid; gap: 10px; }
.room-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: #fbf7ff; border-radius: 20px; border: 3px solid #fff; box-shadow: 0 4px 0 var(--line); }
.room-item .info { flex: 1 1 200px; min-width: 0; }
.room-item .name { font-weight: 900; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-box { text-align: center; padding: 26px 12px; color: var(--ink2); font-weight: 800; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: .9rem; padding: 4px 12px; border-radius: 999px; background: #fff; box-shadow: 0 2px 0 var(--line); }
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); display: inline-block; }
.status.warn i { background: var(--sun); animation: pulse 1s infinite; }
.status.bad i { background: var(--red); }
.invite-card { background: linear-gradient(135deg, #fff1fa, #eaf6ff); border: 3px solid #fff; box-shadow: 0 6px 0 var(--line), 0 14px 26px rgba(90, 50, 140, .14); border-radius: var(--r); padding: 16px; }

/* ---------- 房間 ---------- */
.room-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.seat { position: relative; background: #fbf7ff; border: 3px solid #fff; box-shadow: 0 4px 0 var(--line); border-radius: 20px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 124px; }
.seat.me { background: #eef8ff; box-shadow: 0 4px 0 #bfe3fa; }
.seat.empty { align-items: center; justify-content: center; color: var(--ink3); font-weight: 800; border-style: dashed; border-color: var(--line); background: transparent; box-shadow: none; }
.seat-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seat-name { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.seat-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.seat-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.chat-box { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; min-height: 120px; max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 8px; background: #faf6ff; border-radius: 16px; font-size: .93rem; -webkit-user-select: text; user-select: text; }
.chat-log .msg b { color: var(--grape-d); margin-right: 6px; }
.chat-log .msg.spec b { color: var(--ink3); }
.chat-log .msg.sys { color: var(--ink3); font-weight: 700; text-align: center; font-size: .85rem; }
.chat-log .msg { word-break: break-word; }
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form .text-input { min-height: 44px; }
.quick-chat { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick-chat button { border: 0; background: #f0e8ff; color: var(--grape-d); border-radius: 999px; padding: 4px 12px; font: inherit; font-weight: 800; font-size: .88rem; cursor: pointer; min-height: 34px; }

/* ---------- 彈窗 ---------- */
.mask { position: fixed; inset: 0; z-index: 100; background: rgba(60, 30, 100, .45); display: flex; align-items: center; justify-content: center; padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l)); backdrop-filter: blur(3px); animation: fade .15s; }
.mask.out { opacity: 0; transition: opacity .15s; }
.dialog { background: #fffdf8; border-radius: 28px; width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 10px 0 var(--line), 0 24px 50px rgba(40, 10, 80, .4); border: 4px solid #fff; animation: pop .2s; outline: none; }
.dialog.dialog-sm { width: min(420px, 100%); }
.dialog.dialog-lg { width: min(720px, 100%); }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 4px 20px; }
.dialog-title { flex: 1; font-size: 1.35rem; font-weight: 900; }
.dialog-body { padding: 8px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 10px 20px 18px; }
.dialog-text { font-weight: 700; padding: 6px 0; }
.big-result { text-align: center; padding: 6px 0 10px; }
.big-result .head { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 900; color: var(--pink-d); text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(0, 0, 0, .08); }
.rank { display: grid; gap: 6px; margin-top: 10px; text-align: left; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 6px; background: #faf5ff; border-radius: 18px; font-weight: 800; }
.rank-row.win { background: linear-gradient(90deg, #fff1b8, #ffe48a); }
.rank-row .no { width: 1.6em; text-align: center; font-weight: 900; color: var(--ink3); }
.rank-row.me:not(.win) { box-shadow: inset 0 0 0 2.5px #cdb6ff; }
.rk-mid { flex: 1; min-width: 0; display: grid; gap: 1px; }
.rk-bar { display: block; height: 7px; border-radius: 99px; background: rgba(120, 90, 200, .12); overflow: hidden; }
.rk-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ff9ccb, #ffc94d); }
.rk-meta { font-size: .72rem; font-weight: 700; color: var(--ink3); line-height: 1.25; }
.stat-title { margin-top: 8px; font-weight: 900; color: var(--grape-d); text-align: left; font-size: .95rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; margin-top: 4px; }
.stat-tile { display: grid; justify-items: center; gap: 0; padding: 3px 4px; border-radius: 14px; background: #fff; border: 2.5px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.stat-tile .st-ico { font-size: 1rem; line-height: 1.15; }
.stat-tile b { white-space: nowrap; font-size: 1.1rem; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: .72rem; font-weight: 800; color: var(--ink3); }
.rank-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box { display: flex; gap: 8px; align-items: center; background: #f4ecff; border-radius: 16px; padding: 8px 10px; }
.link-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; user-select: all; -webkit-user-select: all; }

/* ---------- 其他 ---------- */
.toasts { position: fixed; z-index: 200; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: #3b2a5a; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; box-shadow: 0 6px 16px rgba(0, 0, 0, .3); animation: pop .2s; text-align: center; }
.toast.out { opacity: 0; transition: opacity .3s; }
.banner { position: fixed; z-index: 150; left: 50%; transform: translateX(-50%); top: calc(8px + var(--safe-t)); background: #fff1c2; color: #7a5a00; border-radius: 999px; padding: 6px 18px; font-weight: 800; box-shadow: 0 4px 0 #e8cf7a; display: flex; align-items: center; gap: 8px; }
.wake-art { display: flex; align-items: center; gap: 10px; }
.spin { animation: spin 1.1s linear infinite; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.rotate-tip { position: absolute; z-index: 25; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); }

/* ---------- 響應式 ---------- */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  .game-side { position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); transform: translateX(0); transition: transform .2s; }
  .game.side-closed .game-side { display: flex; transform: translateX(-105%); box-shadow: none; visibility: hidden; transition: transform .2s, visibility 0s .2s; }
  .game-main { padding-top: calc(58px + var(--safe-t)); }
  .side-toggle.on-wide { display: grid !important; }
  .game:not(.side-closed) .side-toggle.on-wide { display: none !important; }
  .room-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .btn { font-size: 1rem; }
  .btn-lg { min-height: 58px; font-size: 1.15rem; }
  .field > .label { min-width: 100%; }
  .field > .ctl { justify-content: flex-start; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .home { gap: 8px; flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .hero-cast { display: none; }
  .hero-title { font-size: 2.4rem; }
  .btn-lg { min-height: 50px; }
}

/* ===== 精簡設定面板 ===== */
.more-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; padding: 8px 12px; min-height: 40px; font: inherit; font-weight: 800; font-size: .92rem; color: #5a3d8a; background: transparent; border: 3px dashed #5a3d8a; border-radius: 12px; cursor: pointer; white-space: nowrap; }
.more-btn i { width: 8px; height: 8px; border-right: 3px solid #5a3d8a; border-bottom: 3px solid #5a3d8a; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.more-btn[aria-expanded="true"] i { transform: rotate(-135deg) translateY(-2px); }
.more-btn:focus-visible { outline: 3px solid var(--sun, #ffe03d); outline-offset: 2px; }
.more-box { padding-top: 4px; }
.ai-faces { display: flex; gap: 6px; padding: 4px 0 8px; overflow-x: auto; scrollbar-width: none; }
.ai-faces .face { flex: 0 0 auto; border-radius: 50%; background: #fff; border: 3px solid #5a3d8a; box-shadow: 2px 2px 0 #5a3d8a; padding: 1px; display: inline-flex; }
.ai-faces .face.me { background: #cdf6ff; }
.sticky-cta { position: sticky; bottom: calc(-6px - var(--safe-b)); padding: 10px 0 4px; margin-top: auto; background: linear-gradient(to top, rgba(255,244,250,.96) 55%, rgba(255,244,250,0)); z-index: 5; }
.rules-sum { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }

/* ===== 自訂卷軸（scroll.js）：隱藏原生卷軸，改畫自己的滑軌與滑塊 ===== */
.sc-hide { scrollbar-width: none; -ms-overflow-style: none; }
.sc-hide::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sc-track { position: absolute; z-index: 40; opacity: 0; transition: opacity .25s; pointer-events: none; }
.sc-track.show, .sc-track:hover { opacity: 1; }
.sc-track.v { width: 10px; }
.sc-track.h { height: 8px; }
.sc-track[hidden] { display: none; }
.sc-track::before { content: ""; position: absolute; inset: 0; border-radius: 999px; background: rgba(23, 18, 43, .35); border: 2px solid #5a3d8a; }
.sc-track.v::before { border-radius: 6px; }
.sc-thumb { position: relative; pointer-events: auto; cursor: grab; border-radius: 999px; background: linear-gradient(#ffe86a, #ffc61a); border: 2px solid #5a3d8a; box-sizing: border-box; touch-action: none; }
.sc-track.v .sc-thumb { width: 100%; min-height: 36px; }
.sc-track.h .sc-thumb { height: 100%; min-width: 28px; }
.sc-thumb.drag { cursor: grabbing; background: linear-gradient(#fff2a0, #ffd23a); }
.sc-track.h { pointer-events: none; }
.sc-track.v { pointer-events: auto; }
/* 內容被切到時兩端淡出，提示「還可以捲」 */
.sc-hide.can-r:not(.can-l) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
.sc-hide.can-l:not(.can-r) { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 22px), transparent); }
.sc-hide.can-l.can-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 22px), transparent); }

/* 對局中的離開／暫停鈕 */
.exit-btn { position: absolute; z-index: 30; top: calc(66px + var(--safe-t)); left: calc(10px + var(--safe-l)); }
.game:not(.side-closed) .exit-btn { display: none; }
.exit-in { margin-left: auto; margin-right: 6px; }
/* 線上延遲：設定鈕正下方，跟左邊的暫停鈕對稱；不擋點擊 */
.ping { position: absolute; z-index: 30; top: calc(64px + var(--safe-t)); right: calc(12px + var(--safe-r)); text-align: right; font-size: .78rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; color: #fff; text-shadow: 0 1px 2px #5a3d8a, 0 0 3px #5a3d8a; pointer-events: none; }
.ping::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: #9a93b5; box-shadow: 0 0 0 1.5px #5a3d8a; vertical-align: 1px; }
.ping.good::before { background: #4cd08a; } .ping.mid::before { background: #ff9a3c; } .ping.bad::before { background: #ff4d4d; }
@media (min-width: 861px) and (min-aspect-ratio: 1/1) { .game.side-closed .exit-btn { top: calc(66px + var(--safe-t)); } }
@media (max-width: 560px) and (orientation: landscape) { .exit-btn { top: calc(62px + var(--safe-t)); } }

/* 網格欄位不可被內容撐寬（否則手機上右側會被切掉） */
.room-grid { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr); }
.room-grid > *, .card, .wrap, .field, .ctl { min-width: 0; }
@media (max-width: 860px), (max-aspect-ratio: 1/1) { .room-grid { grid-template-columns: minmax(0, 1fr); } }

/* ===== 自訂下拉選單 ===== */
.dd { display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; min-width: 7.5em; max-width: 100%; padding: 4px 12px; font: inherit; font-weight: 800; color: #5a3d8a; background: #fffdf3; border: 3px solid #5a3d8a; border-radius: 12px; box-shadow: 2px 2px 0 #5a3d8a; cursor: pointer; white-space: nowrap; }
.dd:hover:not(:disabled) { background: #fff6bd; }
.dd:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.dd:focus-visible, .dd-opt:focus-visible { outline: 3px solid #8b5cff; outline-offset: 2px; }
.dd.sm { min-height: 34px; min-width: 6.4em; font-size: .88rem; padding: 2px 10px; }
.dd.lvl { background: #d8fbe9; }
.dd-caret { width: 8px; height: 8px; border-right: 3px solid #5a3d8a; border-bottom: 3px solid #5a3d8a; transform: rotate(45deg) translateY(-2px); flex: 0 0 auto; transition: transform .15s; }
.dd[aria-expanded="true"] .dd-caret { transform: rotate(-135deg) translateY(-2px); }
.pop-layer { position: fixed; inset: 0; z-index: 300; pointer-events: none; }
.dd-list { position: fixed; pointer-events: auto; display: flex; flex-direction: column; gap: 4px; padding: 6px; overflow-y: auto; background: #fffdf3; border: 3px solid #5a3d8a; border-radius: 14px; box-shadow: 5px 5px 0 #5a3d8a; animation: fade .12s; scrollbar-width: none; }
.dd-list::-webkit-scrollbar { display: none; }
.dd-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: 100%; padding: 8px 12px 8px 30px; position: relative; text-align: left; font: inherit; color: #5a3d8a; background: transparent; border: 2px solid transparent; border-radius: 10px; cursor: pointer; }
.dd-opt .dd-name { font-weight: 900; white-space: nowrap; flex: 0 0 auto; }
.dd-opt small { color: #5b5378; font-weight: 700; font-size: .76rem; white-space: nowrap; }
.dd-opt:hover, .dd-opt:focus { background: #ffe86a; border-color: #5a3d8a; }
.dd-opt[aria-selected="true"]::before { content: ""; position: absolute; left: 10px; top: 50%; width: 6px; height: 11px; border-right: 3px solid #5a3d8a; border-bottom: 3px solid #5a3d8a; transform: translateY(-65%) rotate(45deg); }
.ai-row { display: flex; align-items: center; gap: 10px; }
.ai-row .name { flex: 1; min-width: 0; }
.ai-row .dd { margin-left: auto; }
.dd-sw { display: inline-block; width: 18px; height: 18px; border-radius: 6px; border: 2px solid #5a3d8a; flex: 0 0 auto; vertical-align: middle; margin-right: 8px; }
.dd-cur { display: inline-flex; align-items: center; min-width: 0; }
.dd-opt { flex-direction: row; flex-wrap: wrap; align-items: center; }
.dd-opt .dd-sw { position: static; margin-right: 8px; }
.dd-opt small { flex-basis: 100%; }

/* 席位卡：一列式 */
.seats { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.seat { min-height: 0; padding: 8px 10px; gap: 6px; justify-content: center; }
.seat-line { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.seat-line .seat-name { flex: 1 1 0; min-width: 0; }
.seat-line .dd, .seat-line .icon-btn, .seat-line .btn, .seat-line .pill { flex: 0 0 auto; }
.seat.empty { min-height: 58px; padding: 8px 10px; }
.seat.empty .seat-name { font-weight: 800; color: var(--ink2); }

/* 房間列表：不超出卡片；空間不足時按鈕移到下方，標籤可換行 */
.room-list { min-width: 0; max-width: 100%; }
.room-item { flex-wrap: wrap; min-width: 0; max-width: 100%; box-sizing: border-box; }
.room-item .info { flex: 1 1 240px; min-width: 0; }
.room-item .info .chips { flex-wrap: wrap; overflow: visible; }
.room-item > .row, .room-item > div:last-child:not(.info) { flex: 0 0 auto; }

/* 掃描修正：快速聊天改換行、邀請連結不撐破彈窗、首頁角色列窄螢幕換行置中 */
.quick-chat { flex-wrap: wrap; overflow: visible; }
.quick-chat button { white-space: nowrap; flex: 0 1 auto; }
.dialog-body, .dialog-body > *, .link-box { min-width: 0; max-width: 100%; box-sizing: border-box; }
.hero-cast { flex-wrap: wrap; justify-content: center; max-width: 100%; }
.hero-cast .avatar { margin: 0 -2px; }
/* ===== 彩虹泡泡砲：專屬樣式 ===== */
body { background: linear-gradient(180deg, #bfe8ff 0, #e9f8ff 45%, #fff1f8 100%); }
.hero-logo { width: min(520px, 88vw); height: auto; filter: drop-shadow(0 8px 12px rgba(80, 60, 160, .25)); animation: bob 3s ease-in-out infinite; }
.home { gap: 14px; }
.help-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.help-item { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.help-bub { flex: none; }
.help-levels { display: grid; gap: 6px; font-weight: 700; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #ff4d6d; color: #fff; font-size: .75rem; font-weight: 900; display: grid; place-items: center; border: 2px solid #fff; }
.badge[hidden] { display: none; }
.side-toggle { position: relative; }

/* ---------- 對局 ---------- */
.game { position: absolute; inset: 0; display: flex; background-size: cover; background-position: center; overflow: hidden; }
.game-side { flex: 0 0 clamp(220px, 20vw, 290px); display: flex; flex-direction: column; gap: 8px; padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); background: rgba(255, 255, 255, .86); backdrop-filter: blur(6px); border-right: 3px solid #fff; box-shadow: 4px 0 18px rgba(60, 40, 120, .18); z-index: 20; min-height: 0; }
.game.side-closed .game-side { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 1.05rem; }
.summary { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; flex: 0 1 auto; max-height: 64%; min-height: 0; }
.sum-meta { padding: 4px 4px 8px; border-bottom: 2px dashed var(--line); }
.sum-row { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 14px; background: #faf5ff; }
.sum-row.me { background: #fff1b8; }
.sum-row.gone { opacity: .5; }
.sum-rank { width: 1.2em; text-align: center; font-weight: 900; color: var(--ink3); }
.sum-main { flex: 1; min-width: 0; }
.sum-name { font-weight: 800; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-bar { height: 6px; border-radius: 6px; background: #eadff7; overflow: hidden; margin-top: 2px; }
.sum-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff7eb6, #ffcf3a); border-radius: 6px; transition: width .3s; }
.sum-n { font-variant-numeric: tabular-nums; }
.mystats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat { flex: 1 1 60px; background: #f4ecff; border-radius: 12px; padding: 4px 8px; text-align: center; display: flex; flex-direction: column; font-size: .75rem; color: var(--ink2); }
.stat b { font-size: 1.15rem; color: var(--ink); }
.side-keys { padding-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.side-chat { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-height: 0; }
.chat-log { flex: 1 1 0; min-height: 80px; overflow-y: auto; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 8px; font-size: .9rem; }
.chat-log .msg { word-break: break-word; padding: 1px 0; font-weight: 600; }
.chat-log .msg.sys { color: var(--ink3); font-size: .8rem; }
.chat-form { display: flex; gap: 6px; }
.chat-form .text-input { min-height: 40px; }
.quick-chat { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: inherit; font-weight: 800; font-size: .8rem; padding: 3px 10px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--grape-d); cursor: pointer; }
.chip:active { transform: scale(.95); }

.game-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) 10px; gap: 6px; position: relative; }
.hud { display: flex; align-items: center; gap: 8px; padding-right: 58px; min-height: 48px; flex: none; }
.hud-mid { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
/* ---- 盤面正上方中間的計時牌（造型跟著地圖主題 t-<set>；--f0/--f1 外框色、--ac 主題強調色） ---- */
.bslot.has-timer { --tH: 46px; --tbar: calc(var(--tH) + 8px); container-type: inline-size; }   /* 計時牌高度與它專用的上方留白（盤面從留白下面開始，不會被蓋到） */
.bslot.has-timer > .board-wrap { inset: var(--tbar) 0 0 0; }
.board-bar { position: absolute; left: 50%; top: calc(var(--ctop, 0px) - 3px); transform: translate(-50%, -100%); width: var(--cw, 100%); max-width: 100%; z-index: 4;
  display: flex; justify-content: center; align-items: center; gap: 8px; pointer-events: none; }
.board-bar .btag { position: static; flex: 0 1 auto; min-width: 0; height: 36px; box-sizing: border-box; max-width: 100%; overflow: hidden; }
.board-bar .board-time { flex: none; }
.board-bar .board-pause, .board-bar .bar-gap { flex: none; pointer-events: auto; }
.board-bar .board-pause:active { transform: translateY(3px); }
.board-time {
  position: relative; min-width: 5.4em; padding: 0 20px; text-align: center; white-space: nowrap;
  box-sizing: border-box; min-height: var(--tH, 46px); display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .22);
  background: linear-gradient(180deg, var(--f0, #8fe39a), var(--f1, #3fa863));
  border: 3px solid #fff; border-radius: 18px 18px 12px 12px;
  box-shadow: 0 4px 0 rgba(40, 30, 90, .18), 0 8px 16px rgba(40, 30, 90, .18), inset 0 3px 0 rgba(255, 255, 255, .45);
}
.board-time::before, .board-time::after { position: absolute; top: 50%; transform: translateY(-50%); font-size: .8em; line-height: 1; text-shadow: none; pointer-events: none; }
.board-time::before { left: -.55em; }
.board-time::after { right: -.55em; }
/* 彩虹草原：白底彩虹邊、兩側小花 */
.t-default .board-time { color: #2f8f52; text-shadow: 0 2px 0 #fff; border: 4px solid transparent;
  background: linear-gradient(#fff, #f2fff4) padding-box, linear-gradient(90deg, #ff7aa8, #ffcf3a, #46d37f, #4aa8ff, #a678ff) border-box; }
.t-default .board-time::before, .t-default .board-time::after { content: "✿"; color: #ff7aa8; }
.t-default .board-time::after { color: #4aa8ff; }
/* 暖暖海灘：木板告示牌、海星 */
.t-beach .board-time { color: #7a4514; text-shadow: 0 2px 0 rgba(255, 240, 200, .8); border-color: #fff3d2;
  background: repeating-linear-gradient(180deg, #f2c27a 0 9px, #e3a85c 9px 11px); }
.t-beach .board-time::before { content: "★"; color: #ff8a5c; }
.t-beach .board-time::after { content: "☀"; color: #ffb03a; }
/* 糖果山：條紋糖果邊、兩側糖果紙 */
.t-candy .board-time { color: #d9569a; text-shadow: 0 2px 0 #fff; border: 5px solid transparent; border-radius: 999px;
  background: linear-gradient(#fff, #fff0f8) padding-box, repeating-linear-gradient(45deg, #ff9ccb 0 7px, #fff 7px 14px) border-box; }
.t-candy .board-time::before, .t-candy .board-time::after { content: ""; width: 0; height: 0; border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.t-candy .board-time::before { left: -16px; border-right: 14px solid #c06bff; }
.t-candy .board-time::after { right: -16px; border-left: 14px solid #c06bff; }
/* 童話森林：木頭牌子、葉子 */
.t-forest .board-time { color: #fffbe0; border-color: #e9f5c8; text-shadow: 0 2px 0 #4d2f12;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) 0 3px, transparent 3px 11px), linear-gradient(180deg, #b07a43, #7d5226); }
.t-forest .board-time::before, .t-forest .board-time::after { content: "❦"; color: #6fbf4a; }
/* 星星夜空：深藍夜色、金色字與光暈 */
.t-night .board-time { color: #ffd23a; text-shadow: 0 0 8px rgba(255, 210, 58, .7); border-color: #b9a6ff;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .25) 0 2px, transparent 3px), radial-gradient(circle at 75% 70%, rgba(255, 255, 255, .3) 0 1.5px, transparent 2.5px), linear-gradient(180deg, #3a3fa0, #1f2366);
  box-shadow: 0 0 16px rgba(185, 166, 255, .65), 0 4px 0 rgba(20, 15, 60, .35); }
.t-night .board-time::before, .t-night .board-time::after { content: "✦"; color: #ffe27a; }
/* 海底世界：玻璃泡泡、小氣泡 */
.t-ocean .board-time { color: #1a6fb0; text-shadow: 0 2px 0 #fff; border-color: #fff; border-radius: 999px;
  background: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, .9) 0 4px, transparent 5px), linear-gradient(180deg, rgba(235, 252, 255, .95), rgba(127, 224, 238, .95)); }
.t-ocean .board-time::before, .t-ocean .board-time::after { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; background: rgba(127, 224, 238, .6); }
.t-ocean .board-time::before { left: -16px; top: 30%; }
.t-ocean .board-time::after { right: -18px; top: 65%; width: 14px; height: 14px; }
/* 日月光：夜到黃昏的漸層、金邊、日與月 */
.t-sunmoon .board-time { color: #fff4c0; border-color: #ffd36a; text-shadow: 0 2px 0 rgba(60, 30, 80, .5);
  background: linear-gradient(90deg, #2c2a7a, #8a4f8f 50%, #f08a4c); }
.t-sunmoon .board-time::before { content: "☾"; color: #ffe9a8; }
.t-sunmoon .board-time::after { content: "☀"; color: #ffd36a; }
/* 暫停鍵：跟計時牌同一個主題造型（同高、同邊框與底色），不再是白色圓鈕 */
.board-pause { box-sizing: border-box; width: var(--tH, 46px); height: var(--tH, 46px); padding: 0; display: grid; place-items: center; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, var(--f0, #8fe39a), var(--f1, #3fa863)); border: 3px solid #fff; border-radius: 14px;
  box-shadow: 0 4px 0 rgba(40, 30, 90, .18), 0 8px 16px rgba(40, 30, 90, .18), inset 0 3px 0 rgba(255, 255, 255, .45); }
.board-pause svg { width: 56%; height: 56%; stroke-width: 3.2; }
.board-pause:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.t-default .board-pause { color: #2f8f52;  border: 4px solid transparent;
  background: linear-gradient(#fff, #f2fff4) padding-box, linear-gradient(90deg, #ff7aa8, #ffcf3a, #46d37f, #4aa8ff, #a678ff) border-box; }
.t-beach .board-pause { color: #7a4514;  border-color: #fff3d2;
  background: repeating-linear-gradient(180deg, #f2c27a 0 9px, #e3a85c 9px 11px); }
.t-candy .board-pause { color: #d9569a;  border: 5px solid transparent; border-radius: 999px;
  background: linear-gradient(#fff, #fff0f8) padding-box, repeating-linear-gradient(45deg, #ff9ccb 0 7px, #fff 7px 14px) border-box; }
.t-forest .board-pause { color: #fffbe0; border-color: #e9f5c8; 
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) 0 3px, transparent 3px 11px), linear-gradient(180deg, #b07a43, #7d5226); }
.t-night .board-pause { color: #ffd23a;  border-color: #b9a6ff;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .25) 0 2px, transparent 3px), radial-gradient(circle at 75% 70%, rgba(255, 255, 255, .3) 0 1.5px, transparent 2.5px), linear-gradient(180deg, #3a3fa0, #1f2366);
  box-shadow: 0 0 16px rgba(185, 166, 255, .65), 0 4px 0 rgba(20, 15, 60, .35); }
.t-ocean .board-pause { color: #1a6fb0;  border-color: #fff; border-radius: 999px;
  background: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, .9) 0 4px, transparent 5px), linear-gradient(180deg, rgba(235, 252, 255, .95), rgba(127, 224, 238, .95)); }
.t-sunmoon .board-pause { color: #fff4c0; border-color: #ffd36a; 
  background: linear-gradient(90deg, #2c2a7a, #8a4f8f 50%, #f08a4c); }
/* 最後 15 秒：所有主題都變紅並跳動 */
.board-time.low { color: #fff; text-shadow: 0 2px 0 #a31d33; border-color: #fff; background: linear-gradient(180deg, #ff7b8c, #e2394f) !important; animation: tick-pulse .6s ease-in-out infinite; }
@keyframes tick-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .board-time.low { animation: none; } }
.boards { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; gap: 14px; align-items: stretch; justify-content: center; }
.bslot { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.board-canvas { display: block; border-radius: 22px; filter: drop-shadow(0 8px 14px rgba(40, 30, 100, .25)); touch-action: none; cursor: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2240%22 height=%2240%22 viewBox=%220 0 40 40%22%3E%3Ccircle cx=%2220%22 cy=%2220%22 r=%2214%22 fill=%22rgba%28255,255,255,.35%29%22 stroke=%22%23fff%22 stroke-width=%225%22/%3E%3Ccircle cx=%2220%22 cy=%2220%22 r=%2214%22 fill=%22none%22 stroke=%22%23ff7eb6%22 stroke-width=%222.6%22 stroke-dasharray=%226 4%22/%3E%3Cpath d=%22M20 12.5l2.2 4.8 5.2.6-3.9 3.5 1.1 5.1-4.6-2.6-4.6 2.6 1.1-5.1-3.9-3.5 5.2-.6z%22 fill=%22%23ffd43b%22 stroke=%22%23fff%22 stroke-width=%221.6%22 stroke-linejoin=%22round%22/%3E%3C/svg%3E") 20 20, pointer; }
.bslot:not(.mine) .board-canvas { cursor: default; }
.btag { position: absolute; left: 4px; top: 4px; display: flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border-radius: 999px; background: rgba(255, 255, 255, .92); box-shadow: 0 3px 0 var(--line); font-weight: 900; font-size: .9rem; max-width: calc(100% - 8px); z-index: 2; pointer-events: none; }
.bt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-n { background: var(--pink); color: #fff; border-radius: 999px; padding: 0 8px; min-width: 1.8em; text-align: center; font-variant-numeric: tabular-nums; }
.bslot.small .btag { font-size: .75rem; }
.bslot.small .btag .avatar { width: 22px !important; height: 22px !important; }
.boards.l-main { display: grid; grid-template-rows: minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: minmax(0, 2.4fr); }
.boards.l-main .bslot { grid-row: 1; }
.boards.l-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.boards.l-grid.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.g-overlay { position: absolute; inset: 0; z-index: 40; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.g-overlay .result-mask { pointer-events: auto; }
.big-count { font-size: clamp(5rem, 22vmin, 11rem); font-weight: 900; color: #fff; text-shadow: 0 8px 0 var(--pink-d), 0 14px 26px rgba(60, 20, 100, .4); animation: bigpop .9s ease-out both; }
.big-count.go { color: #fff7a8; text-shadow: 0 8px 0 #e0a014, 0 14px 26px rgba(60, 20, 100, .4); font-size: clamp(3.5rem, 16vmin, 8rem); }
@keyframes bigpop { 0% { transform: scale(.3); opacity: 0; } 25% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: .95; } }
.result-mask { overflow-y: auto; overscroll-behavior: contain; position: absolute; inset: 0; background: rgba(60, 30, 100, .45); display: flex; align-items: flex-start; justify-content: center; padding: 12px; animation: fade .25s; }
.result-card { width: min(560px, 100%); max-height: none; display: block; margin: auto; flex: none; padding: 16px 18px 18px; }
.result-dragon { width: clamp(64px, 15vmin, 120px); height: auto; display: block; margin: -4px auto 0; animation: hop 1.4s ease-in-out infinite; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.result-actions .btn-lg { flex: 1 1 100%; }
.result-actions .btn:not(.btn-lg) { flex: 1 1 140px; }
.spec-tag { display: inline-flex; }

/* 窄版／直向：資訊欄變成左側抽屜；3～4 人時其他人排成下方一列 */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  .game-side { position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); display: flex; }
  .game.side-closed .game-side { display: flex; transform: translateX(-105%); visibility: hidden; box-shadow: none; }
  .game-side { transition: transform .22s, visibility 0s; }
  .game-main { padding-left: calc(8px + var(--safe-l)); }
  /* 抽屜打開時，關閉鈕（雙箭頭）在抽屜標題列裡，上方的開關鈕不重複顯示 */
  .game:not(.side-closed) .hud .side-toggle { display: none; }
}
/* 多人（3～4 人）：自己的盤面在左側佔滿高度，其他人固定排成右邊一直列（所有裝置、橫直向） */
.boards.l-main { grid-auto-flow: row; grid-template-columns: minmax(0, 4.4fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.boards.l-main .bslot.mine { grid-column: 1; grid-row: 1; }
.boards.l-main .opp-col { grid-column: 2; grid-row: 1; }
/* 2 人：寬螢幕左右等寬；窄螢幕（手機／窄視窗／直向）改成自己在左、對手在右邊一直列 */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .boards.l-two { display: grid; grid-template-columns: minmax(0, 4.4fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 10px; }
  .boards.l-two .bslot.mine { grid-column: 1; grid-row: 1; }
  .boards.l-two .opp-col { grid-column: 2; grid-row: 1; }
}
@media (max-width: 560px) {
  .hud-mid .pill { display: none; }
  .bslot.has-timer { --tH: 40px; }
  .board-time { font-size: 1.2rem; padding: 0 14px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .hud { min-height: 40px; }
  .bslot.has-timer { --tH: 38px; --tbar: calc(var(--tH) + 6px); }
  .board-time { font-size: 1.05rem; padding: 0 12px; }
  .result-dragon { display: none; }
}

/* 寬螢幕（平板橫向／桌機，資訊欄常駐）：暫停鈕、倒數與模式移到左邊資訊欄的最上方，盤面從頂端用到底，整個放大 */
@media (min-width: 861px) and (min-aspect-ratio: 5/4) {
  .game { --sw: clamp(220px, 20vw, 290px); }
  .game:not(.side-closed) .hud { position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l) - var(--sw)); width: calc(var(--sw) - 20px - var(--safe-l)); padding-right: 0; z-index: 25; gap: 6px; }
  .game:not(.side-closed) .hud-mid { justify-content: flex-start; gap: 6px; flex-wrap: nowrap; }
  .game:not(.side-closed) .hud-mid .pill { display: none; }
  .game:not(.side-closed) .game-side { padding-top: calc(66px + var(--safe-t)); }
  .game:not(.side-closed) .game-main { padding-top: calc(8px + var(--safe-t)); }
  .boards.l-main .opp-col { padding-top: calc(46px + var(--safe-t)); }   /* 讓出右上角設定鈕的位置 */
}

/* 直向平板：左右留白與欄距再縮小，自己的盤面更寬 */
@media (max-width: 1100px) and (max-aspect-ratio: 1/1) and (min-width: 600px) {
  .game-main { padding-left: calc(4px + var(--safe-l)); padding-right: calc(4px + var(--safe-r)); }
  .boards.l-main, .boards.l-two { gap: 8px; grid-template-columns: minmax(0, 5fr) minmax(0, 1fr); }
}

/* ===== 排版：短文字不換行（whole-item wrap，不拆字） ===== */
.rk-meta { display: flex; flex-wrap: wrap; column-gap: .7em; }
.rk-meta i { font-style: normal; white-space: nowrap; }
.mystats .stat { flex: 1 1 auto; min-width: 0; padding: 4px 6px; }
.mystats .stat span, .stat-tile span, .stat-tile b { white-space: nowrap; }
.keyline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.keyline > span { white-space: nowrap; display: inline-flex; align-items: center; }
.help-levels > div { display: flex; align-items: baseline; gap: .5em; }
.help-levels > div > b { flex: none; white-space: nowrap; }
.help-levels > div > .muted { min-width: 0; font-size: clamp(.8rem, 3.4vw, .95rem); }
/* 橫幅：寬度以內容為準（不被 left:50% 擠成半寬），過長才省略 */
.banner { width: max-content; max-width: calc(100vw - 24px); white-space: nowrap; pointer-events: none; }
.banner .banner-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.toast { max-width: 100%; }
@media (max-width: 560px) { .banner { top: calc(64px + var(--safe-t)); font-size: .92rem; } }
/* 標籤／按鈕／膠囊一律單行；放不下時由外層整顆換行或捲動，不拆字 */
.pill, .chip, .seg-btn, .key, .status, .badge, .stat-tile span, .stat span, .sum-name, .dd, .dd-cur, .more-btn, .lobby-home-link, .board-time, .btag, .bt-n, .rank-row .no, .stepper-val, .field > .label, .ai-row .name, .animal-opt, .seat-tags .pill { white-space: nowrap; }
.btn .btn-label, .btn { white-space: nowrap; }
.btn .btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.card h3, .dialog-title, .side-head, .stat-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card h3 > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seg { max-width: 100%; }
/* 一小段說明文字在窄螢幕縮小一點，盡量維持一行 */
.dialog-text, .invite-card p, .empty-box { font-size: clamp(.9rem, 3.9vw, 1rem); }
.toast { font-size: clamp(.88rem, 3.7vw, 1rem); }

/* 側欄鍵盤提示：同一行放得下就不換行 */
.side-keys.keyline { gap: 4px 8px; font-size: .78rem; }
.side-keys .keycap { min-width: 1.7em; }

/* 分段選項（時間、難度…）：一律同一行；放不下時縮小內距與字級，不換行 */
.seg { flex-wrap: nowrap; max-width: 100%; }
.seg-btn { flex: 1 1 auto; min-width: 0; padding-left: clamp(8px, 2.6vw, 16px); padding-right: clamp(8px, 2.6vw, 16px); font-size: clamp(.82rem, 3.4vw, 1rem); }
.seg.small .seg-btn { padding-left: clamp(6px, 2vw, 10px); padding-right: clamp(6px, 2vw, 10px); }

/* 結算卡：內容比畫面高時從頂端開始、可往下捲；手機直向把龍縮掉，盡量一屏放完 */
@media (max-width: 600px) and (max-height: 900px) { .result-dragon { display: none; } .big-result { padding-top: 0; } .result-card { padding-top: 12px; } }

/* 右邊直列的對手：名牌緊貼在自己盤面正上方，不要和盤面隔很遠 */
.boards.l-main .bslot.small { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 3px; }
.boards.l-main .bslot.small .btag { position: static; order: -1; align-self: center; flex: none; max-width: 100%; }

/* 對手欄：從中間往上下排，間距小；寬螢幕雙人時不用這欄（維持左右等寬） */
.opp-col { display: contents; }
.boards.l-main .opp-col { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; min-height: 0; }
.boards.l-main .opp-col .bslot { flex: 0 1 auto; min-height: 0; }
.boards.l-main .opp-col .board-wrap { position: relative; inset: auto; flex: 0 1 auto; width: 100%; aspect-ratio: var(--ar, 3 / 4); min-height: 0; max-height: 100%; }
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .boards.l-two .opp-col { display: flex; flex-direction: column; justify-content: center; min-width: 0; min-height: 0; }
  .boards.l-two .opp-col .bslot { flex: 0 1 auto; min-height: 0; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 3px; }
  .boards.l-two .opp-col .btag { position: static; order: -1; align-self: center; flex: none; max-width: 100%; }
  .boards.l-two .opp-col .board-wrap { position: relative; inset: auto; flex: 0 1 auto; width: 100%; aspect-ratio: var(--ar, 3 / 4); min-height: 0; }
}

/* 寬螢幕、3～4 人：自己的盤面照比例撐滿高度，對手欄緊貼在它旁邊，整組置中（不要中間留一大塊空） */
@media (min-aspect-ratio: 5/4) {
  .boards.l-main { grid-template-columns: auto auto; justify-content: center; column-gap: 22px; }
  .boards.l-main .opp-col .bslot { flex: 1 1 0; }
  .boards.l-main .opp-col .board-wrap { flex: 1 1 0; width: auto; align-self: center; }
  .boards.l-main .bslot.mine { height: 100%; aspect-ratio: var(--ar, 3 / 4); max-width: 100%; }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
  .boards.l-main .opp-col .bt-name { max-width: 3.6em; }
  .boards.l-main .opp-col .btag { gap: 4px; padding-right: 6px; }
}

/* 資訊欄常駐的寬螢幕：暫停、倒數、收合箭頭（««）排在同一排，標題列不再放按鈕；收合後箭頭回到最左邊（»） */
@media (min-width: 861px) and (min-aspect-ratio: 1/1) {
  .game:not(.side-closed) .hud .side-toggle { order: 3; margin-left: auto; }
  .game:not(.side-closed) .side-close { display: none; }
  .game.side-closed .hud .side-toggle { order: -1; }
}

/* 暫停視窗：置中、主按鈕整排、次要按鈕並排；窄螢幕改成直排；矮的橫向手機改成三顆一排 */
.dialog-pause { width: min(440px, 100%); }
.dialog-pause .pause-body { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.dialog-pause .pause-art { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(180deg, #ff9ccd, #ff5fa8); box-shadow: 0 5px 0 #d6407f, 0 8px 14px rgba(214, 64, 127, .3); animation: hop 1.6s ease-in-out infinite; }
.dialog-pause .pause-art svg { stroke-width: 3; }
.dialog-pause .dialog-text { font-size: clamp(.95rem, 3.8vw, 1.1rem); padding: 4px 0 2px; }
.dialog-pause .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; justify-content: stretch; padding: 12px 20px calc(18px + var(--safe-b)); }
.dialog-pause .dialog-actions .btn { width: 100%; min-width: 0; justify-content: center; padding-left: 10px; padding-right: 10px; }
.dialog-pause .pause-main { grid-column: 1 / -1; }
@media (max-width: 400px) {
  .dialog-pause .dialog-actions { grid-template-columns: 1fr; }
  .dialog-pause .pause-art { width: 54px; height: 54px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .dialog.dialog-sm.dialog-pause { width: min(600px, 100%); }
  .dialog-pause .pause-body { flex-direction: row; justify-content: center; gap: 12px; }
  .dialog-pause .pause-art { width: 44px; height: 44px; animation: none; }
  .dialog-pause .dialog-actions { grid-template-columns: 1.2fr 1fr 1.3fr; padding: 8px 16px 12px; }
  .dialog-pause .pause-main { grid-column: auto; min-height: 48px; }
}
