/**
 * JiangGan 遊戲主題 — 覆寫 Bootstrap 預設外觀，與 codex.css 色調一致
 * 仍使用 Bootstrap 網格與 JS 元件，僅改視覺層
 */
:root {
  --wow-ink: #1a2332;
  --wow-ink-soft: #2d3a4f;
  --wow-parchment: rgba(248, 242, 228, 0.94);
  --wow-parchment-edge: rgba(201, 162, 39, 0.45);
  --wow-gold: #c9a227;
  --wow-gold-bright: #e8d48a;
  --wow-text: #2c2416;
  --wow-text-muted: #5c5348;
  --wow-alliance: #2563eb;
  --wow-horde: #b91c1c;
  --wow-success: #2d6a4f;
  --wow-radius: 14px;
  --wow-radius-sm: 10px;
  --wow-shadow: 0 14px 40px rgba(10, 14, 22, 0.28);
  --wow-font: 'ZCOOL XiaoWei', Georgia, 'Noto Serif TC', serif;
  --bs-body-font-family: var(--wow-font);
  --bs-primary: #8b6914;
  --bs-primary-rgb: 139, 105, 20;
  --bs-secondary: #4a5568;
  --bs-success: 45, 106, 79;
  --bs-info: 45, 90, 115;
  --bs-warning: 201, 162, 39;
  --bs-danger: 185, 28, 28;
  --bs-border-radius: var(--wow-radius-sm);
  --bs-border-color: rgba(26, 35, 50, 0.18);
}

/* —— 全站遊戲頁 —— */
body.game-page {
  font-family: var(--wow-font);
  color: var(--wow-text);
  min-height: 100vh;
}

body.game-page a:not(.btn) {
  color: var(--wow-ink-soft) !important;
  text-decoration: none;
  transition: color 0.15s ease;
}

body.game-page a:not(.btn):hover {
  color: var(--wow-gold) !important;
}

body.game-page.bgimg {
  background-image: url('../img/backg.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

.game-main-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.game-main-container--top {
  align-items: flex-start;
}

.game-mainbox,
.mainbox {
  width: 100%;
  background: var(--wow-parchment);
  background-image: url('../img/paper.png');
  background-size: 100% 100%;
  padding: 2rem 1.75rem;
  border-radius: var(--wow-radius);
  box-shadow: var(--wow-shadow);
  border: 1px solid var(--wow-parchment-edge);
  font-family: var(--wow-font);
}

.game-mainbox--narrow {
  max-width: 520px;
}

.game-mainbox--wide {
  max-width: 1200px;
}

.game-page-title {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--wow-ink);
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 1.25rem;
}

/* 首頁選單連結 */
.game-menu-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}

