:root {
  --bg-gradient: linear-gradient(145deg, #0b1120 0%, #1e1b4b 50%, #0f172a 100%);
  --board-bg: #1d4ed8;
  --board-border: #1e3a8a;
  --board-shadow: #172554;
  --slot-bg: #090d16;
  --red-color: #ef4444;
  --red-gradient: radial-gradient(circle at 35% 35%, #fca5a5 0%, #ef4444 45%, #991b1b 100%);
  --yellow-color: #eab308;
  --yellow-gradient: radial-gradient(circle at 35% 35%, #fef08a 0%, #eab308 45%, #854d0e 100%);
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #38bdf8;
  --accent-green: #22c55e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  touch-action: manipulation;
}

/* 遊戲主容器（模擬手機直式螢幕） */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top, 10px) 14px env(safe-area-inset-bottom, 12px) 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

/* 頂部列 */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  height: 48px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(56, 189, 248, 0.5);
}

.version-tag {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.2px;
  text-shadow: none;
  line-height: 1.2;
  user-select: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, background 0.2s;
}

.icon-btn:active {
  transform: scale(0.92);
}

.net-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.status-p2p .badge-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.status-matching .badge-dot {
  background: #38bdf8;
  animation: pulse 1.2s infinite;
}
.status-offline .badge-dot {
  background: #ef4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

/* 計分板區塊 */
.scoreboard-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-card.active-turn {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.player-avatar {
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-details {
  display: flex;
  flex-direction: column;
}

.player-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.player-score {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.turn-indicator {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-green);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  display: none;
  white-space: nowrap;
}

.player-card.active-turn .turn-indicator {
  display: block;
}

.vs-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.vs-text {
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timer-badge {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: monospace;
  transition: all 0.2s ease;
}

.timer-badge.urgent {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.7) !important;
  background: rgba(239, 68, 68, 0.2) !important;
  animation: turnTimerPulse 0.5s ease-in-out infinite alternate;
}

@keyframes turnTimerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.chemapao-theme .timer-badge {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: #fde68a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 遊戲狀態橫幅 */
.game-status-banner {
  text-align: center;
  font-size: 0.85rem;
  color: var(--accent-color);
  font-weight: 600;
  margin: 6px 0;
  min-height: 20px;
}

/* 棋盤整體包裝（專為手機直式比例） */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: auto 0;
}

/* 上方落子提示導軌 */
.column-indicators {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  max-width: 420px;
  height: 28px;
  padding: 0 8px;
  margin-bottom: 4px;
}

.col-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.drop-arrow {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid transparent;
  transition: transform 0.2s, border-top-color 0.2s;
}

.col-indicator.active .drop-arrow {
  transform: translateY(4px);
}

.col-indicator.active.red-turn .drop-arrow {
  border-top-color: var(--red-color);
}

.col-indicator.active.yellow-turn .drop-arrow {
  border-top-color: var(--yellow-color);
}

/* 四子棋主體藍色盤面 */
.connect4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 7 / 6;
  background: var(--board-bg);
  padding: 10px;
  border-radius: 20px;
  border: 4px solid var(--board-border);
  box-shadow: 0 16px 36px var(--board-shadow), inset 0 2px 6px rgba(255, 255, 255, 0.3);
  position: relative;
}

/* 單個棋孔 (Slot) */
.cell {
  position: relative;
  background: var(--slot-bg);
  border-radius: 50%;
  box-shadow: inset 0 6px 10px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(255, 255, 255, 0.2);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 棋子 (Disk) */
.disk {
  width: 90%;
  height: 90%;
  border-radius: 50%;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  position: absolute;
}

.disk.red {
  background: var(--red-gradient);
  border: 2px solid #b91c1c;
}

.disk.yellow {
  background: var(--yellow-gradient);
  border: 2px solid #a16207;
}

/* 落子動畫 (帶回彈手感) */
.disk.drop-anim {
  animation: dropDisk 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.2) forwards;
}

@keyframes dropDisk {
  0% {
    transform: translateY(var(--drop-from, -320px)) scaleY(1.1);
    opacity: 0.8;
  }
  75% {
    transform: translateY(0) scaleY(0.85);
  }
  90% {
    transform: translateY(-6px) scaleY(1.05);
  }
  100% {
    transform: translateY(0) scaleY(1);
    opacity: 1;
  }
}

/* 連線獲勝高亮閃爍動畫 */
.cell.win-cell .disk {
  animation: winGlow 1s ease-in-out infinite alternate;
  z-index: 5;
}

@keyframes winGlow {
  0% {
    box-shadow: 0 0 10px #fff, 0 0 20px #facc15;
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 18px #fff, 0 0 32px #facc15;
    transform: scale(1.08);
  }
}

/* 底部操作與表情互動列 */
.bottom-action-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}

.quick-emojis {
  display: flex;
  justify-content: space-around;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 6px;
  backdrop-filter: blur(8px);
}

.emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.45rem;
  padding: 4px 8px;
  cursor: pointer;
  transition: transform 0.15s;
}

.emoji-btn:active {
  transform: scale(1.4);
}

.game-action-buttons {
  display: flex;
  gap: 10px;
}

/* 通用按鈕元件 */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--card-border);
}

.btn-accent {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.btn-lg {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* 浮動表情符號動畫 */
#floating-emoji-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

.floating-emoji {
  position: absolute;
  font-size: 2.5rem;
  bottom: 80px;
  animation: floatUp 1.8s ease-out forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  50% {
    transform: translateY(-160px) scale(1.3) rotate(15deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-340px) scale(1.6) rotate(-10deg);
  }
}

/* 彩帶畫布 */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

/* 彈窗對話框與大廳 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 29, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  animation: fadeIn 0.25s ease-out;
}

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

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.btn-close-modal:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
  transform: scale(1.05);
}

.modal-header h2 {
  font-size: 1.35rem;
  text-align: center;
  color: #fff;
}

.modal-header .subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent-color);
  margin-top: 4px;
}

.lobby-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 12px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--card-bg);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.tab-pane {
  display: none;
}

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

.random-match-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 0;
}

.match-icon-pulse {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 2rem;
}

.match-vs {
  font-family: 'Fredoka', cursive, sans-serif;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.room-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sub-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-card h3 {
  font-size: 0.95rem;
  color: #fff;
}

.sub-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-badge {
  font-family: monospace;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  color: #facc15;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(250, 204, 21, 0.4);
}

.waiting-spinner-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--accent-color);
  margin-top: 6px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.divider-text {
  text-align: center;
  position: relative;
}

.divider-text span {
  background: #1e293b;
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
}

.input-group input:focus {
  outline: none;
  border-color: #3b82f6;
}

.modal-footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.small-modal {
  text-align: center;
  gap: 14px;
}

.modal-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.modal-btn-row .btn {
  flex: 1;
}

/* =========================================
   遊戲切換導航膠囊 (Game Switch Bar)
   ========================================= */
.game-switch-bar {
  display: flex;
  gap: 4px;
  justify-content: flex-start;
  margin-bottom: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.game-switch-bar::-webkit-scrollbar {
  display: none;
}

.game-switch-btn {
  flex: 1;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 9999px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.game-switch-btn:hover {
  color: #fff;
}

.game-switch-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

/* =========================================
   井字棋 (Tic-Tac-Toe) 專屬樣式
   ========================================= */
.ttt-x-card.active-turn {
  border-color: #f43f5e;
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.4);
}

.ttt-o-card.active-turn {
  border-color: #06b6d4;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.4);
}

.ttt-avatar-x {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  font-weight: 900;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.ttt-avatar-o {
  background: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
  font-weight: 900;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(6, 182, 212, 0.4);
}

.ttt-board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex: 1;
  padding: 12px 0;
  position: relative;
}

.ttt-board {
  width: 100%;
  max-width: 330px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  background: rgba(15, 23, 42, 0.7);
  padding: 12px;
  border-radius: 24px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.4);
  position: relative;
  backdrop-filter: blur(14px);
}

.ttt-cell {
  background: rgba(30, 41, 59, 0.65);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.ttt-cell:not(.occupied):hover {
  background: rgba(51, 65, 85, 0.7);
  border-color: rgba(255, 255, 255, 0.2);
}

.ttt-cell:not(.occupied):active {
  transform: scale(0.93);
  background: rgba(71, 85, 105, 0.8);
}

.ttt-cell.occupied {
  cursor: default;
}

.piece-x {
  color: #f43f5e;
  font-size: 3.2rem;
  font-weight: 900;
  font-family: 'Fredoka', sans-serif;
  text-shadow: 0 0 16px rgba(244, 63, 94, 0.8), 0 0 30px rgba(244, 63, 94, 0.4);
  animation: popIn 0.24s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  line-height: 1;
}

.piece-o {
  color: #06b6d4;
  font-size: 3.2rem;
  font-weight: 900;
  font-family: 'Fredoka', sans-serif;
  text-shadow: 0 0 16px rgba(6, 182, 212, 0.8), 0 0 30px rgba(6, 182, 212, 0.4);
  animation: popIn 0.24s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  line-height: 1;
}

@keyframes popIn {
  0% { transform: scale(0.2) rotate(-15deg); opacity: 0; }
  80% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.ttt-cell.win-cell {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.3);
  animation: winPulse 1.2s infinite alternate;
}

/* 勝利劃線 SVG */
.ttt-strike-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

#strike-line {
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.2s;
}

#strike-line.visible {
  opacity: 1;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: strikeDraw 0.35s ease forwards;
}

@keyframes strikeDraw {
  to {
    stroke-dashoffset: 0;
  }
}

#strike-line.strike-x {
  stroke: #f43f5e;
  filter: drop-shadow(0 0 8px #f43f5e) drop-shadow(0 0 18px rgba(244, 63, 94, 0.8));
}

#strike-line.strike-o {
  stroke: #06b6d4;
  filter: drop-shadow(0 0 8px #06b6d4) drop-shadow(0 0 18px rgba(6, 182, 212, 0.8));
}

.ttt-symbol-glow {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
}

.x-glow {
  color: #f43f5e;
  text-shadow: 0 0 14px rgba(244, 63, 94, 0.8);
}

.o-glow {
  color: #06b6d4;
  text-shadow: 0 0 14px rgba(6, 182, 212, 0.8);
}

.ai-robot-icon, .local-icon {
  font-size: 2.2rem;
}

.difficulty-selector {
  display: flex;
  gap: 10px;
  margin: 12px 0 16px 0;
  justify-content: center;
}

.diff-option input {
  display: none;
}

.diff-chip {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.diff-option input:checked + .diff-chip {
  background: rgba(56, 189, 248, 0.25);
  color: #fff;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.c4-mode-tabs,
.ttt-mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.c4-mode-tabs .tab-btn,
.ttt-mode-tabs .tab-btn {
  font-size: 0.8rem;
  padding: 8px 4px;
}

/* =========================================
   離線小恐龍 (Chrome Dino Runner) 專屬樣式
   ========================================= */
.dino-container {
  max-width: 480px;
}

/* 1. 單人模式：三欄式頂部計分板 */
.dino-solo-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  margin-bottom: 6px;
}

.dino-stat-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.dino-stat-col .stat-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
}

.dino-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  transition: all 0.2s;
}

.dino-timer-pill.urgent {
  background: rgba(244, 63, 94, 0.25);
  border-color: #f43f5e;
  color: #f43f5e;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
  animation: pulseUrgent 0.5s alternate infinite ease-in-out;
}

@keyframes pulseUrgent {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.dino-hi-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.82rem;
  color: #facc15;
  letter-spacing: 1px;
}

.dino-score-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.95rem;
  color: #38bdf8;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* 2. 雙人線上對戰：三欄式頂部對戰板 */
.dino-battle-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  margin-bottom: 6px;
}

.dino-player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.25s ease;
}

.dino-player-card.p1-card {
  border-left: 3px solid #38bdf8;
}

.dino-player-card.p2-card {
  border-right: 3px solid #f43f5e;
}

.dino-player-card.leading {
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.4);
  border-color: rgba(250, 204, 21, 0.7);
}

.dino-player-card .player-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.player-avatar-dino {
  font-size: 0.95rem;
}

