:root {
  --bg-main: #0c0e14;
  --bg-card: #151923;
  --bg-card-border: #262c3e;
  --text-main: #f0f3f8;
  --text-muted: #8c97ad;
  --accent-cyan: #00d2d3;
  --accent-gold: #feca57;
  --accent-crimson: #ff6b6b;
  --accent-purple: #9b59b6;
  --player-pink: #e84393;
  --ai-blue: #0984e3;
  --grid-line: rgba(255, 255, 255, 0.06);
  --radius-lg: 14px;
  --radius-md: 8px;
  --font-sans: system-ui, -apple-system, "Microsoft JhengHei", "PingFang TC", sans-serif;
  --hud-hp-width: 150px;
  --hud-hp-height: 10px;
  --hud-timer-width: 90px;
  --hud-timer-height: 8px;
  --dock-max-width: 760px;
  --wisdom-dock-width: 320px;
}

/* 非侵入式優雅浮動 Toast 系統 (杜絕輸入法中斷) */
#toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.92rem;
  font-weight: bold;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastFadeIn 0.3s ease;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
}

.toast-item.info { background: rgba(9, 132, 227, 0.92); color: #fff; }
.toast-item.success { background: rgba(46, 213, 115, 0.92); color: #fff; }
.toast-item.warning { background: rgba(254, 202, 87, 0.95); color: #1e1e1e; }
.toast-item.error { background: rgba(235, 77, 75, 0.95); color: #fff; }

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Battle Layout (R-UI/UX 空間幾何接管 · 全幅接龍區最大化) */
.battle-grid, .demo-arena-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* 右側主舞台容器 */
.arena-board-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-card-border);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.view-toggles {
  display: flex;
  gap: 6px;
}

.view-btn {
  background: #1e2433;
  color: var(--text-muted);
  border: 1px solid var(--bg-card-border);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.view-btn.active {
  background: rgba(0, 210, 211, 0.2);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  font-weight: bold;
}

.view-btn .view-btn-short {
  display: none;
}

.view-btn .view-btn-full {
  display: inline;
}

/* 依據終端寬度自適應切換：「棋盤 / 紀錄表」(桌面寬螢幕) ➔「盤 / 表」(窄螢幕/手機端) */
@media (max-width: 680px) {
  .view-btn .view-btn-full {
    display: none;
  }
  .view-btn .view-btn-short {
    display: inline;
    font-weight: bold;
    padding: 0 2px;
  }
}

/* 二維縱橫交錯字陣棋盤視圖 (Cross-Word Arena · 100% 彈性高度 · 支援滑鼠按住攀移與滾輪) */
.cross-board-viewport {
  flex: 1;
  min-height: 0;
  height: 100%;
  background: #11141c;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
  overflow: auto;
  position: relative;
  background-image: 
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  padding: 16px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  scrollbar-width: none !important; /* Firefox 隱藏滾動條 */
  -ms-overflow-style: none !important; /* IE/Edge 隱藏滾動條 */
}

.cross-board-viewport::-webkit-scrollbar {
  display: none !important; /* Chrome/Edge/Safari 隱藏原生滾動條 */
  width: 0 !important;
  height: 0 !important;
}

.cross-board-viewport.is-panning {
  cursor: grabbing !important;
}

.cross-board-viewport.is-zooming-in,
.cross-board-viewport.ctrl-zoom {
  cursor: zoom-in !important;
}

.cross-board-viewport.is-zooming-out {
  cursor: zoom-out !important;
}

.cross-board-grid {
  position: relative;
  min-width: 700px;
  min-height: 450px;
  transition: transform 0.05s ease-out;
}

/* Google Maps 風格浮動縮放控制器 (Floating Draggable Zoom HUD) */
.board-zoom-hud {
  position: absolute;
  top: 48px;
  right: 18px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(22, 28, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(0, 206, 201, 0.15);
  backdrop-filter: blur(10px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.zoom-drag-handle {
  width: 100%;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.65;
  transition: opacity 0.2s, color 0.2s;
  padding-top: 1px;
}

.zoom-drag-handle:hover {
  opacity: 1;
  color: var(--accent-cyan);
}

.board-zoom-hud.is-dragging {
  cursor: grabbing !important;
  opacity: 0.95;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75), 0 0 22px rgba(0, 206, 201, 0.35);
  border-color: var(--accent-gold);
}

.board-zoom-hud:hover {
  border-color: rgba(0, 206, 201, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 18px rgba(0, 206, 201, 0.25);
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-main);
  border: none;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
}

.zoom-btn:hover {
  background: rgba(0, 206, 201, 0.22);
  color: var(--accent-cyan);
  transform: scale(1.12);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.zoom-level {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-gold);
  padding: 2px 4px;
  cursor: pointer;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.zoom-level:hover {
  color: #fff;
  text-decoration: underline;
}

/* 棋盤上的單字格子 */
.board-cell {
  position: absolute;
  width: 42px;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 900;
  border-radius: 6px;
  border: 1.5px solid transparent;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.board-cell.player {
  background: rgba(232, 67, 147, 0.15);
  color: var(--player-pink);
  border-color: var(--player-pink);
}

.board-cell.ai {
  background: rgba(9, 132, 227, 0.15);
  color: var(--ai-blue);
  border-color: var(--ai-blue);
}

.board-cell.system {
  background: rgba(0, 210, 211, 0.15);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.board-cell.demo-p1 {
  background: rgba(9, 132, 227, 0.18);
  color: #74b9ff;
  border-color: #0984e3;
  box-shadow: 0 0 10px rgba(9, 132, 227, 0.35);
}

.board-cell.demo-p2 {
  background: rgba(253, 203, 110, 0.18);
  color: #ffeaa7;
  border-color: #fdcb6e;
  box-shadow: 0 0 10px rgba(253, 203, 110, 0.35);
}

.board-cell.cross-pivot {
  background: rgba(254, 202, 87, 0.25) !important;
  color: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 16px rgba(254, 202, 87, 0.4);
  transform: scale(1.06);
  z-index: 10;
}

.board-cell .cell-ruby {
  font-size: 0.55rem;
  line-height: 1;
  color: var(--text-muted);
  margin-top: 1px;
}

/* 棋盤指引氣泡 (浮動在出招字旁) */
.board-bubble {
  position: absolute;
  background: #fdf5d3;
  color: #3e2723;
  border: 2px solid #e0a96d;
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 0.8rem;
  max-width: 220px;
  line-height: 1.35;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  z-index: 20;
  pointer-events: none;
  animation: toastFadeIn 0.3s ease;
}

/* 棋盤氣泡箭頭 (朝向字格) */
.board-bubble::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

.board-bubble.arrow-left::before {
  left: -8px;
  top: 12px;
  border-width: 6px 8px 6px 0;
  border-color: transparent #e0a96d transparent transparent;
}

.board-bubble.arrow-right::before {
  right: -8px;
  top: 12px;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #e0a96d;
}

.board-bubble.arrow-up::before {
  top: -8px;
  left: 24px;
  border-width: 0 6px 8px 6px;
  border-color: transparent transparent #e0a96d transparent;
}

.board-bubble.arrow-down::before {
  bottom: -8px;
  left: 24px;
  border-width: 8px 6px 0 6px;
  border-color: #e0a96d transparent transparent transparent;
}

/* ==========================================
   同音不同字樞紐呈現系統 (A: 合璧雙字磚 / B: 雙星音律橋 / C: 太極翻轉牌)
   ========================================== */

/* 基礎通用高亮 */
.board-cell.cross-pivot-homo {
  z-index: 15;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 方案 A：合璧雙字磚 (Split Diagonal Tile) */
.board-cell.cross-pivot-homo.style-tile {
  background: linear-gradient(135deg, rgba(232, 67, 147, 0.28) 46%, rgba(254, 202, 87, 0.45) 46%, rgba(254, 202, 87, 0.45) 54%, rgba(9, 132, 227, 0.28) 54%) !important;
  border: 1.5px solid var(--accent-gold) !important;
  box-shadow: 0 0 18px rgba(254, 202, 87, 0.5);
  transform: scale(1.08);
}

.homo-tile-box {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1;
  gap: 1px;
}

.homo-tile-box .prev-char {
  color: var(--player-pink);
}

.homo-tile-box .homo-slash {
  font-size: 0.72rem;
  color: var(--accent-gold);
  margin: 0 1px;
}

.homo-tile-box .next-char {
  color: var(--ai-blue);
}

/* 方案 B：雙星音律橋 (Dual-Star Sound Bridge) */
.board-cell.cross-pivot-homo.style-bridge {
  background: #141923 !important;
  border: 1.5px solid #2ed573 !important;
  box-shadow: 0 0 18px rgba(46, 213, 115, 0.45);
  transform: scale(1.1);
  padding: 2px;
}

.homo-bridge-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 2px;
  box-sizing: border-box;
}

.homo-bridge-box .bead {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
}

.homo-bridge-box .bead-prev {
  background: rgba(232, 67, 147, 0.3);
  color: var(--player-pink);
  border: 1px solid var(--player-pink);
}

.homo-bridge-box .bead-next {
  background: rgba(9, 132, 227, 0.3);
  color: var(--ai-blue);
  border: 1px solid var(--ai-blue);
}

.homo-bridge-box .bridge-link {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--player-pink), #2ed573, var(--ai-blue));
  position: relative;
  margin: 0 2px;
}

.homo-bridge-box .bridge-link::after {
  content: "🔗";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.52rem;
}

/* 方案 C：太極翻轉與滑動多維動態系統 (左右翻轉 / 上下翻轉 / 縱向滑動 / 橫向滑動) */
.board-cell.cross-pivot-homo.style-flip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  perspective: 600px;
  cursor: pointer;
  overflow: visible;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(254, 202, 87, 0.45);
}

/* 1. 左右太極翻轉 (Horizontal Flip) */
.flip-card-inner.anim-flip-y {
  transform-style: preserve-3d;
  animation: autoFlipY 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.anim-flip-y .flip-card-back {
  transform: rotateY(180deg);
}

@keyframes autoFlipY {
  0%, 36% { transform: rotateY(0deg); }
  48%, 86% { transform: rotateY(180deg); }
  98%, 100% { transform: rotateY(360deg); }
}

/* 2. 上下乾坤翻轉 (Vertical Flip) */
.flip-card-inner.anim-flip-x {
  transform-style: preserve-3d;
  animation: autoFlipX 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.anim-flip-x .flip-card-back {
  transform: rotateX(180deg);
}

@keyframes autoFlipX {
  0%, 36% { transform: rotateX(0deg); }
  48%, 86% { transform: rotateX(180deg); }
  98%, 100% { transform: rotateX(360deg); }
}

/* 3. 縱向行雲滑動 (Vertical Slide Reveal) */
.flip-card-inner.anim-slide-y {
  overflow: hidden;
  border: 1.5px solid var(--accent-gold);
}

.anim-slide-y .flip-card-front {
  animation: autoSlideFrontY 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.anim-slide-y .flip-card-back {
  transform: translateY(100%);
  animation: autoSlideBackY 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes autoSlideFrontY {
  0%, 36% { transform: translateY(0); }
  48%, 86% { transform: translateY(-100%); }
  98%, 100% { transform: translateY(0); }
}

@keyframes autoSlideBackY {
  0%, 36% { transform: translateY(100%); }
  48%, 86% { transform: translateY(0); }
  98%, 100% { transform: translateY(100%); }
}

/* 4. 橫向流光滑動 (Horizontal Slide Reveal) */
.flip-card-inner.anim-slide-x {
  overflow: hidden;
  border: 1.5px solid var(--accent-gold);
}

.anim-slide-x .flip-card-front {
  animation: autoSlideFrontX 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.anim-slide-x .flip-card-back {
  transform: translateX(100%);
  animation: autoSlideBackX 5.5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes autoSlideFrontX {
  0%, 36% { transform: translateX(0); }
  48%, 86% { transform: translateX(-100%); }
  98%, 100% { transform: translateX(0); }
}

@keyframes autoSlideBackX {
  0%, 36% { transform: translateX(100%); }
  48%, 86% { transform: translateX(0); }
  98%, 100% { transform: translateX(100%); }
}

/* 滑鼠懸停或點擊暫停時定格，便於玩家靜心細賞首尾雙字 */
.board-cell.cross-pivot-homo.style-flip:hover .flip-card-inner,
.board-cell.cross-pivot-homo.style-flip:hover .flip-card-front,
.board-cell.cross-pivot-homo.style-flip:hover .flip-card-back,
.board-cell.cross-pivot-homo.style-flip.paused .flip-card-inner,
.board-cell.cross-pivot-homo.style-flip.paused .flip-card-front,
.board-cell.cross-pivot-homo.style-flip.paused .flip-card-back {
  animation-play-state: paused !important;
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1.5px solid var(--accent-gold);
}

.flip-card-front {
  background: rgba(9, 132, 227, 0.3);
  color: var(--ai-blue);
}

.flip-card-back {
  background: rgba(232, 67, 147, 0.3);
  color: var(--player-pink);
}

.flip-badge {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 0.5rem;
  color: var(--accent-gold);
  line-height: 1;
}

/* 結構化對戰流轉表格 (Table View · 100% 彈性高度 · 內部平滑捲動) */
.table-stream-viewport {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  background: #11141c;
}

.flow-table {
  width: 100%;
  border-collapse: collapse;
}

.flow-table th {
  background: #191f2c;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--bg-card-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.flow-table td {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-bottom: 1px solid #1a202d;
  cursor: pointer;
  transition: background 0.15s;
}

.flow-table tr:hover td {
  background: #1f2738;
}

.flow-table tr.selected td {
  background: rgba(0, 210, 211, 0.15);
  color: #fff;
  border-bottom-color: var(--accent-cyan);
}

/* 實時心戰對白條 (底部常駐元件 · flex-shrink: 0) */
.live-banter-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #181d28;
  border: 1px solid var(--bg-card-border);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin-top: 6px;
  flex-shrink: 0;
}

.banter-speaker-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.banter-text {
  flex: 1;
  font-size: 0.86rem;
  color: var(--accent-gold);
  line-height: 1.35;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
}

/* ==========================================
   Header & Brand (R-UI/UX 空間幾何接管 · 歐文詞塊單行保護)
   ========================================== */
header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--bg-card-border);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
  min-width: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.brand h1 {
  font-size: 1.25rem;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.brand-en {
  font-size: 0.85rem;
  font-weight: normal;
  letter-spacing: 1px;
  color: var(--accent-gold);
  -webkit-text-fill-color: var(--accent-gold);
}

.brand-slogan {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.slogan-highlight {
  color: var(--accent-gold);
  font-weight: bold;
}

/* 狀態膠囊與呼吸燈 (Telemetry Status Badge) */
.badge {
  font-size: 0.74rem;
  background: rgba(0, 210, 211, 0.12);
  color: var(--accent-cyan);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid rgba(0, 210, 211, 0.32);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap !important;
  flex-shrink: 0;
  line-height: 1.2;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.ready {
  background: #2ed573;
  box-shadow: 0 0 8px #2ed573;
}

.status-dot.loading {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
  animation: pulseDot 1.2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* 語意漸進降級標籤 (Semantic Progressive Degradation) */
.status-text-full { display: inline; }
.status-text-med { display: none; }
.status-text-short { display: none; }

.tab-text-full { display: inline; }
.tab-text-short { display: none; }

.btn-text-full, .fs-text-full { display: inline; }
.btn-text-short, .fs-text-short { display: none; }

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap !important;
}

.tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.tab-btn.active {
  background: rgba(254, 202, 87, 0.15);
  color: var(--accent-gold);
  border-color: rgba(254, 202, 87, 0.4);
}

main {
  flex: 1;
  min-height: 0;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 雙雄演示 擂台舞台 (全幅最大化 · R-UI/UX 空間幾何接管) */
.demo-arena-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.demo-stage-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
}

.demo-p-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 8px;
  background: #19202e;
  border: 1px solid transparent;
  transition: all 0.3s;
}

.demo-p-box.active {
  border-color: var(--accent-gold);
  background: #252b3d;
  box-shadow: 0 0 12px rgba(254, 202, 87, 0.2);
}

.demo-stage-title {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 10px;
}

.p-name { font-weight: bold; }
.p1-name { color: var(--accent-cyan); }
.p2-name { color: #fdcb6e; }
.p-status { font-size: 0.8rem; }
.p1-status { color: #00e676; }
.p2-status { color: var(--text-muted); }

.card-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.target-word {
  font-size: 0.95rem;
  font-weight: bold;
  margin-bottom: 4px;
}
.target-phonetic {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.referee-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}
.referee-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
}

/* Controls Bar */
.control-bar {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.control-options-drawer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}

.control-actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.btn-opt-toggle {
  display: none;
}

/* HUD 戰鬥儀表 */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
  flex-shrink: 0;
}

.hud-hp-box {
  width: var(--hud-hp-width);
  height: var(--hud-hp-height);
  background: #222;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}

.hud-timer-box {
  width: var(--hud-timer-width);
  height: var(--hud-timer-height);
  background: #222;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.hud-label-compact {
  display: none;
}

.hud-label-full {
  display: inline;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

select, input, button {
  background: #222736;
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  white-space: nowrap;
}

select:focus, input:focus {
  border-color: var(--accent-cyan);
}

.btn-primary {
  background: linear-gradient(135deg, #0984e3, #00cec9);
  color: #fff;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: linear-gradient(135deg, #2d3748, #4a5568);
  color: #f7fafc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #4a5568, #718096);
  border-color: rgba(255, 255, 255, 0.32);
}

.btn-accent {
  background: linear-gradient(135deg, #e17055, #d63031);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-accent:hover {
  opacity: 0.9;
}

.btn-takeover {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  border: none;
  font-weight: bold;
  cursor: pointer;
  padding: 8px 16px;
  transition: opacity 0.2s;
}

.btn-takeover:hover {
  opacity: 0.9;
}

/* ========================================================= */
/* 📖 右上角典故與縮放整合卡 (Wisdom & Zoom Dock)            */
/* 整合縮放控制與成語典故，動態自適應高度，支援自由拖曳與一鍵收合 */
/* ========================================================= */
.wisdom-zoom-dock {
  position: absolute;
  top: 44px;
  right: 14px;
  width: var(--wisdom-dock-width, 320px);
  max-width: calc(100% - 28px);
  background: rgba(18, 24, 38, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), 0 0 16px rgba(255, 215, 0, 0.1);
  z-index: 45;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, border-color 0.2s;
  user-select: none;
}

.wisdom-zoom-dock.is-dragging {
  cursor: grabbing !important;
  opacity: 0.95;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(255, 215, 0, 0.35);
  border-color: var(--accent-gold);
}

.wisdom-zoom-dock:hover {
  border-color: rgba(255, 215, 0, 0.45);
}

.wisdom-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 8px;
  touch-action: none;
}

.wisdom-drag-handle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--accent-gold);
  cursor: grab;
  flex-shrink: 0;
  padding: 2px 4px;
}

.wisdom-drag-handle:hover {
  color: #fff;
}

.zoom-controls-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.zoom-controls-row .zoom-btn {
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}

.zoom-controls-row .zoom-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--accent-gold);
}

.zoom-controls-row .zoom-level {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--accent-gold);
  padding: 0 4px;
  min-width: 38px;
  text-align: center;
  cursor: pointer;
}

.btn-wisdom-minimize {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.btn-wisdom-minimize:hover {
  color: var(--accent-gold);
}

.wisdom-content {
  padding: 8px 10px;
  user-select: text;
}

.wisdom-zoom-dock.minimized .wisdom-content {
  display: none !important;
}

.wisdom-zoom-dock.minimized {
  width: auto;
}

.wisdom-zoom-dock.minimized .wisdom-dock-header {
  border-bottom: none;
}

/* 迷你目標字膠囊 (收合時顯示於 Header 內) */
.wisdom-mini-target {
  font-size: 0.82rem;
  font-weight: 900;
  color: #fff;
  background: var(--accent-cyan);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  box-shadow: 0 0 8px rgba(0, 206, 201, 0.5);
}

.wisdom-zoom-dock.minimized .wisdom-mini-target {
  display: inline-flex !important;
}

/* 🎯 整合接龍目標橫幅 (原左下角元件，合併至此) */
.wisdom-target-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 14, 22, 0.65);
  border: 1px solid rgba(0, 206, 201, 0.3);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  margin-bottom: 8px;
}

.wisdom-target-banner .target-char {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 206, 201, 0.28) 0%, rgba(10, 14, 22, 0.9) 100%);
  border: 2px solid var(--accent-cyan);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 206, 201, 0.4);
  flex-shrink: 0;
}

.wisdom-target-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wisdom-target-details .target-prev-word {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wisdom-target-details .target-radar-pill {
  font-size: 0.74rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wisdom-content .story-card {
  background: rgba(10, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.wisdom-content .story-title {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.wisdom-content .story-body {
  font-size: 0.82rem;
  color: #dcdde1;
  line-height: 1.5;
  max-height: min(420px, 50vh);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 215, 0, 0.3) transparent;
  padding-right: 4px;
}

.wisdom-content .story-body::-webkit-scrollbar {
  width: 4px;
}

.wisdom-content .story-body::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.3);
  border-radius: 2px;
}

/* ========================================================= */
/* 🎯 左下角極簡目標膠囊 (Mini Target Capsule)                 */
/* 體積極小 (小於 3% 畫面)，顯示目標字、前詞與出度雷達，不擋棋盤   */
/* ========================================================= */
.mini-target-capsule {
  position: absolute;
  bottom: 82px;
  left: 14px;
  z-index: 39;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 24, 38, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 206, 201, 0.35);
  border-radius: 24px;
  padding: 5px 14px 5px 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(0, 206, 201, 0.15);
  user-select: none;
  transition: transform 0.2s, box-shadow 0.2s;
  max-width: calc(100% - 28px);
}

.mini-target-capsule:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 14px rgba(0, 206, 201, 0.25);
  border-color: var(--accent-cyan);
}

.mini-target-capsule .target-char {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 206, 201, 0.28) 0%, rgba(10, 14, 22, 0.9) 100%);
  border: 2px solid var(--accent-cyan);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 206, 201, 0.4);
  flex-shrink: 0;
}

.mini-target-capsule .capsule-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mini-target-capsule .target-prev-word {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-target-capsule .target-radar-pill {
  font-size: 0.72rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 相容性相應樣式 */
.integrated-dashboard-hud {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 40;
}

/* ========================================================= */
/* ⌨️ 中下方視覺焦點區 (Action Dock Container)                */
/* 氣泡、軍師錦囊、出招列居中對齊於玩家視覺焦點前方               */
/* ========================================================= */
.action-dock-container {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--dock-max-width, 760px), calc(100% - 28px));
  z-index: 38;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none; /* 空白處穿透，不阻礙棋盤點擊拖曳 */
}

.action-dock-container > * {
  pointer-events: auto; /* 元件內部恢復點擊 */
}

.action-dock-container .demo-dock-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(22, 28, 42, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* 實時心戰對白氣泡 (視覺焦點核心元件) */
.action-dock-container .live-banter-card {
  background: rgba(22, 28, 42, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 206, 201, 0.35);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.action-dock-container .banter-speaker-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.action-dock-container .banter-text {
  flex: 1;
  font-size: 0.86rem;
  color: #ecf0f1;
  line-height: 1.35;
}

/* 軍師錦囊快捷列 */
#hint-action-bar {
  flex-shrink: 0;
  background: rgba(30, 34, 42, 0.95);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-gold);
}

#hint-action-bar .hint-header {
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

/* 底部出招列 */
.input-dock {
  display: flex;
  gap: 8px;
  background: rgba(18, 23, 34, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  margin-top: 0;
  flex-shrink: 0;
}

.input-dock input {
  flex: 1;
  font-size: 0.95rem;
  padding: 7px 12px;
  background: #161b26;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #fff;
}

.input-dock input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 206, 201, 0.25);
}

/* 詞海手冊表格容器彈性高度自適應與版面優化 (徹底解決頂部大黑框 Bug) */
#tab-learned {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

#tab-learned.active {
  display: flex;
}

#tab-learned .control-bar {
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.learned-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.learned-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.learned-stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-family-display);
}

