/* ----------------------------------------------------
   BaghChal Style System
   Vanilla CSS with CSS Variables, HSL Color Palettes, 
   Glassmorphism, Theme-switching, and Custom Keyframes.
   ---------------------------------------------------- */

/* Reset & Base Rules */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-logo: 'Cinzel', serif;
  --font-body: 'Inter', sans-serif;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  --transition-slow: 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.25);
  --glow-shadow: 0 0 15px var(--accent-glow);
}

/* ----------------------------------------------------
   Theme Tokens
   ---------------------------------------------------- */

/* 1. Himalayan Slate (Dark/Cold Mode) */
.theme-himalayan-slate {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.6);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --border-color: rgba(51, 65, 85, 0.5);
  --border-color-active: rgba(20, 184, 166, 0.8);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-goat: #0d9488; /* Teal */
  --accent-goat-light: #14b8a6;
  --accent-tiger: #d97706; /* Bronze Gold */
  --accent-tiger-light: #f59e0b;
  
  --bg-glow-1: rgba(13, 148, 136, 0.06);
  --bg-glow-2: rgba(217, 119, 6, 0.04);
  --accent-glow: rgba(20, 184, 166, 0.35);
  --board-wood: #1e293b;
  --board-lines: #475569;
  --board-lines-glow: rgba(148, 163, 184, 0.1);
}

/* 2. Royal Brass (Traditional Warm Mode) */
.theme-royal-brass {
  --bg-primary: #1c0c04;
  --bg-secondary: #2d150a;
  --bg-card: rgba(45, 21, 10, 0.6);
  --bg-card-hover: rgba(67, 33, 16, 0.85);
  --border-color: rgba(180, 83, 9, 0.3);
  --border-color-active: rgba(245, 158, 11, 0.8);
  --text-primary: #fffbeb;
  --text-secondary: #fcd34d;
  --text-muted: #b45309;
  
  --accent-goat: #b45309; /* Deep Copper Brass */
  --accent-goat-light: #d97706;
  --accent-tiger: #ea580c; /* Tiger Orange */
  --accent-tiger-light: #f97316;
  
  --bg-glow-1: rgba(180, 83, 9, 0.08);
  --bg-glow-2: rgba(234, 88, 12, 0.06);
  --accent-glow: rgba(245, 158, 11, 0.3);
  --board-wood: #451a03;
  --board-lines: #d97706;
  --board-lines-glow: rgba(251, 191, 36, 0.15);
}

/* 3. Cyber Bagh (Neon Futuristic Mode) */
.theme-cyber {
  --bg-primary: #05020a;
  --bg-secondary: #0e051a;
  --bg-card: rgba(14, 5, 26, 0.65);
  --bg-card-hover: rgba(28, 10, 50, 0.85);
  --border-color: rgba(124, 58, 237, 0.4);
  --border-color-active: rgba(0, 255, 204, 0.8);
  --text-primary: #ffffff;
  --text-secondary: #c084fc;
  --text-muted: #6b21a8;
  
  --accent-goat: #00ffcc; /* Neon Cyan */
  --accent-goat-light: #55ffee;
  --accent-tiger: #ff0055; /* Neon Magenta */
  --accent-tiger-light: #ff5599;
  
  --bg-glow-1: rgba(0, 255, 204, 0.08);
  --bg-glow-2: rgba(255, 0, 85, 0.06);
  --accent-glow: rgba(0, 255, 204, 0.4);
  --board-wood: #130a24;
  --board-lines: #7c3aed;
  --board-lines-glow: rgba(124, 58, 237, 0.3);
}

/* ----------------------------------------------------
   Global Layout & Background Animations
   ---------------------------------------------------- */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-slow);
}

/* Ambient glow blobs */
.ambient-glow {
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: var(--radius-full);
  filter: blur(100px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.8;
  transition: background-color var(--transition-slow);
}
.bg-glow-1 {
  background: var(--bg-glow-1);
  top: -10vw;
  left: -10vw;
  animation: float-glow-1 25s ease-in-out infinite alternate;
}
.bg-glow-2 {
  background: var(--bg-glow-2);
  bottom: -10vw;
  right: -10vw;
  animation: float-glow-2 20s ease-in-out infinite alternate;
}

@keyframes float-glow-1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(10vw, 5vw) scale(1.15); }
}
@keyframes float-glow-2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-8vw, -10vw) scale(0.9); }
}