.p1-color {
  filter: drop-shadow(0 0 4px #38bdf8);
}

.p2-color {
  filter: drop-shadow(0 0 4px #f43f5e);
}

.dino-player-card .player-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.p1-card .player-score {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.p2-card .player-score {
  color: #f43f5e;
  text-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}

.dino-player-card .player-substats {
  display: flex;
  gap: 8px;
  font-size: 0.7rem;
  color: #94a3b8;
}

.dino-battle-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.battle-vs-badge {
  font-family: 'Fredoka', cursive, sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dino-battle-timer-pill {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f59e0b;
  font-family: monospace;
}

.dino-battle-timer-pill.urgent {
  color: #f43f5e;
  animation: pulseUrgent 0.5s alternate infinite ease-in-out;
}

/* 3. 主畫布與像素 CRT 圓角外框 */
.dino-canvas-wrapper {
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.4);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(14px);
  margin-bottom: 6px;
}

#dino-canvas {
  width: 100%;
  height: auto;
  max-width: 600px;
  display: block;
  aspect-ratio: 600 / 240;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

/* 4. 精巧不溢出的畫布浮層 */
.dino-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 17, 32, 0.88);
  backdrop-filter: blur(6px);
  z-index: 10;
  text-align: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.dino-overlay .overlay-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
  animation: bounceDino 1.2s infinite alternate ease-in-out;
}

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

.dino-overlay h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}

.dino-overlay .control-tip {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 90%;
  line-height: 1.3;
}

.start-btn-pill {
  margin-top: 8px;
  display: inline-block;
  padding: 5px 14px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.3) 0%, rgba(37, 99, 235, 0.4) 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.gameover-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #f43f5e;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-shadow: 0 0 16px rgba(244, 63, 94, 0.8);
}

.gameover-score-row {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.gameover-score-row strong {
  color: #38bdf8;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.92rem;
}

.gameover-stats {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gameover-stats b {
  color: #f8fafc;
}

.gameover-battle-table {
  width: 100%;
  max-width: 320px;
  margin: 4px 0 6px;
  background: rgba(30, 41, 59, 0.75);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
}

.battle-result-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.res-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.res-col .res-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
}

.res-col .res-num {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  font-weight: 900;
}

.res-my .res-num {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.res-opp .res-num {
  color: #f43f5e;
  text-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}

.res-col .res-detail {
  font-size: 0.65rem;
  color: #94a3b8;
}

.res-vs {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.9rem;
  font-weight: 900;
  color: #facc15;
}

.dino-restart-btn {
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 6px 18px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
  transition: transform 0.15s, box-shadow 0.2s;
}

.dino-restart-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.6);
}

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

.restart-icon {
  font-size: 1rem;
  font-weight: 900;
}

/* 5. 底部操作區與控制鍵 */
.dino-bottom-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 6px 0;
}

.dino-emojis {
  margin-bottom: 2px;
  width: 100%;
  justify-content: space-around;
}

.mobile-controls-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-ctrl-jump,
.btn-ctrl-duck {
  flex: 1;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.1s, background 0.15s;
}

.btn-ctrl-jump {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.3) 0%, rgba(37, 99, 235, 0.4) 100%);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.2);
}

.btn-ctrl-jump:active {
  transform: scale(0.94);
  background: rgba(56, 189, 248, 0.5);
}

.btn-ctrl-duck {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-ctrl-duck:active {
  transform: scale(0.94);
  background: rgba(51, 65, 85, 0.9);
}

.btn-icon {
  font-size: 1.1rem;
}

.dino-tips-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.dino-avatar-pulse {
  font-size: 2.4rem;
  animation: bounceDino 1.2s infinite alternate ease-in-out;
}

.p1-pulse {
  filter: drop-shadow(0 0 10px #38bdf8);
}

.p2-pulse {
  filter: drop-shadow(0 0 10px #f43f5e);
}

/* ==========================================================================
   語音對話 (WebRTC Voice Chat) 樣式
   ========================================================================== */
.mic-btn {
  position: relative;
  transition: all 0.2s ease;
  user-select: none;
}

/* 關閉/準備狀態 (預設) */
.mic-btn.off {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: #94a3b8;
}

.mic-btn.off:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #f8fafc;
}

/* 麥克風已開啟通話中 (亮綠色光暈) */
.mic-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid #10b981;
  color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* 正在說話時的擴散漣漪動畫 */
.mic-btn.speaking {
  animation: micPulse 0.9s infinite alternate ease-in-out;
  border-color: #34d399;
}

@keyframes micPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
  }
  100% {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.9);
  }
}

/* 麥克風已靜音 (紅色警告感) */
.mic-btn.muted {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid #ef4444;
  color: #ef4444;
}

/* 玩家說話時頭像波紋光環 */
.player-avatar.speaking,
.player-avatar-dino.speaking,
.ttt-avatar-x.speaking,
.ttt-avatar-o.speaking {
  box-shadow: 0 0 0 3px #10b981, 0 0 16px rgba(16, 185, 129, 0.7) !important;
  animation: speakingGlow 0.8s infinite alternate ease-in-out;
}

@keyframes speakingGlow {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

/* 語音通話懸浮提示 (Toast) */
.voice-toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}

.voice-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   紅白機公路賽車 (Road Fighter 8-Bit) 專屬樣式
   ========================================================================== */
.roadfighter-theme {
  --rf-bg: #090c10;
  --rf-red: #d82800;
  --rf-gold: #fce000;
  --rf-cyan: #00e8d8;
  --rf-blue: #0078f8;
}

.roadfighter-container {
  max-width: 480px;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
  .roadfighter-container.battle-active.layout-split {
    max-width: 880px;
  }
}

/* 1. 單人模式三欄式頂部計分板 - 緊湊精簡型 */
.rf-solo-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.1fr;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  margin-bottom: 4px;
}

.rf-stat-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.rf-stat-col .stat-label {
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 600;
  line-height: 1;
}

.rf-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(252, 224, 0, 0.15);
  border: 1px solid rgba(252, 224, 0, 0.4);
  padding: 2px 6px;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fce000;
  white-space: nowrap;
}

.rf-hi-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  color: #f43f5e;
  letter-spacing: 0.5px;
}

.rf-score-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  color: #22c55e;
  letter-spacing: 0.5px;
}

/* 2. 線上雙人對戰資訊面板 - 極致輕量扁平條 (專為直式手機省空間) */
.rf-battle-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  margin-bottom: 3px;
}

.rf-player-card {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
}

.rf-player-card.p1-card {
  border-color: rgba(239, 68, 68, 0.35);
}

.rf-player-card.p2-card {
  border-color: rgba(56, 189, 248, 0.35);
}

.rf-player-card .player-header {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.player-avatar-car {
  font-size: 0.8rem;
  line-height: 1;
  display: inline-block;
  flex-shrink: 0;
}

.rf-player-card .player-name {
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.p1-card .player-name { color: #f87171; }
.p2-card .player-name { color: #38bdf8; }

.player-metrics {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.54rem;
  line-height: 1.1;
  margin-top: 1px;
}

.metric-dist {
  color: #fff;
  font-weight: bold;
}

.metric-speed {
  font-size: 0.48rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rf-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 1px;
}

.rf-progress-bar {
  height: 100%;
  transition: width 0.1s linear;
}

.p1-progress-bar {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.p2-progress-bar {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.rf-battle-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0 2px;
  flex-shrink: 0;
}

.battle-vs-badge {
  font-size: 0.52rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 800;
  line-height: 1;
}

.rf-stage-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: #fce000;
  white-space: nowrap;
  margin-top: 1px;
}

.roadfighter-theme .game-status-banner {
  margin: 2px 0 3px 0;
  font-size: 0.72rem;
  min-height: 16px;
  line-height: 1.2;
}

.roadfighter-theme .top-nav {
  padding-bottom: 2px;
}

.roadfighter-theme .game-switch-bar {
  padding: 3px 0;
  margin-bottom: 3px;
}

/* 3. 街機主畫布容器 */
.rf-canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  margin-bottom: 3px;
}

.rf-arcade-toolbar {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #111827;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: nowrap;
  overflow-x: auto;
}

.rf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rf-sub-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.rf-sub-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.rf-sub-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

.rf-sub-btn.rf-btn-accent {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fca5a5;
}

.rf-sub-btn.rf-btn-accent:hover {
  background: rgba(239, 68, 68, 0.38);
  color: #fff;
}

.roadfighter-container {
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  padding: env(safe-area-inset-top, 6px) 10px env(safe-area-inset-bottom, 8px) 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  overflow: hidden;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
  .roadfighter-container.battle-active.layout-split {
    max-width: 880px;
  }
}

.screen-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1 1 0;
  min-height: 0;
  max-width: 480px;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =========================================================================
   對戰排版模式 1：子母畫面 (PiP 畫中畫浮動小電視 - 手機預設)
   ========================================================================= */
.screen-wrapper.battle-pip-mode {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2px;
}

.screen-wrapper.battle-pip-mode #viewport-p1 {
  width: 100%;
  height: 100%;
  max-width: 460px;
}

.screen-wrapper.battle-pip-mode #viewport-p2 {
  position: absolute;
  top: 8px;
  right: 8px;
  width: clamp(96px, 28vw, 122px) !important;
  height: auto !important;
  max-height: fit-content !important;
  flex: 0 0 auto !important;
  z-index: 35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.95), 0 0 0 1.5px #38bdf8, 0 0 12px rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.screen-wrapper.battle-pip-mode #viewport-p2:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.95), 0 0 0 2px #00e8d8, 0 0 16px rgba(0, 232, 216, 0.6);
}

.screen-wrapper.battle-pip-mode #viewport-p2:active {
  transform: scale(0.96);
}

.screen-wrapper.battle-pip-mode #viewport-p2 .rf-viewport-header {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  padding: 2px 5px;
  margin-bottom: 0;
  font-size: 0.52rem;
  line-height: 1.1;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 0;
  flex-shrink: 0;
  height: auto !important;
}

.screen-wrapper.battle-pip-mode #viewport-p2 .rf-view-title {
  font-size: 0.52rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 3px;
}

.screen-wrapper.battle-pip-mode #viewport-p2 .rf-view-badge {
  display: none !important;
}

.screen-wrapper.battle-pip-mode #viewport-p2 .canvas-aspect-frame {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 256 / 240 !important;
  flex: none !important;
  min-height: 0 !important;
  position: relative !important;
  display: block !important;
  container-type: normal !important; /* 核心：覆寫消除 size containment，允許 aspect-ratio 撐開實際高度 */
  overflow: hidden !important;
}

.screen-wrapper.battle-pip-mode #viewport-p2 .canvas-crt-box {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 256 / 240 !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  border-radius: 0 !important;
  display: block !important;
  box-shadow: none !important;
}

.screen-wrapper.battle-pip-mode #viewport-p2 #opponentCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-fit: fill !important;
  background: #000;
}

/* =========================================================================
   對戰排版模式 2：左右並排 (Split 左右雙屏 - 電腦預設)
   ========================================================================= */
.screen-wrapper.battle-split-mode {
  max-width: 880px;
  height: 100%;
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
  padding: 4px;
}

.rf-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen-wrapper.battle-split-mode .rf-viewport-wrapper {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.rf-viewport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 440px;
  flex-shrink: 0;
  padding: 4px 8px;
  margin-bottom: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
}

.rf-view-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
}

.view-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.my-dot {
  background: #00e800;
  box-shadow: 0 0 8px #00e800;
}

.opp-dot {
  background: #00b0ff;
  box-shadow: 0 0 8px #00b0ff;
}

.rf-view-badge {
  font-size: 0.52rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.my-badge {
  background: rgba(0, 232, 0, 0.15);
  color: #54fc54;
  border: 1px solid rgba(0, 232, 0, 0.3);
}

.opp-badge {
  background: rgba(0, 176, 255, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(0, 176, 255, 0.3);
}

/* 賽車畫布自適應容器：容器查詢 size 支援縱向與橫向動態縮放 */
.canvas-aspect-frame {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.canvas-crt-box {
  position: relative;
  aspect-ratio: 256 / 240;
  width: min(100cqw, calc(100cqh * 256 / 240));
  height: min(100cqh, calc(100cqw * 240 / 256));
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#gameCanvas, #opponentCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* CRT 濾鏡效果套用於每個 canvas-crt-box 視口 */
.screen-wrapper.crt-active .canvas-crt-box::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.75);
}

/* 4. 浮層 Overlay (起始/結算) */
.rf-overlay {
  position: absolute;
  top: 32px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 20;
  padding: 16px;
  text-align: center;
  cursor: pointer;
}

.rf-title-logo {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.4rem;
  color: #fce000;
  text-shadow: 2px 2px 0px #d82800, 0 0 12px rgba(252, 224, 0, 0.6);
  letter-spacing: 2px;
}

.rf-title-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: #00e8d8;
  letter-spacing: 2px;
}

.rf-title-car-preview {
  font-size: 2.2rem;
  animation: pulseCar 1.2s infinite alternate ease-in-out;
}

@keyframes pulseCar {
  0% { transform: scale(1); filter: drop-shadow(0 0 5px #d82800); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 16px #fce000); }
}

.rf-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #d82800, #b91c1c);
  color: #fff;
  border: 1px solid #f87171;
  padding: 10px 24px;
  border-radius: 9999px;
  font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(216, 40, 0, 0.5);
  transition: all 0.2s ease;
}

.rf-restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(216, 40, 0, 0.7);
}

/* 5. 手機虛擬街機按鍵 */
.rf-mobile-controls {
  display: flex;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  flex-shrink: 0;
}

.dpad-group, .gear-group {
  display: flex;
  gap: 8px;
}

.touch-btn {
  background: #1e2633;
  color: #fff;
  border: 2px solid #364459;
  border-radius: 14px;
  min-height: 72px; /* 高度加高 1.5 倍 (原約 46-48px) */
  min-width: 72px;
  padding: 12px 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 5px 0 #0f141c;
  transition: transform 0.05s, box-shadow 0.05s;
}

.touch-btn span {
  font-size: 0.58rem;
  color: #94a3b8;
  margin-top: 4px;
}

.touch-btn:active, .touch-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0f141c;
  background: #2b3648;
}