.learned-stat-lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.learned-table-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-card-border);
}

.learned-table-container table {
  width: 100%;
  border-collapse: collapse;
}

.learned-table-container thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #181d28;
  box-shadow: 0 1px 0 var(--bg-card-border);
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
}

.learned-table-container tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.88rem;
}

.learned-table-container tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.9rem;
}

th {
  color: var(--text-muted);
  background: #181d28;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: bold;
}
.badge-exact {
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
  border: 1px solid rgba(46, 213, 115, 0.4);
}
.badge-homo {
  background: rgba(0, 210, 211, 0.15);
  color: #00d2d3;
  border: 1px solid rgba(0, 210, 211, 0.4);
}
.badge-homo-soul {
  background: linear-gradient(135deg, rgba(241, 196, 15, 0.25), rgba(46, 213, 115, 0.25));
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.6);
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.35);
  font-weight: 800;
  letter-spacing: 0.5px;
  animation: homoSoulPulse 1.8s ease-in-out infinite;
}
@keyframes homoSoulPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 8px rgba(241, 196, 15, 0.3); }
  50% { transform: scale(1.05); box-shadow: 0 0 16px rgba(46, 213, 115, 0.6); }
}
.badge-danger {
  background: rgba(255, 71, 87, 0.15);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.4);
}

