/* ==========================================================================
   CSS GLOBAL DESIGN SYSTEM & 5 PREMIUM THEMES
   ========================================================================== */

:root {
  /* Default Theme: Glassmorphism (Frosted visual crystal aesthetic) */
  --bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #111827 50%, #030712 100%);
  --panel-bg: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-glow: rgba(255, 255, 255, 0.03);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-color: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  
  --player-x: #06b6d4;
  --player-x-glow: rgba(6, 182, 212, 0.4);
  --player-o: #ec4899;
  --player-o-glow: rgba(236, 72, 153, 0.4);
  
  --card-blur: 16px;
  --cell-bg: rgba(255, 255, 255, 0.03);
  --cell-hover: rgba(255, 255, 255, 0.08);
}

/* --- Theme 1: Glassmorphism Explicit Variables --- */
[data-theme="glassmorphism"] {
  --bg-gradient: linear-gradient(135deg, #0f0c1b 0%, #15102a 50%, #06020f 100%);
  --panel-bg: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-glow: rgba(139, 92, 246, 0.12);
  --accent-color: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.4);
  --player-x: #38bdf8;
  --player-x-glow: rgba(56, 189, 248, 0.4);
  --player-o: #f472b6;
  --player-o-glow: rgba(244, 114, 182, 0.4);
}

