/* ============================================
   KMS Chess 3D - Premium Styling
   Royal Gold & Deep Navy Theme
   ============================================ */

:root {
  /* Color Palette - Royal Gold & Navy */
  --bg-primary: #0a0a14;
  --bg-secondary: #0d0d1e;
  --bg-card: rgba(13, 13, 30, 0.96);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --gold-primary: #c9a84c;
  --gold-light: #f0d78c;
  --gold-dark: #8b6914;
  --gold-glow: rgba(201, 168, 76, 0.4);

  --navy-primary: #1a1a3e;
  --navy-light: #2d2d5c;
  --navy-dark: #0d0d1e;

  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;

  --board-light: #e8d5a8;
  --board-dark: #8b6b3d;
  --board-light-hover: #f0ddb8;
  --board-dark-hover: #9a7a4c;
  --board-border: #c9a84c;

  --white-piece: #f5f0e8;
  --white-piece-shadow: rgba(0, 0, 0, 0.4);
  --black-piece: #1a1a2e;
  --black-piece-color: #2a2a44;

  --text-primary: #f0f0f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --highlight-selected: rgba(201, 168, 76, 0.5);
  --highlight-valid: rgba(16, 185, 129, 0.45);
  --highlight-capture: rgba(239, 68, 68, 0.45);
  --highlight-hint: rgba(245, 158, 11, 0.6);
  --highlight-last: rgba(139, 92, 246, 0.35);
  --highlight-check: rgba(239, 68, 68, 0.6);

  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hard: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-gold: 0 0 30px rgba(201, 168, 76, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  --font-display: "Cinzel", serif;
  --font-body: "Inter", sans-serif;

  --cell-size: 68px;
  --board-gap: 0px;
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: radial-gradient(ellipse at center, #0d0d1e 0%, #0a0a14 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
}

.loading-piece-container {
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.loading-chess-piece {
  font-size: 3.5rem;
  animation: loadingBounce 1.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.loading-chess-piece:nth-child(1) {
  color: var(--white-piece);
  animation-delay: 0s;
}
.loading-chess-piece:nth-child(2) {
  color: #555;
  animation-delay: -0.5s;
}
.loading-chess-piece:nth-child(3) {
  color: var(--white-piece);
  animation-delay: -1s;
}

@keyframes loadingBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.08);
  }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--gold-light),
    var(--gold-primary),
    var(--gold-dark)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 30px;
  letter-spacing: 4px;
}

.loading-bar-container {
  width: 240px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 0 auto 16px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-primary), var(--gold-light));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ============================================
   Main Menu
   ============================================ */
.main-menu {
  background: radial-gradient(ellipse at 50% 30%, #0d0d1e 0%, #0a0a14 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.menu-bg-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.menu-bg-particles .particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--gold-primary);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateY(-20vh) scale(1);
  }
}

.menu-content {
  text-align: center;
  z-index: 2;
  position: relative;
}

.menu-logo {
  margin-bottom: 50px;
}

.logo-pieces {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
  font-size: 3.2rem;
}

.logo-piece {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  transform-style: preserve-3d;
}

.logo-piece:nth-child(1) {
  color: #888;
  animation: logoFloat 3s ease-in-out infinite;
}
.logo-piece:nth-child(2) {
  color: var(--white-piece);
  animation: logoFloat 3s ease-in-out infinite;
  animation-delay: -0.6s;
}
.logo-piece:nth-child(3) {
  color: var(--gold-primary);
  animation: logoFloat 3s ease-in-out infinite;
  animation-delay: -1.2s;
}
.logo-piece:nth-child(4) {
  color: var(--white-piece);
  animation: logoFloat 3s ease-in-out infinite;
  animation-delay: -1.8s;
}
.logo-piece:nth-child(5) {
  color: #888;
  animation: logoFloat 3s ease-in-out infinite;
  animation-delay: -2.4s;
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0) rotateY(0deg);
  }
  25% {
    transform: translateY(-12px) rotateY(8deg);
  }
  75% {
    transform: translateY(-6px) rotateY(-8deg);
  }
}

.menu-title {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 900;
  background: linear-gradient(
    135deg,
    var(--gold-light) 0%,
    var(--gold-primary) 50%,
    var(--gold-dark) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.menu-subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 6px;
  text-transform: uppercase;
  font-weight: 300;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.game-footer {
  position: absolute;
  bottom: 30px;
  left: 0;
  width: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-body);
  letter-spacing: 1px;
  pointer-events: none;
}

/* Buttons */
.menu-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 40px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 260px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.menu-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.menu-btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-primary));
  color: #fff;
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(201, 168, 76, 0.5);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  border-color: var(--gold-primary);
}

.btn-icon {
  font-size: 1.3rem;
}

/* Language Toggle */
.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  padding: 4px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
}

.lang-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
}

.lang-btn.active {
  background: var(--gold-primary);
  color: #fff;
}

/* ============================================
   Modal Screens
   ============================================ */
.modal-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-screen.hidden {
  display: none !important;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  min-width: 380px;
  max-width: 500px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-hard);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 24px;
}

