:root {
  /* HSL Color Palette */
  --bg-primary: hsl(222, 30%, 8%);
  --bg-secondary: hsl(222, 25%, 12%);
  --bg-glass: rgba(18, 24, 41, 0.65);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-active: rgba(0, 242, 254, 0.3);
  
  --color-text-main: hsl(210, 38%, 95%);
  --color-text-muted: hsl(215, 20%, 65%);
  
  /* Accent Colors */
  --accent-cyan: hsl(183, 100%, 50%);
  --accent-cyan-rgb: 0, 242, 254;
  --accent-ruby: hsl(345, 100%, 60%);
  --accent-ruby-rgb: 255, 51, 102;
  --accent-amber: hsl(35, 100%, 55%);
  --accent-amber-rgb: 255, 159, 67;
  --accent-green: hsl(152, 100%, 50%);
  
  /* Sizing and Layout */
  --card-radius: 16px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--color-text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background decorative details */
.stars-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(1px 1px at 20px 30px, #ffffff, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,0.5), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 90px 110px, rgba(255,255,255,0.3), rgba(0,0,0,0));
  background-size: 150px 150px;
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  opacity: 0.12;
  z-index: 0;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background-color: var(--accent-cyan);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background-color: var(--accent-ruby);
  bottom: -150px;
  right: -100px;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 20px;
  position: relative;
  z-index: 2;
}

/* Header Styles */
header {
  text-align: center;
  margin-bottom: 35px;
}

.logo {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 30%, var(--color-text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.accent-text {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
}

.accent-text::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
  box-shadow: 0 0 8px var(--accent-cyan);
  border-radius: 2px;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  font-weight: 400;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 310px 1fr 340px;
  gap: 24px;
  align-items: start;
}

/* Glassmorphic Cards */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--card-radius);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.card {
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.02);
}

.card-header .icon {
  font-size: 1.25rem;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 20px;
}

/* Form elements & Custom Select */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '▼';
  font-size: 0.8rem;
  color: var(--color-text-muted);
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

select {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--color-text-main);
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

select option {
  background: var(--bg-secondary);
  color: var(--color-text-main);
}

/* Toggle Switch Styling */
.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 25px;
  margin-bottom: 10px;
}

.toggle-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-text-muted);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(0, 242, 254, 0.15);
  border-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

/* Status Badge */
.status-badge {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.05rem;
  text-align: center;
  margin-bottom: 25px;
  border: 1px solid transparent;
  transition: all var(--transition-normal);
}

.status-badge.turn-player {
  background: rgba(0, 242, 254, 0.08);
  color: var(--accent-cyan);
  border-color: rgba(0, 242, 254, 0.25);
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.3);
  box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.05);
}

.status-badge.turn-ai {
  background: rgba(255, 51, 102, 0.08);
  color: var(--accent-ruby);
  border-color: rgba(255, 51, 102, 0.25);
  text-shadow: 0 0 8px rgba(255, 51, 102, 0.3);
  box-shadow: inset 0 0 10px rgba(255, 51, 102, 0.05);
}

.status-badge.winner-player {
  background: rgba(0, 255, 136, 0.12);
  color: var(--accent-green);
  border-color: rgba(0, 255, 136, 0.3);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.15);
  animation: winner-glow 1.5s infinite alternate;
}

.status-badge.winner-ai {
  background: rgba(255, 51, 102, 0.12);
  color: var(--accent-ruby);
  border-color: rgba(255, 51, 102, 0.3);
  text-shadow: 0 0 8px rgba(255, 51, 102, 0.4);
  box-shadow: 0 0 15px rgba(255, 51, 102, 0.15);
  animation: winner-glow-ai 1.5s infinite alternate;
}

@keyframes winner-glow {
  from { box-shadow: 0 0 10px rgba(0, 255, 136, 0.1); }
  to { box-shadow: 0 0 20px rgba(0, 255, 136, 0.3); }
}
@keyframes winner-glow-ai {
  from { box-shadow: 0 0 10px rgba(255, 51, 102, 0.1); }
  to { box-shadow: 0 0 20px rgba(255, 51, 102, 0.3); }
}