.btn-low {
  border-color: #fc9838;
}
.btn-low.pressed {
  background: #7c2d12;
}

.btn-high {
  border-color: #ef4444;
}
.btn-high.pressed {
  background: #991b1b;
}

.btn-sm-ctrl {
  padding: 6px 8px;
  font-size: 0.62rem;
  border-color: #00e8d8;
}

.rf-tips-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

/* =========================================================================
   手機高度不足時的緊湊自適應 (優先保證賽車畫布完整高度與基本按鍵可見)
   ========================================================================= */
@media (max-height: 720px) {
  .roadfighter-container {
    padding: env(safe-area-inset-top, 4px) 8px env(safe-area-inset-bottom, 4px) 8px;
    gap: 1px;
  }
  .roadfighter-theme .top-nav {
    min-height: 36px;
    padding: 2px 0;
  }
  .roadfighter-theme .top-nav .logo-text {
    font-size: 1.05rem;
  }
  .roadfighter-theme .top-nav .version-tag {
    display: none;
  }
  .roadfighter-theme .game-switch-bar {
    padding: 1px 0;
    margin-bottom: 1px;
  }
  .roadfighter-theme .game-switch-btn {
    padding: 2px 5px;
    font-size: 0.7rem;
  }
  .roadfighter-theme .rf-solo-card,
  .roadfighter-theme .rf-battle-card {
    padding: 3px 6px;
    margin-bottom: 1px;
  }
  .rf-stat-col .stat-label {
    font-size: 0.5rem;
  }
  .rf-stage-pill {
    padding: 1px 5px;
    font-size: 0.55rem;
  }
  .rf-hi-val, .rf-score-val {
    font-size: 0.65rem;
  }
  .roadfighter-theme .game-status-banner {
    font-size: 0.62rem;
    padding: 1px 4px;
    margin: 1px 0;
    line-height: 1.1;
  }
  .rf-arcade-toolbar {
    padding: 2px 6px;
  }
  .rf-sub-btn {
    padding: 2px 6px;
    font-size: 0.65rem;
  }
  .roadfighter-theme .rf-bottom-bar {
    padding: 1px 0 0 0;
    gap: 2px;
  }
  .roadfighter-theme .game-action-buttons {
    margin-bottom: 1px;
    gap: 4px;
  }
  .roadfighter-theme .game-action-buttons .btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
  .rf-mobile-controls {
    padding: 1px 0;
    gap: 6px;
  }
  .touch-btn {
    min-height: 60px; /* 小螢幕高度依然維持 1.5 倍加高手感 */
    min-width: 60px;
    padding: 8px 12px;
    font-size: 0.76rem;
    border-radius: 10px;
  }
  .touch-btn span {
    font-size: 0.5rem;
    margin-top: 3px;
  }
  .rf-tips-text {
    display: none;
  }
  .rf-title-logo {
    font-size: 1.15rem;
  }
  .rf-title-car-preview {
    font-size: 1.6rem;
  }
  .rf-title-sub {
    font-size: 0.68rem;
  }
  .start-btn-pill {
    padding: 8px 18px;
    font-size: 0.8rem;
  }
  .gameover-title {
    font-size: 1.3rem;
  }
}

@media (max-height: 580px) {
  .roadfighter-theme .game-switch-bar {
    display: none;
  }
  .roadfighter-theme .game-status-banner {
    display: none;
  }
  .touch-btn {
    padding: 4px 8px;
    font-size: 0.6rem;
  }
  .roadfighter-theme .game-action-buttons .btn {
    padding: 4px 6px;
    font-size: 0.7rem;
  }
}

/* 6. 大廳與配對動畫 */
.rf-avatar-pulse {
  font-size: 2.4rem;
  animation: bounceCar 1s infinite alternate ease-in-out;
}

.p1-car-pulse {
  filter: drop-shadow(0 0 10px #ef4444);
}

.p2-car-pulse {
  filter: drop-shadow(0 0 10px #38bdf8);
}

@keyframes bounceCar {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(1.1) translateY(-6px); }
}

.player-avatar-car.speaking {
  box-shadow: 0 0 0 3px #10b981, 0 0 16px rgba(16, 185, 129, 0.7) !important;
  animation: speakingGlow 0.8s infinite alternate ease-in-out;
}

/* ==========================================================================
   8x8 黑白棋 (Othello / Reversi) 專屬主題與風格
   ========================================================================== */
.othello-theme {
  background: radial-gradient(circle at 50% 20%, #0d1e18 0%, #06110e 60%, #030706 100%);
}

.othello-theme .top-nav .logo-text {
  color: #34d399;
  text-shadow: 0 2px 10px rgba(52, 211, 153, 0.4);
}

.othello-black-card.active-turn {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45) !important;
}

.othello-white-card.active-turn {
  border-color: #f1f5f9 !important;
  box-shadow: 0 0 16px rgba(241, 245, 249, 0.5) !important;
}

.othello-avatar-black {
  background: radial-gradient(circle at 35% 35%, #475569 0%, #1e293b 40%, #0f172a 100%);
  border: 2px solid #334155;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 4px 8px rgba(0, 0, 0, 0.6);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 44px;
  height: 44px;
}

.othello-avatar-white {
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f1f5f9 50%, #cbd5e1 100%);
  border: 2px solid #e2e8f0;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8), 0 4px 8px rgba(0, 0, 0, 0.4);
  color: #0f172a;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 44px;
  height: 44px;
}

/* 棋盤容器 */
.othello-board-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  width: 100%;
}

.othello-board-frame {
  width: min(92vw, 420px);
  aspect-ratio: 1;
  background: #1c1917;
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), inset 0 2px 3px rgba(255, 255, 255, 0.15), inset 0 -3px 6px rgba(0, 0, 0, 0.7);
  border: 2px solid #292524;
  position: relative;
  box-sizing: border-box;
}

.othello-board {
  width: 100%;
  height: 100%;
  background: #14532d;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  border: 2px solid #0f3d1b;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

.othello-cell {
  background: #15803d;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}

.othello-cell:hover {
  background: #16a34a;
}

/* 4 個星位裝飾點 */
.othello-star-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #062b11;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

/* 棋子樣式與 3D 質感 */
.othello-disc {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

.othello-disc.disc-black {
  background: radial-gradient(circle at 35% 30%, #4b5563 0%, #1f2937 40%, #030712 100%);
  border: 1px solid #374151;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.25), 0 3px 6px rgba(0, 0, 0, 0.6);
}

.othello-disc.disc-white {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f3f4f6 50%, #d1d5db 100%);
  border: 1px solid #e5e7eb;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.8), 0 3px 6px rgba(0, 0, 0, 0.4);
}

/* 翻轉動畫 */
.othello-disc.flipping-to-white {
  animation: flipToWhite 0.45s forwards cubic-bezier(0.4, 0.0, 0.2, 1);
}

.othello-disc.flipping-to-black {
  animation: flipToBlack 0.45s forwards cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes flipToWhite {
  0% { transform: scale(1) rotateY(0deg); }
  50% { transform: scale(1.18) rotateY(90deg); }
  100% { transform: scale(1) rotateY(0deg); }
}

@keyframes flipToBlack {
  0% { transform: scale(1) rotateY(0deg); }
  50% { transform: scale(1.18) rotateY(90deg); }
  100% { transform: scale(1) rotateY(0deg); }
}

/* 最新落子中心高亮點 */
.othello-disc.last-move::after {
  content: '';
  position: absolute;
  width: 24%;
  height: 24%;
  top: 38%;
  left: 38%;
  border-radius: 50%;
  pointer-events: none;
}
.othello-disc.disc-black.last-move::after {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}
.othello-disc.disc-white.last-move::after {
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

/* 合法可落子提示小圓點 */
.valid-move-hint {
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: pulseHint 1.8s infinite ease-in-out;
  transition: transform 0.15s, background 0.15s;
}

.othello-cell:hover .valid-move-hint {
  transform: scale(1.4);
  background: rgba(255, 255, 255, 0.85);
}

@keyframes pulseHint {
  0% { transform: scale(0.9); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 0.95; }
  100% { transform: scale(0.9); opacity: 0.4; }
}

/* 翻轉預覽效果 */
.othello-cell.preview-flip .othello-disc {
  filter: brightness(1.35) drop-shadow(0 0 8px #facc15);
  transform: scale(1.08);
  transition: all 0.15s ease;
}

/* 大廳圖標特效 */
.othello-symbol-glow {
  font-size: 2.2rem;
  display: inline-block;
}
.black-glow {
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.8));
}
.white-glow {
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

/* =========================================
   首頁：遊戲挑選大廳 (Game Portal Lobby)
   ========================================= */
body.portal-body {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px 0 32px 0;
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #0b1120 50%, #030712 100%);
}

.portal-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 10;
}

/* 首頁頂部導航 */
.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
  animation: floatEmoji 3s ease-in-out infinite;
}

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

.portal-brand-text {
  display: flex;
  flex-direction: column;
}

.portal-title {
  font-family: 'Fredoka', cursive, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* 英雄宣傳橫幅 */
.portal-hero {
  text-align: center;
  padding: 24px 16px 14px 16px;
  position: relative;
}

.portal-hero-title {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f8fafc 20%, #38bdf8 70%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.portal-hero-desc {
  font-size: 0.92rem;
  color: #94a3b8;
  max-width: 580px;
  margin: 0 auto 16px auto;
  line-height: 1.5;
}

.portal-hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-random-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.4);
}

.btn-random-pick:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.6);
}

.btn-random-pick:active {
  transform: translateY(0) scale(0.98);
}

/* 遊戲選擇網格 */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
}

.portal-game-card {
  position: relative;
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* 卡片上方彩色光條 */
.portal-game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, #38bdf8);
  opacity: 0.8;
  transition: height 0.25s ease;
}

.portal-game-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), 0 0 24px var(--card-glow, rgba(56, 189, 248, 0.2));
}

.portal-game-card:hover::before {
  height: 6px;
}