/* Application Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

/* ----------------------------------------------------
   Header System
   ---------------------------------------------------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nepal-flag {
  font-size: 2.25rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}
.title-wrapper h1 {
  font-family: var(--font-logo);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
.subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  font-weight: 600;
}
.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Glassmorphism utility card */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}
.glass:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* ----------------------------------------------------
   Button Styles
   ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  user-select: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-goat), var(--accent-goat-light));
  color: #fff;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.45), var(--glow-shadow);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-secondary);
  color: #fff;
}
.btn-secondary:disabled, .btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.btn-full {
  width: 100%;
}
.btn-half {
  flex: 1;
}

/* ----------------------------------------------------
   Dashboard / Layout Grid
   ---------------------------------------------------- */
.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 1.5rem;
  flex: 1;
  align-items: stretch;
}

/* Panels Title */
.panel-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* ----------------------------------------------------
   Stats Panel (Left Sidebar)
   ---------------------------------------------------- */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 0 1.25rem 0;
}

/* Turn Indicator Card */
.turn-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 1.25rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
}
.turn-indicator {
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-full);
  background-color: var(--accent-goat);
  box-shadow: 0 0 10px var(--accent-goat);
  transition: all var(--transition-normal);
}
.turn-card.tiger-turn .turn-indicator {
  background-color: var(--accent-tiger);
  box-shadow: 0 0 10px var(--accent-tiger);
}
.turn-details {
  display: flex;
  flex-direction: column;
}
.turn-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.active-player {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}
.pulse-active {
  animation: pulse-glow 1.5s ease-in-out infinite alternate;
}
@keyframes pulse-glow {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 1; }
}

/* Common Stat Cards */
.stats-card {
  margin: 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.stat-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stat-icon {
  font-size: 1.5rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
}
.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-subtext {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Captures Card with Progress Bar */
.captures-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.captures-fraction {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent-tiger-light);
}
.progress-bar-container {
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-tiger), var(--accent-tiger-light));
  box-shadow: 0 0 8px var(--accent-tiger-light);
  width: 0%;
  transition: width 0.4s ease-out;
}
.progress-subtext {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* General metrics list */
.metrics-card {
  gap: 0.5rem;
  margin-top: auto; /* Push stats metrics to the bottom */
}
.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.metric:last-child {
  border-bottom: none;
}
.metric-label {
  color: var(--text-secondary);
}
.metric-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* ----------------------------------------------------
   Board Stage (Center Play Area)
   ---------------------------------------------------- */
.board-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.board-wrapper {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 580px;
  padding: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  position: relative;
  background: radial-gradient(circle at center, var(--board-wood) 20%, var(--bg-secondary) 100%);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.4) inset;
}

#baghchal-board {
  max-height: 100%;
  max-width: 100%;
  overflow: visible;
}

/* SVG Elements Styling */
.grid-line {
  stroke: var(--board-lines);
  stroke-linecap: round;
  transition: stroke var(--transition-slow);
}
.grid-line.diagonal {
  stroke-width: 2.5px;
  opacity: 0.85;
}
.board-glow-line {
  stroke: var(--accent-glow);
  opacity: 0.15;
  stroke-width: 8px;
  filter: blur(2px);
}

/* Intersection Interactive Points */
.board-node {
  fill: var(--board-wood);
  stroke: var(--board-lines);
  stroke-width: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.board-node:hover {
  fill: rgba(255, 255, 255, 0.15);
  stroke: var(--text-secondary);
  r: 9;
}
.board-node.occupied {
  cursor: default;
}
.node-glow {
  fill: var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}
.node-glow.highlight-destination {
  opacity: 0.25;
  animation: target-ring-pulse 1.2s infinite ease-in-out;
  cursor: pointer;
  pointer-events: all;
}
@keyframes target-ring-pulse {
  0% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(1); opacity: 0.2; }
}

/* Last move highlights */
.highlight-last-move {
  stroke: var(--accent-tiger);
  stroke-width: 4px;
  stroke-linecap: round;
  opacity: 0.6;
  stroke-dasharray: 6 4;
}

/* ----------------------------------------------------
   Game Pieces Rendering
   ---------------------------------------------------- */
.piece-group {
  cursor: pointer;
  transition: transform var(--transition-normal);
}
.piece-group:focus-visible {
  outline: 2px solid var(--accent-goat-light);
  outline-offset: 4px;
}
.piece-plate {
  stroke-width: 3.5px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
  transition: all var(--transition-fast);
}