/* Wall Inventories */
.inventory-section {
  margin-bottom: 20px;
}

.inventory-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.count-value {
  font-weight: 600;
}

.inventory-header span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wall-inventory {
  display: flex;
  gap: 6px;
}

.wall-inv-slot {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.inventory-section:nth-of-type(1) .wall-inv-slot.active {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px rgba(0, 242, 254, 0.6);
}

.inventory-section:nth-of-type(2) .wall-inv-slot.active {
  background: var(--accent-ruby);
  box-shadow: 0 0 6px rgba(255, 51, 102, 0.6);
}

/* Buttons */
.actions-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 25px;
}

.btn {
  width: 100%;
  padding: 14px 20px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), hsl(200, 100%, 45%));
  color: hsl(222, 30%, 8%);
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
  filter: brightness(1.05);
}

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

/* Active wall mode on button */
.btn-primary.active-mode {
  background: linear-gradient(135deg, var(--accent-amber), hsl(25, 100%, 45%));
  color: white;
  box-shadow: 0 4px 15px rgba(255, 159, 67, 0.3);
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(255, 159, 67, 0.4), 0 4px 15px rgba(255, 159, 67, 0.2); }
  70% { box-shadow: 0 0 0 6px rgba(255, 159, 67, 0), 0 4px 15px rgba(255, 159, 67, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(255, 159, 67, 0), 0 4px 15px rgba(255, 159, 67, 0.2); }
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--color-text-main);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

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

/* PANEL TENGAH: ARENA GAME & BOARD */
.arena-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.goal-indicator {
  width: 100%;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.05);
}

.goal-ai {
  color: var(--accent-cyan);
  border-color: rgba(0, 242, 254, 0.15);
  box-shadow: inset 0 0 8px rgba(0, 242, 254, 0.03);
}

.goal-player {
  color: var(--accent-ruby);
  border-color: rgba(255, 51, 102, 0.15);
  box-shadow: inset 0 0 8px rgba(255, 51, 102, 0.03);
}

.board-container {
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

#board {
  display: grid;
  grid-template-columns: repeat(5, 80px);
  grid-template-rows: repeat(5, 80px);
  gap: 8px;
  justify-content: center;
}

/* Cell Styles */
.cell {
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.cell:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.cell:hover::before {
  opacity: 1;
}

/* Valid Move State */
.cell.valid-move {
  background: rgba(0, 242, 254, 0.03);
  border: 1.5px dashed rgba(0, 242, 254, 0.6);
  box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.1);
  animation: pulse-cyan-glow 2s infinite ease-in-out;
}

.cell.valid-move:hover {
  background: rgba(0, 242, 254, 0.08);
  border-style: solid;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

@keyframes pulse-cyan-glow {
  0% { border-color: rgba(0, 242, 254, 0.4); }
  50% { border-color: rgba(0, 242, 254, 0.8); }
  100% { border-color: rgba(0, 242, 254, 0.4); }
}

/* Wall Placement Hover Previews */
.cell.wall-place-hover:hover {
  background: rgba(255, 159, 67, 0.1) !important;
  border: 1.5px dashed var(--accent-amber) !important;
  box-shadow: 0 0 15px rgba(255, 159, 67, 0.25) !important;
}

/* Pawn representation in HTML */
.pawn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  transition: transform var(--transition-normal);
}

.pawn-inner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.pawn.player-pawn {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, hsl(200, 100%, 45%) 100%);
  box-shadow: 0 0 15px var(--accent-cyan), inset 0 2px 4px rgba(255,255,255,0.4);
  animation: pulse-pawn 2s infinite ease-in-out;
}

.pawn.ai-pawn {
  background: linear-gradient(135deg, var(--accent-ruby) 0%, hsl(340, 100%, 40%) 100%);
  box-shadow: 0 0 15px var(--accent-ruby), inset 0 2px 4px rgba(255,255,255,0.4);
  animation: pulse-pawn-ai 2s infinite ease-in-out;
}