.game-menu-links a {
  display: block;
  width: 100%;
  max-width: 300px;
  padding: 0.7rem 1rem;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  color: var(--wow-text) !important;
  text-align: center;
  border-radius: var(--wow-radius-sm);
  border: 1px solid transparent;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.game-menu-links a:hover {
  background: rgba(201, 162, 39, 0.22);
  border-color: rgba(201, 162, 39, 0.35);
  transform: translateY(-2px);
  color: var(--wow-ink) !important;
}

#logo.game-logo-intro {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

/* 首頁 index.html */
.game-page--home .game-home-container {
  justify-content: center;
  align-items: center;
  width: 100%;
}

.game-page--home .game-home-logo {
  display: block;
  width: auto;
  max-width: min(100%, 520px);
  height: auto;
  margin-left: auto;
  margin-right: auto;
}

.game-page--home .game-home-menu {
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.game-page--home .game-menu-links {
  width: 100%;
}

/* 表單 */
body.game-page .form-label {
  font-weight: 700;
  color: var(--wow-ink);
  font-size: 1.05rem;
}

body.game-page .form-control,
body.game-page .form-select {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(26, 35, 50, 0.2);
  border-radius: var(--wow-radius-sm);
  color: var(--wow-text);
}

body.game-page .form-control:focus,
body.game-page .form-select:focus {
  border-color: var(--wow-gold);
  box-shadow: 0 0 0 0.2rem rgba(201, 162, 39, 0.25);
}

body.game-page .form-check-input:checked {
  background-color: var(--wow-gold);
  border-color: var(--wow-gold);
}

/* 按鈕 */
body.game-page .btn {
  font-family: var(--wow-font);
  border-radius: var(--wow-radius-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body.game-page .btn:active {
  transform: translateY(1px);
}

body.game-page .btn-primary {
  background: linear-gradient(180deg, #a8842a 0%, #7a5f12 100%);
  border-color: #6b5310;
  color: #fff8e8;
}

body.game-page .btn-primary:hover {
  background: linear-gradient(180deg, #c9a227 0%, #8b6914 100%);
  border-color: #7a5f12;
  color: #fff;
}

body.game-page .btn-success {
  background: linear-gradient(180deg, #3d8b6a 0%, var(--wow-success) 100%);
  border-color: #245a42;
}

body.game-page .btn-outline-secondary {
  color: var(--wow-ink-soft);
  border-color: rgba(26, 35, 50, 0.35);
}

body.game-page .btn-outline-secondary:hover {
  background: var(--wow-ink);
  border-color: var(--wow-ink);
  color: #f4f0e6 !important;
}

/* 卡片 / 面板 */
body.game-page .card {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(26, 35, 50, 0.15);
  border-radius: var(--wow-radius-sm);
  box-shadow: 0 4px 16px rgba(26, 35, 50, 0.06);
}

body.game-page .card-header {
  background: linear-gradient(180deg, var(--wow-ink) 0%, var(--wow-ink-soft) 100%);
  color: #f4f0e6;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--wow-gold);
  text-transform: uppercase;
  font-size: 0.85rem;
}

body.game-page .card.bg-transparent {
  background: rgba(255, 255, 255, 0.42) !important;
}

body.game-page--battle .card.bg-transparent {
  background: rgba(248, 242, 228, 0.92) !important;
}

body.game-page .alert-info {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--wow-ink);
}

body.game-page .table {
  --bs-table-bg: transparent;
  color: var(--wow-text);
}

body.game-page .table-bordered {
  border-color: rgba(26, 35, 50, 0.22);
}

body.game-page .table thead th {
  background: rgba(26, 35, 50, 0.08);
  color: var(--wow-ink);
  font-weight: 700;
}

body.game-page .badge.bg-primary {
  background: var(--wow-alliance) !important;
}

body.game-page .badge.bg-danger {
  background: var(--wow-horde) !important;
}

body.game-page code {
  color: var(--wow-ink);
  background: rgba(26, 35, 50, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

body.game-page .modal-content {
  background: var(--wow-parchment);
  background-image: url('../img/paper.png');
  background-size: 100% 100%;
  border: 1px solid var(--wow-parchment-edge);
  border-radius: var(--wow-radius);
}

body.game-page .modal-header {
  background: linear-gradient(180deg, var(--wow-ink) 0%, var(--wow-ink-soft) 100%);
  color: #f4f0e6;
  border-bottom: 2px solid var(--wow-gold);
}

body.game-page .modal-header .btn-close {
  filter: invert(1);
}

/* 結算頁 */
.game-result-hero {
  background: linear-gradient(135deg, var(--wow-ink) 0%, var(--wow-ink-soft) 55%, var(--wow-ink) 100%);
  color: #f4f0e6;
  border-radius: var(--wow-radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--wow-shadow);
}

.game-result-hero h3 {
  margin: 0;
  font-size: 1.5rem;
}

.game-result-panel {
  background: var(--wow-parchment);
  background-image: url('../img/paper.png');
  background-size: 100% 100%;
  border-radius: var(--wow-radius);
  border: 1px solid var(--wow-parchment-edge);
  box-shadow: var(--wow-shadow);
  overflow: hidden;
}

.game-result-panel .card-header {
  border-radius: 0;
}

/* 結算：統一欄寬計分表 */
.game-result-score-table {
  table-layout: fixed;
  width: 100%;
  margin-bottom: 0;
}

.game-result-score-table .gr-col-idx { width: 3.25rem; }
.game-result-score-table .gr-col-player { width: 16%; }
.game-result-score-table .gr-col-hero { width: 18%; }
.game-result-score-table .gr-col-faction { width: 5.5rem; }
.game-result-score-table .gr-col-hp { width: 7.5rem; }
.game-result-score-table .gr-col-dmg { width: 6.5rem; }
.game-result-score-table .gr-col-kills { width: 5rem; }
.game-result-score-table .gr-col-status { width: 5.5rem; }

.game-result-score-table th,
.game-result-score-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.game-result-score-table .game-result-section-row td {
  background: rgba(26, 35, 50, 0.06);
  color: var(--wow-ink, #1a2332);
  font-size: 0.92rem;
  padding: 0.45rem 0.65rem;
  white-space: normal;
}

/* 結算：戰報回顧 */
.game-result-feed-panel .card-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

/* 結算：手機卡片式玩家列 */
.game-result-score-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.game-result-player-card {
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(26, 35, 50, 0.12);
  border-radius: var(--wow-radius, 8px);
  background: rgba(255, 255, 255, 0.55);
}

.game-result-player-card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem 0.5rem;
}

.game-result-player-card__stats > div {
  display: flex;
  flex-direction: column;
}

.game-result-player-card__stats dt {
  margin: 0;
  font-weight: 600;
  color: var(--wow-text-muted, #5c5348);
}

.game-result-player-card__stats dd {
  margin: 0;
}

.game-result-player-card__section {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px dashed rgba(26, 35, 50, 0.12);
}

.result-battle-feed {
  max-height: min(52vh, 520px);
  overflow-y: auto;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.42);
  font-size: 0.95rem;
  line-height: 1.5;
}

.result-feed-item {
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(26, 35, 50, 0.08);
  word-break: break-word;
}

.result-feed-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.result-feed-time {
  color: var(--wow-text-muted, #5c5348);
  font-size: 0.85em;
  margin-right: 0.35rem;
  white-space: nowrap;
}

.result-feed-empty {
  padding: 1.5rem;
  text-align: center;
}

.result-battle-feed .card-preview-link {
  font-size: inherit;
  font-weight: 600;
  text-decoration: none;
  vertical-align: baseline;
}

.result-battle-feed .card-preview-link:hover {
  text-decoration: underline;
}

/* Phaser 外殼 */
body.game-page--phaser {
  background: #0f1419;
  color: #e8e8e8;
}

body.game-page--phaser a:not(.btn) {
  color: var(--wow-gold-bright) !important;
}

.battle-phaser-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.75rem 1rem 1.25rem;
}

.battle-phaser-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.65rem 1rem;
  background: linear-gradient(135deg, #1a2332 0%, #243447 100%);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: var(--wow-radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.battle-phaser-toolbar h4 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--wow-gold-bright);
  letter-spacing: 0.05em;
}

.battle-phaser-toolbar .phaser-meta {
  font-size: 0.88rem;
  color: #9ec9b0;
}

#phaser-status {
  margin-left: auto;
  font-size: 0.88rem;
  color: #9ec9b0;
}

#phaser-game {
  border-radius: var(--wow-radius-sm);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(142, 180, 212, 0.25);
}

.battle-phaser-main {
  align-items: flex-start;
}

.battle-phaser-feed {
  min-height: 280px;
  max-height: 520px;
}

.battle-phaser-feed .battle-feed-wrap {
  min-height: 200px;
  max-height: 420px;
}

#phaserBattleFeed {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: 340px;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
}

.phaser-frozen-hint {
  margin-top: 0.35rem;
}

.battle-phaser-actions {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(26, 35, 50, 0.85);
  border-radius: var(--wow-radius-sm);
  border: 1px solid rgba(142, 180, 212, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

body.game-page--phaser .btn-outline-secondary {
  color: #c5d4e0;
  border-color: rgba(197, 212, 224, 0.45);
}

body.game-page--phaser .btn-outline-secondary:hover {
  background: rgba(201, 162, 39, 0.25);
  color: #fff !important;
}

/* 戰鬥頁動畫（自 battle.php 抽出） */
@keyframes damage-popup {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-50px); opacity: 0; }
}

.game-page--battle .damage-popup {
  position: absolute;
  font-size: 2rem;
  font-weight: bold;
  color: #b91c1c;
  text-shadow: 1px 1px 2px #fff, -1px -1px 2px #fff;
  animation: damage-popup 1.5s ease-out forwards;
  pointer-events: none;
  z-index: 9999;
}

.game-page--battle .dice-anim-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.game-page--battle .dice-anim-box {
  background: var(--wow-parchment);
  background-image: url('../img/paper.png');
  background-size: 100% 100%;
  padding: 2rem 2.5rem;
  border-radius: var(--wow-radius);
  border: 2px solid var(--wow-gold);
  box-shadow: var(--wow-shadow);
  font-size: 2.5rem;
  font-weight: bold;
  text-align: center;
  color: var(--wow-ink);
}

.game-page--battle .player-token {
  position: absolute;
  transition: top 0.8s ease-in-out, left 0.8s ease-in-out;
  z-index: 9998;
  padding: 0.35em 0.65em;
  font-size: 0.75em;
  font-weight: 700;
  color: #fff;
  border-radius: 0.25rem;
}

.game-battle-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.game-battle-topbar .btn-sm {
  font-size: 0.8rem;
}

@media (max-width: 767.98px) {
  .game-main-container--top {
    padding: 0.5rem;
  }

  .game-mainbox--wide,
  .mainbox {
    padding: 1.25rem 1rem;
  }
}