/* ========================================== */
/* 「字戀中……」呼吸動態徽章 */
/* ========================================== */
.badge-status-romance {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 107, 129, 0.15);
  color: var(--player-pink, #ff6b81);
  border: 1px solid rgba(255, 107, 129, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: bold;
  animation: romancePulse 2s infinite ease-in-out;
}

@keyframes romancePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 107, 129, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 8px 2px rgba(255, 107, 129, 0.3); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 107, 129, 0); }
}

/* ========================================== */
/* Splash Screen：您今天字戀了沒？ */
/* ========================================== */
.splash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #182030 0%, #0a0d14 85%);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
  cursor: pointer;
}

.splash-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  max-width: 580px;
  width: 90%;
  background: rgba(20, 26, 38, 0.92);
  border: 2px solid rgba(241, 196, 15, 0.45);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(241, 196, 15, 0.15);
  border-radius: 16px;
  padding: 40px 32px 32px;
  text-align: center;
  position: relative;
  backdrop-filter: blur(12px);
  animation: splashZoomIn 0.5s ease-out;
}

@keyframes splashZoomIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.splash-seal {
  position: absolute;
  top: -24px;
  right: 28px;
  background: #c0392b;
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 2px solid #e74c3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif, serif);
  font-weight: bold;
  font-size: 1.1rem;
  line-height: 1.1;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.5);
  transform: rotate(6deg);
}

