/* games/sheng-guan-tu/style.css — v3 (大幅視覺升級) */

/* ── Google Fonts 字型引入 ──────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;600;700&display=swap');

/* ── 色彩系統 (古典宮廷風) ─────────────────── */
:root {
  --sgt-imperial-red:    #8B1A1A;  /* 深宮廷紅 */
  --sgt-imperial-gold:   #C9A84C;  /* 黃金色 */
  --sgt-imperial-amber:  #E8B84B;  /* 琥珀金 */
  --sgt-parchment:       #F5EDD0;  /* 宣紙色 */
  --sgt-parchment-dark:  #E8D5A3;  /* 深宣紙 */
  --sgt-ink:             #1A1008;  /* 墨色 */
  --sgt-vermillion:      #C0392B;  /* 朱砂紅 */
  --sgt-jade:            #1B7A5A;  /* 翡翠綠 */
  --sgt-jade-light:      #27AE72;  /* 嫩翠綠 */
  --sgt-night-blue:      #1A2744;  /* 深藏青 */
  --sgt-board-bg:        #6B3A1F;  /* 棋盤底木 */
  --sgt-board-inner:     #8B4513;  /* 棋盤面木 */
  --sgt-border-gold:     rgba(201, 168, 76, 0.7);
  --sgt-shadow-warm:     rgba(139, 26, 26, 0.35);
  --sgt-shadow-gold:     rgba(201, 168, 76, 0.4);
}

/* ── 字型套用 ──────────────────────────────── */
.sgt-wrap, .sgt-wrap * {
  font-family: 'Noto Serif TC', 'Songti SC', '宋體', serif;
}

/* ── 頁面背景圖 ───────────────────────────── */
body {
  background-image: url('/assets/images/sheng-guan-tu-bg.png');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* ── 整體容器 ──────────────────────────────── */
.sgt-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 0 36px;
}

/* ── 雙骰落點預覽高亮 ───────────────────────── */
.dice-land-preview {
  z-index: 4;
  transition: box-shadow .2s, transform .15s;
  transform: scale(1.04);
}

/* 好格（升遷/皇恩）→ 綠光 */
.dice-land-preview.dice-land-good {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #27ae72,
    0 0 14px 4px rgba(39,174,114,0.5) !important;
}

/* 壞格（降職/查辦）→ 紅光 */
.dice-land-preview.dice-land-bad {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #c0392b,
    0 0 14px 4px rgba(192,57,43,0.5) !important;
}

/* 快馬格 → 金光 */
.dice-land-preview.dice-land-express {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #C9A84C,
    0 0 14px 4px rgba(201,168,76,0.6) !important;
}

/* 終點 → 橙金光 */
.dice-land-preview.dice-land-goal {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #e65100,
    0 0 18px 6px rgba(255,165,0,0.7) !important;
}

/* 一般格 → 白光 */
.dice-land-preview.dice-land-neutral {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px rgba(150,150,150,0.5),
    0 0 8px 2px rgba(200,200,200,0.3) !important;
}

