/* Modern Design System */
:root {
  /* Dark Theme */
  --bg: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --panel: rgba(255, 255, 255, 0.05);
  --panel-elevated: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #6366f1;
  --primary-hover: #5855eb;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --square-light: #f1f5f9;
  --square-dark: #475569;
  --highlight: rgba(99, 102, 241, 0.3);
  --lastmove: rgba(6, 182, 212, 0.4);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

:root.light {
  /* Light Theme */
  --bg: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
  --surface: rgba(255, 255, 255, 0.8);
  --surface-hover: rgba(255, 255, 255, 0.95);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-elevated: rgba(255, 255, 255, 0.95);
  --border: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #0891b2;
  --accent: #d97706;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --square-light: #ffffff;
  --square-dark: #e2e8f0;
  --highlight: rgba(99, 102, 241, 0.2);
  --lastmove: rgba(14, 165, 233, 0.3);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Global Styles */
* { 
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
}

html { 
  height: 100%; 
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  height: 100%;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
}

body.theme-transition {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0;
}

/* Typography */
.title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Button System */
.controls { 
  display: flex; 
  gap: 12px; 
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-focus);
}

/* Input System */
.input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
}

.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: var(--surface-hover);
}

/* Select/Dropdown Styling */
select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

select.input option {
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border: none;
}