.modal-close-btn {
  display: block;
  margin: 24px auto 0;
  padding: 10px 32px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Difficulty Selection */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diff-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: left;
  color: var(--text-primary);
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--gold-primary);
  transform: translateX(4px);
}

.diff-icon {
  font-size: 1.8rem;
}
.diff-label {
  font-size: 1.1rem;
  font-weight: 600;
  display: block;
}
.diff-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* Color Selection */
.color-options {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 32px;
  background: var(--bg-glass);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  color: var(--text-primary);
}

.color-btn:hover {
  border-color: var(--gold-primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(201, 168, 76, 0.2);
}

.color-btn-icon {
  font-size: 3rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.color-btn-label {
  font-weight: 600;
  font-size: 1rem;
}

/* Settings */
.settings-card {
  min-width: 400px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-label {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 26px;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--gold-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Language Select in Settings */
.lang-select {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 3px;
}

.lang-option {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
}

.lang-option.active {
  background: var(--gold-primary);
  color: #fff;
}

/* Tutorial */
.tutorial-card {
  min-width: 500px;
  max-width: 600px;
  max-height: 80vh;
}

.tutorial-content {
  min-height: 280px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tutorial-content::-webkit-scrollbar {
  width: 6px;
}
.tutorial-content::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 3px;
}

.tutorial-page {
  display: none;
}
.tutorial-page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tutorial-page h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gold-primary);
  margin-bottom: 12px;
}

.tutorial-page p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 10px;
  font-size: 0.95rem;
  white-space: pre-line;
}

.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tut-nav-btn {
  padding: 8px 20px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tut-nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tut-page-indicator {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   Game Screen
   ============================================ */
.game-screen {
  background: radial-gradient(ellipse at 50% 40%, #0d0d1e 0%, #0a0a14 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  overflow-y: auto;
}

/* Top Bar */
.game-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.game-title-bar {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold-primary);
  letter-spacing: 2px;
}

.top-bar-controls {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--gold-primary);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Player Info & Captured Pieces */
.game-info-container {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: stretch;
  padding: 10px 20px;
  flex-shrink: 0;
  width: 100%;
  max-width: 700px;
}

.player-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all var(--transition-normal);
  flex-shrink: 0;
}

.player-info.active-player {
  border-color: var(--gold-primary);
  box-shadow:
    0 0 20px rgba(201, 168, 76, 0.15),
    inset 0 0 20px rgba(201, 168, 76, 0.05);
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.player-avatar-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8e0d0);
  border: 2px solid #d4ccb8;
}

.player-avatar-black {
  background: radial-gradient(circle at 35% 35%, #3d3d5c, #1a1a2e);
  border: 2px solid #2d2d44;
}

.player-details {
  flex: 1;
}
.player-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: block;
}

.captured-container {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 24px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.captured-piece {
  font-size: 1rem;
  opacity: 0.7;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* ============================================
   Turn Indicator
   ============================================ */
.turn-indicator {
  text-align: center;
  padding: 6px 24px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold-primary);
  min-width: 200px;
  flex-shrink: 0;
  margin: 4px 0;
}

.turn-indicator.check-alert {
  border-color: var(--accent-red);
  color: var(--accent-red);
  animation: checkFlash 0.5s ease 3;
}

@keyframes checkFlash {
  0%,
  100% {
    background: var(--bg-glass);
  }
  50% {
    background: rgba(239, 68, 68, 0.15);
  }
}

/* ============================================
   Chess Board - 3D Effect
   ============================================ */
.board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  flex-shrink: 0;
}

.board-frame {
  position: relative;
  padding: 8px;
  background: linear-gradient(145deg, #c9982e, #8b6914, #6e5210);
  border-radius: 10px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(201, 168, 76, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transform: perspective(1200px) rotateX(3deg);
  transition: transform 0.5s ease;
}

.board-inner {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--board-gap);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Board Cells */
.board-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  position: relative;
  user-select: none;
}

.cell-light {
  background: var(--board-light);
}

.cell-dark {
  background: var(--board-dark);
}

.cell-light:hover {
  background: var(--board-light-hover);
}
.cell-dark:hover {
  background: var(--board-dark-hover);
}

/* Selected */
.board-cell.selected {
  background: var(--highlight-selected) !important;
  box-shadow: inset 0 0 0 3px rgba(201, 168, 76, 0.8);
}

/* Last move */
.board-cell.last-move.cell-light {
  background: rgba(139, 92, 246, 0.25);
}
.board-cell.last-move.cell-dark {
  background: rgba(139, 92, 246, 0.35);
}

/* Valid moves */
.board-cell.valid-move::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--highlight-valid);
  animation: validPulse 2s ease-in-out infinite;
  pointer-events: none;
}

.board-cell.valid-capture::after {
  content: "";
  position: absolute;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  border: 4px solid var(--highlight-capture);
  background: transparent;
  animation: capturePulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes validPulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes capturePulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.9;
  }
}