.splash-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(241, 196, 15, 0.4);
  margin-bottom: 6px;
  font-family: var(--font-serif, "Noto Serif TC", serif);
}

.splash-subtitle {
  font-size: 0.95rem;
  color: var(--accent-gold);
  letter-spacing: 1.5px;
  margin-bottom: 24px;
}

.splash-quote-box {
  background: rgba(10, 14, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--accent-cyan);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 28px;
  text-align: left;
}

.splash-quote-tag {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.splash-quote-text {
  font-size: 1rem;
  line-height: 1.6;
  color: #e2e8f0;
  font-style: italic;
  font-family: var(--font-serif, serif);
}

.splash-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn-splash-enter {
  background: linear-gradient(135deg, #f1c40f 0%, #e67e22 100%);
  color: #111;
  font-weight: bold;
  font-size: 1.05rem;
  padding: 10px 36px;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(241, 196, 15, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-splash-enter:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(241, 196, 15, 0.6);
}

.splash-tip {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ========================================== */
/* 勝利結算彈窗：您這個完美字戀狂！ */
/* ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.78);
  z-index: 99990;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card.victory-card {
  max-width: 680px;
  width: min(680px, 96vw);
  background: linear-gradient(160deg, #1d2536 0%, #111622 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 18px;
  padding: 38px 24px 28px;
  text-align: center;
  position: relative;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.9), 0 0 50px rgba(241, 196, 15, 0.25);
  animation: vicPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes vicPopIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.victory-seal-stamp {
  position: absolute;
  top: 18px;
  right: 20px;
  background: transparent;
  color: #e74c3c;
  border: 3px solid #e74c3c;
  border-radius: 8px;
  padding: 4px 10px;
  font-family: var(--font-serif, serif);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 2px;
  transform: rotate(12deg);
  opacity: 0.88;
  box-shadow: inset 0 0 6px rgba(231, 76, 60, 0.3);
  text-shadow: 0 0 2px rgba(231, 76, 60, 0.5);
  pointer-events: none;
}

.victory-crown {
  font-size: 3rem;
  margin-bottom: 4px;
  animation: crownFloat 3s infinite ease-in-out;
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.victory-title {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--accent-gold);
  font-family: var(--font-serif, "Noto Serif TC", serif);
  letter-spacing: 1.5px;
  text-shadow: 0 2px 14px rgba(241, 196, 15, 0.5);
  margin-bottom: 6px;
}

.victory-subtitle {
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-bottom: 22px;
  line-height: 1.5;
}

.victory-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 10px;
  margin-bottom: 20px;
}

.victory-stat-box .stat-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.victory-stat-box .stat-val {
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--accent-cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.victory-badge-pill {
  display: inline-block;
  background: rgba(241, 196, 15, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(241, 196, 15, 0.4);
  border-radius: 20px;
  padding: 6px 20px;
  font-weight: bold;
  font-size: 0.95rem;
  margin-bottom: 8px;
  white-space: nowrap;
}

.victory-homo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(46, 213, 115, 0.2), rgba(241, 196, 15, 0.2));
  color: #2ed573;
  border: 1px solid rgba(46, 213, 115, 0.5);
  border-radius: 20px;
  padding: 5px 16px;
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 14px;
  box-shadow: 0 0 12px rgba(46, 213, 115, 0.25);
  animation: homoSoulPulse 2s ease-in-out infinite;
}

.victory-rhyme-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(0, 206, 201, 0.2), rgba(162, 155, 254, 0.2));
  color: #00cec9;
  border: 1px solid rgba(0, 206, 201, 0.5);
  border-radius: 20px;
  padding: 5px 16px;
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 14px;
  box-shadow: 0 0 12px rgba(0, 206, 201, 0.25);
  animation: homoSoulPulse 2s ease-in-out infinite;
}

/* 🔮 詞海八字 · 職業神算卡片 */
.victory-career-box {
  background: linear-gradient(135deg, rgba(165, 94, 234, 0.16), rgba(0, 206, 201, 0.09));
  border: 1px solid rgba(165, 94, 234, 0.45);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 22px;
  text-align: left;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 0 12px rgba(165, 94, 234, 0.12);
}

.career-box-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.career-box-icon {
  font-size: 1.15rem;
}

.career-box-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent-purple);
  letter-spacing: 0.8px;
}

.career-box-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 3px;
  font-family: var(--font-serif, "Noto Serif TC", serif);
  line-height: 1.35;
}

.career-box-desc {
  font-size: 0.84rem;
  color: #cbd5e1;
  line-height: 1.45;
}

/* ========================================== */
/* rud() 按鍵內文字排版與自適應流式律 (Typography Word-Block Flow) */
/* ========================================== */
.victory-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
}

