/* 成熟商業卡牌遊戲風格：實木黃銅牌桌 × 羊毛呢絨 × 舊化卡紙 × 9-slice 實體按鍵 */
:root {
  --wood-dark: #160e09;
  --brass: #c9a24d;
  --brass-dim: rgba(201, 162, 77, 0.38);
  --felt-recess: rgba(7, 20, 14, 0.42);
  --text: #f3ede0;
  --muted: #b5aa95;
  --money: #e6be68;
  --card-paper: #f7f1e3;
  --card-red: #b82525;
  --card-black: #1e1b18;
  --card-w: 66px;
  --card-h: 94px;
  --tcard-w: 72px;
  --tcard-h: 102px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  background-color: var(--wood-dark);
  background-image: radial-gradient(circle at 50% 45%, #241810 0%, #120b07 100%);
  color: var(--text);
  font: 14px/1.4 "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  overflow-x: hidden;
  user-select: none;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  z-index: 900;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100dvh;
  background-color: #163324;
  background-image: url('assets/ui/table_bg.webp');
  background-size: 100% 100%;
  background-position: center;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

#app.in-round { height: 100dvh; overflow: hidden; }
#app.shake-1 { animation: shake1 0.22s ease-out; }
#app.shake-2 { animation: shake2 0.3s ease-out; }
#app.shake-3 { animation: shake3 0.36s ease-out; }

h2 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: 0.5px; color: #f5ebd6; }
h3 { font-size: 14px; margin: 0; color: #f5ebd6; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* ── 統一實體遊戲按鈕（全站 100% 使用同一套黃銅雕花切圖系統，僅以色調區分主次） ── */
button {
  font: inherit;
  font-weight: 700;
  color: #efe6d5;
  background: #2b241d;
  border: 10px solid transparent;
  border-image: url('assets/ui/btn_discard.webp') 28 38 fill stretch;
  filter: saturate(0.15) brightness(0.92) contrast(1.08);
  padding: 0 10px;
  min-height: 38px;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, filter 0.12s ease;
}
button:hover:not(:disabled) { filter: saturate(0.2) brightness(1.06) contrast(1.08); }
button:active:not(:disabled) { transform: translateY(2px); }
button:disabled { opacity: 0.42; cursor: not-allowed; }

button.primary {
  background: #174631;
  border: 14px solid transparent;
  border-image: url('assets/ui/btn_play.webp') 28 38 fill stretch;
  filter: none;
  padding: 0 10px;
  color: #f9f3e3;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.95);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}
button.primary:hover:not(:disabled) { filter: brightness(1.1); }

button.danger {
  background: #5b1a1c;
  border: 14px solid transparent;
  border-image: url('assets/ui/btn_discard.webp') 28 38 fill stretch;
  filter: none;
  padding: 0 10px;
  color: #f9ecea;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.95);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}
button.danger:hover:not(:disabled) { filter: brightness(1.1); }

button.gold {
  background: #6b4d15;
  border: 14px solid transparent;
  border-image: url('assets/ui/btn_play.webp') 28 38 fill stretch;
  filter: sepia(0.75) saturate(1.55) brightness(1.08);
  padding: 0 14px;
  color: #fff6dc;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}
button.gold:hover:not(:disabled) { filter: sepia(0.75) saturate(1.6) brightness(1.18); }

button.big { min-height: 48px; font-size: 15px; }
button.mini { min-height: 32px; border-width: 8px; padding: 0 8px; font-size: 12px; }
button.mini.primary { border-width: 10px; min-height: 34px; padding: 0 6px; }
button.icon-btn {
  min-width: 36px; min-height: 34px; border-width: 8px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
button svg { display: block; }

/* ── 頂部實木黃銅銘牌 HUD ── */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(24, 16, 11, 0.9);
  border: 1.5px solid var(--brass-dim);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 230, 170, 0.1);
  flex-shrink: 0;
}

.hud-score-box { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hud-score-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.hud-blind-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(201, 162, 77, 0.14);
  border: 1px solid rgba(201, 162, 77, 0.3);
  color: #e2cfa2;
  white-space: nowrap;
}
.hud-blind-tag.boss { background: rgba(140, 30, 34, 0.55); border-color: rgba(210, 90, 88, 0.5); color: #f2b8b5; }
.hud-nums { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-nums .cur { color: var(--money); font-size: 16px; }
.hud-nums .sep { color: var(--muted); margin: 0 3px; font-weight: 400; }
.hud-nums .tgt { color: #dfd5c0; font-size: 13px; }

.hud-score-box { position: relative; }
.hud-bar {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  border: 1px solid rgba(201, 162, 77, 0.32);
}
.hud-bar.charging .hud-bar-fill { transition: none; } /* 計分中由數字滾動逐格帶動，長度跟數字同步 */
.hud-bar.overflow { border-color: #ffe08a; box-shadow: 0 0 10px rgba(255, 214, 102, 0.85), 0 0 22px rgba(255, 140, 60, 0.45); }
.hud-bar.overflow .hud-bar-fill { filter: saturate(1.15) brightness(1.08); }
.hud-bar-fill {
  height: 100%;
  width: 0%;
  /* 垂直漸層：顏色不隨長度拉伸，分數增加時整條顏色不會變 */
  background: linear-gradient(180deg, #ffe39a 0%, #e0b04e 55%, #b8862e 100%);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
/* 數字旁的「+N」：這一手打進來的分數先記在這裡，最後才滾進總分、長進分數條 */
.hud-nums .pend {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255, 209, 102, 0.14);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: #ffd166;
  font-size: 13px;
  font-weight: 900;
  vertical-align: 1px;
}
.hud-nums .pend:empty { display: none; }
.hud-nums .pend.pop { animation: pendPop 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pendPop { 0% { transform: scale(1.55); color: #fff; } 100% { transform: scale(1); } }

.hud-pills { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(12, 8, 5, 0.65);
  border: 1px solid rgba(201, 162, 77, 0.22);
  font-variant-numeric: tabular-nums;
}
.pill .lbl { font-size: 10px; color: var(--muted); line-height: 1.1; }
.pill .val { font-size: 13px; font-weight: 800; line-height: 1.2; }
.pill.hands .val { color: #6fb3f2; }
.pill.discards .val { color: #e06c6c; }
.pill.money .val { color: var(--money); }

/* ── 上方裝備列（確保 5 張加成卡完整可見不遺漏） ── */
.shelf {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--felt-recess);
  border: 1px solid rgba(201, 162, 77, 0.22);
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}
.shelf-group { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.shelf-group.grow { flex: 1; }
.shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #cfc4ad;
  font-weight: 700;
}
.shelf-row {
  display: flex;
  gap: 6px;
  padding: 2px 0;
}

/* ── 裝備與道具卡牌（舊化卡紙底紋 + 精雕多色向量圖騰） ── */
.tcard {
  position: relative;
  width: var(--tcard-w);
  height: var(--tcard-h);
  flex-shrink: 0;
  border-radius: 7px;
  background-color: #2c2824;
  background-image: url('assets/ui/card_paper.webp');
  background-size: cover;
  border: 2px solid #8c8270;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
  transition: transform 0.14s ease;
}
.tcard:hover { transform: translateY(-3px); }
.tcard.joker.common { border-color: #9e9585; }
.tcard.joker.uncommon { border-color: #4f8bc2; }
.tcard.joker.rare { border-color: #d6a947; }
.tcard.upgrade { border-color: #5ea3b8; }

.tcard.triggering {
  animation: cardTrigger 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  border-color: #f2cf72;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(242, 207, 114, 0.7);
}

.tcard.empty {
  background: rgba(0, 0, 0, 0.22);
  border: 1px dashed rgba(201, 162, 77, 0.28);
  box-shadow: none;
  align-items: center;
  justify-content: center;
  color: rgba(224, 212, 188, 0.45);
  font-size: 11px;
  cursor: default;
}
.tcard.empty:hover { transform: none; }

.tcard .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.tcard .art ~ .tcard-emblem { display: none; }

.tcard-emblem {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(201, 162, 77, 0.35);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 18px;
  z-index: 0;
  pointer-events: none;
}
.tcard-emblem svg { width: 42px; height: 42px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.75)); }

.tcard-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 800;
  background: rgba(18, 13, 9, 0.92);
  color: var(--money);
  border: 1px solid rgba(201, 162, 77, 0.55);
}

.tcard-plate {
  position: relative;
  z-index: 2;
  padding: 10px 3px 3px;
  background: linear-gradient(180deg, transparent 0%, rgba(14, 11, 8, 0.9) 42%, rgba(14, 11, 8, 0.98) 100%);
  text-align: center;
}
.tcard-name { font-size: 10px; font-weight: 800; color: #f5ebd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard-sub { font-size: 8.5px; color: #b8ad96; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 牌桌主舞台 & 非回合場景 ── */
.panel {
  background: rgba(12, 26, 19, 0.65);
  border: 1.5px solid var(--brass-dim);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.4);
}
.panel.parchment {
  background-color: #2b2620;
  background-image: url('assets/ui/card_paper.webp');
  background-size: cover;
  border: 2px solid var(--brass);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), inset 0 0 0 3px rgba(201, 162, 77, 0.25);
}

.panel.round {
  flex: 1;
  min-height: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0 0;
}

.boss-banner {
  background: rgba(110, 24, 28, 0.88);
  border: 1px solid rgba(201, 105, 95, 0.55);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.score-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(8, 22, 15, 0.34);
  border: 1px solid rgba(201, 162, 77, 0.18);
  min-height: 104px;
  flex: 1;
}

.stage-top { display: flex; align-items: center; justify-content: center; width: 100%; gap: 18px; flex-wrap: wrap; }
.hand-name { font-size: 17px; font-weight: 800; color: #f7f0e2; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7); }
.hand-name small {
  font-size: 11px;
  color: var(--money);
  background: rgba(20, 14, 10, 0.75);
  border: 1px solid rgba(201, 162, 77, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* 立體黃銅鑲邊籌碼 & 倍率銘牌 */
.calc { display: flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.calc .chips, .calc .mult {
  min-width: 50px;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  color: #fff;
  border: 1.5px solid #c9a24d;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.12s ease;
}
.calc .chips { background: linear-gradient(180deg, #2d6ca6 0%, #1c4770 100%); }
.calc .mult { background: linear-gradient(180deg, #a62b30 0%, #6e1a1d 100%); }
.calc .chips.bump, .calc .mult.bump { transform: scale(1.14); }
.calc .mult.tier-3 { background: linear-gradient(180deg, #c23b22 0%, #7d2010 100%); border-color: #f2be5c; }
.calc .mult.tier-4 { background: linear-gradient(180deg, #d14822 0%, #8a230b 100%); border-color: #ffe08a; }
.calc .x { color: #d6cbb5; font-weight: 800; font-size: 15px; }
.calc .est-total {
  font-size: 21px;
  font-weight: 900;
  color: var(--money);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  min-width: 40px;
  text-align: right;
}

.est-line { font-size: 12px; color: #d6cbb5; text-align: center; width: 100%; }
.est-line .ok { color: #8fe3a8; font-weight: 700; }

.stage-cards { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 76px; width: 100%; }
/* 出牌區：中間（牌／提示／展開的清單）可以縮，標題列與最下面的按鈕列不縮，矮螢幕也不會被切掉 */
.score-stage > .stage-top, .score-stage > .stage-step-label, .score-stage > .bd-btns { flex-shrink: 0; }
.score-stage > .stage-cards, .score-stage > .stage-drawer { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.stage-drawer { width: 100%; max-width: 520px; display: flex; flex-direction: column; }
.stage-drawer .bd-list { max-height: none; min-height: 0; }
.score-stage > .bd-btns { width: 100%; max-width: 520px; justify-content: space-between; margin-top: auto; }
.no-anim { animation: none !important; }
.stage-step-label { font-size: 12px; font-weight: 700; color: #edd79a; min-height: 18px; text-align: center; }

/* ── 手牌區：自然由左至右疊層，無倒立角標，選中不遮鄰牌左上角 ── */
.hand-zone { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--card-h) + 22px);
  padding: 18px 4px 4px;
  touch-action: none;
}

.pcard {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  flex-shrink: 0;
  background: linear-gradient(165deg, #fbf7ec 0%, #ede3ce 100%);
  border: 1.5px solid #c9ba9b;
  border-bottom: 3px solid #96876b;
  border-radius: 7px;
  box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 3px #f6efe0, inset 0 0 0 4px rgba(176, 144, 78, 0.35);
  color: var(--card-black);
  cursor: pointer;
  margin-left: -10px;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.12s ease;
  overflow: hidden;
  transform-style: preserve-3d;
}
.pcard:first-child { margin-left: 0; }
.pcard.red { color: var(--card-red); }
/* 只有滑鼠才有懸停效果；手機觸控後瀏覽器會讓 :hover 黏在最後摸到的牌上，看起來像卡在半空中 */
@media (hover: hover) and (pointer: fine) { .pcard:hover { transform: translateY(-6px); } }
/* 按住手牌左右滑動時，手指下那張突出（跟著手指走），放開就選那張 */
.pcard.peek {
  transform: translateY(-24px) scale(1.12);
  z-index: 6;
  border-color: #ffd76a;
  box-shadow: 0 0 0 2px #ffd76a, 0 12px 20px rgba(0, 0, 0, 0.6);
  transition-duration: 0.09s;
}
.pcard.selected.peek { transform: translateY(-32px) scale(1.12); }
.pcard.selected {
  transform: translateY(-15px);
  border: 2px solid #e6be68;
  box-shadow: -2px 8px 14px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(230, 190, 104, 0.45);
}
/* 封印：牌面保持看得清楚（只微微變灰），用紅色鎖鏈邊框＋底部「封印」緞帶標示 */
.pcard.debuffed {
  filter: grayscale(0.55) brightness(0.92);
  box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(196, 40, 40, 0.9), inset 0 0 0 4px rgba(196, 40, 40, 0.25);
}
.pcard.debuffed::after {
  content: "封印";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9%;
  padding: 1px 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 3px;
  text-indent: 3px;
  text-align: center;
  color: #fff;
  background: linear-gradient(90deg, rgba(150, 20, 20, 0.92), rgba(210, 50, 50, 0.95), rgba(150, 20, 20, 0.92));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  z-index: 3;
  pointer-events: none;
}
.pcard.mini-stage.debuffed::after { font-size: 8px; letter-spacing: 1px; text-indent: 1px; bottom: 6%; }

.pcard-back-face {
  position: absolute;
  inset: 0;
  background: #1b243b url('assets/cards/back.webp') center / cover no-repeat;
  backface-visibility: hidden;
  transform: rotateY(180deg);
  pointer-events: none;
}
.pcard.dealing { animation: dealFlipIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.pcard.discarding { animation: discardOut 0.24s ease-in forwards; }
.pcard.scoring-pop {
  transform: translateY(-12px) scale(1.08);
  border: 2px solid #e6be68;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.65);
}
.pcard.mini-stage { width: 52px; height: 74px; margin-left: 0; cursor: default; }
.pcard.mini-stage .corner { font-size: 12px; }
.pcard.mini-stage .pip svg { width: 22px; height: 22px; }

.pcard .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pcard .art ~ .corner, .pcard .art ~ .pip { display: none; }
.pcard .corner {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 12.5px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  z-index: 2;
}
.pcard .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 8px;
  padding-top: 6px;
  pointer-events: none;
}

/* ── 底部操作列與立體牌堆 ── */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.play-discard-group {
  flex: 1;
  max-width: 440px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 8px;
}
.utility-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-pair {
  display: flex;
  align-items: center;
  gap: 6px;
}

.deck-pile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.deck-pile {
  position: relative;
  width: 46px;
  height: 64px;
  border-radius: 6px;
  background: #1b243b url('assets/cards/back.webp') center / cover no-repeat;
  border: 1.5px solid #c9a24d;
  box-shadow:
    2px 2px 0 #d4cbb8,
    3px 3px 0 #1f1711,
    5px 5px 0 #c2b8a3,
    6px 6px 0 #0d0a07,
    0 6px 12px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}
.deck-count-tag {
  font-size: 10px;
  font-weight: 800;
  color: #e6be68;
  background: rgba(20, 14, 10, 0.92);
  border: 1px solid rgba(201, 162, 77, 0.4);
  padding: 0 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* ── 選關 / 結算 / 商店 ── */
.blinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.blind {
  position: relative;
  background: rgba(28, 20, 14, 0.92);
  border: 1.5px solid var(--brass-dim);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.blind.current { border-color: var(--money); box-shadow: inset 0 0 0 1px rgba(230, 190, 104, 0.25); }
.blind.done, .blind.later { opacity: 0.6; }
.blind.boss .boss-rule { background: rgba(110, 24, 28, 0.65); border: 1px solid rgba(201, 105, 95, 0.45); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.blind .art { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }
.blind-target strong { display: block; font-size: 22px; color: #e06c6c; font-variant-numeric: tabular-nums; }
.blind-reward { color: var(--money); font-weight: 700; font-size: 13px; }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: auto; padding-top: 6px; }

/* 商店 3 欄橫向貨架陳列（圖文分離：上方卡名標題、中間純淨插畫、下方價格鈕） */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.shop-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(16, 12, 9, 0.78);
  border: 1.5px solid rgba(201, 162, 77, 0.35);
  border-radius: 8px;
  padding: 7px 6px;
}
.shop-card-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border-bottom: 1px solid rgba(201, 162, 77, 0.22);
  padding-bottom: 4px;
}
.shop-card-title { font-size: 11.5px; font-weight: 800; color: #f5ebd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-card-tag { flex-shrink: 0; font-size: 9.5px; font-weight: 800; color: var(--money); background: rgba(201, 162, 77, 0.14); padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
/* 加成卡（金）／道具（藍綠）用顏色分開：外框、標籤、上方圖例同色 */
.shop-slot.kind-item { border-color: rgba(94, 163, 184, 0.6); background: rgba(10, 20, 24, 0.8); }
.shop-slot.kind-item .shop-card-head { border-bottom-color: rgba(94, 163, 184, 0.3); }
.shop-slot.kind-item .shop-card-tag { color: #bfe6f2; background: rgba(94, 163, 184, 0.28); }
.shop-slot.kind-joker .shop-card-tag { color: #2a1d0e; background: var(--money); }
.shop-legend { margin: 4px 0 0; font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.shop-legend .k { font-weight: 800; font-size: 10.5px; padding: 1px 5px; border-radius: 3px; }
.shop-legend .k-joker { color: #2a1d0e; background: var(--money); }
.shop-legend .k-item { color: #bfe6f2; background: rgba(94, 163, 184, 0.28); margin-left: 4px; }
.shop-slot .tcard { width: 82px; height: 114px; cursor: default; }
.shop-slot .tcard:hover { transform: none; }
.shop-slot .tcard .tcard-badge, .shop-slot .tcard .tcard-plate { display: none; }
.shop-slot-desc { font-size: 10.5px; color: #d5cab5; text-align: center; flex: 1; display: flex; align-items: center; line-height: 1.3; }
.shop-slot button { width: 100%; }

.panel.cashout { margin: auto 0; }

.receipt { width: 100%; max-width: 440px; border-collapse: collapse; margin: 10px 0; }
.receipt td { padding: 7px 4px; border-bottom: 1px solid rgba(201, 162, 77, 0.22); }
.receipt td:last-child { text-align: right; color: var(--money); font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt tr.sum td { font-size: 18px; border-top: 2px solid var(--money); border-bottom: 0; padding-top: 10px; }

/* ── Modal 彈窗 ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 5, 3, 0.78);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.14s ease-out;
}
.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 86dvh;
  overflow-y: auto;
  background: #1d150f;
  border: 1.5px solid var(--brass);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* 標題列（名稱＋✕）固定在視窗頂端，內容往下捲也看得到 */
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid rgba(201, 162, 77, 0.2);
  position: sticky; top: -16px; z-index: 3; margin: -16px -16px 0; padding: 16px 16px 8px; background: #1d150f; border-radius: 10px 10px 0 0; flex-shrink: 0; }
.modal-head h3 { margin: 0; }
.mh-nav { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.mh-nav h3 { flex: 1; justify-content: center; display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-count { font-size: 12px; font-weight: 400; color: var(--muted, #b9a888); }
.mh-arrow { font-size: 20px; line-height: 1; padding: 2px 10px; }
.inspector-top { display: flex; gap: 14px; align-items: center; }
.inspector-top .tcard { width: 92px; height: 130px; cursor: default; }
.inspector-top .tcard:hover { transform: none; }
.inspector-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.inspector-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tcard-value {
  font-size: 12px;
  color: var(--money);
  background: rgba(201, 162, 77, 0.1);
  border: 1px solid rgba(201, 162, 77, 0.3);
  border-radius: 6px;
  padding: 6px 8px;
}

.fx-float {
  position: fixed;
  z-index: 950;
  transform: translate(-50%, 0);
  font-size: 15px;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95);
  animation: floatUp 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.fx-float.chips { color: #7bbcf7; }
.fx-float.mult { color: #ef7575; }
.fx-float.xmult { color: #f2cf72; font-size: 17px; }
.fx-float.money { color: #f2cf72; }

.hands-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hands-table th, .hands-table td { padding: 6px 4px; border-bottom: 1px solid rgba(201, 162, 77, 0.18); text-align: left; }
.hands-table td.chips { color: #6fb3f2; font-weight: 700; }
.hands-table td.mult { color: #e06c6c; font-weight: 700; }
.steps-list, .log-list { padding-left: 18px; margin: 6px 0; font-size: 12px; color: var(--muted); }
.steps-list li.debuffed { text-decoration: line-through; opacity: 0.55; }
.message { background: rgba(120, 34, 34, 0.92); border: 1px solid #c9695f; border-radius: 6px; padding: 8px 12px; font-size: 13px; }

@keyframes dealFlipIn {
  0% { opacity: 0; transform: translate3d(80px, -25px, 0) scale(0.7) rotateY(180deg); }
  55% { opacity: 1; transform: translate3d(10px, -4px, 0) scale(0.95) rotateY(90deg); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1) rotateY(0deg); }
}
@keyframes discardOut {
  to { opacity: 0; transform: translate3d(70px, 35px, 0) scale(0.8); }
}
@keyframes cardTrigger {
  0% { transform: scale(1); }
  40% { transform: translateY(-5px) scale(1.1) rotate(-2deg); }
  100% { transform: scale(1); }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.85); }
  25% { opacity: 1; transform: translate(-50%, -10px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(0.95); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ghostFlow { from { background-position: 0 0; } to { background-position: 24px 0; } }
@keyframes ringOut { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1); opacity: 0; } }
@keyframes barFlash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
@keyframes screenFlash { 0% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes shake1 { 0%, 100% { transform: translate(0, 0); } 33% { transform: translate(-2px, 1px); } 66% { transform: translate(2px, -1px); } }
@keyframes shake2 { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-4px, 2px); } 50% { transform: translate(4px, -2px); } 75% { transform: translate(-2px, -1px); } }
@keyframes shake3 { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-6px, 3px); } 40% { transform: translate(6px, -3px); } 60% { transform: translate(-4px, -2px); } 80% { transform: translate(4px, 2px); } }

/* ── 手機版響應式微調 ── */
@media (max-width: 720px) {
  :root {
    --card-w: 53px;
    --card-h: 78px;
  }
  #app { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); gap: 5px; }
  .hud { padding: 5px 8px; gap: 5px; flex-wrap: wrap; }
  .hud-score-box { flex: 1 1 100%; order: 1; }
  .hud-pills { flex: 1; order: 2; }
  .hud .icon-btn { order: 3; min-width: 32px; min-height: 32px; }
  .pill { flex: 1; min-width: 34px; padding: 2px 4px; }

  /* 修正「5/5 只看到 3 張」：手機版改為 5 格全覽網格 + 道具同行不遺漏 */
  .shelf { flex-direction: column; align-items: stretch; gap: 5px; padding: 5px 7px; }
  .shelf-group.grow .shelf-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .shelf-group:not(.grow) .shelf-row { display: grid; grid-template-columns: repeat(2, 62px); gap: 5px; }
  .shelf .tcard { width: 100%; height: 78px; }

  .pcard { margin-left: -11px; }
  .pcard .corner { font-size: 11.5px; left: 3px; top: 3px; }
  .pcard .pip svg { width: 22px; height: 22px; }

  /* 選關：手機也維持三欄並排（原本一欄疊三張，畫面超出一屏） */
  .blinds { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .blind { padding: 8px 6px; gap: 4px; text-align: center; }
  .blind h3 { margin: 0; font-size: 15px; }
  .blind-target .hint { font-size: 10.5px; }
  .blind-target strong { font-size: 20px; }
  .blind-reward { font-size: 11.5px; }
  .blind.boss .boss-rule { font-size: 10.5px; padding: 4px 5px; line-height: 1.35; }
  .blind > .hint { font-size: 10.5px; }
  .blind > .hint:empty { display: none; }
  .blind .btns { grid-template-columns: 1fr; gap: 6px; padding-top: 4px; }
  .blind .btns button { min-height: 40px; padding: 4px 2px; font-size: 14px; }
  .blind .art { height: 64px; }
  .shop-slot .tcard { width: 70px; height: 98px; }
  .shop-slot-desc { font-size: 10px; }
  .calc .chips, .calc .mult { min-width: 44px; font-size: 16px; padding: 3px 6px; }
  .calc .est-total { font-size: 18px; }

  .controls-bar { flex-wrap: wrap; gap: 6px; }
  .play-discard-group { width: 100%; max-width: none; flex: none; order: 2; }
  .utility-group { width: 100%; justify-content: space-between; order: 1; position: relative; }
  /* 點數／花色對齊下方「出牌｜棄牌」的分界線（兩鈕比例 1.15 : 1、間距 8px） */
  .utility-group .sort-pair { position: absolute; left: calc((100% - 8px) * 1.15 / 2.15 + 4px); top: 50%; transform: translate(-50%, -50%); }
}

/* ── 出牌攻擊特效（飛彈、命中閃光、衝擊波、全螢幕閃光）：等級 t1~t5 越高越華麗 ── */
/* 彗星本體畫在 canvas 上；這個元素只是不可見的定位標記（測試靠它辨識等級） */
.fx-missile { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }

.fx-barflash {
  position: fixed;
  z-index: 955;
  pointer-events: none;
  border-radius: 8px;
  background: radial-gradient(ellipse at center, rgba(255, 244, 214, 0.9) 0%, rgba(255, 210, 110, 0.35) 55%, transparent 80%);
  animation: barFlash 0.5s ease-out forwards;
}
.fx-barflash.t4, .fx-barflash.t5 { background: radial-gradient(ellipse at center, #fff 0%, rgba(255, 120, 60, 0.6) 55%, transparent 85%); }
.fx-barflash.big { box-shadow: 0 0 24px rgba(255, 214, 102, 0.9); }

.fx-ring {
  position: fixed;
  z-index: 958;
  pointer-events: none;
  border-radius: 50%;
  border: 3px solid #ffd166;
  box-shadow: 0 0 12px #ffb347, inset 0 0 10px rgba(255, 179, 71, 0.6);
  animation: ringOut 0.55s ease-out forwards;
}
.fx-ring.t4 { border-color: #ff6b3d; box-shadow: 0 0 16px #ff6b3d, inset 0 0 12px rgba(255, 107, 61, 0.6); }
.fx-ring.t5 { border-color: #7cf3ff; box-shadow: 0 0 20px #ff5ec4, inset 0 0 14px rgba(124, 243, 255, 0.7); }

.fx-screenflash {
  position: fixed;
  z-index: 940;
  pointer-events: none;
  /* 閃光中心放在牌桌中央、避開頂部分數條，免得分數條底色看起來跳色 */
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 244, 214, 0.45) 0%, rgba(255, 160, 60, 0.15) 40%, transparent 70%);
  animation: screenFlash 0.5s ease-out forwards;
}
.fx-screenflash.t5 { background: radial-gradient(ellipse at 50% 55%, rgba(255, 255, 255, 0.5) 0%, rgba(255, 94, 196, 0.2) 38%, rgba(124, 243, 255, 0.1) 60%, transparent 75%); }

@media (prefers-reduced-motion: reduce) {
  .fx-ring, .fx-screenflash { display: none; }
  .fx-barflash { animation-duration: 0.25s; }
}

/* 手機版 HUD 下方緊接著按鈕列，蓄力數字會疊到按鈕上 → 只留發光虛影 */

/* 道具卡右上角「使用」按鈕 */
button.tcard-badge.use-btn {
  cursor: pointer;
  border: 1px solid #ffe08a;
  background: linear-gradient(180deg, #3c8c5e, #1f5a3a);
  color: #fff6d8;
  font-family: inherit;
  min-height: 0;
  line-height: 1.2;
  z-index: 4;
}
button.tcard-badge.use-btn:hover { filter: brightness(1.15); }

/* 計分明細預覽（選牌時） */
.score-stage { min-height: 0; overflow: hidden; }
.bd-toggle {
  align-self: flex-start;
  background: none; border: none; color: var(--muted, #b9ad94); font: inherit; font-size: 12px; font-weight: 800;
  cursor: pointer; padding: 4px 6px; min-height: 28px;
}
.bd-list {
  list-style: none; margin: 0; padding: 4px 6px; flex: 1 1 auto; min-height: 48px; max-height: 180px; overflow-y: auto;
  background: rgba(0, 0, 0, 0.32); border: 1px solid rgba(201, 162, 77, 0.25); border-radius: 6px;
  font-size: 11.5px; line-height: 1.35;
}
.bd-list li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) auto; gap: 6px; padding: 2px 0; border-bottom: 1px dashed rgba(201, 162, 77, 0.12); }
.bd-list li:last-child { border-bottom: none; }
.bd-src { color: #dfd5c0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-txt { color: #cfc4ad; }
.bd-run { color: #f5e6c4; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bd-list li.base .bd-txt { color: #f5e6c4; font-weight: 800; }
.bd-list li.chips .bd-txt { color: #8fd0ff; }
.bd-list li.mult .bd-txt { color: #ff9a9a; }
.bd-list li.x .bd-txt { color: #ffd166; font-weight: 800; }
.bd-list li.off { opacity: 0.75; }
.bd-list li.off .bd-txt { color: #ff8a8a; }
.bd-list li.chance .bd-txt { color: #c9b8ff; }
.bd-list li.sum { border-top: 1px solid rgba(201, 162, 77, 0.4); margin-top: 2px; padding-top: 4px; font-weight: 900; }
.bd-list li.sum .bd-run { color: #ffd166; }
.bd-note { margin: 4px 2px 0; font-size: 11px; color: #ffb3b3; }
.bd-btns { display: flex; flex-wrap: wrap; gap: 2px 10px; flex-shrink: 0; }
.hist-list li.hist-row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
.hist-no { color: #dfd5c0; white-space: nowrap; font-weight: 700; }
.hist-cards { display: flex; flex-wrap: wrap; gap: 3px; }
.hist-cards .ex-card { font-size: 11px; padding: 0 4px; min-width: 0; }
.hist-res { color: #ffd166; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.hist-row.discard { opacity: 0.6; }
.hist-row.discard .hist-res { color: var(--muted); }
.hist-list li.hist-empty { display: block; color: var(--muted); }


/* ── 試用對比：沒有這張 vs 加上這張（分數 × 倍率 = 得分） ── */
.try-compare {
  background: rgba(16, 12, 9, 0.7);
  border: 1px solid rgba(201, 162, 77, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tc-sample { font-size: 13px; color: #d5cab5; }
.tc-row { display: flex; align-items: center; gap: 10px; }
.tc-lbl { width: 64px; flex: none; font-size: 13px; font-weight: 800; color: #b9ad97; }
.tc-row.after .tc-lbl { color: #f5ebd6; }
.tc-f { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tc-f i { font-style: normal; color: #b9ad97; font-weight: 800; }
.tc-n { min-width: 40px; text-align: center; padding: 2px 6px; border-radius: 5px; font-size: 15px; color: #fff; opacity: 0.75; }
.tc-n.c { background: linear-gradient(180deg, #2d6ca6 0%, #1c4770 100%); }
.tc-n.m { background: linear-gradient(180deg, #a62b30 0%, #6e1a1d 100%); }
.tc-n.changed { opacity: 1; outline: 2px solid #ffd76a; box-shadow: 0 0 10px rgba(255, 215, 106, 0.55); }
.tc-row.after .tc-n { opacity: 1; }
.tc-t { font-size: 17px; color: var(--money); min-width: 44px; }
.tc-gain { font-size: 22px; font-weight: 900; color: #8fe08a; margin-top: 2px; padding-top: 8px; border-top: 1px solid rgba(201, 162, 77, 0.2); }
.tc-gain small { font-size: 14px; font-weight: 700; color: #b8e6b4; }
.tc-head .tc-n, .tc-head .tc-t { background: none; outline: 0; box-shadow: none; opacity: 1; font-size: 12px; font-weight: 700; color: #b9ad97; padding-top: 0; padding-bottom: 0; }
.tc-head .tc-f i { visibility: hidden; }
.tc-gain.neg { color: #ef7575; }
.tc-note { font-size: 13px; color: #d5cab5; }
.tc-hint { margin: 0; font-size: 14px; line-height: 1.55; color: #e8dcc2; border-top: 1px solid rgba(201, 162, 77, 0.2); padding-top: 6px; }
@media (max-width: 600px) {
  .inspector-actions button.mini, .modal-head button.mini { min-height: 44px; min-width: 44px; font-size: 14px; }
  .shop-slot button.mini { min-height: 40px; }
}

@media (max-width: 600px) {
}
/* 很矮的手機（例如有網址列、或 640 高）：加成卡／道具格縮矮，讓出牌區至少放得下標題列＋按鈕列 */
@media (max-width: 600px) and (max-height: 700px) {
  .shelf .tcard { height: 44px; }
  .shelf .tcard .tcard-plate, .shelf .tcard .tcard-emblem { display: none; }
  .score-stage { min-height: 94px; gap: 3px; padding: 4px 8px; }
}
@media (max-width: 600px) and (max-height: 760px) {
  .shop-slot .tcard { width: 60px; height: 84px; }
  .shop-slot { gap: 4px; padding: 5px 4px; }
}

/* ── 說明與範例（商店／加成卡檢視） ── */
.ex-desc { margin: 0; font-size: 15px; font-weight: 800; color: #f5ebd6; }
.example { display: flex; flex-direction: column; gap: 10px; }
.ex-case { border-top: 1px dashed rgba(201, 162, 77, 0.28); padding-top: 9px; }
.ex-case h4 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ex-tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 3px; letter-spacing: 0; }
.ex-tag.hit { background: #2f6b3a; color: #dff5d8; }
.ex-tag.miss { background: #4a4038; color: #d5cab5; }
.ex-sec h4 { margin: 0 0 4px; font-size: 13px; color: var(--money); letter-spacing: 0.5px; }
.ex-sec p { margin: 0 0 4px; font-size: 14px; line-height: 1.55; color: #e8dcc2; }
.ex-sec p.ex-note { font-size: 13px; color: #d5cab5; }
.ex-cards { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 2px 0 6px; }
.ex-card { display: inline-block; min-width: 30px; padding: 3px 5px; border-radius: 4px; background: #f3ead6; font-weight: 900; font-size: 14px; text-align: center; color: #1d1712; }
.ex-card.red { color: #c0262d; }
.ex-held { font-size: 12.5px; color: #d5cab5; margin-left: 6px; display: inline-flex; align-items: center; gap: 4px; }
.ex-steps { font-size: 13px; color: #e8dcc2; margin-top: 6px; }
.ex-steps > span { font-weight: 800; color: #b9ad97; }
.ex-steps ol { margin: 2px 0 0; padding-left: 20px; }
.ex-steps li { line-height: 1.5; }
button.shop-slot-desc.ex-link {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  line-height: 1.3;
  color: #d5cab5;
  text-align: center;
  cursor: pointer;
  border-radius: 5px;
  padding: 3px 2px;
}
button.shop-slot-desc.ex-link:hover, button.shop-slot-desc.ex-link:focus-visible { background: rgba(201, 162, 77, 0.12); outline: 1px solid rgba(201, 162, 77, 0.45); }
.ex-link .ex-more { font-size: 11px; font-weight: 800; color: var(--money); text-decoration: underline; text-underline-offset: 2px; }