/* Status Bar */
.statusbar { 
  display: flex; 
  align-items: center;
  gap: 24px; 
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.statusbar .status {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.statusbar .status strong { 
  color: var(--text);
  font-weight: 700;
}

.status--gameover {
  color: var(--danger);
  font-weight: 700;
}

/* Clock System */
.clocks { 
  margin-left: auto; 
  display: flex; 
  gap: 16px; 
}

.clock {
  background: var(--panel-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.clock strong { 
  font-family: 'JetBrains Mono', 'Fira Code', monospace; 
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.clock--w { border-left: 3px solid var(--primary); }
.clock--b { border-left: 3px solid var(--text-muted); }

/* Last Moves */
.lastmoves { 
  display: flex; 
  gap: 24px; 
  padding: 16px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.lastmoves span {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
}

/* Game Board Layout */
.board-wrap { 
  display: grid; 
  grid-template-columns: 300px 1fr 300px; 
  gap: 24px; 
  align-items: start;
  max-width: 100%;
}

/* Revolutionary Board Design */
.board {
  --size: min(70vw, 600px);
  width: var(--size); 
  height: var(--size); 
  position: relative; 
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: linear-gradient(135deg, var(--panel), var(--surface));
  border: 3px solid var(--border);
  backdrop-filter: blur(20px);
  box-shadow: 
    var(--shadow-xl),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.1), transparent 50%);
  pointer-events: none;
  z-index: 1;
}

.grid { 
  display: grid; 
  grid-template-columns: repeat(8, 1fr); 
  grid-template-rows: repeat(8, 1fr); 
  width: 100%; 
  height: 100%;
  position: relative;
  z-index: 2;
}

.square { 
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  cursor: pointer;
}

.square:hover {
  transform: scale(1.02);
}

/* Enhanced hover for squares with pieces */
.square:has(.piece):hover {
  transform: scale(1.05);
}

.square::before { 
  content: ""; 
  position: absolute; 
  inset: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.square.light::before { 
  background: var(--square-light);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.02);
}

.square.dark::before { 
  background: var(--square-dark);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
}

.square:hover::before {
  transform: scale(0.95);
  filter: brightness(1.1);
  box-shadow: 
    inset 0 0 30px rgba(99, 102, 241, 0.1),
    0 0 20px rgba(99, 102, 241, 0.1);
}

/* Board Coordinates */
.coord { 
  position: absolute; 
  font-size: 11px; 
  font-weight: 600;
  color: var(--text-muted); 
  padding: 4px; 
  z-index: 2;
  pointer-events: none;
}

.coord.file { 
  bottom: 4px; 
  right: 4px; 
}

/* Captured Pieces Panel */
.captured { 
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 200px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.captured h3 { 
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.captured__list { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); 
  gap: 8px;
}

.captured__list img { 
  width: 100%;
  border-radius: 6px;
  transition: transform 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.captured__list img:hover {
  transform: scale(1.1);
}

/* Modern Piece Design */
.piece { 
  position: absolute; 
  inset: 0; 
  display: grid; 
  place-items: center; 
  pointer-events: none;
  z-index: 3;
}

.piece img { 
  width: 85%; 
  max-width: 80px;
  transition: all 0.2s ease;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
  animation: fadeIn .25s ease;
}

/* Enhanced Color Rings */
.piece .color-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  pointer-events: none;
  transition: all 0.3s ease;
}

.piece .ring--w {
  background: radial-gradient(circle, rgba(255,255,255,0.1), transparent 70%);
  box-shadow: 
    0 0 0 2px rgba(255, 255, 255, 0.8),
    0 0 0 4px rgba(255, 255, 255, 0.3),
    0 0 15px rgba(255, 255, 255, 0.4);
}

.piece .ring--b {
  background: radial-gradient(circle, rgba(0,0,0,0.2), transparent 70%);
  box-shadow: 
    0 0 0 2px rgba(0, 0, 0, 0.9),
    0 0 0 4px rgba(255, 255, 255, 0.4),
    0 0 15px rgba(0, 0, 0, 0.5);
}

/* Revolutionary Selection System */
.highlight { 
  position: relative;
  background: radial-gradient(circle at center, rgba(255, 200, 0, 0.15), transparent 60%);
  box-shadow: 
    inset 0 0 0 3px rgba(255, 200, 0, 0.8),
    0 0 20px rgba(255, 200, 0, 0.4),
    0 0 40px rgba(255, 200, 0, 0.2);
  animation: energyPulse 1.5s ease-in-out infinite;
}

.highlight::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg, #ffc800, #ff6a00, #ff007a, #7a00ff, #00d4ff, #ffc800);
  border-radius: 8px;
  z-index: -1;
  animation: energyRotate 3s linear infinite;
  opacity: 0.6;
}

.highlight::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: radial-gradient(circle, rgba(255, 200, 0, 0.2), transparent);
  border-radius: 50%;
  animation: energyCore 2s ease-in-out infinite;
}

@keyframes energyPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 
      inset 0 0 0 3px rgba(255, 200, 0, 0.8),
      0 0 20px rgba(255, 200, 0, 0.4),
      0 0 40px rgba(255, 200, 0, 0.2);
  }
  50% { 
    transform: scale(1.02);
    box-shadow: 
      inset 0 0 0 3px rgba(255, 200, 0, 1),
      0 0 30px rgba(255, 200, 0, 0.6),
      0 0 60px rgba(255, 200, 0, 0.3);
  }
}

@keyframes energyRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes energyCore {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

@keyframes fadeIn { 
  from { transform:scale(.85); opacity:0; } 
  to { transform:scale(1); opacity:1; } 
}

.piece { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.piece img { width: 80%; max-width: 78px; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { transform:scale(.85); opacity:0; } to { transform:scale(1); opacity:1; } }

/* Circular color ring around pieces to show side clearly */
.piece .color-ring {
  position: absolute;
  inset: 8px; /* sit just inside the square edges */
  border-radius: 50%;
  pointer-events: none;
}
.piece .ring--w {
  /* white ring: bright with subtle glow */
  box-shadow: 0 0 0 3px #ffffff, 0 0 10px 2px rgba(255,255,255,0.35);
}
.piece .ring--b {
  /* black ring: dark ring with light outline for contrast */
  box-shadow: 0 0 0 3px #000000, 0 0 0 5px rgba(255,255,255,0.25), 0 0 10px 2px rgba(0,0,0,0.4);
}

/* Optional: tone down or hide the old side dot if present */
.piece .side-dot { display: none; }

/* Quantum Legal Move Dots */
.legal {
  position: relative;
}

.legal::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, 
    rgba(0, 212, 255, 0.9) 0%, 
    rgba(0, 212, 255, 0.6) 40%, 
    rgba(0, 212, 255, 0.2) 70%, 
    transparent 100%);
  border-radius: 50%;
  box-shadow: 
    0 0 10px rgba(0, 212, 255, 0.6),
    0 0 20px rgba(0, 212, 255, 0.3),
    inset 0 0 8px rgba(255, 255, 255, 0.3);
  animation: quantumFloat 2.5s ease-in-out infinite;
  z-index: 10;
}

.legal::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: quantumCore 1.8s ease-in-out infinite reverse;
  z-index: 11;
}