.vic-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  flex: 1 1 0;
  min-width: fit-content;
  min-height: 48px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease, filter 0.16s ease;
}

.vic-action-btn.btn-warning {
  background: linear-gradient(135deg, #d35400, #e67e22);
  color: #ffffff;
  border: 1px solid rgba(243, 156, 18, 0.6);
  box-shadow: 0 4px 14px rgba(211, 84, 0, 0.4);
}

.vic-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  filter: brightness(1.1);
}

.vic-action-btn:active {
  transform: translateY(0);
}

.vic-btn-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.vic-btn-label {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.vic-btn-sub {
  font-size: 0.82em;
  font-weight: 500;
  opacity: 0.88;
  letter-spacing: 0.2px;
  margin-left: 1px;
}

/* ==========================================
   R-UI/UX 空間幾何接管自適應階層 (rud Multi-Tier System)
   ========================================== */
@media (max-width: 1024px) {
  .brand-slogan {
    display: none;
  }
  .status-text-full { display: none !important; }
  .status-text-med { display: inline !important; }
  .status-text-short { display: none !important; }
}

@media (max-width: 768px) {
  /* 0. 行動端根容器彈性滾動接管：徹底破除 100vh 鎖死與無法回捲 */
  html, body {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 1. Header 永駐置頂 (Sticky Header)：毛玻璃背景、杜絕被擠出畫面 */
  header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(21, 25, 35, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    padding: 6px 10px;
    gap: 6px;
  }
  .brand {
    gap: 6px;
    min-width: 0;
  }
  .brand-icon {
    font-size: 1.4rem;
  }
  .brand-title-row {
    gap: 5px;
  }
  .brand h1 {
    font-size: 1.05rem;
  }
  .brand-en {
    display: none;
  }
  .brand-slogan {
    display: none;
  }
  .badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    max-width: none !important;
    white-space: nowrap !important;
  }
  .status-text-full { display: none !important; }
  .status-text-med { display: none !important; }
  .status-text-short { display: inline !important; }

  .nav-tabs {
    gap: 3px;
    flex-shrink: 0;
  }
  .tab-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
    gap: 3px;
    white-space: nowrap !important;
  }
  .tab-icon {
    font-size: 0.9rem;
  }
  .tab-text-full { display: none !important; }
  .tab-text-short { display: inline !important; }
  .btn-text-full, .fs-text-full { display: none !important; }
  .btn-text-short, .fs-text-short { display: inline !important; }

  /* ========================================================= */
  /* 2. rud() 空間接管第一原理：全幅自適應主容器 (No Dead Void) */
  /* ========================================================= */
  html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden !important;
  }

  main {
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 4px 6px;
    gap: 4px;
    display: flex;
    flex-direction: column;
  }

  .battle-grid, .demo-arena-grid {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    gap: 4px;
    position: relative;
  }

  /* 3. 控制面板：單行優先原則 + 抽屜式優雅折疊 */
  .control-bar {
    padding: 3px 6px;
    gap: 4px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  .control-actions-row {
    display: flex;
    gap: 4px;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    margin-left: 0;
  }

  .btn-opt-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 3px 7px !important;
    font-size: 0.78rem !important;
    border-radius: var(--radius-md);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    flex-shrink: 0;
  }

  .btn-opt-toggle.active {
    background: rgba(254, 202, 87, 0.25);
    box-shadow: 0 0 8px rgba(254, 202, 87, 0.4);
  }

  .control-actions-row button {
    padding: 3px 7px;
    font-size: 0.76rem;
    flex: 1;
    white-space: nowrap;
  }

  .control-actions-row button.btn-primary {
    flex: 1.4;
    font-weight: bold;
  }

  .control-options-drawer {
    display: none;
    flex-wrap: wrap;
    gap: 3px 6px;
    padding-top: 4px;
    border-top: 1px dashed var(--bg-card-border);
    animation: drawerSlide 0.2s ease-out;
  }

  .control-options-drawer.open {
    display: flex !important;
  }

  @keyframes drawerSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .control-group {
    font-size: 0.72rem;
    gap: 3px;
  }

  select, input {
    padding: 2px 4px;
    font-size: 0.74rem;
  }

  /* 4. HUD 戰鬥狀態儀表：小型終端三欄收斂，左右兩翼對齊與緊湊血條 */
  .hud-bar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 3px 6px !important;
    min-height: 28px !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
  }

  .hud-player-cell {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex: 1 1 0 !important;
    justify-content: flex-start !important;
    min-width: 0 !important;
  }

  .hud-ai-cell {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex: 1 1 0 !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
  }

  .hud-timer-cell {
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
    flex: 0 0 auto !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .hud-bar .badge-status-romance {
    display: none !important;
  }

  .hud-hp-box {
    width: 28px !important;
    height: 5px !important;
    flex-shrink: 0 !important;
  }

  .hud-timer-box {
    width: 20px !important;
    height: 4px !important;
    flex-shrink: 0 !important;
  }

  #lbl-player-score, #lbl-ai-score {
    font-size: 0.72rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #lbl-timer {
    font-size: 0.75rem !important;
    white-space: nowrap !important;
  }

  .hud-label-full {
    display: none !important;
  }

  .hud-label-compact {
    display: inline !important;
    font-size: 0.72rem !important;
  }

  /* 5. 棋盤主舞台：100% 空間接管，徹底消滅 320px 假高度限制與黑洞死區 */
  .arena-board-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100% !important;
    max-height: none !important;
    padding: 4px;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-md);
  }

  .board-header {
    padding: 1px 4px 3px;
    margin-bottom: 2px;
    flex-shrink: 0;
  }

  .board-header .board-subtitle {
    display: none !important;
  }

  .view-btn {
    padding: 2px 6px;
    font-size: 0.72rem;
  }

  .cross-board-viewport {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    padding: 4px;
    border-radius: var(--radius-sm);
  }

  /* 6. 右上角成語典故視窗 (Wisdom & Zoom Dock) 直版自適應優化 */
  .wisdom-zoom-dock {
    top: 6px !important;
    right: 6px !important;
    max-width: calc(100% - 12px) !important;
    z-index: 50 !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .wisdom-zoom-dock.minimized {
    width: auto;
    background: rgba(18, 24, 38, 0.94);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    border-radius: 20px;
  }

  .wisdom-zoom-dock.minimized .wisdom-dock-header {
    padding: 2px 6px;
    gap: 4px;
  }

  .wisdom-drag-handle {
    font-size: 0.72rem;
    padding: 1px 2px;
  }

  .wisdom-mini-target {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
  }

  .zoom-controls-row {
    gap: 2px;
  }

  .zoom-btn {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }

  .zoom-level {
    font-size: 0.62rem;
    padding: 0 1px;
  }

  .btn-wisdom-minimize {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
  }

  .wisdom-zoom-dock:not(.minimized) {
    width: min(320px, calc(100% - 12px));
    max-height: 230px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85);
  }

  .wisdom-zoom-dock:not(.minimized) .wisdom-content {
    max-height: 180px;
    overflow-y: auto;
    padding: 4px 6px;
  }

  .wisdom-target-banner {
    padding: 4px 6px;
    gap: 6px;
  }

  .wisdom-target-banner .target-char {
    width: 28px;
    height: 28px;
    font-size: 1.05rem;
  }

  .wisdom-target-details .target-prev-word {
    font-size: 0.72rem;
  }

  .wisdom-target-details .target-radar-pill {
    font-size: 0.68rem;
    padding: 1px 4px;
  }

  .wisdom-content .story-card {
    padding: 4px 6px;
  }

  .wisdom-content .story-title {
    font-size: 0.74rem;
  }

  .wisdom-content .story-body {
    font-size: 0.68rem;
    max-height: 70px;
  }

  /* 7. 底部即時心戰與輸入出招列：浮動置底，不擠壓棋盤主視窗 */
  .action-dock-container {
    position: absolute;
    bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 8px);
    max-width: 480px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
  }

  .action-dock-container > * {
    pointer-events: auto;
  }

  .live-banter-card {
    padding: 3px 6px;
    margin-top: 0;
    border-radius: var(--radius-md);
  }

  .banter-speaker-icon {
    font-size: 0.82rem;
  }

  .banter-text {
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .input-dock {
    margin-top: 0;
    gap: 4px;
    display: flex;
  }

  .input-dock input {
    font-size: 0.84rem;
    padding: 5px 8px;
    height: 34px;
  }

  .input-dock button {
    padding: 0 12px;
    font-size: 0.82rem;
    height: 34px;
    white-space: nowrap;
  }

  .demo-dock-bar {
    gap: 4px;
  }

  .demo-dock-bar button {
    padding: 4px 8px;
    font-size: 0.76rem;
  }
}

