/* style.css - 現代簡約版 (SVG 牌面 + Grid 佾局 + 動畫 + 響應式)
 */

:root {
  --bg-deep: #0a2a22;
  --bg-mid: #14463a;
  --bg-soft: #1d5e4e;
  --table-glow: #2a8a6a;

  --accent: #f4c95d;
  --accent-deep: #c98a2b;
  --danger: #c0392b;
  --info: #5bb8d0;
  --success: #6bcf7f;

  --tile-face: #fbf8ee;
  --tile-edge: #c9c0a8;
  --tile-shadow: 0 0.5vmin 0.8vmin rgba(0,0,0,0.35), 0 0.1vmin 0 rgba(0,0,0,0.2);

  --text: #f4f1e6;
  --text-dim: #b9c9c0;
  --text-soft: #8aa89a;

  --tile-big-w: clamp(34px, 5.8vmin, 60px);
  --tile-big-h: clamp(46px, 7.8vmin, 82px);
  --tile-mid-w: clamp(24px, 4vmin, 40px);
  --tile-mid-h: clamp(32px, 5.4vmin, 54px);
  --tile-small-w: clamp(18px, 3vmin, 30px);
  --tile-small-h: clamp(24px, 4vmin, 40px);
  --tile-tiny-w: clamp(14px, 2.4vmin, 22px);
  --tile-tiny-h: clamp(19px, 3.2vmin, 30px);
  --radius: clamp(4px, 0.8vmin, 8px);
  --font-ui: clamp(11px, 2.2vmin, 18px);
  --font-h: clamp(14px, 2.8vmin, 24px);
  --tile-mid-w-modal: clamp(20px, 3.2vmin, 32px);
  --tile-mid-h-modal: clamp(26px, 4.2vmin, 44px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { min-height: 100%; width: 100%; overflow: hidden; font-family: "PingFang SC", "Microsoft YaHei", "Heiti TC", "Noto Sans TC", sans-serif; background: var(--bg-deep); color: var(--text); user-select: none; -webkit-user-select: none; }

#rotate-hint { display: none; position: fixed; inset: 0; background: var(--bg-deep); z-index: 999; align-items: center; justify-content: center; font-size: 5vmin; text-align: center; padding: 5vmin; }
@media (orientation: portrait) { #rotate-hint { display: flex; } #app, #setup { display: none !important; } }

.hidden { display: none !important; }

/* ---- 設定頁 ---- */
#setup { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vmin; background: radial-gradient(circle at 50% 30%, var(--bg-soft), var(--bg-deep)); }
#setup::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 6vmin, rgba(244,201,93,0.03) 6vmin, rgba(244,201,93,0.03) 12vmin); pointer-events: none; }
#setup h1 { font-size: clamp(28px, 7vmin, 64px); letter-spacing: 0.8vmin; color: var(--accent); text-shadow: 0 2px 8px rgba(0,0,0,0.5); font-weight: 800; position: relative; }
@keyframes h1-glow { 0%, 100% { text-shadow: 0 2px 8px rgba(0,0,0,0.5); } 50% { text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 2.5vmin rgba(244,201,93,0.4); } }
#setup h1 { animation: h1-glow 3.6s ease-in-out infinite; }
#setup .sub { font-size: clamp(13px, 2.8vmin, 22px); color: var(--text-dim); position: relative; }
.setup-row { display: flex; flex-direction: column; align-items: stretch; gap: 0.6vmin; font-size: var(--font-ui); background: rgba(0,0,0,0.25); padding: 1.4vmin 2.4vmin; border-radius: 1.2vmin; border: 1px solid rgba(255,255,255,0.08); position: relative; min-width: min(64vmin, 320px); }
.setup-row label { color: var(--text-dim); font-size: clamp(10px, 1.8vmin, 14px); }
.setup-row select { font-size: var(--font-ui); padding: 0.8vmin 1.6vmin; border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); color: var(--text); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.setup-row select:hover { border-color: rgba(244,201,93,0.5); background: rgba(255,255,255,0.12); }
#start-btn { font-size: var(--font-h); padding: 1.6vmin 7vmin; border: none; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #3a2400; font-weight: bold; box-shadow: 0 4px 14px rgba(244,201,93,0.4); transition: transform 0.15s, box-shadow 0.15s, filter 0.15s; cursor: pointer; position: relative; }
#start-btn:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(244,201,93,0.55); }
#start-btn:active { transform: translateY(2px) scale(0.98); box-shadow: 0 2px 8px rgba(244,201,93,0.3); }
#setup .hint { font-size: clamp(11px, 2.4vmin, 18px); color: var(--text-soft); max-width: 80vmin; text-align: center; line-height: 1.6; position: relative; }
#setup button, #setup .setup-row, #setup .sub, #setup .hint { z-index: 1; }

/* ---- 牌桌 (Grid 佾局) ---- */
#app { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; }
#table {
  position: relative; width: 100vw; height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr);
  background: radial-gradient(ellipse at center, var(--bg-soft) 0%, var(--bg-mid) 55%, var(--bg-deep) 100%);
  box-shadow: inset 0 0 12vmin rgba(0,0,0,0.5);
  outline: 1px solid rgba(244,201,93,0.12); outline-offset: -1vmin;
}

.seat { position: relative; display: flex; z-index: 2; padding: clamp(4px, 1vmin, 12px); min-width: 0; min-height: 0; }
.seat-top { grid-area: 1 / 2 / 2 / 3; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.6vmin; }
.seat-bottom { grid-area: 3 / 1 / 4 / 4; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.8vmin; position: relative; }
.seat-left { grid-area: 1 / 1 / 3 / 2; flex-direction: column; align-items: center; justify-content: center; gap: 0.5vmin; padding-top: clamp(8px, 2vmin, 18px); overflow: hidden; }
.seat-right { grid-area: 1 / 3 / 3 / 4; flex-direction: column; align-items: center; justify-content: center; gap: 0.5vmin; padding-top: clamp(8px, 2vmin, 18px); overflow: hidden; }
#center { grid-area: 2 / 2 / 3 / 3; z-index: 1; }

/* 側家排版同下家(column)，然後整體旋轉 */
.seat-left .seat-inner, .seat-right .seat-inner {
  display: flex; flex-direction: column; align-items: center; gap: 0.5vmin;
  width: min(50vh, 100%); height: min(30vw, 100%); max-width: 100%; max-height: 100%;
  justify-content: center;
}
.seat-left  .seat-inner { transform: rotate(90deg); }
.seat-right .seat-inner { transform: rotate(-90deg); }

/* 側家 seat-inner 內 order: hand 靠中央(1) → melds-flowers(2) → pinfo 靠邊緣(3) (discards 已移到中央) */
.seat-left .seat-inner .hand,           .seat-right .seat-inner .hand           { order: 1; }
.seat-left .seat-inner .melds-flowers,  .seat-right .seat-inner .melds-flowers  { order: 2; }
.seat-left .seat-inner .pinfo,          .seat-right .seat-inner .pinfo          { order: 3; }

/* 當前回合高亮 (呼吸光) */
.seat.active { position: relative; }
.seat.active::after { content: ''; position: absolute; inset: 0; border-radius: clamp(8px, 1.5vmin, 16px); box-shadow: inset 0 0 0 2px var(--accent), 0 0 3vmin rgba(244,201,93,0.35); pointer-events: none; animation: seat-pulse 2.4s ease-in-out infinite; }
@keyframes seat-pulse { 0%, 100% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 2vmin rgba(244,201,93,0.25); } 50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 4.5vmin rgba(244,201,93,0.55); } }