@keyframes quantumFloat {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  33% { 
    transform: translate(-50%, -55%) scale(1.1);
    opacity: 1;
  }
  66% { 
    transform: translate(-50%, -45%) scale(0.95);
    opacity: 0.9;
  }
}

@keyframes quantumCore {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  50% { 
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.4;
  }
}

.footer { margin-top: 24px; color: var(--muted); font-size: 12px; }
.footer a { color: var(--accent-2); }

/* Promotion Modal Animations */
@keyframes promotionEnter {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    backdrop-filter: blur(0px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    backdrop-filter: blur(8px);
  }
}

@keyframes promotionExit {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
}

@keyframes promotionChoice {
  0% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 
      0 8px 25px rgba(0, 0, 0, 0.3),
      0 0 20px rgba(100, 200, 255, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

@keyframes evolutionBurst {
  0% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    transform: scale(1.5);
    filter: brightness(2);
    box-shadow: 0 0 50px rgba(255, 255, 255, 1);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
}

/* Modal Styles */
.modal { 
  position: fixed; 
  inset: 0; 
  display: none; 
  place-items: center; 
  background: rgba(0,0,0,.6); 
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.modal[aria-hidden="false"] { 
  display: grid; 
  animation: promotionEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal--exiting {
  animation: promotionExit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.modal__dialog { 
  width: 400px; 
  max-width: 90%;
  background: linear-gradient(135deg, var(--panel), var(--surface)); 
  border: 2px solid var(--border-accent); 
  border-radius: 20px; 
  padding: 24px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
}

.modal__dialog h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  background: linear-gradient(45deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.promotion__choices { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); 
  gap: 12px; 
  margin-top: 16px; 
}

.promo { 
  height: 90px; 
  border-radius: 16px; 
  background: linear-gradient(135deg, var(--surface), var(--panel)); 
  border: 2px solid var(--border); 
  cursor: pointer; 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.promo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, 
    rgba(255, 255, 255, 0.1), 
    transparent, 
    rgba(255, 255, 255, 0.1));
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.promo:hover {
  transform: translateY(-5px);
  border-color: var(--accent-2);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(100, 200, 255, 0.3);
  animation: promotionChoice 0.6s ease-in-out;
}

.promo:hover::before {
  transform: translateX(100%);
}

.promo:focus { 
  outline: 3px solid var(--accent-2); 
  outline-offset: 2px;
}

.promo:active {
  transform: translateY(-2px) scale(0.95);
}

/* Evolution effect for promoted pieces */
.piece--evolution {
  animation: evolutionBurst 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Multiplayer */
.multiplayer { margin: 10px 0 18px; background: #0f1736; border: 1px solid #27326e; border-radius: 14px; padding: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mp-controls { display: flex; gap: 8px; align-items: center; }
.input { background: #101944; color: var(--text); border: 1px solid #2a3877; border-radius: 10px; padding: 10px 12px; min-width: 220px; }
.badge { background: #2a3666; color: var(--text); padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.badge--white { background: #e8f1ff; color: #162056; }
.badge--black { background: #162056; color: #e8f1ff; border: 1px solid #2a3877; }

.mp-adv { margin-top: 8px; }
.mp-turn { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
@media (max-width: 700px) { .mp-turn { grid-template-columns: 1fr; } }

/* Visualize sides on board edges */
.board::after, .board::before {
  content: '';
  position: absolute; left: 0; right: 0; height: 8px;
}
.board::before { top: 0; background: linear-gradient(90deg, #fff 0 50%, transparent 50%); opacity: .2; }
.board::after { bottom: 0; background: linear-gradient(90deg, #000 0 50%, transparent 50%); opacity: .25; }

/* Captured headers clearer */
.captured--white h3::before { content: '⚪ '; }
.captured--black h3::before { content: '⚫ '; }

/* Optional piece tint to reinforce color */
.piece img.white { filter: drop-shadow(0 0 0 rgba(255,255,255,.0)); }
.piece img.black { filter: drop-shadow(0 0 0 rgba(0,0,0,.0)); }

/* Responsive */
@media (max-width: 900px) {
  .board-wrap { grid-template-columns: 1fr; }
  .captured { order: 2; }
}

.points { display: inline-block; margin-left: 6px; font-weight: 800; background: #1a2558; color: var(--accent-2); padding: 2px 6px; border-radius: 999px; font-size: 12px; border: 1px solid #2a3877; }

/* Revolutionary Last Move Trail Effects */
.last-move {
  position: relative;
  background: linear-gradient(45deg, 
    rgba(255, 0, 122, 0.1), 
    rgba(122, 0, 255, 0.1), 
    rgba(255, 0, 122, 0.1));
  background-size: 400% 400%;
  animation: lastMoveShimmer 3s ease-in-out infinite;
  box-shadow: 
    inset 0 0 0 2px rgba(255, 0, 122, 0.8),
    0 0 20px rgba(255, 0, 122, 0.4),
    0 0 40px rgba(255, 0, 122, 0.2);
}

.last-move::before {
  content: "";
  position: absolute;
  inset: -3px;
  background: linear-gradient(45deg, 
    #ff007a, #7a00ff, #00d4ff, #ffc800, #ff007a);
  background-size: 400% 400%;
  border-radius: 12px;
  z-index: -1;
  animation: trailFlow 4s linear infinite;
  opacity: 0.6;
}

.last-move::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  border-style: dashed;
  animation: trailDash 2s linear infinite;
  mix-blend-mode: difference;
}

@keyframes lastMoveShimmer {
  0%, 100% {
    background-position: 0% 50%;
    box-shadow: 
      inset 0 0 0 2px rgba(255, 0, 122, 0.8),
      0 0 20px rgba(255, 0, 122, 0.4),
      0 0 40px rgba(255, 0, 122, 0.2);
  }
  50% {
    background-position: 100% 50%;
    box-shadow: 
      inset 0 0 0 2px rgba(122, 0, 255, 1),
      0 0 30px rgba(122, 0, 255, 0.6),
      0 0 60px rgba(122, 0, 255, 0.3);
  }
}

@keyframes trailFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 400% 50%; }
}

@keyframes trailDash {
  0% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 20px; opacity: 0.7; }
}
#materialIndicator { margin-left: 8px; }

.movetools { display:flex; gap:8px; margin:0 0 8px; flex-wrap:wrap; }
.movetools .btn { background:#2a3666; box-shadow:none; }
.movetools .btn.btn--secondary { background:#1b274d; }

/* Cool Piece Movement Animations */
@keyframes pieceSlide {
  0% { 
    transform: scale(1) translateZ(0);
    filter: brightness(1);
  }
  50% { 
    transform: scale(1.1) translateZ(10px);
    filter: brightness(1.3) drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
  }
  100% { 
    transform: scale(1) translateZ(0);
    filter: brightness(1);
  }
}

@keyframes pieceCapture {
  0% { 
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  30% { 
    transform: scale(1.3) rotate(-10deg);
    opacity: 0.8;
  }
  60% { 
    transform: scale(0.8) rotate(15deg);
    opacity: 0.4;
  }
  100% { 
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

@keyframes checkFlash {
  0%, 100% { 
    box-shadow: 
      inset 0 0 0 3px rgba(255, 50, 50, 0.8),
      0 0 20px rgba(255, 50, 50, 0.6),
      0 0 40px rgba(255, 50, 50, 0.4);
  }
  50% { 
    box-shadow: 
      inset 0 0 0 5px rgba(255, 100, 100, 1),
      0 0 30px rgba(255, 50, 50, 0.8),
      0 0 60px rgba(255, 50, 50, 0.6);
  }
}

@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-0.5deg); }
  75% { transform: translateX(3px) rotate(0.5deg); }
}

@keyframes pieceGlow {
  0%, 100% { 
    filter: brightness(1) drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
  }
  50% { 
    filter: brightness(1.4) drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
  }
}

/* Animation Classes */
.piece--moved {
  animation: pieceSlide 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece--captured {
  animation: pieceCapture 0.8s cubic-bezier(0.6, 0, 0.4, 1) forwards;
}

.square--check {
  animation: checkFlash 1.5s ease-in-out infinite;
}

.board--shake {
  animation: boardShake 0.5s ease-in-out;
}

.piece--glow {
  animation: pieceGlow 2s ease-in-out infinite;
}

/* Particle Effects */
@keyframes sparkle {
  0%, 100% { 
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }
  50% { 
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(0.5);
  }
}

/* Particle classes */
.particle {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
}

.particle--sparkle {
  width: 8px;
  height: 8px;
  background: radial-gradient(circle, #fff, #4ade80);
  border-radius: 50%;
  animation: sparkle 1s ease-in-out;
}

.particle--star {
  width: 12px;
  height: 12px;
  background: linear-gradient(45deg, #fbbf24, #f59e0b);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: floatUp 2s ease-out forwards;
}

/* Enhanced piece states */
.piece--selected {
  transform: scale(1.1);
  filter: brightness(1.3) drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
  animation: pieceGlow 1s ease-in-out infinite;
}

/* Turn indicator animations */
.status {
  transition: all 0.3s ease;
}

.status--turn-change {
  animation: turnChange 0.6s ease-in-out;
}

@keyframes turnChange {
  0%, 100% {
    transform: scale(1);
    color: var(--text);
  }
  50% {
    transform: scale(1.1);
    color: var(--accent-1);
    filter: drop-shadow(0 0 10px currentColor);
  }
}

/* Clock animations */
.clock {
  transition: all 0.3s ease;
}

.clock--active {
  animation: clockPulse 2s ease-in-out infinite;
  border-color: var(--accent-1);
}

.clock--warning {
  animation: clockWarning 1s ease-in-out infinite;
  border-color: var(--danger);
}

@keyframes clockPulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(100, 200, 255, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.6);
    transform: scale(1.02);
  }
}

@keyframes clockWarning {
  0%, 100% {
    background-color: var(--surface);
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.5);
  }
  50% {
    background-color: rgba(255, 50, 50, 0.1);
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.8);
  }
}

/* Smooth transitions for UI elements */
.btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    var(--shadow-lg),
    0 0 20px rgba(100, 200, 255, 0.3);
}

.btn:active {
  transform: translateY(0);
  transition: all 0.1s ease;
}

/* AI Badge Animation */
@keyframes aiPulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.8);
    transform: scale(1.05);
  }
}

.badge--ai {
  background: linear-gradient(45deg, #6366f1, #8b5cf6) !important;
  color: white !important;
  animation: aiPulse 2s ease-in-out infinite;
}

.badge--thinking {
  background: linear-gradient(45deg, #f59e0b, #f97316) !important;
  color: white !important;
  animation: aiPulse 1s ease-in-out infinite;
}

/* AI Controls Styling */
.ai-controls {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.ai-controls h4 {
  background: linear-gradient(45deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 8px 0;
}

/* Enhanced button hover for AI controls */
#playAiBtn:hover {
  background: linear-gradient(45deg, #10b981, #059669);
  transform: translateY(-2px) scale(1.05);
}

#stopAiBtn:hover {
  background: linear-gradient(45deg, #ef4444, #dc2626);
  transform: translateY(-2px) scale(1.05);
}

/* Board entrance animation */
.board {
  animation: boardEnter 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes boardEnter {
  0% {
    opacity: 0;
    transform: scale(0.9) rotateX(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotateX(0deg);
  }
}

/* Resign state highlight for checkIndicator reuse */
.status--gameover { color:var(--danger); font-weight:700; }
/* Colorful move arrow overlay */
.board .move-arrow { position:absolute; pointer-events:none; z-index:5; }
.move-arrow .shaft { position:absolute; transform-origin:0 50%; height:8px; border-radius:4px; background:linear-gradient(90deg,#ff6a00,#ffcc00,#00d4ff,#7a00ff); filter:drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.move-arrow .head { position:absolute; width:0; height:0; border-top:12px solid transparent; border-bottom:12px solid transparent; border-left:18px solid #7a00ff; filter:drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.move-arrow.fade { animation: arrowFade 3.5s forwards; }
@keyframes arrowFade { 0%{opacity:1;} 70%{opacity:1;} 100%{opacity:0;} }

/* Game result summary modal */
#resultModal { position:fixed; inset:0; display:none; place-items:center; background:rgba(0,0,0,.55); backdrop-filter:blur(3px); z-index:1000; }
#resultModal[aria-hidden="false"] { display:grid; }
.result__dialog { width:360px; max-width:90%; background:var(--panel); border:2px solid #27407d; border-radius:18px; padding:24px 24px 20px; box-shadow:0 10px 30px rgba(0,0,0,.5); text-align:center; }
.result__dialog h2 { margin:4px 0 14px; font-size:20px; letter-spacing:.5px; }
.result__details { font-size:14px; color:var(--muted); margin-bottom:18px; line-height:1.4; }
.result__actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.result__actions .btn { flex:1 1 120px; }

/* Toast notifications */
.toast-container { position:fixed; top:16px; right:16px; display:flex; flex-direction:column; gap:10px; z-index:2000; max-width:320px; }
.toast { background:linear-gradient(135deg,#1e2d5c,#0f1736); border:1px solid #2f4b99; padding:10px 14px 10px 12px; border-radius:14px; color:var(--text); font-size:13px; line-height:1.3; box-shadow:0 6px 18px -4px rgba(0,0,0,.55),0 0 0 1px rgba(255,255,255,.04); display:flex; align-items:flex-start; gap:10px; position:relative; overflow:hidden; }
.toast::before { content:""; position:absolute; inset:0; background:radial-gradient(circle at 20% 15%, rgba(110,231,255,.18), transparent 60%); pointer-events:none; }
.toast__icon { font-size:16px; line-height:1; }
.toast__close { background:transparent; border:0; color:var(--muted); cursor:pointer; font-size:14px; padding:2px 4px; position:absolute; top:6px; right:6px; }
.toast__close:hover { color:var(--accent-2); }
.toast--warn { border-color:#cc7a00; }
.toast--error { border-color:#b4003b; }
.toast--error::before { background:radial-gradient(circle at 20% 15%, rgba(255,0,90,.25), transparent 60%); }
.toast--success { border-color:#0b7d4a; }
.toast-progress { position:absolute; left:0; bottom:0; height:3px; background:linear-gradient(90deg,#ffcc00,#ff007a,#7a00ff,#00d4ff); width:100%; transform-origin:left; animation: toastBar linear forwards; }
@keyframes toastBar { from { transform:scaleX(1);} to { transform:scaleX(0);} }
.toast-enter { animation: toastIn .42s cubic-bezier(.4,.0,.2,1); }
@keyframes toastIn { 0%{opacity:0; transform:translateY(-10px) scale(.95);} 100%{opacity:1; transform:translateY(0) scale(1);} }
.toast-exit { animation: toastOut .35s ease forwards; }
@keyframes toastOut { to { opacity:0; transform:translateY(-8px) scale(.97);} }