/* Tiger styling */
.piece-group.tiger .piece-plate {
  fill: #271404;
  stroke: var(--accent-tiger);
}
.piece-group.tiger:hover .piece-plate {
  fill: #3b1e06;
  stroke: var(--accent-tiger-light);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 6px var(--accent-tiger));
}
.tiger-icon {
  fill: var(--accent-tiger-light);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: bold;
  user-select: none;
  pointer-events: none;
}

/* Goat styling */
.piece-group.goat .piece-plate {
  fill: #041a18;
  stroke: var(--accent-goat);
}
.piece-group.goat:hover .piece-plate {
  fill: #092c29;
  stroke: var(--accent-goat-light);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 6px var(--accent-goat));
}
.goat-icon {
  fill: var(--accent-goat-light);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: bold;
  user-select: none;
  pointer-events: none;
}

/* Selection and status states */
.piece-group.selected .piece-plate {
  transform: scale(1.15);
  stroke: var(--text-primary);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 10px var(--border-color-active)) !important;
}

/* Dynamic placement and movement animations */
.place-bounce {
  animation: piece-place var(--transition-slow);
}
@keyframes piece-place {
  0% { transform: scale(2); opacity: 0; }
  60% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); }
}

.capture-shake {
  animation: screen-shake 0.4s ease-out;
}
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(8px, -4px); }
  45% { transform: translate(-6px, -2px); }
  60% { transform: translate(6px, 2px); }
  75% { transform: translate(-2px, 1px); }
}

/* ----------------------------------------------------
   Log Panel (Right Sidebar)
   ---------------------------------------------------- */
.log-panel {
  display: flex;
  flex-direction: column;
  padding-bottom: 1.25rem;
}

.history-container {
  height: clamp(200px, 35vh, 320px);
  margin: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.history-container:focus-visible {
  outline: 2px solid var(--border-color-active);
}

.empty-log-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 1.5rem;
  color: var(--text-muted);
}
.empty-log-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}
.empty-subtext {
  font-size: 0.7rem;
  margin-top: 0.5rem;
  line-height: 1.3;
}

/* Live Move History List */
.move-list {
  padding: 0.75rem 1rem;
  list-style: none;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.move-item {
  display: grid;
  grid-template-columns: 24px 1fr 1fr;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.move-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}
.move-number {
  color: var(--text-muted);
  font-weight: 700;
}
.move-goat, .move-tiger {
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-body);
}
.move-goat {
  color: var(--accent-goat-light);
}
.move-tiger {
  color: var(--accent-tiger-light);
}
.move-active {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: var(--border-color) !important;
  font-weight: 600;
}

/* Log Actions Panel (Undo/Redo) */
.log-actions {
  display: flex;
  gap: 0.75rem;
  margin: 0 1.25rem 1rem;
}

/* Tip container card */
.tips-card {
  margin: 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(13, 148, 136, 0.03);
  border: 1px solid rgba(13, 148, 136, 0.1);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}
.tips-title {
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--accent-goat-light);
}

/* ----------------------------------------------------
   Native Modal Dialog Styling (<dialog>)
   ---------------------------------------------------- */
.modal-dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 550px;
  width: 90%;
  color: var(--text-primary);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9);
  transition: all var(--transition-normal) allow-discrete;
}
.modal-dialog[open] {
  opacity: 1;
  transform: scale(1);
}

@starting-style {
  .modal-dialog[open] {
    opacity: 0;
    transform: scale(0.9);
  }
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: backdrop-filter var(--transition-normal);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}
.dialog-header h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}
.close-dialog-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}
.close-dialog-btn:hover {
  color: #fff;
}

