/* [claude code] 2026-08-17 Phase 1:整站樣式(深色 · 手機優先 · 零圖片) */
/* [claude code] 2026-08-18 v1.2:桌機把版面收成一欄置中(手機優先的 100% 寬在寬螢幕會散開) */

/* 🔴 一定要有這條:只要任何選擇器給了 display,HTML 的 hidden 屬性就會失效,
   畫面上會冒出一堆「空盒子」(dadatg v1.3 線上事故)。 */
[hidden] { display: none !important; }

:root {
  --bg: #101725;
  --bg2: #17203180;
  --card: #1b2436;
  --line: #2b3a55;
  --fg: #e8eefc;
  --muted: #8fa3c8;
  --gold: #ffc53d;
  --good: #4cc46a;
  --bad: #ff5c7a;
  --accent: #3fa9ff;
  --r: 12px;
  font-size: 15px;
}

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

body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  overscroll-behavior: none;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- 共用元件 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #0d1320; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar b { flex: 1; font-size: 1.05rem; }
.brand { flex: 1; font-size: 1.1rem; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--gold);
  border-radius: 999px; padding: 5px 12px; font-size: .9rem; font-weight: 700;
}
button {
  font: inherit; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: 9px 14px; cursor: pointer;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #2f7fe0, #2463b4); border-color: #3f8fe6; font-weight: 700; }
button.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 12px; }
button.x { background: none; border: none; font-size: 1.3rem; padding: 4px 8px; }
/* 認輸:寫出字才看得懂那是退出(只放一面白旗沒人找得到) */
button.leave { background: none; border: 1px solid var(--line); font-size: .85rem; padding: 5px 10px; color: var(--muted); }
.muted { color: var(--muted); font-size: .88rem; line-height: 1.6; }
.mini-title { color: var(--muted); font-size: .8rem; margin: 14px 0 6px; letter-spacing: .05em; }
.page { padding: 12px; padding-bottom: 40px; overflow-y: auto; flex: 1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv b { color: var(--muted); font-weight: 400; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .85rem; }

/* ---------- 大廳 ---------- */
.lobby-body { flex: 1; overflow-y: auto; padding: 12px 12px 80px; }
.chapter { margin-bottom: 18px; }
.chapter h3 { margin: 0 0 8px; font-size: .95rem; color: var(--muted); }
.stage {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; margin-bottom: 8px;
}
.stage .em { font-size: 1.6rem; }
.stage .t { flex: 1; }
.stage .t b { display: block; }
.stage .t small { color: var(--muted); }
.stage .st { font-size: .8rem; color: var(--muted); text-align: right; }
.stage.locked { opacity: .5; }
.stage.cleared { border-color: #3c6b45; }
.stage.cleared .st { color: var(--good); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; z-index: 30;
  background: #0d1320; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; border-radius: 0; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.15rem; color: var(--muted);
}
.tab span { font-size: .7rem; }
.tab.on { color: var(--fg); }

/* ---------- 底部彈出面板 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 86dvh;
  background: #16203080; backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; animation: up .18s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #131b2b; border-radius: 18px 18px 0 0; }
.sheet-head b { flex: 1; }
.sheet-body { padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; background: #131b2b; }

.row-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.row-cards.wrap { flex-wrap: wrap; overflow: visible; }
.pick {
  min-width: 108px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px; text-align: center;
}
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pick .em { font-size: 1.8rem; }
.pick b { display: block; margin: 4px 0 2px; font-size: .9rem; }
.pick small { color: var(--muted); font-size: .74rem; display: block; line-height: 1.4; }

/* ---------- 天賦 / 卡組 ---------- */
.line-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 12px; }
.node { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #24314a; }
.node:first-of-type { border-top: none; }
.node .em { font-size: 1.4rem; }
.node .t { flex: 1; }
.node .t b { display: block; font-size: .92rem; }
.node .t small { color: var(--muted); font-size: .78rem; }
.pips { display: flex; gap: 3px; margin-top: 3px; }
.pips i { width: 16px; height: 5px; border-radius: 3px; background: #2b3a55; }
.pips i.on { background: var(--gold); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; text-align: left; }
.gcard.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.gcard.lock { opacity: .62; }
.gcard b { display: block; font-size: .92rem; }
.gcard small { color: var(--muted); font-size: .76rem; line-height: 1.45; display: block; margin-top: 3px; }

/* ---------- 棋盤 ---------- */
.game-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.board-wrap { padding: 6px; }
.board {
  position: relative; width: min(100vw - 12px, 62dvh); aspect-ratio: 1; margin: 0 auto;
  display: grid; grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr); gap: 2px;
  container-type: inline-size;
}
.tile {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 2.1cqw; line-height: 1.1; overflow: hidden; padding: 1px; cursor: pointer;
}
.tile .em { font-size: 3.4cqw; }
.tile .nm { font-size: 1.7cqw; color: var(--muted); text-align: center; max-width: 100%; }
.tile .own { position: absolute; top: 0; left: 0; right: 0; height: 8%; }
.tile .lv { position: absolute; bottom: 1px; font-size: 1.9cqw; letter-spacing: -1px; }
.tile.corner { background: #223049; }
.tile.pickable { outline: 2px solid var(--gold); animation: blink 1s infinite; }
.tile.cur { box-shadow: 0 0 0 2px var(--accent) inset; }
@keyframes blink { 50% { outline-color: transparent; } }

/* 🔴 棋子 = 有底色 + 有色圈的籌碼。
   原本是一顆裸 emoji 疊在格子的 emoji 與地名上面,兩者混成一團
   (使用者:「人和地有點合在一起,看不出來,難注意到」)。
   深色底 + 玩家色的圈 + 陰影 → 它明顯是「站在格子上的東西」,不是格子的一部分。 */
.pawns { position: absolute; inset: auto 0 8% 0; display: flex; justify-content: center; gap: 2%; z-index: 6; }
.pawns i {
  font-style: normal; font-size: clamp(10px, 2.4cqw, 15px); line-height: 1;
  background: #0b1220; border: 0.35cqw solid currentColor; border-radius: 999px;
  padding: 0.5cqw 0.7cqw; box-shadow: 0 0.2cqw 0.5cqw #000b;
  transition: transform .18s;
}
/* 現在輪到的那個人:多一圈脈動,一眼看得到「我在哪 / 他在哪」 */
.pawns i.now { animation: pawnnow 1.4s ease-in-out infinite; }
@keyframes pawnnow {
  0%, 100% { box-shadow: 0 0.2cqw 0.5cqw #000b, 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0.2cqw 0.5cqw #000b, 0 0 0 0.5cqw color-mix(in srgb, currentColor 45%, transparent); }
}

/* 💰 頭上跳的金額 —— 加錢 / 扣錢原本只有播報文字,看不出「誰的錢動了」。
   🔴 位置綁在【那個玩家的棋子所在格】,所以收租時付錢的人跳紅、收錢的人跳綠,
   同一秒就看得出錢從誰那裡跑到誰那裡。 */
.flt {
  position: absolute; z-index: 9; pointer-events: none; white-space: nowrap;
  font-weight: 800; font-size: clamp(12px, 2.7cqw, 18px); letter-spacing: -0.03em;
  text-shadow: 0 1px 3px #000, 0 0 6px #000, 0 0 10px #000;
  animation: floatup 1.25s cubic-bezier(.2, .7, .3, 1) forwards;
}
.flt.plus { color: #6ee787; }
.flt.minus { color: #ff7a93; }
.flt.point { color: var(--gold); }
@keyframes floatup {
  0%   { opacity: 0; transform: translate(-50%, 10%) scale(.7); }
  18%  { opacity: 1; transform: translate(-50%, -30%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}

.center {
  grid-column: 2 / 11; grid-row: 2 / 11; background: #131c2c; border: 1px solid var(--line);
  border-radius: 10px; padding: 2%; display: flex; flex-direction: column; gap: 2%;
  /* 🔴 動作按鈕搬進來之後不能再 overflow: hidden ——
     蓋房子那一題有六個選項,關掉捲動的話最後幾個會被裁掉、玩家永遠選不到。 */
  overflow-y: auto;
}
/* 🔴 現在輪到誰:一行明講。玩家列的底色差異(#1a2436 vs #26365a)在小圖上根本看不出來 */
/* 字級跟著棋盤走但要夾下限:手機棋盤只有 ~363px,純 2.5cqw 會掉到 9px(讀不動) */
.turnbar {
  text-align: center; font-size: clamp(11px, 2.5cqw, 16px); font-weight: 700; border-radius: 6px;
  padding: 1.2% 0; background: #1a2436; color: var(--muted); border: 1px solid var(--line);
}
.turnbar.me {
  background: linear-gradient(180deg, #2f7fe0, #2463b4); color: #fff; border-color: #6fb4ff;
  animation: turnpulse 1.6s ease-in-out infinite;
}
.turnbar.over { background: #2a2438; color: var(--gold); border-color: var(--gold); }
@keyframes turnpulse { 50% { box-shadow: 0 0 0 0.5cqw #6fb4ff44; } }

.players { display: flex; flex-direction: column; gap: 2%; flex: 0 0 auto; }
.prow {
  display: flex; align-items: center; gap: 2%; font-size: 2.1cqw; background: #1a2436;
  border-radius: 6px; padding: 1.2% 2%; border-left: 0.7cqw solid transparent;
}
.prow.me { outline: 1px solid var(--accent); }
.prow.dead { opacity: .4; text-decoration: line-through; }
/* 輪到的人:左邊亮一條 + ▶ 標記(只靠底色深一階看不出來) */
.prow.turn { background: #26365a; border-left-color: var(--accent); }
.prow .mark { width: 2.2cqw; color: var(--accent); font-size: 2.2cqw; }
.prow .nm { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.prow .cash { color: var(--gold); font-variant-numeric: tabular-nums; }
.prow .god { font-size: 2.3cqw; }
.dice { display: flex; gap: 3%; justify-content: center; font-size: 5cqw; }
.dice.roll span { animation: shake .4s; }
@keyframes shake { 50% { transform: rotate(20deg) scale(1.25); } }
.hint { text-align: center; font-size: 2.2cqw; color: var(--muted); min-height: 1.2em; }

/* 棋盤中央的動作區:字級跟著棋盤大小走(cqw),手機不會爆版、桌機不會變成一排巨無霸按鈕 */
.center .actions { padding: 0; gap: 1.5%; justify-content: center; align-content: flex-start; }
/* 🔴 字級跟著棋盤大小走(cqw),但要夾住下限 —— 小視窗的棋盤只有 ~500px,
   純 2.3cqw 會掉到 11px 以下,「看得到」跟「讀得動」是兩回事。 */
.center .actions button {
  flex: 0 1 auto; min-width: 0; font-size: clamp(12px, 2.3cqw, 15px);
  padding: 1.4% 3%; border-radius: 8px;
}
.center .actions .why { text-align: center; font-size: clamp(11px, 1.95cqw, 13px); margin: -0.5% 0 0.5%; }

/* ---------- 側邊 / 下方面板 ---------- */
.side { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 8px 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; }
.actions button { flex: 1 1 auto; min-width: 96px; }
.actions .why { flex-basis: 100%; color: var(--muted); font-size: .8rem; }
.panelbar { display: flex; gap: 6px; margin-bottom: 6px; }
.pbtn { flex: 1; padding: 6px; font-size: .85rem; background: #131b2b; }
.pbtn.on { background: var(--card); border-color: var(--accent); }
.pbtn i { font-style: normal; color: var(--gold); }
.panel {
  background: #131b2b; border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px; overflow-y: auto; flex: 1; min-height: 120px; max-height: 34dvh;
}
.log div { padding: 4px 2px; border-bottom: 1px solid #1e2940; font-size: .86rem; animation: fade .3s; }
.log div:last-child { border-bottom: none; }
@keyframes fade { from { opacity: 0; transform: translateX(-6px); } }
.log .t-news { color: var(--gold); }
.log .t-god { color: #c084fc; }
.log .t-pay, .log .t-bankrupt { color: var(--bad); }
.log .t-cash, .log .t-buy, .log .t-upgrade { color: var(--good); }
.log .t-over { color: var(--gold); font-weight: 700; }

.hcard { display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 6px; text-align: left; }
.hcard .em { font-size: 1.4rem; }
.hcard .t { flex: 1; }
.hcard .t b { display: block; font-size: .9rem; }
.hcard .t small { color: var(--muted); font-size: .76rem; }

.srow { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #1e2940; font-size: .88rem; }
.srow .nm { flex: 1; }
.srow .px { font-variant-numeric: tabular-nums; }
.srow .up { color: var(--bad); }   /* 🔴 台灣慣例:紅漲綠跌 */
.srow .dn { color: var(--good); }
.srow button { padding: 4px 9px; font-size: .8rem; }
.srow .hold { color: var(--gold); font-size: .8rem; min-width: 44px; text-align: right; }

/* ---------- 結算 ---------- */
.result-page { text-align: center; max-width: 480px; margin: 0 auto; }
.badge { font-size: 4rem; margin-top: 8dvh; animation: pop .4s; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.result-page .kv { text-align: left; margin: 16px auto; max-width: 300px; }
.tokens { font-size: 2.4rem; color: var(--gold); font-weight: 700; }
.detail { list-style: none; padding: 0; color: var(--muted); font-size: .85rem; }
.detail li { padding: 2px 0; }

/* ---------- 詢問框 / toast ---------- */
.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; max-width: 340px; width: 100%; }
.modal-btns { display: flex; gap: 8px; margin-top: 14px; }
.modal-btns button { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 12dvh; transform: translateX(-50%); z-index: 70;
  background: #0009; backdrop-filter: blur(6px); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: .88rem; animation: fade .2s;
}

form label { display: block; color: var(--muted); font-size: .8rem; margin: 8px 0 3px; }
form input {
  width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #0d1320; color: var(--fg); font: inherit;
}
form button { width: 100%; margin-top: 10px; }

/* ---------- 桌機:棋盤左、面板右 ---------- */
@media (min-width: 900px) {
  .game-wrap { flex-direction: row; align-items: flex-start; justify-content: center; }
  .board-wrap { flex: 0 0 auto; }
  .board { width: min(72dvh, 60vw); }
  .side { max-width: 420px; height: calc(100dvh - 52px); }
  .panel { max-height: none; }
}

/* ---------- 桌機:把手機版面收成一欄置中 ----------
   🔴 本作是手機直向設計,每一塊都是 100% 寬。在 1900px 的螢幕上這會變成:
   一列關卡橫跨整個畫面(關卡名黏在最左、「26 輪 / 2 人」黏在最右、中間一大片空白)、
   出戰面板的角色卡孤零零站在左下角、「出發!」是一顆 1900px 寬的按鈕
   —— 每個元件都沒錯,但彼此離太遠,看起來就是「東西散在四周」。

   🔴 只做一件事:給內容一個欄寬並置中,**不改任何 HTML**。
   滿版的橫條(topbar / tabbar)背景仍然通到底 —— 那是對的,收的是「內容」不是「底色」,
   所以用 padding 把內容推進欄裡,而不是把整條變窄。 */
@media (min-width: 760px) {
  :root { --col: 760px; }

  /* 底色通到底、內容對齊中央那一欄 */
  .topbar, .tabbar { padding-inline: max(12px, calc((100% - var(--col)) / 2)); }

  /* 會捲動的內容區收成一欄。
     🔴 排除 .result-page —— 它自己有更窄的 480px,被這條蓋掉會變寬(結算是短內容,窄一點才好讀)。 */
  .lobby-body,
  .page:not(.result-page) { max-width: var(--col); margin-inline: auto; width: 100%; }

  /* 出戰面板:手機是貼底的 sheet,桌機收成同一欄寬、置中。
     🔴 用 left + margin-left 定位,不要用 transform: translateX(-50%) ——
     .sheet 的入場動畫 @keyframes up 就是在動 transform,兩邊會打架(面板會瞬間跳掉一半)。 */
  .sheet { left: 50%; right: auto; width: var(--col); margin-left: calc(var(--col) / -2); }
}