@keyframes pulse-pawn {
  0% { transform: scale(1); box-shadow: 0 0 12px rgba(0, 242, 254, 0.6); }
  50% { transform: scale(1.06); box-shadow: 0 0 20px rgba(0, 242, 254, 0.9); }
  100% { transform: scale(1); box-shadow: 0 0 12px rgba(0, 242, 254, 0.6); }
}

@keyframes pulse-pawn-ai {
  0% { transform: scale(1); box-shadow: 0 0 12px rgba(255, 51, 102, 0.6); }
  50% { transform: scale(1.06); box-shadow: 0 0 20px rgba(255, 51, 102, 0.9); }
  100% { transform: scale(1); box-shadow: 0 0 12px rgba(255, 51, 102, 0.6); }
}

/* Wall block representation in HTML */
.wall-block {
  width: 100%;
  height: 100%;
  background-color: #1a1510;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(255, 159, 67, 0.15) 8px,
    rgba(255, 159, 67, 0.15) 16px
  );
  border: 1.5px solid var(--accent-amber);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(255, 159, 67, 0.25), inset 0 0 10px rgba(0,0,0,0.8);
  animation: wall-spawn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes wall-spawn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.aiMove {
  animation: ai-pulse-move 0.6s ease-out;
}

@keyframes ai-pulse-move {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); box-shadow: 0 0 25px var(--accent-ruby); }
  100% { transform: scale(1); }
}

/* PANEL KANAN: STATISTIK & TELEMETRI */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  transition: all var(--transition-fast);
}

.stat-box:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.01);
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
  margin-bottom: 4px;
}

#prunedCount {
  color: var(--accent-ruby);
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.2);
}

#calcTime {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* GAME TREE CARD */
.tree-card {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.tree-card .card-body {
  padding: 0;
  height: 320px;
  display: flex;
  flex-direction: column;
}

#treeContainer {
  padding: 15px;
  overflow: auto;
  flex-grow: 1;
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  background: #090d16;
}

#treeContainer pre {
  color: var(--accent-green);
  text-align: left;
}

.tree-info-placeholder {
  color: var(--color-text-muted);
  text-align: center;
  font-size: 0.85rem;
  padding-top: 100px;
  font-family: inherit;
}

/* Highlight tree node types */
.tree-pruned {
  color: var(--accent-ruby) !important;
  font-weight: 600;
}

.tree-evaluated {
  color: var(--accent-cyan) !important;
}

.tree-ai-turn {
  color: var(--accent-ruby);
}

.tree-player-turn {
  color: var(--accent-cyan);
}

/* Custom Scrollbar for tree and document */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Responsive Breakpoints */
@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 300px 1fr;
  }
  
  .right-panel {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  
  .right-panel .card {
    margin-bottom: 0;
  }
  
  .tree-card .card-body {
    height: 250px;
  }
}

@media (max-width: 820px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .side-panel, .right-panel {
    grid-column: span 1;
  }
  
  .right-panel {
    display: flex;
    flex-direction: column;
  }
  
  #board {
    grid-template-columns: repeat(5, 65px);
    grid-template-rows: repeat(5, 65px);
    gap: 6px;
  }
  
  .cell {
    border-radius: 6px;
  }
  
  .pawn {
    width: 38px;
    height: 38px;
  }
  
  .pawn-inner {
    width: 16px;
    height: 16px;
  }
  
  .logo {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  #board {
    grid-template-columns: repeat(5, 52px);
    grid-template-rows: repeat(5, 52px);
    gap: 5px;
  }
  
  .pawn {
    width: 32px;
    height: 32px;
  }
  
  .pawn-inner {
    width: 12px;
    height: 12px;
  }
  
  .container {
    padding: 15px 10px;
  }
  
  .logo {
    font-size: 1.8rem;
  }
}