/* --- Theme 2: Neon Cyberpunk (Hot pink and cyan neon pulses) --- */
[data-theme="neon-cyberpunk"] {
  --bg-gradient: radial-gradient(circle at center, #050508 0%, #010103 100%);
  --panel-bg: rgba(4, 4, 8, 0.75);
  --panel-border: #390099;
  --panel-glow: rgba(255, 0, 127, 0.1);
  
  --text-primary: #00f0ff;
  --text-secondary: #ff007f;
  --text-muted: #7209b7;
  
  --accent-color: #f72585;
  --accent-glow: rgba(247, 37, 133, 0.6);
  
  --player-x: #00f0ff;
  --player-x-glow: rgba(0, 240, 255, 0.6);
  --player-o: #ff007f;
  --player-o-glow: rgba(255, 0, 127, 0.6);
  
  --cell-bg: rgba(0, 240, 255, 0.02);
  --cell-hover: rgba(255, 0, 127, 0.06);
}

/* --- Theme 3: Galaxy Space (Deep purple starfields) --- */
[data-theme="galaxy-space"] {
  --bg-gradient: linear-gradient(180deg, #090916 0%, #050510 50%, #020205 100%);
  --panel-bg: rgba(13, 10, 36, 0.55);
  --panel-border: rgba(147, 51, 234, 0.25);
  --panel-glow: rgba(79, 70, 229, 0.15);
  
  --text-primary: #c084fc;
  --text-secondary: #818cf8;
  --text-muted: #4b4875;
  
  --accent-color: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.5);
  
  --player-x: #a78bfa;
  --player-x-glow: rgba(167, 139, 250, 0.5);
  --player-o: #f472b6;
  --player-o-glow: rgba(244, 114, 182, 0.5);
  
  --cell-bg: rgba(139, 92, 246, 0.03);
  --cell-hover: rgba(244, 114, 182, 0.08);
}

/* --- Theme 4: Dark Elite (Premium carbon gold weave) --- */
[data-theme="dark-elite"] {
  --bg-gradient: linear-gradient(135deg, #111111 0%, #0a0a0a 50%, #050505 100%);
  --panel-bg: rgba(20, 20, 20, 0.85);
  --panel-border: #d4af37; /* Gold border */
  --panel-glow: rgba(212, 175, 55, 0.08);
  
  --text-primary: #f5f5f7;
  --text-secondary: #d4af37; /* Metallic Gold Accent */
  --text-muted: #555555;
  
  --accent-color: #d4af37;
  --accent-glow: rgba(212, 175, 55, 0.4);
  
  --player-x: #ffffff;
  --player-x-glow: rgba(255, 255, 255, 0.35);
  --player-o: #d4af37;
  --player-o-glow: rgba(212, 175, 55, 0.5);
  
  --cell-bg: rgba(255, 255, 255, 0.01);
  --cell-hover: rgba(212, 175, 55, 0.05);
}

/* --- Theme 5: Futuristic Holographic (Teal cyan scanline grid) --- */
[data-theme="futuristic-holographic"] {
  --bg-gradient: linear-gradient(135deg, #01161e 0%, #000c11 50%, #000508 100%);
  --panel-bg: rgba(2, 48, 71, 0.3);
  --panel-border: rgba(142, 202, 230, 0.4);
  --panel-glow: rgba(33, 150, 243, 0.15);
  
  --text-primary: #8ecae6;
  --text-secondary: #2196f3;
  --text-muted: #124559;
  
  --accent-color: #2196f3;
  --accent-glow: rgba(33, 150, 243, 0.5);
  
  --player-x: #8ecae6;
  --player-x-glow: rgba(142, 202, 230, 0.5);
  --player-o: #ffb703;
  --player-o-glow: rgba(255, 183, 3, 0.5);
  
  --cell-bg: rgba(33, 150, 243, 0.02);
  --cell-hover: rgba(142, 202, 230, 0.08);
}

/* --- Theme 6: Sunset Retro (Warm synthwave gradients) --- */
[data-theme="sunset-retro"] {
  --bg-gradient: linear-gradient(135deg, #2d145b 0%, #7c2cf5 45%, #ff6e6c 100%);
  --panel-bg: rgba(255, 151, 214, 0.08);
  --panel-border: rgba(255, 120, 160, 0.25);
  --panel-glow: rgba(255, 111, 97, 0.18);
  
  --text-primary: #fde68a;
  --text-secondary: #fbcfe8;
  --text-muted: #c084fc;
  
  --accent-color: #fb7185;
  --accent-glow: rgba(251, 113, 133, 0.45);
  
  --player-x: #f472b6;
  --player-x-glow: rgba(244, 114, 182, 0.45);
  --player-o: #fda4af;
  --player-o-glow: rgba(253, 164, 175, 0.45);
  
  --cell-bg: rgba(249, 168, 212, 0.05);
  --cell-hover: rgba(251, 146, 255, 0.08);
}

/* --- Theme 7: Matrix Green (Digital code rain ambiance) --- */
[data-theme="matrix-green"] {
  --bg-gradient: linear-gradient(180deg, #020801 0%, #050c02 55%, #0b1b04 100%);
  --panel-bg: rgba(2, 18, 3, 0.85);
  --panel-border: rgba(16, 185, 129, 0.25);
  --panel-glow: rgba(16, 185, 129, 0.18);
  
  --text-primary: #a7f3d0;
  --text-secondary: #6ee7b7;
  --text-muted: #4d7c63;
  
  --accent-color: #22c55e;
  --accent-glow: rgba(34, 197, 94, 0.5);
  
  --player-x: #4ade80;
  --player-x-glow: rgba(74, 222, 128, 0.4);
  --player-o: #86efac;
  --player-o-glow: rgba(134, 239, 172, 0.4);
  
  --cell-bg: rgba(34, 197, 94, 0.04);
  --cell-hover: rgba(34, 197, 94, 0.09);
}

/* --- Theme 8: Ice Crystal (Cool glacier glass and frost) --- */
[data-theme="ice-crystal"] {
  --bg-gradient: linear-gradient(135deg, #0b1724 0%, #0f2c44 45%, #0a1d2d 100%);
  --panel-bg: rgba(219, 234, 254, 0.08);
  --panel-border: rgba(191, 219, 254, 0.3);
  --panel-glow: rgba(191, 219, 254, 0.18);
  
  --text-primary: #e0f2fe;
  --text-secondary: #bae6fd;
  --text-muted: #7dd3fc;
  
  --accent-color: #60a5fa;
  --accent-glow: rgba(96, 165, 250, 0.45);
  
  --player-x: #93c5fd;
  --player-x-glow: rgba(147, 197, 253, 0.4);
  --player-o: #38bdf8;
  --player-o-glow: rgba(56, 189, 248, 0.4);
  
  --cell-bg: rgba(134, 239, 255, 0.03);
  --cell-hover: rgba(96, 165, 250, 0.08);
}

/* --- Theme 9: Plasma Pulse (Electric violet and lime neon) --- */
[data-theme="plasma-pulse"] {
  --bg-gradient: radial-gradient(circle at top, #1f0c3c 0%, #09020f 45%, #020106 100%);
  --panel-bg: rgba(14, 6, 28, 0.82);
  --panel-border: rgba(167, 139, 250, 0.3);
  --panel-glow: rgba(168, 85, 247, 0.18);
  
  --text-primary: #f5f3ff;
  --text-secondary: #c084fc;
  --text-muted: #a78bfa;
  
  --accent-color: #a855f7;
  --accent-glow: rgba(168, 85, 247, 0.45);
  
  --player-x: #8b5cf6;
  --player-x-glow: rgba(139, 92, 246, 0.45);
  --player-o: #84cc16;
  --player-o-glow: rgba(132, 204, 22, 0.45);
  
  --cell-bg: rgba(167, 139, 250, 0.03);
  --cell-hover: rgba(132, 204, 22, 0.08);
}

/* ==========================================================================
   RESET & FOUNDATIONS
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background 0.8s ease, color 0.5s ease;
}

/* Smooth custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Background & FX Canvases absolute layering */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1; /* Layer behind everything */
  pointer-events: none;
}

#fx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999; /* Layer fully on top of all interactions */
  pointer-events: none;
}

/* Global Application Wrapper */
.app-wrapper {
  position: relative;
  z-index: 10; /* Render above background canvas */
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 100px 24px 40px 24px; /* Space top for global header absolute position */
}

/* ==========================================================================
   GLOBAL HEADER (Theme selection and Volume triggers top right)
   ========================================================================== */

.global-header {
  position: fixed;
  top: 0;
  left: 5%;
  width: 90%;
  max-width: 1400px;
  margin: 0 auto;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  padding: 0 20px;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
}

.logo-text {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--text-primary) 0%, var(--accent-color) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Theme selector dropdown styling absolute top-right */
.theme-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-wrapper label {
  color: var(--text-secondary);
  font-size: 1.05rem;
  text-shadow: 0 0 10px var(--accent-glow);
}

.theme-wrapper select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 10px;
  outline: none;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-wrapper select:hover {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Sound volume toggles */
.header-audio-controls {
  display: flex;
  gap: 8px;
}

.header-audio-btn {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

.header-audio-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

.header-audio-btn.muted {
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.5);
  border-color: var(--panel-border);
}

.header-audio-btn.muted i {
  position: relative;
}

.header-audio-btn.muted i::after {
  content: "/";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  font-weight: 800;
  color: #ef4444;
  font-size: 1.1rem;
}

/* ==========================================================================
   VIEW/PAGES CONTROL UTILITY
   ========================================================================== */

.view-panel {
  width: 100%;
  animation: view-fade-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-hidden {
  display: none !important;
}

@keyframes view-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   PAGE 1: HOME PAGE LAYOUT & HERO HERO
   ========================================================================== */

.hero-split-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  min-height: 70vh;
  margin-bottom: 80px;
}

.hero-left-pane {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.badge-tag {
  align-self: flex-start;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-color);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 5px 12px;
  border-radius: 30px;
  text-shadow: 0 0 8px var(--accent-glow);
}

.hero-title {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-color) 70%, var(--player-o) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 1px;
  line-height: 1.4;
  margin-top: 5px;
}

.hero-desc {
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 90%;
}

.decor-nodes-line {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-muted);
}

.decor-nodes-line span {
  font-size: 0.55rem;
}
.decor-nodes-line span:nth-child(2) { color: var(--accent-color); }

/* Glassmorphism settings setup box on Home Page Right */
.setup-box {
  padding: 35px;
  border-radius: 24px;
}

.setup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 15px;
}

.setup-icon {
  font-size: 1.6rem;
  color: var(--accent-color);
}

.setup-header h3 {
  font-size: 1.3rem;
  font-weight: 800;
}

.setup-group {
  margin-bottom: 25px;
}

.group-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 10px;
}

/* Radio pills toggle selection rules */
.toggle-pills {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 5px;
  gap: 5px;
}

.toggle-pills input[type="radio"] {
  display: none;
}

.toggle-pills label {
  flex: 1;
  text-align: center;
  padding: 12px 6px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toggle-pills input[type="radio"]:checked + label {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* Difficulty specific pills colors check */
.difficulty-pills label:hover {
  background: rgba(255, 255, 255, 0.04);
}

.difficulty-pills input#diff-easy:checked + label {
  background: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.difficulty-pills input#diff-medium:checked + label {
  background: #f59e0b;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.difficulty-pills input#diff-hard:checked + label {
  background: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Massive Launch Button */
.launch-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--player-o) 100%);
  border: none;
  color: white;
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.launch-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.5);
  filter: brightness(1.1);
}