/* 遊戲特色色彩配置 */
.card-connect4 {
  --card-accent: linear-gradient(90deg, #ef4444, #eab308);
  --card-glow: rgba(239, 68, 68, 0.25);
}

.card-tictactoe {
  --card-accent: linear-gradient(90deg, #f43f5e, #06b6d4);
  --card-glow: rgba(6, 182, 212, 0.25);
}

.card-othello {
  --card-accent: linear-gradient(90deg, #22c55e, #38bdf8);
  --card-glow: rgba(34, 197, 94, 0.25);
}

.card-dino {
  --card-accent: linear-gradient(90deg, #10b981, #f59e0b);
  --card-glow: rgba(16, 185, 129, 0.25);
}

.card-roadfighter {
  --card-accent: linear-gradient(90deg, #ef4444, #f97316);
  --card-glow: rgba(239, 68, 68, 0.3);
}

.card-chemapao {
  --card-accent: linear-gradient(90deg, #dc2626, #b45309);
  --card-glow: rgba(220, 38, 38, 0.3);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-icon-box {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.08);
  transition: transform 0.25s ease;
}

.portal-game-card:hover .card-icon-box {
  transform: scale(1.1) rotate(-3deg);
}

.card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 9999px;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
}

.card-badge.badge-hot {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.card-badge.badge-new {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
}

.card-info {
  margin-bottom: 16px;
}

.card-name-cn {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-name-en {
  font-size: 0.78rem;
  font-family: 'Fredoka', sans-serif;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.card-desc {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.45;
  min-height: 38px;
  margin-bottom: 14px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.portal-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.card-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.action-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.portal-game-card:hover .action-label {
  color: #fff;
  transform: translateX(4px);
}

.action-arrow-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.portal-game-card:hover .action-arrow-circle {
  background: #38bdf8;
  color: #041226;
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

/* 平台特色標籤底欄 */
.portal-features-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.feature-mini-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.feature-mini-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.feature-mini-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
}

.feature-mini-desc {
  font-size: 0.74rem;
  color: #94a3b8;
}

/* 首頁頁尾 */
.portal-footer {
  text-align: center;
  padding: 20px 0 10px 0;
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.6;
}

.portal-footer a {
  color: #38bdf8;
  text-decoration: none;
}

/* ==========================================================================
   車馬炮兵兵 (象棋麻將 / 32張雙人對弈) 專屬樣式
   ========================================================================== */

.chemapao-theme {
  --table-felt: radial-gradient(circle at 50% 45%, #065f46 0%, #044332 60%, #022c22 100%);
  --table-border: #78350f;
  --table-wood: linear-gradient(135deg, #451a03 0%, #78350f 50%, #451a03 100%);
  --gold-glow: #f59e0b;
  --tile-bg: radial-gradient(circle at 35% 35%, #fffbeb 0%, #fef3c7 40%, #fde68a 75%, #f59e0b 100%);
  --tile-border: #b45309;
  background: radial-gradient(circle at 50% 30%, #064e3b 0%, #022c22 55%, #051310 100%);
  color: #f8fafc;
  overflow: hidden;
}

/* 象棋麻將對局桌面容器 */
.chemapao-container {
  width: 100%;
  max-width: 500px;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top, 8px) 12px env(safe-area-inset-bottom, 10px) 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

/* 綠絨面牌桌框 */
.chemapao-table {
  flex: 1;
  min-height: 0;
  background: var(--table-felt);
  border: 4px solid var(--table-border);
  border-radius: 20px;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.7), 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  padding: 10px 10px 8px 10px;
  position: relative;
  overflow: hidden;
  margin: 6px 0;
  gap: 4px;
}

/* 對手區與玩家區卡片 */
.chemapao-player-bar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 10px;
  gap: 8px;
}

.chemapao-player-bar.active-turn {
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
  background: rgba(30, 41, 59, 0.85);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-chess-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  font-weight: 800;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.badge-red {
  background: #fee2e2;
  color: #dc2626;
  border: 2px solid #ef4444;
}

.badge-black {
  background: #e2e8f0;
  color: #0f172a;
  border: 2px solid #475569;
}

.player-role-info {
  display: flex;
  flex-direction: column;
}

.role-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
}

.role-sub {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* 副露區 (已吃牌順子展示) */
.melds-display {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 38px;
}

.meld-group {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(245, 158, 11, 0.5);
  border-radius: 8px;
  padding: 2px 4px;
  gap: 3px;
}

/* 手牌背面 (對手) */
.opponent-hand-backs {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  min-height: 62px;
}

.tile-back {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #a16207 0%, #854d0e 40%, #713f12 75%, #451a03 100%);
  border: 2px solid #b45309;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.45), inset 0 2px 2px rgba(255, 255, 255, 0.25), inset 0 -2px 3px rgba(0,0,0,0.4);
  position: relative;
  flex-shrink: 0;
}

.tile-back::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border-radius: 50%;
  border: 1px solid rgba(254, 240, 138, 0.25);
  pointer-events: none;
}

/* 對手胡牌掀牌特效 */
.opponent-revealed-tile {
  width: 66px !important;
  height: 66px !important;
  font-size: 2.05rem !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.7), inset 0 2px 2px #fff !important;
  border: 2px solid #f59e0b !important;
  transform-origin: center center;
}

@keyframes flip-in {
  0% {
    transform: rotateY(90deg) scale(0.7);
    opacity: 0;
  }
  60% {
    transform: rotateY(-10deg) scale(1.08);
  }
  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
  }
}

/* 中間桌池區 (牌山 + 棄牌池) */
.pond-zone {
  flex: 1;
  min-height: 0; /* 防止子元素撐爆 Flexbox */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  padding: 2px 0;
  position: relative;
}

.pond-header-row {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

/* 牌山狀態盒 */
.wall-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 20px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fde68a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.wall-icon {
  font-size: 1rem;
}

.game-status-pill {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: #cbd5e1;
}

/* 棄牌池網格：滿牌時整齊排列，全盤清晰可視 */
.discard-pond {
  background: rgba(0, 0, 0, 0.28);
  border: 1.5px dashed rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  flex: 1;
  min-height: 80px;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-start;
  gap: 5px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.discard-pond::-webkit-scrollbar {
  width: 4px;
}
.discard-pond::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.4);
  border-radius: 4px;
}

.discard-pond:empty::before {
  content: "棄牌池 (對戰打出的棋子將置於此)";
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.8rem;
  margin: auto;
  font-style: italic;
}

/* 3D 圓形木質象棋牌樣式 (放大50%) */
.tile-piece {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--tile-bg);
  border: 2.5px solid var(--tile-border);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.45), inset 0 2px 2px #fff, inset 0 -3px 4px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Sans TC", "Songti TC", "Kaiti TC", serif;
  font-weight: 800;
  font-size: 2.15rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
  user-select: none;
  flex-shrink: 0;
}

/* 棋子內圈凹痕刻字線條 */
.tile-piece::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border-radius: 50%;
  border: 1px solid rgba(180, 83, 9, 0.35);
  pointer-events: none;
}

/* 紅方棋子 */
.tile-piece.color-red {
  color: #dc2626;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

/* 黑方棋子 */
.tile-piece.color-black {
  color: #0f172a;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

/* 小尺寸棋子通用預設 */
.tile-piece.tile-mini {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  border-width: 2px;
}

.tile-piece.tile-mini::after {
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
}

/* 副露區吃牌棋子 (較大顆顯眼) */
.melds-display .tile-mini {
  width: 46px;
  height: 46px;
  font-size: 1.45rem;
}

/* 棄牌池內棋子專屬尺寸：保證在滿牌時整齊排開，每行8-10顆，不擋視野 */
.discard-pond .tile-mini {
  width: 42px;
  height: 42px;
  font-size: 1.35rem;
}

/* 最新打出的棋子高亮標記 */
.tile-piece.latest-discard {
  animation: pulse-gold 1.4s infinite;
  border-color: #f59e0b;
  border-width: 2.5px;
  z-index: 5;
}

.tile-piece.latest-discard::before {
  content: "新";
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f59e0b;
  color: #041226;
  font-size: 0.52rem;
  font-weight: 800;
  padding: 1px 3px;
  border-radius: 4px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 6;
}

@keyframes pulse-gold {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7), 0 4px 8px rgba(0,0,0,0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 14px 4px rgba(245, 158, 11, 0.9), 0 6px 12px rgba(0,0,0,0.4);
    transform: scale(1.08);
  }
}

/* 玩家手牌托盤 */
.player-hand-container {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hand-tiles-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  min-height: 88px;
  padding: 6px 0 2px 0;
}

/* 選中手牌浮起效果 */
.tile-piece.selected-tile {
  transform: translateY(-16px) scale(1.08);
  box-shadow: 0 14px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(245, 158, 11, 0.8);
  border-color: #f59e0b;
}

/* 摸入的新牌微距隔開 */
.tile-piece.drawn-tile {
  margin-left: 10px;
  position: relative;
}

.tile-piece.drawn-tile::before {
  content: "摸";
  position: absolute;
  top: -11px;
  background: #22c55e;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
}

/* 浮動動作按鈕列 (吃、胡、過、打出) - 預設不佔空間，有動作時顯現 */
.action-buttons-overlay {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  min-height: 0;
  margin: 2px 0;
  z-index: 25;
}

.action-buttons-overlay.has-actions {
  display: flex;
}

.btn-action-chemapao {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 18px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

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

/* 胡牌大按鈕（閃耀金色火焰） */
.btn-action-hu {
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  color: #fff;
  border: 2px solid #fef08a;
  animation: hu-glow 1s infinite alternate;
  font-size: 1.05rem;
}

@keyframes hu-glow {
  0% {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6), 0 4px 12px rgba(0,0,0,0.4);
  }
  100% {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.95), 0 6px 16px rgba(0,0,0,0.5);
    transform: scale(1.04);
  }
}

/* 吃牌按鈕 */
.btn-action-chi {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: #fff;
  border: 1px solid #7dd3fc;
}

/* 打出按鈕 */
.btn-action-discard {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #041226;
  border: 1px solid #fef08a;
}

/* 過 / 摸牌按鈕 */
.btn-action-pass {
  background: rgba(51, 65, 85, 0.85);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 隱私手牌切換遮罩 (同機雙人模式) */
.privacy-mask-banner {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid #f59e0b;
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.privacy-mask-btn {
  background: #f59e0b;
  color: #041226;
  font-weight: 800;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
}

/* 規則說明彈窗卡片樣式 */
.rules-grid-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.rule-sample-row {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
}

.rule-sample-title {
  font-weight: 700;
  color: #fde68a;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 車馬炮兵兵 狀態通知 Toast */
.chemapao-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-24px);
  background: rgba(15, 23, 42, 0.96);
  border: 1.5px solid #f59e0b;
  color: #fde68a;
  padding: 8px 20px;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 16px rgba(245, 158, 11, 0.45);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.chemapao-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   iPhone SE / 迷你小螢幕專屬極致排版適配 (針對寬度 <= 400px 或高度 <= 720px)
   ========================================================================== */

@media (max-height: 720px), (max-width: 400px) {
  /* 容器與邊距極致壓縮 */
  .chemapao-container {
    padding: env(safe-area-inset-top, 4px) 6px env(safe-area-inset-bottom, 4px) 6px;
  }

  /* 頂部導航列 */
  .chemapao-theme .top-nav {
    min-height: 36px;
    padding: 2px 0;
    margin-bottom: 2px;
  }
  .chemapao-theme .logo-icon {
    font-size: 1.15rem;
  }
  .chemapao-theme .logo-text {
    font-size: 1.02rem;
  }
  .chemapao-theme .version-tag {
    display: none; /* 隱藏版本標籤，節省橫向排版空間 */
  }
  .chemapao-theme .header-actions {
    gap: 4px;
  }
  .chemapao-theme .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .chemapao-theme .net-badge {
    padding: 2px 6px;
    font-size: 0.65rem;
    gap: 4px;
  }

  /* 綠絨牌桌外框 */
  .chemapao-table {
    border-width: 2.5px;
    border-radius: 14px;
    padding: 5px 6px 4px 6px;
    margin: 2px 0;
  }

  /* 玩家狀態列 (對手與我方) */
  .chemapao-player-bar {
    padding: 3px 6px;
    border-radius: 8px;
    gap: 4px;
  }
  .player-meta {
    gap: 5px;
  }
  .player-chess-badge {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }
  .role-title {
    font-size: 0.72rem;
  }
  .role-sub {
    font-size: 0.62rem;
  }

  /* 副露區 (已吃牌，放大50%) */
  .melds-display {
    min-height: 40px;
    gap: 3px;
  }
  .meld-group {
    padding: 2px 3px;
    gap: 2px;
    border-radius: 6px;
  }
  .tile-piece.tile-mini {
    width: 38px;
    height: 38px;
    font-size: 1.25rem;
    border-width: 1.5px;
  }

  /* 對手手牌背面 (放大50%) */
  .opponent-hand-backs {
    min-height: 44px;
    padding: 2px 0;
    gap: 5px;
  }
  .tile-back {
    width: 38px;
    height: 38px;
    border-width: 2px;
  }
  .opponent-revealed-tile {
    width: 45px !important;
    height: 45px !important;
    font-size: 1.4rem !important;
  }

  /* 中間桌池區：自然填滿中央空間 */
  .pond-zone {
    flex: 1;
    min-height: 0;
    gap: 4px;
    padding: 1px 0;
  }

  .pond-header-row {
    margin-bottom: 2px;
    gap: 4px;
  }
  .wall-box {
    padding: 2px 7px;
    font-size: 0.68rem;
    border-radius: 12px;
    gap: 4px;
    white-space: nowrap;
  }
  .game-status-pill {
    padding: 2px 6px;
    font-size: 0.66rem;
    border-radius: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  .chemapao-theme .timer-badge {
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 12px;
    white-space: nowrap;
  }

  /* 棄牌池：高度自適應佔據中央大片區域，滿牌時(最多24顆)整齊排開，全盤無遮蔽，一覽無遺 */
  .discard-pond {
    flex: 1;
    min-height: 80px;
    max-height: none;
    padding: 6px 6px;
    gap: 4px;
    border-radius: 8px;
  }
  .discard-pond .tile-mini {
    width: 33px;
    height: 33px;
    font-size: 1.08rem;
    border-width: 1.5px;
  }
  .melds-display .tile-mini {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
  }

  /* 浮動動作按鈕 (吃、胡、過、打出) - 浮於手牌托盤上方，不擠壓棄牌池空間 */
  .action-buttons-overlay {
    min-height: 0;
    padding: 2px 0;
    gap: 5px;
    margin: 1px 0;
  }
  .btn-action-chemapao {
    padding: 4px 10px;
    font-size: 0.8rem;
    gap: 4px;
  }
  .btn-action-hu {
    font-size: 0.88rem;
  }

  /* 玩家手牌托盤與卡牌 (放大50%，大顆超清晰) */
  .player-hand-container {
    gap: 4px;
  }
  .hand-tiles-row {
    min-height: 74px;
    padding: 4px 0 2px 0;
    gap: 4px;
  }
  .tile-piece {
    width: 63px;
    height: 63px;
    font-size: 1.9rem;
    border-width: 2.5px;
  }
  .tile-piece.selected-tile {
    transform: translateY(-10px) scale(1.06);
  }
  .tile-piece.drawn-tile {
    margin-left: 6px;
  }
  .tile-piece.drawn-tile::before {
    top: -10px;
    font-size: 0.55rem;
    padding: 0 4px;
  }
  .tile-piece.latest-discard::before {
    top: -11px;
    font-size: 0.55rem;
    padding: 0 4px;
  }

  /* 底部操作與快捷表情列 */
  .bottom-action-bar {
    gap: 3px;
    padding: 2px 0 0 0;
  }
  .quick-emojis {
    padding: 2px 4px;
    border-radius: 10px;
  }
  .emoji-btn {
    font-size: 1.15rem;
    padding: 1px 4px;
  }
  .game-action-buttons {
    gap: 5px;
  }
  .game-action-buttons .btn {
    padding: 5px 6px;
    font-size: 0.74rem;
    border-radius: 8px;
  }

  /* 狀態 Toast */
  .chemapao-toast {
    top: 42px;
    padding: 5px 14px;
    font-size: 0.75rem;
    max-width: 90vw;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  /* 大廳與彈窗視窗適配 */
  .modal-card {
    max-height: 92vh;
    max-height: 92dvh;
    padding: 14px 10px;
    gap: 10px;
    border-radius: 16px;
  }
  .modal-header h2 {
    font-size: 1.1rem;
  }
  .modal-header .subtitle {
    font-size: 0.72rem;
  }
  .chemapao-theme .lobby-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 3px;
  }
  .chemapao-theme .tab-btn {
    flex: 1 1 30%;
    padding: 5px 2px;
    font-size: 0.72rem;
    text-align: center;
  }
}

/* 極致超薄視窗 (如手機橫向或 Safari 上下網址列/鍵盤展開時) */
@media (max-height: 560px) {
  .chemapao-container {
    padding: 2px 4px;
  }
  .quick-emojis {
    display: none; /* 隱藏表情列，保障手牌與棋池完全可見 */
  }
  .discard-pond {
    flex: 1;
    min-height: 70px;
    max-height: none;
  }
  .hand-tiles-row {
    min-height: 64px;
    gap: 4px;
  }
  .tile-piece {
    width: 52px;
    height: 52px;
    font-size: 1.55rem;
  }
  .opponent-hand-backs {
    min-height: 34px;
  }
  .tile-back {
    width: 30px;
    height: 30px;
  }
}

/* 超窄螢幕適配 (如 320px 寬度) */
@media (max-width: 350px) {
  .tile-piece {
    width: 54px;
    height: 54px;
    font-size: 1.6rem;
  }
  .hand-tiles-row {
    min-height: 64px;
    gap: 3px;
  }
  .tile-back {
    width: 32px;
    height: 32px;
  }
}





/* ==========================================================================
   雙人麻將 (Two-Player Mahjong · 64張極速雀神) 樣式
   ========================================================================== */

.card-mahjong {
  --card-accent: linear-gradient(90deg, #059669, #10b981);
  --card-glow: rgba(16, 185, 129, 0.35);
}

.mahjong-theme {
  --mj-felt: radial-gradient(circle at 50% 48%, #086348 0%, #044b36 52%, #022a1e 100%);
  --mj-border: #78350f;
  --mj-wood: linear-gradient(135deg, #451a03 0%, #78350f 50%, #451a03 100%);
  --mj-gold: #f59e0b;
  --mj-tile-bg: linear-gradient(180deg, #ffffff 0%, #fdfbf7 55%, #f4eee1 100%);
  --mj-tile-back: radial-gradient(circle at 40% 35%, #059669 0%, #047857 50%, #064e3b 100%);
  background: radial-gradient(circle at 50% 25%, #064e3b 0%, #022c22 65%, #051310 100%);
  color: #f8fafc;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.mahjong-container {
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top, 4px) 8px env(safe-area-inset-bottom, 6px) 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 10;
  margin: 0 auto;
  box-sizing: border-box;
}

/* 牌桌頂部精簡 HUD 導航列 */
.mahjong-container .top-nav {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 4px;
  min-height: 38px;
  box-sizing: border-box;
}

.mahjong-container .top-nav .logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mahjong-container .top-nav .logo-icon {
  font-size: 1.15rem;
}

.mahjong-container .top-nav .logo-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mahjong-container .top-nav .version-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  font-weight: 600;
}

/* 牌桌主體 (豪華綠呢絨桌布 + 沉穩木紋邊框 + 金絲細邊) */
.mahjong-table {
  flex: 1;
  min-height: 0;
  background: var(--mj-felt);
  border: 4px solid #78350f;
  border-top-color: #92400e;
  border-bottom-color: #451a03;
  border-radius: 18px;
  box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.82), 0 8px 24px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 8px 6px 8px;
  position: relative;
  overflow: hidden;
  margin: 2px 0;
  gap: 4px;
  box-sizing: border-box;
}

.mahjong-table::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 14px;
  pointer-events: none;
}

/* 1. 對手區舞台整合 */
.mj-opponent-stage {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 角色資訊條 (對手 / 玩家) */
.mahjong-player-bar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 3px 8px;
  gap: 6px;
  min-height: 38px;
  transition: all 0.25s ease;
  box-sizing: border-box;
}

.mahjong-player-bar.active-turn {
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5), inset 0 0 8px rgba(245, 158, 11, 0.15);
  background: rgba(30, 41, 59, 0.85);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

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

.player-role-info .role-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-role-info .role-sub {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 500;
}

.mahjong-player-bar.active-turn .role-sub {
  color: #fde68a;
  font-weight: 700;
}

.mahjong-role-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.mahjong-role-badge.badge-host {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #dc2626;
  border: 1.5px solid #ef4444;
}

.mahjong-role-badge.badge-guest {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #2563eb;
  border: 1.5px solid #3b82f6;
}

/* 副露區 (吃/碰/槓) */
.mj-melds-display {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  max-width: 55%;
  flex-shrink: 0;
}

.mj-meld-group {
  display: flex;
  gap: 1px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(245, 158, 11, 0.6);
  border-radius: 4px;
  padding: 1px 2px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 對手手牌背面列 (微俯視立體感) */
.opponent-hand-backs {
  flex-shrink: 0;
  display: flex;
  gap: 2px;
  justify-content: center;
  align-items: center;
  padding: 2px 0;
  min-height: 32px;
  overflow: visible;
}

.mj-tile-back {
  width: clamp(17px, 5.2vw, 23px);
  height: clamp(25px, 7.6vw, 34px);
  border-radius: 3px;
  background: var(--mj-tile-back);
  border: 1px solid #064e3b;
  border-top: 1.5px solid #34d399;
  border-bottom: 2px solid #022c22;
  box-shadow: 0 2px 4px rgba(0,0,0,0.45), inset 0 1px 1px rgba(255,255,255,0.3);
  flex-shrink: 0;
  position: relative;
  transition: transform 0.15s ease;
}

.mj-tile-back::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(167, 243, 208, 0.25);
  border-radius: 2px;
}

/* 2. 中間公共桌池區 (核心中樞 + 8列無縫牌河) */
.mj-pond-zone {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  position: relative;
  padding: 2px 0;
}

.mj-pond-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.wall-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  padding: 2px 7px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fde68a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.wall-icon {
  font-size: 0.85rem;
}

.suit-badge {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 16px;
  padding: 2px 7px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fde68a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.game-status-pill {
  flex: 1;
  min-width: 0;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #cbd5e1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-badge {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  border: 1.5px solid #fecaca;
  border-radius: 16px;
  padding: 2px 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
  flex-shrink: 0;
  animation: timer-pulse 1s infinite alternate;
}

@keyframes timer-pulse {
  from { transform: scale(1); box-shadow: 0 0 6px rgba(239, 68, 68, 0.6); }
  to { transform: scale(1.05); box-shadow: 0 0 14px rgba(239, 68, 68, 1); }
}

/* 棄牌池 (動態寬度鋪滿畫面寬度，避免遮蔽與捲軸；橫向緊密相連無空格) */
.mj-discard-pond {
  flex: 0 1 auto;
  min-height: 44px;
  max-height: clamp(145px, 25vh, 195px);
  width: 100%;
  max-width: 100%;
  margin: 0;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(25px, 6.8vw, 32px), 1fr));
  column-gap: 0;
  row-gap: 2px;
  justify-items: stretch;
  align-items: stretch;
  align-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

.mj-discard-pond::-webkit-scrollbar {
  width: 4px;
}

.mj-discard-pond::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.35);
  border-radius: 4px;
}

.mj-discard-pond:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mj-discard-pond:empty::after {
  content: "🀄 棄牌區";
  color: rgba(255, 255, 255, 0.22);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 2px;
}

/* 麻將牌基礎造型 (象牙白質感 - 雙列優化版) */
.mj-tile {
  width: clamp(35px, 10.5vw, 47px);
  height: clamp(50px, 15vw, 67px);
  background: var(--mj-tile-bg);
  border-radius: 4px;
  border: 1px solid #d4cebe;
  border-right: 2px solid #b5ae9f;
  border-bottom: 3.5px solid #9c9584;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
  padding: 2px 0;
  font-family: 'Noto Sans TC', sans-serif;
  user-select: none;
  box-sizing: border-box;
}

.mj-tile:hover {
  transform: translateY(-4px);
}

.mj-tile.selected {
  transform: translateY(-10px);
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.85), 0 6px 10px rgba(0,0,0,0.5);
}

.mj-tile.just-drawn {
  margin-left: clamp(6px, 2.2vw, 12px);
  position: relative;
}

.mj-tile.just-drawn::before {
  content: "新";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #1e293b;
  font-size: 0.62rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 5;
}

/* 牌池與副露中的小型牌 */
.mj-tile-mini {
  width: clamp(19px, 5.5vw, 25px);
  height: clamp(28px, 8.2vw, 37px);
  border-bottom: 2px solid #9c9584;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: default;
  pointer-events: none;
}

/* 棄牌池專用牌面 (8 列均分排版，橫向緊貼無空格，消除空隙，兼顧易讀性與緊湊度) */
.mj-tile-in-pond {
  width: 100%;
  height: clamp(34px, 10.2vw, 43px);
  margin: 0 !important;
  padding: 1px 0;
  border-radius: 2px;
  border: 1px solid #d4cebe;
  border-right: 1px solid #b5ae9f;
  border-bottom: 2px solid #9c9584;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  cursor: default;
  pointer-events: none;
}

.mj-tile-in-pond .mj-wan-num {
  font-size: clamp(0.68rem, 2.6vw, 0.92rem);
}
.mj-tile-in-pond .mj-wan-char {
  font-size: clamp(0.52rem, 2.0vw, 0.72rem);
}
.mj-tile-in-pond .mj-zi-char {
  font-size: clamp(0.85rem, 3.4vw, 1.25rem);
}

.mj-tile-in-pond.latest-discard {
  position: relative;
  z-index: 2;
  border-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-discard 1.2s infinite alternate;
}

/* 萬字牌面文字排版 */
.mj-wan-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 0.95;
  width: 100%;
}

.mj-wan-num {
  font-size: clamp(1.05rem, 4.2vw, 1.45rem);
  font-weight: 800;
  color: #1e3a8a;
}

.mj-wan-char {
  font-size: clamp(0.9rem, 3.6vw, 1.25rem);
  font-weight: 800;
  color: #dc2626;
}

.mj-tile-mini .mj-wan-num {
  font-size: clamp(0.56rem, 2.1vw, 0.8rem);
}
.mj-tile-mini .mj-wan-char {
  font-size: clamp(0.48rem, 1.8vw, 0.68rem);
}

/* 字牌文字排版 */
.mj-zi-char {
  font-size: clamp(1.4rem, 5.8vw, 2.1rem);
  font-weight: 900;
  line-height: 1;
}

.mj-tile-mini .mj-zi-char {
  font-size: clamp(0.78rem, 3.1vw, 1.15rem);
}

.mj-zi-wind {
  color: #1e293b;
}

.mj-zi-zhong {
  color: #dc2626;
}

.mj-zi-fa {
  color: #16a34a;
}

.mj-zi-bai {
  display: block;
  width: 65%;
  height: 65%;
  border: 2px solid #2563eb;
  border-radius: 2px;
  background: #ffffff;
}

/* 3. 玩家手牌區容器 (置於底部，整合牌架底板與浮動動作條) */
.player-hand-container {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}

/* 動作按鈕浮動列 (胡/槓/碰/吃/打出/過) - 採用懸浮氣泡條設計，不推擠版面 */
.action-buttons-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
  max-width: 96%;
  white-space: nowrap;
}

.btn-action-mj {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 18px;
  font-weight: 800;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255,255,255,0.4);
  transition: transform 0.1s ease, filter 0.15s ease;
  pointer-events: auto;
}

.btn-action-mj:active {
  transform: scale(0.93);
}

.btn-action-hu {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border: 2px solid #fecaca;
  animation: hu-pulse 0.9s infinite alternate;
}

.btn-action-gang {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border: 1px solid #c4b5fd;
}

.btn-action-peng {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 1px solid #93c5fd;
}

.btn-action-chi {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: #ffffff;
  border: 1px solid #6ee7b7;
}

.btn-action-discard {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1e293b;
  border: 1px solid #fde68a;
}

.btn-action-pass {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: #ffffff;
  border: 1px solid #cbd5e1;
}

/* 玩家手牌托盤 (仿木質階梯牌架底座) */
.mj-hand-tiles-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px 4px 4px;
  background: linear-gradient(180deg, rgba(69, 26, 3, 0.4) 0%, rgba(30, 10, 2, 0.65) 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45), 0 3px 8px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  overflow: visible;
}

.mj-hand-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 3px;
  width: 100%;
  overflow: visible;
}

.mj-hand-row-top {
  margin-bottom: -2px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

/* 底部操作列與表情 (單列緊湊整合) */
.mahjong-container .bottom-action-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 3px 0 0 0;
  min-height: 34px;
  box-sizing: border-box;
}

.mahjong-container .quick-emojis {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 2px 6px;
  backdrop-filter: blur(8px);
}

.mahjong-container .emoji-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  padding: 2px;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.12s ease;
}

.mahjong-container .emoji-btn:hover {
  transform: scale(1.25);
}

.mahjong-container .game-action-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mahjong-container .game-action-buttons .btn {
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 8px;
  white-space: nowrap;
}

.mahjong-container #btn-restart {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1e293b;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 5px 14px;
  border-radius: 10px;
  border: 1.5px solid #fde68a;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.45);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.mahjong-container #btn-restart:hover:not(:disabled) {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.mahjong-container #btn-restart:active:not(:disabled) {
  transform: scale(0.95);
}

/* 連線真人對戰中禁用重新開始：置灰不可用 */
.mahjong-container #btn-restart:disabled,
.mahjong-container #btn-restart.btn-disabled-online {
  background: #334155 !important;
  color: #94a3b8 !important;
  border: 1.5px solid #475569 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 0.55 !important;
  transform: none !important;
  filter: grayscale(0.8) !important;
  pointer-events: auto !important; /* 允許 hover / 點擊時提示 */
}