@media (max-width: 580px) {
  /* 品牌副標在極窄螢幕隱藏，保留核心 Title 與詞庫 Badge */
  .brand-slogan {
    display: none !important;
  }
  .brand-en {
    display: none !important;
  }
  .brand h1 {
    font-size: 1.05rem !important;
  }
  .brand-icon {
    font-size: 1.25rem !important;
  }

  .modal-card.victory-card {
    padding: 26px 14px 18px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .victory-title {
    font-size: 1.5rem;
  }

  .victory-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 10px 8px;
  }

  .victory-actions {
    flex-direction: column;
    gap: 8px;
  }

  .vic-action-btn {
    width: 100%;
    flex: none;
    min-height: 42px;
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

/* ==========================================
   全螢幕屏保禪境模式 (Fullscreen Zen Screensaver Mode)
   完全乾淨純粹：只保留縱橫交錯棋盤與動態字陣（完美符合 Image 3）
   ========================================== */
html:has(body.fullscreen-zen),
body.fullscreen-zen {
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--bg-main, #0b0f19) !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

/* 徹底消除極端縮放 (如 500%) 下出現的右側與底部原生粗糙滾動條 */
html:has(body.fullscreen-zen)::-webkit-scrollbar,
body.fullscreen-zen::-webkit-scrollbar,
body.fullscreen-zen *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

body.fullscreen-zen,
body.fullscreen-zen * {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

/* 隱藏全體頁首導航、工具列、儀表、對白與控制埠 */
body.fullscreen-zen header,
body.fullscreen-zen .control-bar,
body.fullscreen-zen .hud-bar,
body.fullscreen-zen .board-header,
body.fullscreen-zen .wisdom-zoom-dock,
body.fullscreen-zen .action-dock-container,
body.fullscreen-zen .demo-dock-bar,
body.fullscreen-zen .table-stream-viewport,
body.fullscreen-zen #table-stream-viewport,
body.fullscreen-zen #integrated-hud-battle,
body.fullscreen-zen #integrated-hud-demo,
body.fullscreen-zen .target-card,
body.fullscreen-zen .demo-stage-card,
body.fullscreen-zen #live-banter-card,
body.fullscreen-zen #input-dock-human,
body.fullscreen-zen #hint-action-bar,
body.fullscreen-zen footer {
  display: none !important;
}

/* 主容器接管 100% 視窗，零邊界零留白 */
body.fullscreen-zen main {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background: transparent !important;
}

/* 嚴格隔離非對戰分頁（詞海手冊與舊相容層） */
body.fullscreen-zen #tab-learned,
body.fullscreen-zen #tab-demo,
body.fullscreen-zen .tab-pane:not(#tab-battle) {
  display: none !important;
}

body.fullscreen-zen #tab-battle.tab-pane {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

body.fullscreen-zen .battle-grid,
body.fullscreen-zen .demo-arena-grid {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  border: none !important;
  background: transparent !important;
}

body.fullscreen-zen .arena-board-container {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  flex: 1 1 100% !important;
}

body.fullscreen-zen .cross-board-viewport {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  flex: 1 1 100% !important;
  background-image: none !important; /* 全螢幕禪境模式讓位給動態漣漪格線與微光方格 */
}

/* 全螢幕動態禪境畫布 (Zen Ambient Atmosphere Canvas) */
.zen-ambient-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  display: none;
}

body.fullscreen-zen .zen-ambient-canvas {
  display: block !important;
}

.cross-board-grid {
  position: relative;
  z-index: 2;
}

/* 觀戰屏保專用半透明浮動退出鈕 (滑鼠移入或觸控時浮現) */
.zen-exit-btn {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.6);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  opacity: 0.3;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, transform 0.2s ease;
}

.zen-exit-btn:hover, .zen-exit-btn:active {
  opacity: 1 !important;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  border-color: var(--accent-cyan);
  transform: scale(1.04);
}

body.fullscreen-zen .zen-exit-btn {
  display: block !important;
}

/* 全螢幕觀戰滑鼠閒置自動淡出與游標隱形 (Auto-hide Cursor on Idle) */
body.fullscreen-zen.zen-cursor-fading .zen-exit-btn {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.8s ease-out !important;
}

body.fullscreen-zen.zen-cursor-hidden,
body.fullscreen-zen.zen-cursor-hidden * {
  cursor: none !important;
}

body.fullscreen-zen.zen-cursor-hidden .zen-exit-btn {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ==========================================
   極端橫向螢幕自適應 (Ultra-Wide / Mobile Landscape: max-height: 560px)
   完美應對: Samsung Galaxy Z Flip 5 橫放 (22:9)、iPhone 橫向、手機摺疊半折等極矮寬屏
   ========================================== */
@media (orientation: landscape) and (max-height: 560px) {
  html, body {
    height: 100% !important;
    overflow-y: auto !important;
  }

  header {
    padding: 2px 10px !important;
  }
  .brand-icon { font-size: 1.1rem !important; }
  .brand h1 { font-size: 0.92rem !important; }
  .brand-slogan { display: none !important; }
  .badge { font-size: 0.62rem !important; padding: 1px 5px !important; }
  .tab-btn { padding: 3px 8px !important; font-size: 0.74rem !important; }

  main {
    padding: 3px 8px !important;
  }

  .control-bar {
    padding: 2px 6px !important;
    gap: 4px !important;
    margin-bottom: 3px !important;
  }
  .control-bar button {
    padding: 2px 8px !important;
    font-size: 0.74rem !important;
  }

  /* 橫向模式：全幅接龍主舞台 */
  .battle-grid, .demo-arena-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    height: calc(100vh - 78px) !important;
    min-height: 240px !important;
    overflow: hidden !important;
  }

  .arena-board-container {
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 1 0 !important;
    padding: 4px 8px !important;
  }

  .cross-board-viewport {
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 1 0 !important;
  }
}

/* ==========================================
   4K 旗艦超寬螢幕全方位自適應最佳化 (4K & Ultra-Wide: min-width: 2000px)
   徹底解放 4K/QHD 空間，消除兩側黑邊，文字、血條與操作塢大氣呈現
   ========================================== */
@media (min-width: 2000px) {
  :root {
    --hud-hp-width: 260px;
    --hud-hp-height: 16px;
    --hud-timer-width: 160px;
    --hud-timer-height: 12px;
    --dock-max-width: 1080px;
    --wisdom-dock-width: 400px;
  }

  header {
    padding: 12px 28px !important;
  }
  .brand-icon {
    font-size: 1.6rem !important;
  }
  .brand h1 {
    font-size: 1.4rem !important;
  }
  .brand-slogan {
    font-size: 0.95rem !important;
  }
  .tab-btn {
    font-size: 1.05rem !important;
    padding: 8px 18px !important;
  }

  main {
    padding: 12px 24px !important;
  }

  /* HUD 戰鬥狀態列放大 */
  .hud-bar {
    padding: 10px 20px !important;
    min-height: 52px !important;
  }
  .hud-player-cell, .hud-ai-cell, .hud-timer-cell {
    gap: 12px !important;
  }
  #lbl-player-score, #lbl-ai-score {
    font-size: 1.15rem !important;
  }
  #lbl-timer {
    font-size: 1.25rem !important;
  }
  .badge-status-romance {
    font-size: 0.95rem !important;
    padding: 4px 10px !important;
  }

  /* 控制面板控制列 */
  .control-bar {
    padding: 8px 18px !important;
    gap: 12px !important;
  }
  .control-group {
    font-size: 1.05rem !important;
    gap: 8px !important;
  }
  select, input, button {
    font-size: 1.0rem !important;
    padding: 7px 14px !important;
  }
  .btn-opt-toggle {
    font-size: 1.0rem !important;
    padding: 7px 14px !important;
  }

  /* 棋盤標題與工具按鈕 */
  .board-header {
    padding: 8px 16px !important;
  }
  .board-title {
    font-size: 1.25rem !important;
  }
  .view-btn {
    font-size: 1.05rem !important;
    padding: 6px 14px !important;
  }

  /* 右上角典故小箋 */
  .wisdom-zoom-dock {
    width: var(--wisdom-dock-width, 400px) !important;
  }
  .wisdom-dock-header {
    padding: 10px 14px !important;
  }
  .wisdom-dock-title {
    font-size: 1.15rem !important;
  }
  .wisdom-content {
    font-size: 1.05rem !important;
    line-height: 1.6 !important;
  }

  /* 底部出招塢 Action Dock */
  .action-dock-container {
    width: min(var(--dock-max-width, 1080px), calc(100% - 48px)) !important;
    bottom: 20px !important;
    gap: 10px !important;
  }
  .input-dock {
    padding: 8px 14px !important;
    border-radius: var(--radius-lg) !important;
  }
  .input-dock input {
    font-size: 1.25rem !important;
    height: 52px !important;
  }
  .input-dock button {
    font-size: 1.15rem !important;
    height: 52px !important;
    padding: 0 26px !important;
  }
  .live-banter-card {
    font-size: 1.1rem !important;
    padding: 10px 18px !important;
  }

  /* 勝利結算彈窗 */
  .modal-card.victory-card {
    max-width: 920px !important;
    width: min(920px, 94vw) !important;
    padding: 44px 36px 36px !important;
  }
  .victory-seal-stamp {
    font-size: 1.15rem !important;
    padding: 6px 14px !important;
  }
  .victory-crown {
    font-size: 3.8rem !important;
  }
  .victory-title {
    font-size: 2.2rem !important;
  }
  .victory-subtitle {
    font-size: 1.25rem !important;
  }
  .victory-score-vs-pill {
    font-size: 1.15rem !important;
    padding: 6px 20px !important;
  }
  .victory-stat-box {
    padding: 16px 14px !important;
  }
  .victory-stat-box .stat-lbl {
    font-size: 0.95rem !important;
  }
  .victory-stat-box .stat-val {
    font-size: 1.6rem !important;
  }
  .victory-badge-pill {
    font-size: 1.1rem !important;
    padding: 8px 20px !important;
  }
  .victory-career-box {
    padding: 18px 22px !important;
  }
  .career-box-title {
    font-size: 1.25rem !important;
  }
  .career-box-desc {
    font-size: 1.05rem !important;
  }
  .vic-action-btn {
    font-size: 1.1rem !important;
    padding: 10px 22px !important;
  }
}