/* Hint */
.board-cell.hint-cell {
  box-shadow: inset 0 0 0 3px var(--highlight-hint) !important;
  animation: hintGlow 1.5s ease-in-out infinite;
}

@keyframes hintGlow {
  0%,
  100% {
    box-shadow: inset 0 0 0 3px rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow:
      inset 0 0 0 4px rgba(245, 158, 11, 0.9),
      0 0 12px rgba(245, 158, 11, 0.3);
  }
}

/* Check highlight */
.board-cell.in-check {
  background: var(--highlight-check) !important;
  animation: checkGlow 1s ease-in-out infinite;
}

@keyframes checkGlow {
  0%,
  100% {
    box-shadow: inset 0 0 8px rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: inset 0 0 16px rgba(239, 68, 68, 0.8);
  }
}

/* Coordinate labels */
.coord-rank {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
}

.coord-file {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
}

.cell-light .coord-rank,
.cell-light .coord-file {
  color: var(--board-dark);
}

.cell-dark .coord-rank,
.cell-dark .coord-file {
  color: var(--board-light);
}

/* ============================================
   Chess Pieces - 3D Styled
   ============================================ */
.chess-piece {
  font-size: 2.8rem;
  line-height: 1;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    filter var(--transition-fast);
  user-select: none;
  position: relative;
  z-index: 2;
}

.chess-piece:hover {
  transform: scale(1.08) translateY(-2px);
}

.piece-w {
  color: var(--white-piece);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.piece-b {
  color: #2a2a44;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Promotion Dialog
   ============================================ */
.promo-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.promo-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  box-shadow: var(--shadow-hard), var(--shadow-glow-gold);
  animation: modalIn 0.3s ease;
  text-align: center;
}

.promo-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-primary);
  margin-bottom: 20px;
}

.promo-pieces {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg-glass);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  color: var(--text-primary);
}

.promo-btn:hover {
  border-color: var(--gold-primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(201, 168, 76, 0.2);
}

.promo-symbol {
  font-size: 2.8rem;
  line-height: 1;
}

.promo-symbol.piece-w {
  color: var(--white-piece);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.promo-symbol.piece-b {
  color: #2a2a44;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.promo-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ============================================
   Game Over Overlay
   ============================================ */
.game-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
}

.game-over-card {
  text-align: center;
  padding: 48px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-hard), var(--shadow-glow-gold);
  animation: gameOverIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 360px;
}

@keyframes gameOverIn {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game-over-crown {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: crownBounce 1s ease-in-out infinite;
}

@keyframes crownBounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(5deg);
  }
}

.game-over-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.game-over-subtitle {
  color: var(--text-secondary);
  font-size: 1.2rem;
  margin-bottom: 28px;
  font-family: var(--font-display);
}

.game-over-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* Game Menu */
.game-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   Confetti
   ============================================ */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 650;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  opacity: 0.9;
  animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  :root {
    --cell-size: 52px;
  }

  .board-frame {
    padding: 6px;
    transform: perspective(1200px) rotateX(2deg);
  }

  .game-info-container {
    gap: 10px;
    padding: 8px 12px;
  }

  .menu-title {
    font-size: 2.2rem;
  }

  .modal-card {
    min-width: 320px;
    padding: 24px;
  }
  .tutorial-card {
    min-width: 340px;
    max-width: 95vw;
  }
  .settings-card {
    min-width: 320px;
  }

  .chess-piece {
    font-size: 2.2rem;
  }
}

@media (max-width: 600px) {
  :root {
    --cell-size: 42px;
  }

  .board-frame {
    padding: 4px;
    transform: none;
  }

  .game-info-container {
    flex-direction: column;
    align-items: center;
  }

  .player-panel {
    width: 100%;
    max-width: 340px;
  }

  .menu-title {
    font-size: 1.8rem;
    letter-spacing: 3px;
  }

  .menu-subtitle {
    letter-spacing: 3px;
    font-size: 0.8rem;
  }

  .logo-pieces {
    font-size: 2.2rem;
  }
  .game-top-bar {
    padding: 8px 12px;
  }

  .turn-indicator {
    font-size: 0.8rem;
    padding: 5px 16px;
  }

  .chess-piece {
    font-size: 1.8rem;
  }

  .color-options {
    flex-direction: column;
    align-items: center;
  }
  .color-btn {
    flex-direction: row;
    padding: 16px 24px;
  }
}

@media (max-height: 780px) {
  :root {
    --cell-size: 50px;
  }

  .game-info-container {
    padding: 4px 20px;
  }
  .player-info {
    padding: 6px 12px;
  }
  .board-container {
    padding: 4px;
  }
  .board-frame {
    padding: 6px;
  }
  .turn-indicator {
    margin: 2px 0;
    padding: 4px 20px;
  }
  .chess-piece {
    font-size: 2.1rem;
  }
}

@media (max-height: 680px) {
  :root {
    --cell-size: 44px;
  }
  .chess-piece {
    font-size: 1.9rem;
  }
  .captured-container {
    min-height: 18px;
    padding: 2px 6px;
  }
  .captured-piece {
    font-size: 0.85rem;
  }
}