/* iPhone SE2 (375px) 與超窄螢幕微調 */
@media (max-width: 380px) {
  .mahjong-container {
    padding: env(safe-area-inset-top, 4px) 4px env(safe-area-inset-bottom, 4px) 4px;
  }
  .mahjong-table {
    padding: 6px 4px;
    gap: 2px;
  }
  .mj-hand-row {
    gap: 2px;
  }
  .mj-tile {
    width: clamp(33px, 10.2vw, 42px);
    height: clamp(48px, 14.4vw, 60px);
  }
  .btn-action-mj {
    padding: 4px 8px;
    font-size: 0.78rem;
  }
}

/* 超薄高度螢幕 (<620px) 彈性壓縮 */
@media (max-height: 620px) {
  .mahjong-container .quick-emojis {
    display: none;
  }
  .mj-discard-pond {
    min-height: 44px;
    max-height: 110px;
  }
  .mj-tile {
    height: 44px;
  }
  .mj-tile-in-pond {
    height: 29px;
  }
  .opponent-hand-backs {
    min-height: 26px;
  }
  .mj-tile-back {
    height: 24px;
  }
}

/* -------------------------------------------------------------
   雙人麻將 震撼胡牌爆炸字卡特效 (自摸 / 放槍 / 對方自摸 / 胡牌)
   ------------------------------------------------------------- */