/* 選擇按鈕顏色提示（JS 設定 data-land-type） */
.sgt-dice-pick-btn[data-land-type="dice-land-good"]    { border-color: #27ae72; color: #1b5e3b; }
.sgt-dice-pick-btn[data-land-type="dice-land-bad"]     { border-color: #c0392b; color: #7B1A1A; }
.sgt-dice-pick-btn[data-land-type="dice-land-express"] { border-color: #C9A84C; color: #7A5500; }
.sgt-dice-pick-btn[data-land-type="dice-land-goal"]    { border-color: #e65100; color: #8B2500; background: linear-gradient(145deg, #fff3cd, #ffe08a); }

/* ── 棋盤外框（仿古木框架）────────────────── */
.sgt-board-frame {
  position: relative;
  padding: 10px;
  background: linear-gradient(145deg, #7A3F1A, #4A2009, #7A3F1A);
  border-radius: 18px;
  box-shadow:
    0 0 0 2px var(--sgt-imperial-gold),
    0 8px 32px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,220,120,0.25),
    inset 0 -1px 0 rgba(0,0,0,0.3);
  /* 龍紋裝飾邊框 */
  border: 3px solid #5A2A0A;
}

/* 棋盤框四角裝飾 */
.sgt-board-frame::before,
.sgt-board-frame::after {
  content: '✦';
  position: absolute;
  font-size: 14px;
  color: var(--sgt-imperial-gold);
  text-shadow: 0 0 6px rgba(201,168,76,0.8);
}

.sgt-board-frame::before {
  top: 4px;
  left: 8px;
}

.sgt-board-frame::after {
  top: 4px;
  right: 8px;
}

/* ── 棋盤本體 ──────────────────────────────── */
.sgt-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  width: min(356px, calc(100vw - 40px));
  aspect-ratio: 1;
  background: linear-gradient(160deg, #2C1206, #3D1A08, #2C1206);
  border-radius: 10px;
  padding: 4px;
}

/* ── 格子 ──────────────────────────────────── */
.sgt-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: linear-gradient(145deg, #F8EFD4, #EDE0B5);
  border: 1px solid rgba(139, 69, 19, 0.4);
  overflow: hidden;
  transition: background .2s, box-shadow .2s, transform .1s;
  z-index: 0;
  cursor: default;
}

/* 格子數字角標 */
.cell-num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 8px;
  color: rgba(100, 50, 10, 0.55);
  line-height: 1;
  font-weight: 700;
  user-select: none;
  letter-spacing: -0.5px;
}

/* 格子主圖示 */
.cell-icon {
  font-size: 1rem;
  line-height: 1;
  margin-top: 2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* 格子官職名稱 */
.cell-label {
  font-size: clamp(7px, 2vw, 10px);
  color: rgba(80, 35, 5, 0.75);
  line-height: 1.2;
  text-align: center;
  font-weight: 700;
  margin-top: 1px;
  letter-spacing: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

/* ── hover 效果 ──────────────────────────────── */
.sgt-cell:hover {
  transform: scale(1.06);
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ── 當前格脈衝光圈 ──────────────────────────── */
.sgt-cell.cell-current {
  z-index: 2;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--sgt-imperial-gold),
    0 0 12px 3px rgba(201,168,76,0.5);
  animation: cellPulse 1.0s ease-out;
}

@keyframes cellPulse {
  0%   { box-shadow: 0 0 0 0px #fff, 0 0 0 0px var(--sgt-imperial-gold), 0 0 0 0px transparent; }
  50%  { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sgt-imperial-gold), 0 0 16px 5px rgba(201,168,76,0.5); }
  100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sgt-imperial-gold), 0 0 12px 3px rgba(201,168,76,0.4); }
}

/* ── 特殊格顏色 ────────────────────────────────── */
.cell-start {
  background: linear-gradient(145deg, #d4edda, #b8dfc2);
  border-color: var(--sgt-jade-light) !important;
  border-width: 1.5px !important;
}

.cell-goal {
  background: linear-gradient(135deg, #ffe082, #ff8f00, #ffe082);
  border-color: #c0392b !important;
  border-width: 2px !important;
  box-shadow: 0 0 10px rgba(255, 165, 0, .6), inset 0 0 8px rgba(255,220,100,0.4) !important;
  animation: goalGlow 2s ease-in-out infinite;
}

@keyframes goalGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 165, 0, .6), inset 0 0 8px rgba(255,220,100,0.4); }
  50%       { box-shadow: 0 0 18px rgba(255, 165, 0, .9), inset 0 0 14px rgba(255,220,100,0.6); }
}

.ev-up   {
  background: linear-gradient(145deg, #d4f1e3, #b7e3c9);
  border-color: #27ae72 !important;
  border-width: 1.5px !important;
}

.ev-down {
  background: linear-gradient(145deg, #fdd9d7, #f5b7b1);
  border-color: #c0392b !important;
  border-width: 1.5px !important;
}

.ev-star {
  background: linear-gradient(145deg, #fff9c4, #ffe48a);
  border-color: #e67e22 !important;
  border-width: 1.5px !important;
}

/* 快馬格：金色閃爍 */
.ev-express {
  background: linear-gradient(145deg, #fff3cd, #ffe08a);
  border-color: #C9A84C !important;
  border-width: 1.5px !important;
  box-shadow: 0 0 6px rgba(201, 168, 76, 0.5);
}

/* 查辦格：灰色邊框 */
.ev-skip {
  background: linear-gradient(145deg, #ece4d8, #d8cebe);
  border-color: #78716a !important;
  border-width: 1.5px !important;
}

/* ── 棋子 ──────────────────────────────────────── */
.sgt-token {
  position: absolute;
  bottom: 1px;
  font-size: 1.25rem;
  line-height: 1;
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5));
  animation: tokenLand .3s cubic-bezier(.34, 1.56, .64, 1);
  transition: filter .2s;
}

.tok-p  { right: 1px; }
.tok-ai { left: 1px; }

@keyframes tokenLand {
  from { transform: scale(1.8) translateY(-8px); opacity: .4; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ── 玩家資訊區塊 ─────────────────────────── */
.sgt-players-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  width: min(376px, calc(100vw - 16px));
}

.sgt-vs-badge {
  font-size: 14px;
  font-weight: 700;
  color: var(--sgt-imperial-gold);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  letter-spacing: 1px;
  text-align: center;
}

/* ── 狀態卡片 ──────────────────────────────────── */
/* ── 官銀列 ───────────────────────────────── */
.sgt-silver-row {
  font-size: 12px;
  font-weight: 600;
  color: #8B6914;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ── 狀態旗標 ─────────────────────────────── */
.sgt-status-flag {
  font-size: 10px;
  color: var(--sgt-imperial-red, #8B1A1A);
  font-weight: 700;
  margin-top: 3px;
  line-height: 1.4;
  letter-spacing: 0.3px;
}

/* ── 狀態面板 ─────────────────────────────── */
.sgt-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(376px, calc(100vw - 16px));
}

.sgt-card {
  background: linear-gradient(145deg, #FDF6E3, #F5E8C5);
  border-radius: 14px;
  padding: 12px 14px 10px;
  text-align: center;
  border: 2px solid var(--sgt-parchment-dark);
  transition: border-color .3s, box-shadow .3s, transform .2s;
  position: relative;
  overflow: hidden;
}

/* 卡片頂部裝飾線 */
.sgt-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--tier-color, var(--sgt-imperial-red));
  border-radius: 12px 12px 0 0;
  transition: background .3s;
}

/* 頭像按鈕（點擊切換棋子）*/
.sgt-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
  transition: transform .15s;
  position: relative;
}

.sgt-avatar-btn::after {
  content: '↻';
  position: absolute;
  top: -4px;
  right: -6px;
  font-size: 9px;
  color: rgba(139,26,26,0.7);
  font-weight: 700;
  background: rgba(245,237,208,0.9);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  line-height: 12px;
  text-align: center;
}

.sgt-avatar-btn:hover {
  transform: scale(1.2);
}

.sgt-avatar-btn:active {
  transform: scale(1.0);
}

/* 品秩層級顏色 */
.sgt-card.tier-0    { --tier-color: #9e9e9e; }
.sgt-card.tier-9    { --tier-color: #78909c; }
.sgt-card.tier-8    { --tier-color: #42a5f5; }
.sgt-card.tier-7    { --tier-color: #26a69a; }
.sgt-card.tier-6    { --tier-color: #66bb6a; }
.sgt-card.tier-5    { --tier-color: #7e57c2; }
.sgt-card.tier-4    { --tier-color: #ab47bc; }
.sgt-card.tier-3    { --tier-color: #ef5350; }
.sgt-card.tier-2    { --tier-color: #e53935; }
.sgt-card.tier-1    { --tier-color: #c62828; }
.sgt-card.tier-goal { --tier-color: #e65100; }

.sgt-card.active-card {
  border-color: var(--tier-color, var(--sgt-imperial-red));
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--tier-color, #D4380D) 25%, transparent),
    0 4px 16px color-mix(in srgb, var(--tier-color, #D4380D) 20%, transparent);
  transform: translateY(-2px);
}

.sgt-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 6px;
}

.sgt-card-avatar {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

/* ── 官銀重擲按鈕 ─────────────────────────── */
.sgt-reroll-row { display: flex; justify-content: center; }
.sgt-reroll-row.hidden { display: none; }

.sgt-reroll-btn {
  padding: 6px 16px;
  border: 1.5px dashed var(--sgt-imperial-gold, #C9A84C);
  border-radius: 20px;
  background: rgba(213,170,66,0.1);
  color: #7A5500;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Noto Serif TC', serif;
  transition: background .15s, transform .12s;
  letter-spacing: 0.5px;
}
.sgt-reroll-btn:hover {
  background: rgba(213,170,66,0.22);
  transform: translateY(-1px);
}
.sgt-reroll-btn:active { transform: scale(.96); }
.sgt-reroll-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sgt-card-label {
  font-size: 13px;
  color: var(--sgt-ink);
  font-weight: 700;
}

.sgt-card-rank {
  font-size: 13px;
  font-weight: 700;
  min-height: 1.3em;
  color: var(--tier-color, var(--sgt-imperial-red));
  transition: color .3s;
  letter-spacing: 0.5px;
}

.sgt-card-pos {
  font-size: 11px;
  color: rgba(80,50,10,0.6);
  margin-top: 2px;
}

/* ── 進度條（捲軸樣式）─────────────────────── */
.sgt-card-bar-wrap {
  height: 6px;
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
  position: relative;
}

.sgt-card-bar-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 8px,
    rgba(0,0,0,0.04) 8px,
    rgba(0,0,0,0.04) 9px
  );
}

.sgt-card-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--tier-color, var(--sgt-imperial-red)), color-mix(in srgb, var(--tier-color, #D4380D) 70%, #FFD700));
  border-radius: 4px;
  transition: width .65s cubic-bezier(.34, 1.56, .64, 1), background .35s;
  position: relative;
}

/* ── 骰子區 ─────────────────────────────────── */
.sgt-dice-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ── 雙骰子排列 ──────────────────────────────── */
.sgt-dual-dice {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sgt-dice-vs {
  font-size: 11px;
  font-weight: 900;
  color: rgba(139,26,26,0.4);
  letter-spacing: 1px;
}

/* ── 雙骰選擇按鈕列 ─────────────────────────── */
.sgt-dice-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sgt-dice-pick-row.hidden { display: none; }

.sgt-dice-pick-sep {
  font-size: 12px;
  color: rgba(80,50,10,0.6);
  white-space: nowrap;
}

.sgt-dice-pick-btn {
  padding: 8px 18px;
  border: 2px solid var(--sgt-imperial-gold, #C9A84C);
  border-radius: 30px;
  background: linear-gradient(145deg, #FDF6E3, #EDE0B5);
  color: var(--sgt-imperial-red, #8B1A1A);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Noto Serif TC', serif;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.sgt-dice-pick-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(139,26,26,0.25);
}

.sgt-dice-pick-btn:active { transform: scale(.95); }

.sgt-dice-stage {
  width: 90px;
  height: 90px;
  background: linear-gradient(145deg, #F5EDD0, #DEC98A);
  border-radius: 22px;
  border: 3px solid var(--sgt-imperial-gold);
  box-shadow:
    0 6px 24px rgba(0,0,0,0.3),
    inset 0 2px 4px rgba(255,255,255,0.6),
    inset 0 -2px 4px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* 骰子舞台光澤 */
.sgt-dice-stage::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 10px;
  width: 30px;
  height: 16px;
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  transform: rotate(-20deg);
  pointer-events: none;
}

.sgt-dice {
  font-size: 4.2rem;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .3));
  user-select: none;
  position: relative;
  z-index: 1;
}

/* 骰子旋轉動畫 */
@keyframes diceRoll {
  0%   { transform: rotate(0deg)   scale(1.0); }
  15%  { transform: rotate(-22deg) scale(1.2); }
  35%  { transform: rotate(18deg)  scale(1.25); }
  55%  { transform: rotate(-15deg) scale(1.18); }
  75%  { transform: rotate(10deg)  scale(1.12); }
  100% { transform: rotate(0deg)   scale(1.0); }
}

.sgt-dice.rolling {
  animation: diceRoll 0.3s ease infinite;
  filter: drop-shadow(0 5px 12px rgba(212, 56, 13, .5));
}

/* 骰子落定彈跳 */
@keyframes diceLand {
  0%   { transform: scale(1.5); opacity: 0.7; }
  45%  { transform: scale(0.85); }
  75%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.sgt-dice.dice-land {
  animation: diceLand .5s cubic-bezier(.34, 1.56, .64, 1);
}

.sgt-info-wrap {
  text-align: center;
}

.sgt-turn-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--sgt-imperial-gold);
  background: var(--sgt-imperial-red);
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 4px;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(139,26,26,0.4);
}

.sgt-info {
  font-size: 13.5px;
  color: var(--color-text, #333);
  text-align: center;
  min-height: 1.4em;
  font-weight: 600;
}

/* ── 擲骰子按鈕 ──────────────────────────── */
.sgt-roll-btn {
  font-size: 1.05rem;
  padding: 14px 44px;
  border-radius: 50px;
  background: linear-gradient(145deg, #C0392B, #8B1A1A);
  color: #FFF9E0;
  border: 2px solid rgba(201, 168, 76, 0.6);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow:
    0 5px 20px rgba(139, 26, 26, .45),
    inset 0 1px 0 rgba(255, 220, 120, 0.3);
  transition: transform .15s, box-shadow .15s, background .15s;
  font-family: 'Noto Serif TC', serif;
}

.sgt-roll-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.04);
  background: linear-gradient(145deg, #C9392B, #A02020);
  box-shadow:
    0 8px 28px rgba(139, 26, 26, .55),
    inset 0 1px 0 rgba(255, 220, 120, 0.4);
}

.sgt-roll-btn:active:not(:disabled) {
  transform: scale(.96);
  box-shadow: 0 2px 10px rgba(139, 26, 26, .4);
}

.sgt-roll-btn:disabled {
  background: linear-gradient(145deg, #aaa, #888);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
  color: #ccc;
}

/* ── 移動統計區 ──────────────────────────── */
.sgt-stats-row {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: rgba(80,50,10,0.65);
}

.sgt-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sgt-stat-value {
  font-weight: 700;
  color: var(--sgt-imperial-red);
}

/* ── 圖例 ─────────────────────────────────────── */
.sgt-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
  color: rgba(80,50,10,0.7);
  background: rgba(245, 237, 208, 0.6);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(201,168,76,0.3);
}

.sgt-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sgt-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid rgba(0, 0, 0, .15);
}

.sgt-dot.ev-up      { background: linear-gradient(145deg, #d4f1e3, #b7e3c9); border-color: #27ae72; }
.sgt-dot.ev-down    { background: linear-gradient(145deg, #fdd9d7, #f5b7b1); border-color: #c0392b; }
.sgt-dot.ev-star    { background: linear-gradient(145deg, #fff9c4, #ffe48a); border-color: #e67e22; }
.sgt-dot.ev-express { background: linear-gradient(145deg, #fff3cd, #ffe08a); border-color: #C9A84C; }
.sgt-dot.ev-skip    { background: linear-gradient(145deg, #ece4d8, #d8cebe);   border-color: #78716a; }
.sgt-dot.cell-goal  { background: linear-gradient(135deg, #ffe082, #ff8f00); border-color: #e65100; }
.sgt-dot.fortune    { background: linear-gradient(145deg, #e8eaf6, #c5cae9); border-color: #7986cb; }

/* ── 覆蓋層 Modal ──────────────────────────── */
.sgt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.sgt-overlay.hidden { display: none; }

.sgt-modal {
  background: linear-gradient(160deg, #FDF6E3, #F5E8C5);
  border-radius: 20px;
  padding: 0 26px 28px;
  text-align: center;
  max-width: 300px;
  width: 100%;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, .38),
    0 0 0 1px rgba(201,168,76,0.3);
  overflow: hidden;
  border-top: 6px solid var(--color-border, #eee);
  transition: border-color .1s;
  animation: modalIn .28s cubic-bezier(.34, 1.4, .64, 1);
}

@keyframes modalIn {
  from { transform: scale(0.82) translateY(16px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* 事件類型頂部色條 */
.sgt-overlay[data-ev-type="up"]   .sgt-modal { border-top-color: #27ae72; }
.sgt-overlay[data-ev-type="star"] .sgt-modal { border-top-color: #e67e22; }
.sgt-overlay[data-ev-type="down"] .sgt-modal { border-top-color: #c0392b; }
.sgt-overlay[data-ev-type="neu"]  .sgt-modal { border-top-color: #78909c; }

.sgt-modal-icon {
  font-size: 4.2rem;
  display: block;
  margin: 22px 0 8px;
  line-height: 1;
  animation: iconBounce .5s cubic-bezier(.34, 1.56, .64, 1) .1s both;
}

@keyframes iconBounce {
  from { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0deg);   opacity: 1; }
}

.sgt-modal-ribbon {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 3px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.sgt-overlay[data-ev-type="up"]   .sgt-modal-ribbon { background: #e8f8f0; color: #1b7a5a; border: 1px solid #27ae72; }
.sgt-overlay[data-ev-type="star"] .sgt-modal-ribbon { background: #fff9e0; color: #8B6914; border: 1px solid #e67e22; }
.sgt-overlay[data-ev-type="down"] .sgt-modal-ribbon { background: #fef0ee; color: #7B1A1A; border: 1px solid #c0392b; }
.sgt-overlay[data-ev-type="neu"]  .sgt-modal-ribbon { background: #f0f4f8; color: #546e7a; border: 1px solid #78909c; }

.sgt-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--sgt-ink, #1A1008);
  letter-spacing: 0.5px;
}

.sgt-modal-msg {
  font-size: 14px;
  white-space: pre-line;
  line-height: 1.9;
  margin-bottom: 22px;
  color: rgba(50,30,5,0.75);
}

.sgt-modal-btn {
  padding: 12px 38px;
  border: 2px solid rgba(201,168,76,0.5);
  border-radius: 50px;
  background: linear-gradient(145deg, #C0392B, #8B1A1A);
  color: #FFF9E0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  letter-spacing: 1px;
  font-family: 'Noto Serif TC', serif;
  box-shadow: 0 4px 14px rgba(139,26,26,0.35);
}

.sgt-modal-btn:hover  {
  opacity: .88;
  box-shadow: 0 6px 20px rgba(139,26,26,0.45);
  transform: translateY(-1px);
}

.sgt-modal-btn:active { transform: scale(.95); }

/* ── 戰績統計區（結果 Modal）──────────────── */
.sgt-result-stats {
  margin: 10px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.sgt-result-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--sgt-ink);
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  padding: 6px 12px;
  gap: 8px;
}
.sgt-result-stat-row strong {
  color: var(--sgt-crimson, #8B1A1A);
}

/* ── 遊戲內成就 Toast ───────────────────── */
.sgt-ach-toast {
  position: fixed; bottom: 74px; right: 14px;
  background: #fffdf5;
  border: 2px solid #C9A84C;
  border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  z-index: 9500; max-width: 220px;
  opacity: 0; transform: translateX(110%);
  transition: opacity .35s, transform .35s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.sgt-ach-toast.sgt-ach-in  { opacity: 1; transform: translateX(0); }
.sgt-ach-toast.sgt-ach-out { opacity: 0; transform: translateX(110%);
                               transition: opacity .3s, transform .3s ease-in; }
.sgt-ach-toast-icon  { font-size: 2rem; flex-shrink: 0; line-height: 1; }
.sgt-ach-toast-label { font-size: 10px; color: #7A5500; font-weight: 700; letter-spacing: .5px; }
.sgt-ach-toast-name  { font-size: 14px; font-weight: 700; color: #3A2800; margin-top: 1px; }


/* ── 降職免除額外按鈕樣式 ───────────────────── */
.sgt-modal-exempt .sgt-modal-msg {
  font-size: 14px;
  line-height: 1.9;
}

.sgt-exempt-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.sgt-btn-gold {
  background: linear-gradient(145deg, #C9A84C, #A07830);
  border-color: rgba(255,220,120,0.5);
  font-size: 13px;
  padding: 11px 20px;
}

.sgt-btn-gray {
  background: linear-gradient(145deg, #9e9e9e, #757575);
  border-color: transparent;
  font-size: 13px;
  padding: 11px 20px;
}

/* ── 命運牌二選一 Modal ─────────────────────── */
.sgt-fortune-modal {
  background: linear-gradient(160deg, #FDF6E3, #F0E4C0);
  border-radius: 20px;
  padding: 20px 16px 24px;
  text-align: center;
  max-width: 360px;
  width: calc(100vw - 32px);
  box-shadow: 0 14px 52px rgba(0,0,0,0.42), 0 0 0 1px rgba(201,168,76,0.35);
  animation: modalIn .3s cubic-bezier(.34, 1.4, .64, 1);
}

.sgt-fortune-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--sgt-imperial-red, #8B1A1A);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.sgt-fortune-subtitle {
  font-size: 12px;
  color: rgba(80,50,10,0.6);
  margin-bottom: 16px;
}

.sgt-fortune-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sgt-fc-card {
  border-radius: 14px;
  padding: 12px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform .15s, box-shadow .15s;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.sgt-fc-safe {
  background: linear-gradient(160deg, #e8f8f0, #c8eeda);
  border: 2px solid #27ae72;
}

.sgt-fc-risky {
  background: linear-gradient(160deg, #fef0e4, #f5d5b0);
  border: 2px solid #C0392B;
}

.sgt-fc-tag {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 2px;
}

.sgt-fc-safe .sgt-fc-tag  { background: #27ae72; color: #fff; }
.sgt-fc-risky .sgt-fc-tag { background: #C0392B; color: #fff; }

.sgt-fc-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin: 4px 0;
}

.sgt-fc-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--sgt-ink, #1A1008);
  letter-spacing: 0.5px;
}

.sgt-fc-effect {
  font-size: 11px;
  font-weight: 700;
  color: #555;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 3px 8px;
  line-height: 1.4;
  text-align: center;
}

.sgt-fc-desc {
  font-size: 11px;
  color: rgba(50,30,5,0.7);
  line-height: 1.55;
  text-align: center;
  white-space: pre-line;
}

.sgt-fc-disable {
  font-size: 10px;
  color: #c0392b;
  font-weight: 700;
  min-height: 14px;
}

.sgt-fc-btn {
  margin-top: 4px;
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Noto Serif TC', serif;
  transition: transform .12s, opacity .12s;
  letter-spacing: 0.5px;
  width: 100%;
}

.sgt-fc-btn:hover:not(:disabled) { transform: translateY(-1px); opacity: 0.9; }
.sgt-fc-btn:active { transform: scale(.96); }

.sgt-fc-btn-safe  { background: #27ae72; color: #fff; }
.sgt-fc-btn-risky { background: #C0392B; color: #fff; }

/* 禁用狀態 */
.sgt-fc-card.fc-disabled .sgt-fc-btn {
  background: #aaa;
  cursor: not-allowed;
  opacity: 0.6;
}

.sgt-fc-card.fc-disabled {
  opacity: 0.7;
  filter: grayscale(0.3);
}

/* 骰子選中效果 */
.sgt-dice.dice-selected {
  animation: diceSelect .4s ease;
  filter: drop-shadow(0 0 12px rgba(201,168,76,0.9));
}

@keyframes diceSelect {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ── 結果 Modal ─────────────────────────────── */
.sgt-result-msg {
  font-size: 22px;
  font-weight: 700;
  margin: 22px 0 10px;
  color: var(--sgt-imperial-red, #8B1A1A);
  letter-spacing: 1px;
}

.sgt-result-sub {
  font-size: 14px;
  color: rgba(80,50,10,0.65);
  margin-bottom: 22px;
  line-height: 1.7;
}

/* ── 命運牌翻轉動畫（fortune 格閃爍）──────── */
.fortune-cell-glow {
  animation: fortuneGlow .6s ease-out;
}

@keyframes fortuneGlow {
  0%   { background: linear-gradient(145deg, #F8EFD4, #EDE0B5); }
  30%  { background: linear-gradient(145deg, #e8eaf6, #c5cae9); box-shadow: 0 0 14px rgba(121,134,203,0.6); }
  70%  { background: linear-gradient(145deg, #e8eaf6, #c5cae9); box-shadow: 0 0 10px rgba(121,134,203,0.4); }
  100% { background: linear-gradient(145deg, #F8EFD4, #EDE0B5); }
}

/* ── 升遷/降職粒子效果文字 ───────────────── */
.sgt-delta-toast {
  position: fixed;
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 600;
  animation: toastFloat 1.4s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-family: 'Noto Serif TC', serif;
}

.sgt-delta-toast.up   { color: #1b7a5a; }
.sgt-delta-toast.down { color: #c0392b; }
.sgt-delta-toast.star { color: #e67e22; }

@keyframes toastFloat {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  60%  { transform: translateY(-40px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-70px) scale(0.9); opacity: 0; }
}

/* ── 回合紀錄區 ──────────────────────────── */
.sgt-log {
  width: min(376px, calc(100vw - 16px));
  max-height: 100px;
  overflow-y: auto;
  background: rgba(245,237,208,0.5);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  color: rgba(60,35,5,0.7);
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,26,26,0.3) transparent;
}

.sgt-log:empty::before {
  content: '尚無回合記錄';
  color: rgba(80,50,10,0.4);
  font-style: italic;
}

.sgt-log-entry { animation: logIn .3s ease; }

@keyframes logIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 響應式（手機優化）──────────────────── */
@media (max-width: 400px) {
  .sgt-board-frame { padding: 7px; }
  .sgt-board { width: calc(100vw - 28px); }
  .sgt-dice-stage { width: 68px; height: 68px; }
  .sgt-dice { font-size: 3rem; }
  .sgt-roll-btn { padding: 12px 30px; font-size: 0.95rem; }
  .cell-icon  { display: none; }
  .cell-label { font-size: clamp(8px, 2.5vw, 10px); }
  .sgt-fortune-cards { grid-template-columns: 1fr; gap: 8px; }
  .sgt-fortune-modal { padding: 16px 12px 20px; }
  .sgt-dual-dice { gap: 8px; }
}