.dialog-body {
  padding: 1.75rem;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.dialog-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

/* Custom Scrollbars */
.dialog-body::-webkit-scrollbar, .history-container::-webkit-scrollbar {
  width: 6px;
}
.dialog-body::-webkit-scrollbar-track, .history-container::-webkit-scrollbar-track {
  background: transparent;
}
.dialog-body::-webkit-scrollbar-thumb, .history-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
.dialog-body::-webkit-scrollbar-thumb:hover, .history-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Setting Sections Form Layout */
.setting-group {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.setting-group legend {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

/* Radio Option Toggles */
.radio-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.radio-toggle-group input[type="radio"] {
  display: none;
}
.radio-toggle-group label {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.radio-toggle-group label:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}
.radio-toggle-group input[type="radio"]:checked + label {
  background: rgba(13, 148, 136, 0.05);
  border-color: var(--accent-goat-light);
  box-shadow: 0 0 10px rgba(13, 148, 136, 0.15);
}
.opt-title {
  font-weight: 700;
  font-size: 0.9rem;
}
.opt-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Side Selector Buttons */
.button-toggle-group {
  display: flex;
  gap: 0.75rem;
}
.button-toggle-group input[type="radio"] {
  display: none;
}
.button-toggle-group label {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.button-toggle-group label:hover {
  background: rgba(255, 255, 255, 0.04);
}
.button-toggle-group input[type="radio"]:checked + label.side-label {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--text-primary);
}
.button-toggle-group input#side-goat:checked + label {
  background: rgba(13, 148, 136, 0.06);
  border-color: var(--accent-goat-light);
  box-shadow: 0 0 10px rgba(13, 148, 136, 0.15);
}
.button-toggle-group input#side-tiger:checked + label {
  background: rgba(217, 119, 6, 0.06);
  border-color: var(--accent-tiger-light);
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.15);
}

/* Multi-Segment Triple Toggle Button */
.triple-toggle-group {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.triple-toggle-group input[type="radio"] {
  display: none;
}
.triple-toggle-group label {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.triple-toggle-group label:hover {
  color: #fff;
}
.triple-toggle-group input[type="radio"]:checked + label {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Slider Checkbox Switch Toggle */
.checkbox-setting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
}
.switch-container {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}
.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  transition: .3s;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: .3s;
}
.switch-container input:checked + .switch-slider {
  background-color: var(--accent-goat);
  border-color: var(--accent-goat-light);
}
.switch-container input:checked + .switch-slider:before {
  transform: translateX(22px);
  background-color: #fff;
}
.setting-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Visual Theme Selection Grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-card:hover {
  background: rgba(255, 255, 255, 0.04);
}
.theme-card.active {
  border-color: var(--border-color-active);
  background: rgba(255, 255, 255, 0.06);
}
.theme-preview {
  display: flex;
  height: 14px;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
}
.theme-preview span {
  flex: 1;
  height: 100%;
}
.theme-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.theme-card.active .theme-name {
  color: var(--text-primary);
}

/* ----------------------------------------------------
   Rules Disclosures (Details/Summary Native Accordions)
   ---------------------------------------------------- */
.rules-body {
  gap: 0.85rem;
}
.rules-body details {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all var(--transition-normal);
}
.rules-body details[open] {
  border-color: var(--border-color-active);
}
.rules-body summary {
  padding: 0.85rem 1.25rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  list-style-position: inside;
  transition: background var(--transition-fast);
}
.rules-body summary:hover {
  background: rgba(255, 255, 255, 0.03);
}
.disclosure-content {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.disclosure-content p {
  margin-bottom: 0.75rem;
}
.disclosure-content ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.disclosure-content li strong {
  color: var(--text-primary);
}

/* ----------------------------------------------------
   Game Over Dialog Overlay
   ---------------------------------------------------- */
.game-over-modal {
  max-width: 480px;
  text-align: center;
}
.game-over-content {
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.win-trophy {
  font-size: 4rem;
  line-height: 1;
  animation: bounce-trophy 2s infinite alternate;
}
@keyframes bounce-trophy {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-10px) scale(1.1); }
}
.game-over-content h2 {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.go-text-highlight {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 320px;
  line-height: 1.4;
}

.stats-summary-card {
  width: 100%;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 0.75rem 0 1.25rem;
}
.stats-summary-card h3 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.go-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}
.go-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.go-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.go-stat-val {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* ----------------------------------------------------
   Footer Styles
   ---------------------------------------------------- */
.app-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}

/* ----------------------------------------------------
   Responsive Adjustments (Mobile, Tablet, Desktop)
   ---------------------------------------------------- */

@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 1.25rem;
  }
  .board-stage {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .stats-panel {
    grid-column: 1;
    grid-row: 2;
  }
  .log-panel {
    grid-column: 2;
    grid-row: 2;
  }
  .metrics-card {
    margin-top: 1rem;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 0.75rem;
  }
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .header-actions {
    justify-content: space-between;
  }
  .btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
  }
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 1rem;
  }
  .board-stage {
    grid-column: 1;
    grid-row: 1;
  }
  .stats-panel {
    grid-column: 1;
    grid-row: 2;
  }
  .log-panel {
    grid-column: 1;
    grid-row: 3;
  }
  .board-wrapper {
    padding: 1.25rem;
  }
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .close-dialog-btn {
    font-size: 1.5rem;
  }
  .dialog-body {
    padding: 1.25rem;
  }
}