@keyframes mjTableShake {
  0% { transform: translate(0, 0) scale(1); }
  15% { transform: translate(-5px, 6px) scale(1.008); }
  35% { transform: translate(6px, -5px) scale(0.995); }
  55% { transform: translate(-4px, 3px) scale(1.004); }
  75% { transform: translate(3px, -2px) scale(1); }
  100% { transform: translate(0, 0) scale(1); }
}

.mahjong-table.mj-impact-shake {
  animation: mjTableShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.mj-explosion-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.35s ease-out;
}

.mj-explosion-overlay.show {
  display: flex !important;
  opacity: 1;
}

.mj-explosion-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.mj-explosion-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.8) 100%);
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
  pointer-events: none;
}

.mj-explosion-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
  animation: mjCardSlam 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes mjCardSlam {
  0% {
    transform: scale(2.8) rotate(-7deg);
    opacity: 0;
  }
  38% {
    transform: scale(0.9) rotate(2deg);
    opacity: 1;
  }
  62% {
    transform: scale(1.08) rotate(-1deg);
  }
  80% {
    transform: scale(0.97) rotate(0.5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* 爆炸放射光束 (Sunburst Rays) */
.mj-burst-rays {
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.88;
  background: repeating-conic-gradient(
    from 0deg,
    var(--mj-burst-c1, rgba(245, 158, 11, 0.85)) 0deg 11.25deg,
    transparent 11.25deg 22.5deg
  );
  mask-image: radial-gradient(circle, rgba(0,0,0,1) 25%, rgba(0,0,0,0) 70%);
  -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,1) 25%, rgba(0,0,0,0) 70%);
  animation: mjBurstSpin 7s linear infinite;
}

@keyframes mjBurstSpin {
  from { transform: rotate(0deg) scale(0.95); }
  50% { transform: rotate(180deg) scale(1.08); }
  to { transform: rotate(360deg) scale(0.95); }
}

/* 擴散沖擊波環 */
.mj-shockwave {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 4px solid var(--mj-shock-color, #fbbf24);
  box-shadow: 0 0 24px var(--mj-shock-color, #fbbf24), inset 0 0 16px var(--mj-shock-color, #fbbf24);
  pointer-events: none;
  opacity: 0;
}

.mj-shockwave.wave-1 {
  animation: mjShockwaveAnim 0.75s cubic-bezier(0.1, 0.8, 0.3, 1) 0.05s forwards;
}

.mj-shockwave.wave-2 {
  animation: mjShockwaveAnim 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) 0.18s forwards;
}

@keyframes mjShockwaveAnim {
  0% { transform: scale(0.25); opacity: 1; border-width: 8px; }
  50% { opacity: 0.9; }
  100% { transform: scale(3.4); opacity: 0; border-width: 1px; }
}

/* 迸發粒子 */
.mj-spark-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mj-spark-particles span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mj-shock-color, #fbbf24);
  box-shadow: 0 0 12px var(--mj-shock-color, #fbbf24);
  opacity: 0;
  animation: mjSparkFly 0.85s ease-out 0.08s forwards;
}

@keyframes mjSparkFly {
  0% {
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateY(0) scale(1.6);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateY(-160px) scale(0.2);
    opacity: 0;
  }
}

/* 核心爆炸字卡徽章 */
.mj-explosion-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 36px 14px 36px;
  border-radius: 26px;
  background: var(--mj-card-bg, linear-gradient(135deg, rgba(69, 26, 3, 0.95) 0%, rgba(26, 10, 2, 0.98) 100%));
  border: 3.5px solid var(--mj-card-border, #f59e0b);
  box-shadow: 
    0 0 40px var(--mj-card-glow, rgba(245, 158, 11, 0.65)),
    0 18px 40px rgba(0, 0, 0, 0.82),
    inset 0 2px 3px rgba(255, 255, 255, 0.35),
    inset 0 -2px 6px rgba(0, 0, 0, 0.6);
  transform: translateZ(0);
}

.mj-explosion-sub {
  font-size: clamp(0.76rem, 2.7vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--mj-sub-color, #fde68a);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  margin-bottom: 2px;
  user-select: none;
}

.mj-explosion-title {
  font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
  font-size: clamp(3rem, 11.5vw, 4.8rem);
  font-weight: 900;
  letter-spacing: 8px;
  line-height: 1.05;
  margin: 4px 0 6px 0;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  background: var(--mj-text-gradient, linear-gradient(180deg, #ffffff 0%, #fef08a 25%, #f59e0b 65%, #b45309 100%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 var(--mj-text-shadow-color, #451a03))
          drop-shadow(0 8px 14px rgba(0, 0, 0, 0.95))
          drop-shadow(0 0 24px var(--mj-text-glow, #f59e0b));
  animation: mjTitlePulse 1.2s ease-in-out infinite alternate;
}

@keyframes mjTitlePulse {
  from {
    transform: scale(1);
    filter: drop-shadow(0 4px 0 var(--mj-text-shadow-color, #451a03))
            drop-shadow(0 8px 14px rgba(0, 0, 0, 0.95))
            drop-shadow(0 0 22px var(--mj-text-glow, #f59e0b));
  }
  to {
    transform: scale(1.05);
    filter: drop-shadow(0 5px 0 var(--mj-text-shadow-color, #451a03))
            drop-shadow(0 10px 18px rgba(0, 0, 0, 0.95))
            drop-shadow(0 0 36px var(--mj-text-glow, #f59e0b));
  }
}

.mj-explosion-fan {
  margin-top: 4px;
  padding: 4px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.72);
  border: 1.5px solid var(--mj-card-border, #f59e0b);
  color: var(--mj-fan-color, #fef08a);
  font-size: clamp(0.75rem, 2.5vw, 0.92rem);
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  max-width: 320px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

/* 放槍對手牌組與放槍牌展示容器 */
.mj-explosion-hand-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 4px;
  padding: 6px 10px 8px 10px;
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(248, 113, 113, 0.5);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65), inset 0 1px 2px rgba(255, 255, 255, 0.15);
  max-width: 94vw;
  box-sizing: border-box;
}

.mj-explosion-hand-header {
  font-size: clamp(0.72rem, 2.4vw, 0.82rem);
  font-weight: 800;
  color: #fecaca;
  margin-bottom: 5px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.mj-explosion-tiles-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  flex-wrap: nowrap;
  max-width: 90vw;
  overflow-x: auto;
  padding: 16px 4px 4px 4px; /* 頂部預留放槍標籤位置 */
  scrollbar-width: none;
}
.mj-explosion-tiles-row::-webkit-scrollbar {
  display: none;
}

.mj-exp-melds {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  margin-right: 4px;
}

.mj-exp-hand {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.mj-exp-gun-divider {
  font-size: 1.1rem;
  font-weight: 900;
  color: #ef4444;
  margin: 0 3px;
  align-self: center;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.mj-exp-gun-tile {
  display: inline-flex;
  position: relative;
}

/* 放槍牌專屬高亮與發光外框 */
.mj-tile.mj-tile-gun-win {
  position: relative;
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 14px #ef4444, inset 0 0 6px rgba(239, 68, 68, 0.4) !important;
  transform: translateY(-2px) scale(1.05);
  animation: gunTileGlow 1.2s infinite alternate ease-in-out;
}

@keyframes gunTileGlow {
  0% {
    box-shadow: 0 0 8px #ef4444, inset 0 0 4px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px) scale(1.03);
  }
  100% {
    box-shadow: 0 0 18px #f87171, 0 0 24px rgba(239, 68, 68, 0.6), inset 0 0 8px rgba(239, 68, 68, 0.6);
    transform: translateY(-4px) scale(1.08);
  }
}

/* 放槍牌頂部發光小徽章 */
.mj-tile-gun-badge {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  font-size: 0.58rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  border: 1px solid #fca5a5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), 0 0 8px rgba(239, 68, 68, 0.8);
  pointer-events: none;
  z-index: 10;
}

.mj-explosion-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 8px;
  letter-spacing: 0.8px;
  user-select: none;
  background: rgba(0, 0, 0, 0.45);
  padding: 3px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  animation: hintBlink 2s infinite ease-in-out;
}

@keyframes hintBlink {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* 主題 1：自摸 (金色霸氣雀神光芒) */
.mj-explosion-overlay.theme-zimo {
  --mj-burst-c1: rgba(245, 158, 11, 0.9);
  --mj-shock-color: #fbbf24;
  --mj-card-bg: linear-gradient(135deg, rgba(85, 33, 4, 0.96) 0%, rgba(30, 10, 2, 0.98) 100%);
  --mj-card-border: #f59e0b;
  --mj-card-glow: rgba(245, 158, 11, 0.75);
  --mj-text-gradient: linear-gradient(180deg, #ffffff 0%, #fef08a 25%, #f59e0b 65%, #d97706 100%);
  --mj-text-shadow-color: #78350f;
  --mj-text-glow: #f59e0b;
  --mj-sub-color: #fde68a;
  --mj-fan-color: #fef08a;
}

/* 主題 2：放槍 (暗紅烈焰雷擊警報) */
.mj-explosion-overlay.theme-fangqiang {
  --mj-burst-c1: rgba(239, 68, 68, 0.92);
  --mj-shock-color: #ef4444;
  --mj-card-bg: linear-gradient(135deg, rgba(85, 10, 10, 0.96) 0%, rgba(28, 4, 4, 0.98) 100%);
  --mj-card-border: #ef4444;
  --mj-card-glow: rgba(239, 68, 68, 0.75);
  --mj-text-gradient: linear-gradient(180deg, #ffffff 0%, #fca5a5 20%, #ef4444 65%, #991b1b 100%);
  --mj-text-shadow-color: #450a0a;
  --mj-text-glow: #ef4444;
  --mj-sub-color: #fca5a5;
  --mj-fan-color: #fecaca;
}

/* 主題 3：對方自摸 (紫電幽冥雷暴) */
.mj-explosion-overlay.theme-opponent-zimo {
  --mj-burst-c1: rgba(168, 85, 247, 0.92);
  --mj-shock-color: #c084fc;
  --mj-card-bg: linear-gradient(135deg, rgba(58, 16, 105, 0.96) 0%, rgba(20, 5, 45, 0.98) 100%);
  --mj-card-border: #a855f7;
  --mj-card-glow: rgba(168, 85, 247, 0.75);
  --mj-text-gradient: linear-gradient(180deg, #ffffff 0%, #e9d5ff 25%, #a855f7 65%, #6b21a8 100%);
  --mj-text-shadow-color: #3b0764;
  --mj-text-glow: #a855f7;
  --mj-sub-color: #e9d5ff;
  --mj-fan-color: #f3e8ff;
}

/* 主題 4：胡牌 / 抓砲 (喜慶紅金榮和光彩) */
.mj-explosion-overlay.theme-hu {
  --mj-burst-c1: rgba(244, 63, 94, 0.92);
  --mj-shock-color: #fb7185;
  --mj-card-bg: linear-gradient(135deg, rgba(88, 8, 30, 0.96) 0%, rgba(30, 2, 10, 0.98) 100%);
  --mj-card-border: #f43f5e;
  --mj-card-glow: rgba(244, 63, 94, 0.75);
  --mj-text-gradient: linear-gradient(180deg, #ffffff 0%, #fecdd3 25%, #f43f5e 65%, #9f1239 100%);
  --mj-text-shadow-color: #4c0519;
  --mj-text-glow: #f43f5e;
  --mj-sub-color: #fecdd3;
  --mj-fan-color: #ffe4e6;
}

/* 行動設備窄屏微調 (<480px) */
@media (max-width: 480px) {
  .mj-explosion-card {
    padding: 12px 22px 10px 22px;
    border-radius: 20px;
  }
  .mj-explosion-title {
    font-size: clamp(2.4rem, 10vw, 3.4rem);
    letter-spacing: 5px;
  }
  .mj-burst-rays {
    width: 330px;
    height: 330px;
  }
  .mj-explosion-fan {
    max-width: 260px;
    font-size: 0.72rem;
  }
}

/* -------------------------------------------------------------
   雙人麻將 再來一局中央懸浮按鈕 (等待點擊)
   ------------------------------------------------------------- */
.mj-rematch-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 185;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}

.mj-rematch-overlay.show {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
}

.mj-rematch-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.btn-rematch-floating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 34px;
  border-radius: 40px;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 50%, #b45309 100%);
  color: #ffffff;
  border: 2.5px solid #fde68a;
  font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
  font-size: clamp(1.2rem, 4.5vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 
    0 0 28px rgba(245, 158, 11, 0.7),
    0 12px 32px rgba(0, 0, 0, 0.75),
    inset 0 2px 2px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35);
  user-select: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  animation: rematchFloatPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
             rematchButtonPulse 1.6s ease-in-out infinite alternate 0.4s;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.2s ease;
}

.btn-rematch-floating:hover:not(:disabled) {
  transform: scale(1.05);
  filter: brightness(1.12);
}

.btn-rematch-floating:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-rematch-floating:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  animation: none;
  background: #475569;
  border-color: #94a3b8;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.btn-rematch-icon {
  font-size: 1.35em;
  display: inline-block;
}

@keyframes rematchFloatPop {
  0% { transform: scale(0.7); opacity: 0; }
  65% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes rematchButtonPulse {
  0% {
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.55), 0 10px 28px rgba(0, 0, 0, 0.7);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 38px rgba(245, 158, 11, 0.9), 0 14px 36px rgba(0, 0, 0, 0.85), 0 0 18px rgba(254, 240, 138, 0.7);
    transform: scale(1.04);
  }
}

@media (max-width: 480px) {
  .btn-rematch-floating {
    padding: 12px 26px;
    font-size: 1.15rem;
    letter-spacing: 2px;
  }
}



/* ==========================================================================
   九局下半 (Bottom of the 9th · 棒球卡牌對決) 沉浸式球場轉播視覺樣式
   ========================================================================== */

/* 大廳首頁卡片造型 */
.card-bottom9 {
  --card-accent: linear-gradient(135deg, #059669 0%, #10b981 50%, #f59e0b 100%);
  --card-glow: rgba(16, 185, 129, 0.4);
}

.bottom9-theme {
  background: radial-gradient(circle at 50% 12%, #0f3d2e 0%, #062319 45%, #020c08 100%);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* 夜間球場探照燈光與看台背景 */
.stadium-night-sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.stadium-light-tower {
  position: absolute;
  top: -20px;
  width: 90px;
  height: 90px;
}
.light-left {
  left: 2%;
}
.light-right {
  right: 2%;
}
.light-head {
  width: 60px;
  height: 24px;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 0 40px #ffffff, 0 0 80px rgba(254, 240, 138, 0.8);
  opacity: 0.85;
}
.light-cone {
  position: absolute;
  top: 18px;
  width: 280px;
  height: 480px;
  opacity: 0.22;
  filter: blur(25px);
  pointer-events: none;
}
.cone-left {
  left: -20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(254, 240, 138, 0.4) 40%, transparent 80%);
  transform: rotate(-15deg);
}
.cone-right {
  right: -20px;
  background: linear-gradient(225deg, rgba(255, 255, 255, 0.9) 0%, rgba(254, 240, 138, 0.4) 40%, transparent 80%);
  transform: rotate(15deg);
}

.stadium-stands-backdrop {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 240px;
  background: radial-gradient(ellipse at bottom, rgba(5, 46, 32, 0.6) 0%, transparent 70%);
  opacity: 0.6;
}

/* 主容器 */
body.bottom9-theme .app-container.b9-container {
  max-width: 500px;
  width: 100%;
  height: auto;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  padding: env(safe-area-inset-top, 8px) 12px calc(env(safe-area-inset-bottom, 12px) + 20px) 12px;
  position: relative;
  z-index: 2;
  overflow: visible;
  transition: transform 0.1s ease;
}

/* 擊球畫面劇烈晃動 (Screen Shake) */
.b9-screen-shake {
  animation: b9-camera-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes b9-camera-shake {
  10%, 90% { transform: translate3d(-3px, 2px, 0) scale(1.01); }
  20%, 80% { transform: translate3d(4px, -3px, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 4px, 0) scale(1.02); }
  40%, 60% { transform: translate3d(6px, -4px, 0); }
}

.b9-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.b9-logo-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.b9-logo-sub {
  font-size: 0.65rem;
  color: #a7f3d0;
  letter-spacing: 0.5px;
}

/* ==========================================
   巨型球場 Jumbotron 比分板
   ========================================== */
.jumbotron-board {
  flex-shrink: 0;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #334155;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 10px;
  position: relative;
}
.jumbotron-metal-frame {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
}

.b9-scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  padding-bottom: 5px;
  margin-bottom: 6px;
}

.b9-inning-badge {
  background: #047857;
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 0 10px rgba(4, 120, 87, 0.7);
}
.b9-inning-badge .inning-arrow {
  color: #fde047;
  font-size: 0.72rem;
}

.b9-scores-display {
  display: flex;
  align-items: center;
  gap: 10px;
}
.b9-team-score {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.b9-team-score .team-tag {
  font-size: 0.6rem;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.lcd-font {
  font-family: 'Share Tech Mono', monospace, sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
}
.away-score .score-digit {
  color: #f87171;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.85);
}
.home-score .score-digit {
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.85);
}
.b9-score-divider {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.3rem;
  color: #64748b;
  font-weight: 700;
}

/* 測速雷達槍視覺 */
.b9-speed-radar {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 6px;
  padding: 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: inset 0 0 6px rgba(245, 158, 11, 0.25);
}
.radar-label {
  font-size: 0.5rem;
  color: #f59e0b;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.radar-speed {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fef08a;
  text-shadow: 0 0 6px rgba(254, 240, 138, 0.7);
  line-height: 1;
}
.radar-unit {
  font-size: 0.5rem;
  color: #94a3b8;
}

/* B-S-O 復古球場燈泡 */
.stadium-bso {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 2px 0;
}
.count-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.count-label {
  font-family: 'Fredoka', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  width: 12px;
}
.group-ball .count-label { color: #4ade80; }
.group-strike .count-label { color: #facc15; }
.group-out .count-label { color: #f87171; }

.led-dots {
  display: flex;
  gap: 5px;
}
.led-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0f172a;
  border: 1.5px solid #334155;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  position: relative;
}
.lamp-filament {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}
.ball-dot.active {
  background: #16a34a;
  border-color: #86efac;
  box-shadow: 0 0 14px #22c55e, inset 0 0 4px #fff;
}
.ball-dot.active .lamp-filament {
  background: #ffffff;
  box-shadow: 0 0 6px #fff;
}
.strike-dot.active {
  background: #ca8a04;
  border-color: #fef08a;
  box-shadow: 0 0 14px #eab308, inset 0 0 4px #fff;
}
.strike-dot.active .lamp-filament {
  background: #ffffff;
  box-shadow: 0 0 6px #fff;
}
.out-dot.active {
  background: #dc2626;
  border-color: #fca5a5;
  box-shadow: 0 0 14px #ef4444, inset 0 0 4px #fff;
}
.out-dot.active .lamp-filament {
  background: #ffffff;
  box-shadow: 0 0 6px #fff;
}

/* ==========================================
   3D 立體棒球內野鑽石球場
   ========================================== */
.stadium-infield-3d {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #04432d;
  border: 2px solid rgba(16, 185, 129, 0.35);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.6), 0 6px 18px rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 10px 8px 8px 8px;
  position: relative;
  overflow: hidden;
}

/* 深淺交錯草皮割草條紋 (Turf Stripes) */
.field-turf-stripes {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(6, 95, 70, 0.4) 0px,
    rgba(6, 95, 70, 0.4) 20px,
    rgba(4, 120, 87, 0.25) 20px,
    rgba(4, 120, 87, 0.25) 40px
  );
  pointer-events: none;
}

/* 紅土內野弧面 (Clay Dirt Arc) */
.field-dirt-infield {
  position: absolute;
  top: 10px;
  width: 155px;
  height: 115px;
  background: radial-gradient(ellipse at center, #9a3412 0%, #7c2d12 70%, transparent 72%);
  opacity: 0.7;
  border-radius: 50% 50% 15% 15%;
  pointer-events: none;
}

.b9-diamond-wrap {
  width: 140px;
  height: 130px;
  position: relative;
  margin: 4px 0 8px 0;
  z-index: 2;
}

.diamond-chalk-svg {
  position: absolute;
  inset: 0;
  width: 140px;
  height: 130px;
  pointer-events: none;
  z-index: 1;
}

/* 立體厚實壘包 (3D Base Cushion) */
.base-diamond {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: rotate(45deg);
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px #fff;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 3;
}
.base-diamond.runner-active {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  border-color: #fef08a;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.95), 3px 3px 8px rgba(0, 0, 0, 0.7);
  transform: rotate(45deg) scale(1.15);
}

.base-second { top: 5px; left: 59px; }
.base-third { top: 54px; left: 11px; }
.base-first { top: 54px; left: 107px; }

.base-home {
  position: absolute;
  top: 104px;
  left: 59px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.home-plate-shape {
  width: 20px;
  height: 20px;
  background: #ffffff;
  clip-path: polygon(50% 100%, 100% 40%, 100% 0%, 0% 0%, 0% 40%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  border: 1px solid #94a3b8;
}

/* 跑者動態小球員 */
.runner-avatar-chip {
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  position: relative;
  animation: runner-breathe 1.5s ease-in-out infinite alternate;
}
.runner-cap {
  position: absolute;
  top: -7px;
  font-size: 10px;
}
@keyframes runner-breathe {
  0% { transform: rotate(-45deg) translateY(0); }
  100% { transform: rotate(-45deg) translateY(-2px); }
}

.batter-icon-3d {
  position: absolute;
  font-size: 16px;
  top: -8px;
  left: 20px;
}

.b9-situation-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: #fef08a;
  background: rgba(15, 23, 42, 0.88);
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  text-align: center;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

/* ==========================================
   對決身分與氣勢欄
   ========================================== */
.b9-role-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.b9-player-badge {
  flex: 1;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.my-role-badge {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18) 0%, rgba(15, 23, 42, 0.9) 100%);
}
.badge-avatar-frame {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.badge-role-icon {
  font-size: 1.15rem;
}
.badge-role-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}
.badge-role-sub {
  font-size: 0.62rem;
  color: #94a3b8;
  line-height: 1.2;
}
.b9-versus-badge {
  font-family: 'Fredoka', cursive;
  font-size: 0.8rem;
  font-weight: 900;
  padding: 3px 5px;
}
.vs-text-glowing {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

/* ==========================================
   MLB 轉播級本壘板特寫視角 (Homeplate Duel Cam)
   ========================================== */
.stadium-duel-stage {
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(11, 15, 25, 0.98) 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 10px 12px 10px;
  position: relative;
  overflow: visible;
  height: auto;
  min-height: auto;
}

/* 打擊區背景擬真白灰標線與捕手焦點 */
.batter-box-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.chalk-batter-box {
  position: absolute;
  top: 20px;
  width: 48px;
  height: 130px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.box-left { left: 6px; }
.box-right { right: 6px; }

.catcher-mitt-target {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  opacity: 0.18;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}
.batter-silhouette {
  position: absolute;
  top: 50px;
  right: 14px;
  opacity: 0.2;
  font-size: 1.6rem;
}

/* 投球飛行動畫 */
.pitch-flight-layer {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 10;
}
.flying-baseball {
  position: absolute;
  font-size: 2rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
  transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.flying-baseball.fly-to-tl {
  top: 70px; left: 36%;
  transform: translate(-50%, -50%) scale(1.3);
}
.flying-baseball.fly-to-tr {
  top: 70px; left: 64%;
  transform: translate(-50%, -50%) scale(1.3);
}
.flying-baseball.fly-to-bl {
  top: 130px; left: 36%;
  transform: translate(-50%, -50%) scale(1.3);
}
.flying-baseball.fly-to-br {
  top: 130px; left: 64%;
  transform: translate(-50%, -50%) scale(1.3);
}
.flying-baseball.fly-to-ball {
  top: 185px; left: 50%;
  transform: translate(-50%, -50%) scale(1.2);
}

/* 擊球炸裂光芒 */
.impact-blast-ring {
  position: absolute;
  top: 100px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 4px solid #fef08a;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  box-shadow: 0 0 30px #facc15, 0 0 60px #ef4444;
}
.impact-blast-ring.active {
  animation: blast-expand 0.35s ease-out forwards;
}
@keyframes blast-expand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(18); opacity: 0; }
}

/* ==========================================
   3D 浮空光學好球帶 (AR Virtual K-Zone)
   ========================================== */
.decision-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.decision-tag-group {
  display: flex;
  align-items: center;
  gap: 5px;
}
.kzone-hud-icon {
  font-size: 0.95rem;
}
.decision-prompt {
  font-size: 0.8rem;
  font-weight: 800;
  color: #38bdf8;
}
.decision-step-tag {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.6rem;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  color: #7dd3fc;
  letter-spacing: 0.5px;
}

.kzone-3d-perspective-frame {
  perspective: 700px;
  margin-bottom: 8px;
}

.strike-zone-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
  transform: rotateX(5deg);
  transition: transform 0.3s ease;
}

.strike-zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(14, 165, 233, 0.05);
  border: 2px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15), inset 0 0 10px rgba(56, 189, 248, 0.08);
}

.zone-cell {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 7px;
  padding: 8px 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.zone-cell:hover {
  background: rgba(30, 58, 138, 0.6);
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}
.zone-cell.selected {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.7) 0%, rgba(14, 165, 233, 0.9) 100%);
  border-color: #facc15;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.75), inset 0 0 6px #fff;
  transform: scale(1.02);
}

/* HUD 準心細節角標 */
.hud-corner {
  position: absolute;
  width: 5px;
  height: 5px;
  border-color: rgba(56, 189, 248, 0.6);
  pointer-events: none;
}
.corner-tl { top: 2px; left: 2px; border-top: 1.5px solid; border-left: 1.5px solid; }
.corner-tr { top: 2px; right: 2px; border-top: 1.5px solid; border-right: 1.5px solid; }
.corner-bl { bottom: 2px; left: 2px; border-bottom: 1.5px solid; border-left: 1.5px solid; }
.corner-br { bottom: 2px; right: 2px; border-bottom: 1.5px solid; border-right: 1.5px solid; }

.zone-label {
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}
.zone-en {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.58rem;
  color: #94a3b8;
}

.zone-ball-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px dashed rgba(245, 158, 11, 0.5);
  border-radius: 7px;
  padding: 6px;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  transition: all 0.2s ease;
}
.zone-ball-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: #f59e0b;
  color: #fef08a;
}
.zone-ball-btn.selected {
  background: rgba(245, 158, 11, 0.25);
  border-color: #facc15;
  color: #fde047;
  border-style: solid;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.65);
}

/* ==========================================
   球種轉播開關 (Broadcast Pitch Switch)
   ========================================== */
.broadcast-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.broadcast-switch .pitch-type-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.broadcast-switch .pitch-type-btn input { display: none; }
.broadcast-switch .type-name {
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
}
.broadcast-switch .type-sub {
  font-size: 0.56rem;
  color: #94a3b8;
}
.broadcast-switch .pitch-type-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.45) 100%);
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.45);
}
.broadcast-switch .pitch-type-btn.active .type-sub {
  color: #a7f3d0;
}

/* ==========================================
   收藏級棒球球員卡 (Trading Cards)
   ========================================== */
.tactic-cards-section {
  margin-bottom: 10px;
}
.tactic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.tactic-title-box {
  display: flex;
  align-items: center;
  gap: 5px;
}
.tactic-title {
  font-size: 0.75rem;
  color: #cbd5e1;
  font-weight: 800;
}
.tactic-status {
  font-size: 0.7rem;
  color: #f59e0b;
  font-weight: 700;
}

.tactic-cards-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
@media (min-width: 480px) {
  .tactic-cards-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

.b9-tactic-card.trading-card-foil {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1.5px solid #b45309;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 3px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 70px;
}
.b9-tactic-card:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.4);
}

/* 燙金閃卡全像光澤 (Foil Sheen) */
.card-foil-sheen {
  position: absolute;
  inset: -50%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 45%,
    rgba(254, 240, 138, 0.25) 50%,
    transparent 55%
  );
  transform: rotate(25deg);
  pointer-events: none;
  opacity: 0.6;
}

.b9-tactic-card.active {
  background: linear-gradient(145deg, rgba(180, 83, 9, 0.45) 0%, rgba(245, 158, 11, 0.55) 100%);
  border-color: #fef08a;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.8), 0 0 30px rgba(254, 240, 138, 0.35);
  transform: translateY(-2px);
}
.b9-tactic-card.used {
  opacity: 0.35;
  filter: grayscale(1);
  cursor: not-allowed;
  pointer-events: none;
}

.b9-tactic-card .card-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.b9-tactic-card .card-rarity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 0.5rem;
  line-height: 1;
  margin-bottom: 1px;
}
.b9-tactic-card .card-rarity-stars {
  color: #facc15;
}
.b9-tactic-card .card-role-chip {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 3px;
  border-radius: 3px;
  color: #94a3b8;
  font-size: 0.55rem;
  font-weight: 700;
}
.b9-tactic-card .card-icon {
  font-size: 0.95rem;
}
.b9-tactic-card .card-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fef08a;
}
.b9-tactic-card .card-desc {
  font-size: 0.66rem;
  color: #cbd5e1;
  line-height: 1.25;
  margin: 0;
  min-height: auto;
}
.b9-tactic-card .card-badge-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.b9-tactic-card .card-badge {
  font-size: 0.55rem;
  font-weight: 800;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  padding: 1px 5px;
  border-radius: 4px;
}
.b9-tactic-card.used .card-badge {
  background: rgba(100, 116, 139, 0.2);
  border-color: rgba(100, 116, 139, 0.4);
  color: #94a3b8;
}

.stadium-commit-btn {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #0c4a6e 100%);
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 10px;
  color: #fff;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.2s ease;
  width: 100%;
}
.stadium-commit-btn:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.7);
}

/* ==========================================
   投打揭示與 3D 雙骰對決舞台
   ========================================== */
.duel-telecast {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stadium-dice-arena {
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95) 0%, rgba(5, 8, 15, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 8px;
}

.b9-dice {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  font-family: 'Fredoka', cursive;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 2px 3px rgba(255, 255, 255, 0.3);
  transition: transform 0.2s ease;
}

.die-pitcher {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  border: 2px solid #fca5a5;
}
.die-batter {
  background: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
  color: #fff;
  border: 2px solid #7dd3fc;
}

.stadium-callout {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(6, 78, 59, 0.65) 100%);
  border: 2px solid rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  margin-bottom: 8px;
}
.stadium-next-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  font-size: 0.95rem;
  font-weight: 900;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
  color: #fff;
  width: 100%;
  cursor: pointer;
}

/* 廣播跑馬燈與底部列 */
.b9-announcer-footer {
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.announcer-mic { font-size: 1rem; flex-shrink: 0; }
.announcer-content {
  font-size: 0.72rem;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.b9-bottom-nav {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
}
.btn-sub-nav {
  flex: 1;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #cbd5e1;
  padding: 8px 4px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.btn-sub-nav:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

/* 終局結算與規則彈窗微調 */
.modal-gameover { text-align: center; }
.gameover-trophy { font-size: 3.5rem; margin-bottom: 6px; }
.gameover-title { font-size: 1.4rem; font-weight: 900; margin-bottom: 4px; }
.gameover-sub { font-size: 0.82rem; color: #94a3b8; margin-bottom: 14px; }
.gameover-final-box {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
}
.final-score-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.final-team {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.final-name { font-size: 0.72rem; color: #94a3b8; }
.final-num { font-family: 'Share Tech Mono', monospace; font-size: 2rem; font-weight: 800; color: #fff; }
.final-vs { font-size: 1rem; font-weight: 800; color: #64748b; }
.final-highlight { font-size: 0.78rem; color: #facc15; margin-top: 6px; }

.b9-log-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.b9-log-item {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
}
.log-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.log-pitch-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
}
.log-result-tag { font-size: 0.75rem; font-weight: 800; color: #fde047; }
.log-item-body { font-size: 0.75rem; line-height: 1.3; }

.rules-body {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.rule-block h3 { font-size: 0.92rem; color: #38bdf8; margin-bottom: 4px; }
.rule-block p { font-size: 0.78rem; line-height: 1.5; color: #cbd5e1; }
.rule-table { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
}
.badge-bonus-demo {
  font-weight: 800;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 12px;
  white-space: nowrap;
}
.badge-bonus-demo.full { background: #059669; color: #fff; }
.badge-bonus-demo.half { background: #0284c7; color: #fff; }
.badge-bonus-demo.none { background: #dc2626; color: #fff; }

.b9-role-selector { display: flex; flex-direction: column; gap: 8px; }
.role-opt { display: flex; align-items: center; cursor: pointer; }
.role-opt input { margin-right: 8px; }
.role-chip { font-size: 0.82rem; font-weight: 700; color: #f8fafc; }

