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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 600px;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hidden {
  display: none !important;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-toggle {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #334;
}

.btn-mode,
.btn-difficulty {
  background: #222;
  color: #aaa;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-mode:hover,
.btn-difficulty:hover {
  background: #333;
}

.btn-mode.active,
.btn-difficulty.active {
  background: #2457c5;
  color: #fff;
}

.btn-new-game {
  background: #333;
  color: #eee;
  border: 2px solid #555;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-new-game:hover {
  background: #444;
}

.difficulty-toggle {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #334;
}

/* CvC difficulty */
.cvc-difficulty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.cvc-difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cvc-label {
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 55px;
  text-align: right;
}

.cvc-label-red { color: #e63946; }
.cvc-label-yellow { color: #ffd166; }

/* Auto-restart toggle */
.auto-restart-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #aaa;
  cursor: pointer;
}

.auto-restart-toggle input[type="checkbox"] {
  accent-color: #2457c5;
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 600;
  min-height: 32px;
}

.status-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  transition: background 0.3s;
}

.dot-p1 { background: #e63946; }
.dot-p2 { background: #ffd166; }
.dot-draw { background: #888; }

.status-dot.thinking {
  animation: think-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes think-pulse {
  0%   { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.1); }
}

.notification {
  font-size: 0.85rem;
  color: #ff9f43;
  min-height: 20px;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
}

.notification.visible {
  opacity: 1;
}

/* Indicators */
.indicators {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: min(90vw, 560px);
  padding: 0 4px;
}

.indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  height: 28px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
  color: #888;
}

.indicator:hover {
  opacity: 1;
}

.indicator-p1 { color: #e63946; }
.indicator-p2 { color: #ffd166; }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  width: min(90vw, 560px);
  aspect-ratio: 7 / 6;
  background: #2457c5;
  border-radius: 12px;
  padding: 8px;
  gap: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Cells */
.cell {
  position: relative;
  border-radius: 50%;
  background: #1a1a2e;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  overflow: hidden;
}

.cell::after {
  content: '';
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  transition: background 0.15s;
}

.cell.player-1::after {
  background: #e63946;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cell.player-2::after {
  background: #ffd166;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Hover previews (desktop only) */
@media (hover: hover) {
  .cell.preview-p1::after {
    background: rgba(230, 57, 70, 0.3);
  }

  .cell.preview-p2::after {
    background: rgba(255, 209, 102, 0.3);
  }
}

/* Drop animations */
.cell[data-drop] {
  animation: drop calc(0.3s + var(--row) * 0.05s) ease-in forwards;
  --drop-y: calc(-100% * (var(--row) + 1));
}

@keyframes drop {
  0%   { transform: translateY(var(--drop-y)); opacity: 0.7; }
  80%  { transform: translateY(5%); }
  100% { transform: translateY(0); opacity: 1; }
}

/* Winner highlight */
.cell.winner::after {
  animation: pulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse {
  0%   { box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 0 0 rgba(255, 255, 255, 0); }
  100% { box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 0 16px rgba(255, 255, 255, 0.7); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cell[data-drop] {
    animation: none;
  }

  .status-dot.thinking {
    animation: none;
  }

  .cell.winner::after {
    animation: none;
    box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 0 16px rgba(255, 255, 255, 0.7);
  }
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .container {
    gap: 12px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .btn-mode,
  .btn-difficulty {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .btn-new-game {
    padding: 6px 16px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .controls {
    flex-direction: column;
    gap: 8px;
  }

  .board {
    width: 95vw;
  }

  .indicators {
    width: 95vw;
  }

  h1 {
    font-size: 1.4rem;
  }

  .status {
    font-size: 1rem;
  }
}