/* 玩家資訊條 */
.pinfo { display: flex; align-items: center; gap: 1.2vmin; font-size: clamp(10px, 2vmin, 16px); background: rgba(0,0,0,0.4); padding: 0.5vmin 1.2vmin; border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,0.08); white-space: nowrap; box-shadow: 0 0.4vmin 1vmin rgba(0,0,0,0.3); }
.pinfo .name { font-weight: bold; color: var(--accent); }
.pinfo .dealer { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 0.8vmin; font-size: clamp(9px, 1.7vmin, 14px); }
.pinfo .ting-tag { background: var(--info); color: #fff; border-radius: 999px; padding: 0 0.8vmin; font-size: clamp(9px, 1.7vmin, 14px); }
.pinfo .score { color: #aef; }
.pinfo .debt { color: #ffd; }

/* 手牌/牌河/面子 容器 */
.hand { display: flex; gap: 0.4vmin; flex-wrap: wrap; justify-content: center; align-items: center; }
.melds { display: flex; gap: 0.8vmin; flex-wrap: wrap; justify-content: center; }
.flowers { display: flex; gap: 0.3vmin; flex-wrap: wrap; justify-content: center; }
.melds-flowers { display: flex; flex-direction: row; gap: 1vmin; align-items: center; justify-content: center; flex-wrap: wrap; }
.discards { display: flex; flex-wrap: wrap; gap: 0.3vmin; justify-content: center; opacity: 0.95; max-width: 100%; }

/* 摸牌間隔 */
.hand-sep { width: 1.2vmin; flex: none; }

/* ---- 牌 (獨立 SVG 檔案) ---- */
.tile { position: relative; flex: none; transition: transform 0.15s ease, box-shadow 0.15s ease; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: var(--radius); border: 0.5px solid var(--tile-edge); box-shadow: var(--tile-shadow); }
.tile svg, .tile .tile-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tile .tile-img { pointer-events: none; }
.tile.back { background: linear-gradient(#2c7a4f, #18603a); }

/* 尺寸 */
.tile.big { width: var(--tile-big-w); height: var(--tile-big-h); }
.tile.mid { width: var(--tile-mid-w); height: var(--tile-mid-h); }
.tile.small { width: var(--tile-small-w); height: var(--tile-small-h); }
.tile.tiny { width: var(--tile-tiny-w); height: var(--tile-tiny-h); }

/* 玩家手牌互動 */
.seat-bottom .hand .tile.big { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.seat-bottom .hand .tile.big:hover { transform: translateY(-1.8vmin); box-shadow: 0 1.8vmin 2.2vmin rgba(0,0,0,0.5), 0 0 0 1px rgba(244,201,93,0.4); z-index: 5; }
.seat-bottom .hand .tile.big:active { transform: translateY(-0.6vmin) scale(0.97); }

.tile.selectable { box-shadow: 0 0.5vmin 0.8vmin rgba(0,0,0,0.4); }

/* 打牌確認高亮 */
.tile.selected { box-shadow: 0 0 0 3px var(--danger), 0 0 3vmin 1vmin rgba(192,57,43,0.5), 0 0.5vmin 1vmin rgba(0,0,0,0.4); transform: translateY(-2.2vmin) scale(1.05); z-index: 6; }

/* 剛摸的牌: 柔光脈動 */
@keyframes tile-glow {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--accent), 0 0.5vmin 0.8vmin rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 2.5px var(--accent), 0 0 2.5vmin 1vmin rgba(244,201,93,0.6), 0 0.5vmin 1vmin rgba(0,0,0,0.4); }
}
.tile.fresh { animation: tile-glow 1.4s ease-in-out infinite; }

/* 摸牌滑入 */
@keyframes tile-draw-in { from { opacity: 0; transform: translateY(-3vmin) scale(0.8); } to { opacity: 1; transform: translateY(0) scale(1); } }
.tile.draw-in { animation: tile-draw-in 0.3s ease-out; }

/* 打牌下沉 */
@keyframes tile-discard { 0% { transform: translateY(-1.5vmin); opacity: 0.6; } 60% { transform: translateY(0.3vmin); } 100% { transform: translateY(0); opacity: 1; } }
.tile.discard-in { animation: tile-discard 0.28s ease-out; }

/* 被借的牌高亮 (碰槓上) */
@keyframes tile-claim { 0%, 100% { box-shadow: 0 0 0 2px var(--info), 0 0 1.5vmin rgba(91,184,208,0.6); } 50% { box-shadow: 0 0 0 3px var(--info), 0 0 2.5vmin rgba(91,184,208,0.9); } }
.tile.claim-ani { animation: tile-claim 0.8s ease-in-out 2; }

/* 面子中被借牌旋轉 (碰/上/槓門牌) */
.tile.claimed-tile { transform: rotate(90deg); }

/* 側家門牌區：跟隨 seat-inner 旋轉，自然直向顯示 */

/* 可上/碰/槓的牌高亮 */
@keyframes tile-highlight { 0%, 100% { box-shadow: 0 0 0 3px var(--accent), 0 0 2vmin rgba(244,201,93,0.7); } 50% { box-shadow: 0 0 0 4px var(--accent), 0 0 4vmin rgba(244,201,93,0.95), 0 0 0 1px #fff; } }
.tile.discard-highlight {
  animation: tile-highlight 0.9s ease-in-out infinite;
  transform: scale(1.2);
  z-index: 10;
}

/* 胡牌放大 */
@keyframes tile-win { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-3deg); } 70% { transform: scale(1.15) rotate(2deg); } 100% { transform: scale(1.2) rotate(0); } }
.tile.winning { animation: tile-win 0.6s ease-out forwards; z-index: 10; }

/* 中央資訊 + 牌河分區 (3欄 × 3行 grid) */
#center {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  justify-items: stretch;
  overflow: visible;
}
#center::before { content: ''; position: absolute; inset: 8%; border-radius: 50%; background: radial-gradient(circle, rgba(244,201,93,0.12), transparent 70%); pointer-events: none; }
#center-info { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8vmin; z-index: 1; width: 100%; text-align: center; }
#dice { font-size: clamp(18px, 4vmin, 36px); min-height: 1.2em; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
#turn-info { font-size: clamp(13px, 2.6vmin, 22px); color: var(--accent); font-weight: bold; text-shadow: 0 1px 3px rgba(0,0,0,0.5); padding: 0.4vmin 1.6vmin; border: 1px solid rgba(244,201,93,0.3); border-radius: 999px; background: rgba(0,0,0,0.25); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* 剩餘牌數/圈風 — 固定左下角 */
#wall-info { position: fixed; left: clamp(4px, 1vmin, 12px); bottom: clamp(4px, 1vmin, 12px); z-index: 55; font-size: clamp(11px, 2.2vmin, 18px); color: var(--text-dim); background: rgba(0,0,0,0.45); padding: 0.4vmin 1.2vmin; border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,0.1); pointer-events: none; }

.discard-zone { display: flex; flex-wrap: wrap; gap: 0.3vmin; justify-content: center; align-content: center; opacity: 0.95; min-width: 0; min-height: 0; overflow: visible; }
.dz-top {
  grid-column: 2; grid-row: 1;
  flex-direction: row;
  justify-content: center;
  width: 100%; height: 100%;
}
.dz-bottom {
  grid-column: 2; grid-row: 3;
  flex-direction: row;
  justify-content: center;
  width: 100%; height: 100%;
}
.dz-left {
  grid-column: 1; grid-row: 1 / 4;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-end;
  justify-content: flex-start;
  width: 100%; height: 100%;
  padding: 0.4vmin;
}
.dz-right {
  grid-column: 3; grid-row: 1 / 4;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-start;
  width: 100%; height: 100%;
  padding: 0.4vmin;
}
/* 左右家牌河: 直向 column 排列，每張牌用 wrapper 包住並旋轉 */
.dz-left .dz-inner,
.dz-right .dz-inner {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-end;
  justify-content: flex-start;
  gap: 0.3vmin;
  width: 100%;
  height: 100%;
  max-height: 100%;
}
.dz-right .dz-inner { align-content: flex-start; }
/* 側家每張牌 wrapper: 寬高對調 (slot 用旋轉後視覺尺寸) */
.dz-left .dz-tile-wrap,
.dz-right .dz-tile-wrap {
  width: var(--tile-small-h);
  height: var(--tile-small-w);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.dz-left .dz-tile-wrap .tile { transform: rotate(90deg); }
.dz-right .dz-tile-wrap .tile { transform: rotate(-90deg); }
/* 側家 discard-highlight 縮放以 wrapper 為基準 */
.dz-left .dz-tile-wrap .tile.discard-highlight,
.dz-right .dz-tile-wrap .tile.discard-highlight {
  transform: rotate(90deg) scale(1.2);
}
.dz-right .dz-tile-wrap .tile.discard-highlight { transform: rotate(-90deg) scale(1.2); }

/* 訊息列 */
#message { position: fixed; left: 50%; top: clamp(6px, 1.5vmin, 16px); transform: translateX(-50%) translateY(-1vmin); text-align: center; font-size: var(--font-h); padding: 1vmin 2.4vmin; background: rgba(0,0,0,0.6); border-radius: 999px; z-index: 50; pointer-events: none; transition: opacity 0.3s, transform 0.3s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#message[style*="opacity: 1"], #message:not([style]) { transform: translateX(-50%) translateY(0); }

/* 動作按鈕列 — 手牌右上方 floating bar (托盤背景) */
#actions { position: fixed; bottom: clamp(55px, 8vmin, 90px); right: clamp(8px, 2vmin, 16px); display: none; gap: 1vmin; z-index: 60; flex-wrap: nowrap; max-height: 18vmin; padding: 0.8vmin 1.2vmin; border-radius: 1vmin 0 0 0; overflow: hidden; background: rgba(0,0,0,0.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.08); border-right: none; border-bottom: none; }
#actions:not(:empty) { display: flex; }
.btn { font-size: clamp(13px, 2.4vmin, 20px); padding: 1vmin 2vmin; border: none; border-radius: 999px; font-weight: bold; box-shadow: 0 0.3vmin 0 rgba(0,0,0,0.35); min-height: 38px; min-width: 38px; transition: transform 0.12s, box-shadow 0.12s, filter 0.12s; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(0.3vmin); box-shadow: 0 0.1vmin 0 rgba(0,0,0,0.35); }
.btn.hu { background: linear-gradient(135deg, #ff7a7a, var(--danger)); color: #fff; }
.btn.kong { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #3a2400; }
.btn.pong { background: linear-gradient(135deg, #7ad6f5, #2c8fd0); color: #fff; }
.btn.chi { background: linear-gradient(135deg, #8be0a8, #2caf6a); color: #063; }
.btn.pass { background: rgba(255,255,255,0.12); color: var(--text); border: 1px solid rgba(255,255,255,0.15); }
.btn.tiny-t { background: linear-gradient(135deg, #f0f0f0, #ccc); color: #333; font-size: var(--font-ui); }

/* 可胡按鈕脈動 */
@keyframes btn-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); box-shadow: 0 0 2vmin rgba(255,122,122,0.6); } }
.btn.hu { animation: btn-pulse 1.2s ease-in-out infinite; }

/* 結算 modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 3vmin; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(2vmin) scale(0.96); } to { opacity: 1; transform: none; } }
#modal-box { background: linear-gradient(180deg, #fff, #f5f1e6); color: #222; border-radius: clamp(12px, 2.5vmin, 24px); padding: clamp(16px, 4vmin, 40px); max-width: min(90vw, 560px); max-height: 90vh; overflow: auto; font-size: clamp(12px, 2.6vmin, 20px); box-shadow: 0 2vmin 5vmin rgba(0,0,0,0.6); width: 100%; animation: modal-in 0.28s ease-out; }
#modal-box h2 { color: var(--danger); font-size: clamp(22px, 5vmin, 40px); margin-bottom: 2vmin; text-align: center; }
#modal-box .fan-row { display: flex; justify-content: space-between; gap: 3vmin; padding: 0.5vmin 0; border-bottom: 1px dashed #ddd; }
#modal-box .fan-total { font-size: clamp(18px, 4vmin, 30px); font-weight: bold; color: var(--danger); text-align: center; margin: 2vmin 0; }
#modal-box .pay { font-size: clamp(12px, 2.8vmin, 20px); margin: 0.4vmin 0; }
#modal-box .scores { margin-top: 2vmin; }
#modal-box .cont { margin-top: 3vmin; text-align: center; }
#modal-box button { font-size: var(--font-h); padding: 1.4vmin 6vmin; border: none; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #3a2400; font-weight: bold; box-shadow: 0 4px 12px rgba(244,201,93,0.4); cursor: pointer; transition: transform 0.15s, filter 0.15s; }
#modal-box button:hover { filter: brightness(1.08); }
#modal-box button:active { transform: translateY(2px); }

/* 結算牌面視覺排列 — 無框無背景 */
.hand-visual { display: flex; flex-wrap: wrap; gap: 0.4vmin; align-items: center; justify-content: center; margin: 0; }
#modal-box .hand-visual .tile { pointer-events: none; border: 1px solid var(--tile-edge); border-radius: var(--radius); }
#modal-box .hand-visual .tile.mid { width: var(--tile-mid-w-modal); height: var(--tile-mid-h-modal); }
#modal-box .hand-visual .tile.small { width: var(--tile-small-w); height: var(--tile-small-h); }
#modal-box .hand-visual .tile.tiny { width: var(--tile-tiny-w); height: var(--tile-tiny-h); }
#modal-box .hand-visual .tile.winning { box-shadow: 0 0 0 2px var(--danger), 0 0 1vmin rgba(192,57,43,0.5); border-radius: var(--radius); }
/* 胡牌 modal 內 claimed-tile 旋轉 (僅上牌中間那張) */
#modal-box .hand-visual .tile.claimed-tile { transform: rotate(90deg); }

/* 結算: 花牌/門牌/手牌 同一行水平排列，各群組帶標題 */
.hand-visual-row { display: flex; flex-direction: row; gap: 2.2vmin; align-items: flex-start; justify-content: center; margin: 1.5vmin 0; flex-wrap: wrap; }
.hand-visual-group { display: flex; flex-direction: column; align-items: center; gap: 0.4vmin; }
.hand-visual-group .bd-section { color: var(--accent-deep); font-size: clamp(10px, 1.8vmin, 14px); margin: 0 0 0.3vmin 0; border-bottom: 1px solid #ddd6bf; padding-bottom: 0.2vmin; }

/* 小螢幕微調 */
@media (max-width: 640px) and (orientation: landscape) {
  :root {
    --tile-big-w: clamp(28px, 7vw, 44px);
    --tile-big-h: clamp(38px, 9.4vw, 60px);
  }
}

/* ---- 全屏 / 番數表 按鈕 (遊戲中浮動, 改到左側避免遮擋玩家牌) ---- */
.fs-btn, .ft-btn {
  position: fixed; top: env(safe-area-inset-top, 0); z-index: 70;
  width: clamp(32px, 5vmin, 44px); height: clamp(32px, 5vmin, 44px);
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(0,0,0,0.45); color: var(--accent);
  font-size: clamp(14px, 2.6vmin, 20px); font-weight: bold;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.fs-btn { right: clamp(4px, 1vmin, 10px); margin-top: clamp(4px, 1vmin, 10px); }
.ft-btn { right: clamp(4px, 1vmin, 10px); margin-top: calc(clamp(36px, 6vmin, 52px) + clamp(4px, 1vmin, 10px)); width: auto; padding: 0 clamp(8px, 1.4vmin, 14px); border-radius: 999px; }
.fs-btn:active, .ft-btn:active { transform: scale(0.92); }
.fs-btn:hover, .ft-btn:hover { background: rgba(0,0,0,0.6); }

/* 設定頁的番數表連結按鈕 */
.btn-link { background: transparent; color: var(--text-dim); border: 1px solid rgba(255,255,255,0.2); padding: 1vmin 3vmin; border-radius: 999px; font-size: var(--font-ui); cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.btn-link:hover { border-color: rgba(244,201,93,0.5); color: var(--accent); }
.btn-link:active { transform: scale(0.97); }

/* ---- 番數表 modal 內容 ---- */
.fan-table { text-align: left; margin: 1vmin 0; }
.ft-cat { font-size: clamp(13px, 2.6vmin, 20px); font-weight: bold; color: var(--accent-deep); margin: 1.8vmin 0 0.6vmin; border-bottom: 2px solid var(--accent); padding-bottom: 0.3vmin; }
.ft-row { display: flex; align-items: baseline; gap: 1.2vmin; padding: 0.5vmin 0; border-bottom: 1px dashed #e0d8c0; }
.ft-name { flex: none; min-width: clamp(64px, 12vmin, 110px); font-weight: bold; color: #333; display: flex; align-items: center; gap: 0.6vmin; }
.ft-val { display: inline-block; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 0.6vmin; font-size: clamp(10px, 1.8vmin, 14px); min-width: 1.6em; text-align: center; }
.ft-desc { flex: 1; color: #666; font-size: clamp(10px, 2vmin, 16px); line-height: 1.4; }
.ft-example { display: inline-block; margin-left: 0.6vmin; font-size: clamp(14px, 2.4vmin, 20px); letter-spacing: 0.1em; }

/* ---- 結算: 牌型組成 ---- */
.hand-breakdown { background: #f6f1e0; border-radius: clamp(6px, 1.2vmin, 12px); padding: clamp(8px, 1.6vmin, 16px); margin: 1.5vmin 0; border: 1px solid #e0d8c0; }
.bd-row { display: flex; gap: 1vmin; padding: 0.3vmin 0; font-size: clamp(11px, 2.2vmin, 17px); color: #333; align-items: baseline; }
.bd-label { flex: none; min-width: clamp(48px, 9vmin, 80px); color: #888; font-weight: bold; }
.bd-val { flex: 1; letter-spacing: 0.1em; }
.bd-win { color: var(--danger); font-weight: bold; font-size: clamp(13px, 2.6vmin, 20px); }
.bd-section { color: var(--accent-deep); font-size: clamp(10px, 1.8vmin, 14px); margin-top: 0.8vmin; border-bottom: 1px solid #ddd6bf; padding-bottom: 0.2vmin; }

/* 結算按鈕群組 */
#modal-box .cont { display: flex; gap: 1.5vmin; justify-content: center; flex-wrap: wrap; }
#modal-box .btn-fantable { background: #fff; color: #333; border: 1px solid #ccc; }
#modal-box .btn-fantable:hover { background: #f5f1e6; }
#modal-box .btn-fantable:active { transform: translateY(2px); }

/* 安全區: 動作列避開手機底邊 */
.seat-bottom { padding-left: max(env(safe-area-inset-left, 0), 1vmin); padding-right: max(env(safe-area-inset-right, 0), 1vmin); }
