/* ════════════════════════════════════════════════════════════
   CHECKERS GAME  ·  style.css
   Responsive board design, animations, dark/light themes
   ════════════════════════════════════════════════════════════ */

:root {
  --color-red: #e74c3c;
  --color-black: #2c3e50;
  --color-light: #ecf0f1;
  --color-dark: #34495e;
  --color-board-light: #f4e4d3;
  --color-board-dark: #704214;
  --color-green-highlight: #27ae60;
  --color-capture: #e67e22;

  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --border-color: #bdc3c7;

  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

.dark-theme {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #ecf0f1;
  --text-secondary: #bdc3c7;
  --border-color: #404040;
  --color-board-light: #5a4a3a;
  --color-board-dark: #3a2a1a;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.game-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.game-header h1 {
  font-size: 1.5rem;
  text-align: center;
  flex: 1;
}

.back-button {
  padding: 0.5rem 1rem;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

.back-button:hover {
  background-color: var(--bg-secondary);
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: background-color var(--transition-fast);
}

.icon-button:hover {
  background-color: var(--bg-primary);
  border-color: var(--text-primary);
}

.icon-button.muted {
  opacity: 0.5;
}

/* ════════════════════════════════════════════════════════════
   GAME CONTAINER
   ════════════════════════════════════════════════════════════ */

.game-container {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 2rem;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
}

.game-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-space {
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--bg-secondary);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.game-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ════════════════════════════════════════════════════════════
   CONTROL PANEL
   ════════════════════════════════════════════════════════════ */

.control-panel {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.mode-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mode-controls label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mode-controls select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.status-display {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: center;
}

.status-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.piece-count {
  display: flex;
  gap: 1rem;
  justify-content: center;
  font-size: 0.95rem;
}

.red-info, .black-info {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.vs {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--color-green-highlight);
  color: white;
}

.btn-primary:hover {
  background-color: #229954;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.btn-secondary:hover {
  background-color: var(--border-color);
}

/* ════════════════════════════════════════════════════════════
   BOARD
   ════════════════════════════════════════════════════════════ */

.board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background-color: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.checkers-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  aspect-ratio: 1;
  width: 100%;
  max-width: 500px;
  background-color: var(--color-board-dark);
  border: 2px solid var(--color-board-dark);
  position: relative;
}

.checkers-square {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.checkers-square.light {
  background-color: var(--color-board-light);
  cursor: default;
}

.checkers-square.dark {
  background-color: var(--color-board-dark);
}

.checkers-square.dark:hover {
  background-color: #5a3c1a;
}

.checkers-square.dark.valid-move {
  background-color: var(--color-green-highlight);
}

.checkers-square.dark.capture-target {
  background-color: var(--color-capture);
  box-shadow: inset 0 0 10px rgba(230, 126, 34, 0.5);
}

.checkers-square.dark.selected {
  background-color: #27ae60;
  box-shadow: inset 0 0 15px rgba(39, 174, 96, 0.6);
}

/* Coordinates */
.rank-label, .file-label {
  position: absolute;
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--text-secondary);
  opacity: 0.7;
}

.rank-label {
  top: 2px;
  left: 2px;
}

.file-label {
  bottom: 2px;
  right: 2px;
}

/* ════════════════════════════════════════════════════════════
   PIECES
   ════════════════════════════════════════════════════════════ */

.piece {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  user-select: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset -2px -2px 5px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 10;
}

.piece.red {
  background: radial-gradient(circle at 30% 30%, #ff6b6b, var(--color-red));
  border: 2px solid #c0392b;
}

.piece.red:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4), inset -3px -3px 8px rgba(0, 0, 0, 0.3);
}

.piece.black {
  background: radial-gradient(circle at 30% 30%, #34495e, var(--color-black));
  border: 2px solid #1a252f;
}

.piece.black:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5), inset -3px -3px 8px rgba(0, 0, 0, 0.4);
}

.piece.king {
  font-weight: bold;
  color: #f1c40f;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.piece.captured {
  animation: capturePop 250ms ease-out forwards;
}

.piece.promote-animation {
  animation: promoteGlow 400ms ease-out;
}

/* ════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════ */

@keyframes capturePop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes promoteGlow {
  0% {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset -2px -2px 5px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.8), inset 0 0 10px rgba(241, 196, 15, 0.5);
  }
  100% {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), inset -2px -2px 5px rgba(0, 0, 0, 0.2);
  }
}

/* ════════════════════════════════════════════════════════════
   OVERLAY
   ════════════════════════════════════════════════════════════ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  background-color: var(--bg-primary);
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 300ms ease;
}

.overlay-content h2 {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  color: var(--color-green-highlight);
}

.overlay-content .btn {
  margin: 0.5rem;
  min-width: 120px;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .game-container {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }

  .game-sidebar {
    display: none;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .game-header {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .game-header h1 {
    font-size: 1.2rem;
    order: 2;
    width: 100%;
  }

  .back-button {
    order: 1;
    flex: 1;
  }

  .header-controls {
    order: 3;
    width: 100%;
    gap: 0.75rem;
  }

  .icon-button {
    flex: 1;
  }

  .control-panel {
    flex-direction: column;
    gap: 1rem;
  }

  .action-buttons {
    gap: 0.5rem;
  }

  .btn {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
  }

  .checkers-board {
    max-width: 90vw;
  }
}

@media (max-width: 480px) {
  .game-header {
    padding: 0.5rem;
  }

  .game-header h1 {
    font-size: 1rem;
  }

  .back-button {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .icon-button {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  .control-panel {
    padding: 1rem;
    gap: 0.75rem;
  }

  .mode-controls select {
    font-size: 0.8rem;
    padding: 0.4rem;
  }

  .status-text {
    font-size: 0.95rem;
  }

  .piece-count {
    gap: 0.5rem;
    font-size: 0.85rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .checkers-board {
    max-width: 100%;
  }

  .piece {
    font-size: 1.5rem;
  }

  .rank-label, .file-label {
    font-size: 0.55rem;
  }
}

/* ════════════════════════════════════════════════════════════
   PRINT STYLES
   ════════════════════════════════════════════════════════════ */

@media print {
  .game-header,
  .control-panel,
  .game-sidebar {
    display: none;
  }

  .game-container {
    max-width: 100%;
  }
}