/* ----------------------------------------------------
   Phase 2 Premium Visual Upgrades
   ---------------------------------------------------- */

/* 1. Concentric Ring Accents for the 13 Diagonal intersections */
.node-diagonal {
  fill: none;
  stroke: var(--board-lines);
  stroke-width: 1.5px;
  stroke-opacity: 0.4;
  stroke-dasharray: 4 2;
  pointer-events: none;
  transition: all var(--transition-slow);
}
.theme-royal-brass .node-diagonal {
  stroke: var(--accent-goat);
  stroke-opacity: 0.6;
}
.theme-cyber .node-diagonal {
  stroke: var(--border-color);
  stroke-opacity: 0.7;
}

/* 2. Interactive SVG Pieces Styling */
.piece-svg {
  fill: currentColor;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  transition: transform var(--transition-fast), fill var(--transition-fast);
}

.piece-group.goat .piece-svg {
  color: var(--accent-goat-light);
}

.piece-group.tiger .piece-svg {
  color: var(--accent-tiger-light);
}

/* 3. Wiggle Shake Animation on illegal Moves */
.wiggle-invalid {
  animation: wiggle-shake-keyframes 0.38s cubic-bezier(.36,.07,.19,.97) both;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes wiggle-shake-keyframes {
  10%, 90% { transform: translate(-3px, 0); }
  20%, 80% { transform: translate(3px, 0); }
  30%, 50%, 70% { transform: translate(-5px, 0); }
  40%, 60% { transform: translate(5px, 0); }
}

/* 4. Animated Flowing Dotted Path Connectors */
.path-connector {
  stroke: var(--accent-goat-light);
  stroke-width: 2.5px;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  stroke-opacity: 0.8;
  fill: none;
  pointer-events: none;
  animation: path-flow-keyframes 1.2s linear infinite;
  transition: stroke var(--transition-normal);
}

.piece-group.tiger + .path-connector,
.tiger-path-connector {
  stroke: var(--accent-tiger-light) !important;
}

@keyframes path-flow-keyframes {
  to {
    stroke-dashoffset: -20;
  }
}

/* 5. Trapped Locked Red Overlay with Padlock */
.trapped-locked .piece-plate {
  stroke: #ef4444 !important;
  filter: drop-shadow(0 0 10px #ef4444) !important;
  fill: #1a0505 !important;
}

.trapped-locked .piece-svg {
  color: #f87171 !important;
  opacity: 0.4;
}

.trapped-locked .piece-lock-badge {
  fill: #ef4444;
  stroke: #000;
  stroke-width: 0.5px;
  animation: lock-pulse-keyframes 1.5s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes lock-pulse-keyframes {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.15); opacity: 1; }
}

/* 6. Ghost Previews on Hover in Phase 1 */
.ghost-piece {
  opacity: 0.0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.board-node:hover ~ .ghost-piece,
.ghost-piece.visible {
  opacity: 0.45;
}

.ghost-piece .piece-plate {
  stroke-dasharray: 4 3;
  fill: transparent !important;
}

/* 7. Screen-wide Gold Translucent Phase splash banner Overlay */
.phase-splash-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.phase-splash-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.phase-splash-content {
  text-align: center;
  padding: 3rem 2rem;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at center, rgba(217, 119, 6, 0.15) 0%, rgba(15, 23, 42, 0.9) 100%);
  border: 2px solid var(--accent-tiger);
  box-shadow: 0 0 50px rgba(217, 119, 6, 0.4), var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  transform: scale(0.8);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.phase-splash-overlay.show .phase-splash-content {
  transform: scale(1);
}

.splash-shield {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float-shield-keyframes 3s ease-in-out infinite alternate;
}

@keyframes float-shield-keyframes {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

.splash-title {
  font-family: var(--font-logo);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent-tiger-light);
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
  margin-bottom: 0.5rem;
}

.splash-subtitle {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.splash-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 8. Accessibility focus states for high-contrast glows */
.board-node:focus-visible, .piece-group:focus-visible {
  outline: 3px solid var(--border-color-active) !important;
  outline-offset: 4px;
  border-radius: var(--radius-full);
}
.piece-group.tiger:focus-visible {
  outline: 3px solid var(--accent-tiger-light) !important;
}