.launch-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   GLASSMORPHISM BASE CARDS VISUAL GLOWS
   ========================================================================== */

.glass-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15), inset 0 0 15px var(--panel-glow);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 45px 0 rgba(0, 0, 0, 0.25), inset 0 0 20px var(--panel-glow);
}

/* ==========================================================================
   PAGE 1 SCROLL SECTIONS: PREMIUM FEATURES GRID
   ========================================================================== */

.features-section, .how-to-play-section {
  margin-bottom: 80px;
}

.section-title {
  font-size: 2.2rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  letter-spacing: -0.5px;
}

.section-title i {
  color: var(--accent-color);
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.section-desc {
  font-size: 0.98rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 600px;
  margin: 0 auto 40px auto;
  line-height: 1.6;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  padding: 30px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  transform: translateY(0);
}

.feature-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-color);
}

.feature-icon {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--accent-color);
}

.feature-card h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.feature-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ==========================================================================
   HOW TO PLAY & THEORY CARDS
   ========================================================================== */

.theory-main-card {
  padding: 40px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.main-explanation {
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.7;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

/* Beginner-Advanced-Master Tips indicators */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.tip-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  padding: 20px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}

.tip-box:hover {
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.3);
}

.tip-badge {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #10b981; /* Green */
}

.font-orange { color: #f59e0b; }
.font-red { color: #ef4444; }

.tip-box p {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.4;
}

.rules-flex-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  border-top: 1px solid var(--panel-border);
  padding-top: 25px;
}

.rule-box h4 {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.rule-box h4 i {
  color: var(--accent-color);
}

.rule-box p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.conclusion-box {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  border-top: 1px solid var(--panel-border);
  padding-top: 20px;
  text-shadow: 0 0 10px var(--accent-glow);
}

.home-footer {
  text-align: center;
  padding: 30px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
}

/* ==========================================================================
   PAGE 2: PLAY ARENA VIEW LAYOUT (Splits 3D network grids and details)
   ========================================================================== */

.arena-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
  align-items: start;
}

.arena-left-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.arena-right-pane {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Turn active visual card */
.turn-display-card {
  width: 100%;
  max-width: 440px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 15px;
  font-size: 0.98rem;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.status-icon {
  color: var(--accent-color);
  display: flex;
  align-items: center;
}

.tag-status {
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Board Wrapper */
.board-wrapper {
  position: relative;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
}

.board-grid-mesh {
  display: grid;
  grid-template-columns: repeat(var(--board-cols, 3), 1fr);
  grid-template-rows: repeat(var(--board-rows, 3), 1fr);
  gap: 10px;
  width: 100%;
  height: 100%;
}

.grid-cell {
  background: var(--cell-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.1s ease;
}

.grid-cell:hover {
  background: var(--cell-hover);
  border-color: rgba(255, 255, 255, 0.18);
}

.grid-cell:active {
  transform: scale(0.96);
}

/* X & O programmatical drawing values */
.grid-cell::before, .grid-cell::after {
  content: "";
  position: absolute;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* X symbol style details */
.grid-cell.cell-x::before, .grid-cell.cell-x::after {
  opacity: 1;
  transform: scale(1) rotate(45deg);
  background: var(--player-x);
  box-shadow: 0 0 12px var(--player-x-glow);
  border-radius: 4px;
}

.grid-cell.cell-x::before {
  width: 10%;
  height: 52%;
}

.grid-cell.cell-x::after {
  width: 52%;
  height: 10%;
}

/* O symbol style details */
.grid-cell.cell-o::before {
  opacity: 1;
  transform: scale(1);
  width: 48%;
  height: 48%;
  border-radius: 50%;
  border: calc(9px - var(--board-cols, 3) * 1px) solid var(--player-o);
  box-shadow: 0 0 12px var(--player-o-glow);
  background: transparent;
}

.grid-cell.cell-x, .grid-cell.cell-o {
  cursor: default;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.12);
}

/* Win Path Strike-line overlay dimensions */
.winning-strike {
  position: absolute;
  background: linear-gradient(90deg, var(--player-x), var(--player-o));
  box-shadow: 0 0 18px var(--accent-glow);
  border-radius: 10px;
  pointer-events: none;
  display: none;
  z-index: 5;
}

/* Strike patterns alignments matching indexes */
.winning-strike.strike-row-0 { display: block; width: 92%; height: 6px; top: 15.5%; left: 4%; }
.winning-strike.strike-row-1 { display: block; width: 92%; height: 6px; top: 49%; left: 4%; }
.winning-strike.strike-row-2 { display: block; width: 92%; height: 6px; top: 82.5%; left: 4%; }

.winning-strike.strike-col-0 { display: block; width: 6px; height: 92%; top: 4%; left: 15.5%; }
.winning-strike.strike-col-1 { display: block; width: 6px; height: 92%; top: 4%; left: 49%; }
.winning-strike.strike-col-2 { display: block; width: 6px; height: 92%; top: 4%; left: 82.5%; }

.winning-strike.strike-diag-main {
  display: block;
  width: 120%;
  height: 6px;
  top: 49%;
  left: -10%;
  transform: rotate(45deg);
}
.winning-strike.strike-diag-anti {
  display: block;
  width: 120%;
  height: 6px;
  top: 49%;
  left: -10%;
  transform: rotate(-45deg);
}

/* ==========================================================================
   GAMEPLAY ACTION BAR (Undo, Restart, Quit)
   ========================================================================== */

.game-action-bar {
  display: flex;
  width: 100%;
  max-width: 440px;
  gap: 10px;
}

.action-btn {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  padding: 12px 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

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

.action-btn.active-highlight {
  background: linear-gradient(135deg, var(--accent-color) 0%, rgba(99, 102, 241, 0.6) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.action-btn.active-highlight:hover {
  box-shadow: 0 6px 20px var(--accent-glow);
  filter: brightness(1.1);
}

.action-btn.quit-highlight:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   STATS SCOREBOARD (Directly below board)
   ========================================================================== */

.stats-scoreboard {
  width: 100%;
  max-width: 440px;
  padding: 20px;
  border-radius: 20px;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.stat-score-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: all 0.3s ease;
}

.stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: center;
}

.stat-val {
  font-size: 1.35rem;
  font-weight: 800;
}

.x-win-box { border-bottom: 3px solid var(--player-x); }
.x-win-box .stat-val { color: var(--player-x); text-shadow: 0 0 8px var(--player-x-glow); }

.o-win-box { border-bottom: 3px solid var(--player-o); }
.o-win-box .stat-val { color: var(--player-o); text-shadow: 0 0 8px var(--player-o-glow); }

.reset-stats-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  padding: 8px 15px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.reset-stats-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ==========================================================================
   AI PANEL INSIGHTS (Game View Right Pane)
   ========================================================================== */

.brain-card {
  padding: 24px;
  border-radius: 20px;
}

.brain-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.brain-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brain-header h2 i {
  color: var(--accent-color);
}

.brain-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.live-badge {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  animation: beacon 1.2s infinite alternate;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.metric-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.3s ease;
}

.metric-box:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
}

.metric-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 700;
}

.metric-value {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
}

.code-font {
  font-family: 'JetBrains Mono', monospace;
}

#brain-nodes { color: #f59e0b; }
#brain-time { color: #10b981; }
#brain-score { color: #8b5cf6; }

/* Dev Console terminal */
.console-wrapper {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.console-header {
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.console-header button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.3s ease;
}

.console-header button:hover {
  color: var(--text-primary);
}

.console-body {
  padding: 12px;
  height: 180px;
  overflow-y: auto;
  font-size: 0.7rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-line {
  word-break: break-all;
  border-left: 2px solid transparent;
  padding-left: 6px;
}

.system-log { border-left-color: var(--text-muted); color: var(--text-muted); }
.player-log { border-left-color: var(--player-x); color: var(--text-primary); }
.ai-log { border-left-color: var(--player-o); color: var(--player-o); }
.prune-log { border-left-color: #f59e0b; color: #f59e0b; font-style: italic; }

.search-tree-mini {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--panel-border);
  padding: 12px;
  border-radius: 12px;
}

.tree-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.tree-nodes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.tree-tag {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
}

.tag-max { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.tag-prune { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.tag-min { background: rgba(6, 182, 212, 0.15); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.3); }

.tree-arrow {
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* ==========================================================================
   ANIMATIONS SYSTEM
   ========================================================================== */

@keyframes beacon {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

.winner-pulse {
  animation: winner-glow-pulse 1s infinite alternate;
}

@keyframes winner-glow-pulse {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 255, 255, 0.05); }
  100% { transform: scale(1.02); box-shadow: 0 0 20px var(--accent-glow); }
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: reveal-entry 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.scroll-reveal:nth-child(2) { animation-delay: 0.15s; }
.scroll-reveal:nth-child(3) { animation-delay: 0.3s; }

@keyframes reveal-entry {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN ADAPTATIONS
   ========================================================================== */

@media (max-width: 1200px) {
  .hero-split-container {
    grid-template-columns: 1fr;
    gap: 30px;
    text-align: center;
    min-height: auto;
  }
  
  .hero-left-pane {
    align-items: center;
  }
  
  .hero-desc {
    max-width: 100%;
  }
  
  .features-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .arena-grid {
    grid-template-columns: 1fr;
    gap: 35px;
  }
  
  .arena-right-pane {
    display: block;
  }
  
  .brain-card {
    height: auto;
  }
}

@media (max-width: 768px) {
  .app-wrapper {
    padding: 90px 16px 20px 16px;
  }
  
  .global-header {
    flex-direction: column;
    height: auto;
    padding: 12px;
    gap: 10px;
    border-radius: 0;
    width: 100%;
    left: 0;
  }
  
  .hero-title {
    font-size: 2.8rem;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .tips-grid {
    grid-template-columns: 1fr;
  }
  
  .rules-flex-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .setup-box {
    padding: 20px;
  }
  
  .stats-container {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   DYNAMIC MODE STYLING UPDATES (TIMED, SURVIVAL, TOURNAMENT & WIN GLOWS)
   ========================================================================== */

/* Winning highlights */
.grid-cell.cell-win {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4), inset 0 0 10px rgba(16, 185, 129, 0.2);
  animation: winner-glow-pulse 1s infinite alternate;
}

/* Timed countdown bar */
.timer-bar-wrapper {
  width: 100%;
  max-width: 440px;
  padding: 10px 15px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-bottom: 5px;
}
#timer-text {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-primary);
  min-width: 45px;
}
.timer-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, var(--accent-color));
  border-radius: 10px;
  transition: width 0.1s linear, background-color 0.3s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}
.timer-fill.timer-danger {
  background: linear-gradient(90deg, #ef4444, #f43f5e) !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
  animation: danger-pulse 0.5s infinite alternate;
}
@keyframes danger-pulse {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Survival stats card */
.survival-status-card {
  width: 100%;
  max-width: 440px;
  padding: 15px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-bottom: 5px;
}
.survival-stat-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.3s ease;
}
.survival-stat-box:hover {
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.3);
}
.survival-lbl {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: center;
}
.survival-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-color);
  text-shadow: 0 0 8px var(--accent-glow);
}
#survival-highscore-val {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Esports Tournament Bracket Panel */
.bracket-container {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 15px;
  margin-top: 15px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 10px;
}
.bracket-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 12px;
  min-width: 120px;
}
.bracket-column-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 800;
  text-align: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.match-card {
  padding: 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--panel-border);
  transition: all 0.3s ease;
}
.match-card.match-active {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.03);
}
.player-row {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.15);
}
.player-row.row-winner {
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 800;
}
.player-row.row-winner::after {
  content: "🏆";
  font-size: 0.65rem;
}
.player-row.row-winner span {
  color: #10b981 !important;
}
.player-row.row-loser {
  color: var(--text-muted);
  opacity: 0.55;
  text-decoration: line-through;
}
.column-champ {
  justify-content: center;
}
.champ-badge-gold {
  padding: 15px 10px;
  border-radius: 14px;
  text-align: center;
  font-weight: 900;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d4af37 100%);
  color: #000;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
  border: 1px solid #f59e0b;
  animation: winner-glow-pulse 1s infinite alternate;
}

/* ==========================================================================
   GAME OVER MODAL POPUP WITH EMOJIS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modal-fade-in 0.4s ease-out;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

.modal-card {
  position: relative;
  padding: 50px 40px;
  border-radius: 30px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  animation: modal-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-slide-in {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-card.blast {
  animation: modal-slide-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), modal-blast 1.2s ease-out;
  box-shadow: 0 0 32px rgba(56, 189, 248, 0.25), 0 0 58px rgba(236, 72, 153, 0.18), 0 0 95px rgba(255, 255, 255, 0.12);
}

@keyframes modal-blast {
  0% {
    transform: scale(0.96);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0);
  }
  40% {
    transform: scale(1.04);
    box-shadow: 0 0 45px rgba(56, 189, 248, 0.35), 0 0 60px rgba(236, 72, 153, 0.3);
  }
  70% {
    transform: scale(0.99);
    box-shadow: 0 0 28px rgba(56, 189, 248, 0.2), 0 0 40px rgba(236, 72, 153, 0.18);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 32px rgba(56, 189, 248, 0.25), 0 0 58px rgba(236, 72, 153, 0.18), 0 0 95px rgba(255, 255, 255, 0.12);
  }
}

.modal-emoji-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  display: inline-block;
  line-height: 1;
}

.modal-emoji-icon.emoji-bounce {
  animation: emoji-bounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emoji-bounce {
  0% {
    transform: scale(0.5) translateY(20px);
    opacity: 0;
  }
  50% {
    transform: scale(1.15) translateY(-10px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-main-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  text-shadow: 0 0 15px var(--accent-glow);
}

.modal-subtitle-text {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-btn {
  padding: 14px 20px !important;
  font-size: 1rem !important;
  border-radius: 14px !important;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-btn:hover {
  transform: translateY(-3px) !important;
}

#modal-replay-btn {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--player-o) 100%) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.3) !important;
}

#modal-replay-btn:hover {
  box-shadow: 0 12px 35px rgba(236, 72, 153, 0.5) !important;
  filter: brightness(1.1);
}

#modal-quit-btn {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

#modal-quit-btn:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.2) !important;
}
