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

body {
  background-color: #0C0D14;
  color: #fff;
  font-family: 'Courier New', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 12px;
}

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

/* Header */
.game-header {
  text-align: center;
}

.game-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 72px;
  padding: 10px 16px;
  background: #1A1B26;
  border-radius: 10px;
}

.score-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: #666;
}

.score-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-score .score-value {
  color: #ffcc00;
}

.ai-score .score-value {
  color: #ff4466;
}

.draw-score .score-value {
  color: #888;
}

/* Status */
.status {
  font-size: 1rem;
  font-weight: 600;
  color: #aaa;
  min-height: 24px;
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
}

.status.player-turn {
  color: #ffcc00;
}

.status.ai-turn {
  color: #ff4466;
}

/* Board Wrapper */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Ghost Row */
.ghost-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  max-width: 392px;
  height: 40px;
  gap: 4px;
  padding: 0 6px;
}

.ghost-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ghost-cell .ghost-disc {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 204, 0, 0.25);
  border: 2px solid rgba(255, 204, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ghost-cell:hover .ghost-disc {
  opacity: 1;
}

.ghost-cell.disabled {
  pointer-events: none;
}

.ghost-cell.full .ghost-disc {
  opacity: 0 !important;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 392px;
  background: #1a2a4a;
  border-radius: 12px;
  padding: 8px;
  box-shadow:
    0 4px 24px rgba(26, 42, 74, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.cell {
  aspect-ratio: 1;
  background: #0C0D14;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}

.cell:hover {
  background: #14151f;
}

.cell .disc {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  position: absolute;
}

.cell .disc.player {
  background: radial-gradient(circle at 35% 35%, #ffe066, #ffcc00 40%, #cc9900);
  box-shadow: 0 2px 8px rgba(255, 204, 0, 0.4), inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.cell .disc.ai {
  background: radial-gradient(circle at 35% 35%, #ff7788, #ff4466 40%, #cc2244);
  box-shadow: 0 2px 8px rgba(255, 68, 102, 0.4), inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

/* Drop Animation */
@keyframes dropIn {
  0% {
    transform: translateY(var(--drop-from));
    opacity: 0.8;
  }
  60% {
    transform: translateY(0);
    opacity: 1;
  }
  75% {
    transform: translateY(-8px);
  }
  90% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(0);
  }
}

.cell .disc.dropping {
  animation: dropIn 0.45s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* Winning Discs */
@keyframes winPulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.1);
    filter: brightness(1.3);
  }
}

.cell .disc.winner {
  animation: winPulse 0.7s ease-in-out infinite;
  z-index: 1;
}

.cell .disc.winner.player {
  box-shadow: 0 0 16px rgba(255, 204, 0, 0.7), 0 0 32px rgba(255, 204, 0, 0.3);
}

.cell .disc.winner.ai {
  box-shadow: 0 0 16px rgba(255, 68, 102, 0.7), 0 0 32px rgba(255, 68, 102, 0.3);
}

/* Board disabled */
.board.disabled .cell {
  cursor: default;
  pointer-events: none;
}

/* Buttons */
.reset-btn,
.reset-score-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.reset-btn {
  background: #00ff88;
  color: #0C0D14;
}

.reset-btn:hover {
  background: #00cc6a;
  transform: scale(1.03);
}

.reset-score-btn {
  background: transparent;
  color: #666;
  border: 2px solid #333;
  letter-spacing: 1px;
  font-size: 0.75rem;
  padding: 8px 18px;
}

.reset-score-btn:hover {
  border-color: #ff4466;
  color: #ff4466;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(12, 13, 20, 0.92);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay.active {
  display: flex;
}

.overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}

.overlay-content h2 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-content h2.win {
  color: #ffcc00;
}

.overlay-content h2.lose {
  color: #ff4466;
}

.overlay-content h2.draw {
  color: #888;
}

.overlay-content p {
  font-size: 1rem;
  color: #aaa;
  letter-spacing: 0.05em;
}

.overlay-btn {
  padding: 14px 36px;
  border: none;
  border-radius: 8px;
  background: #00ff88;
  color: #0C0D14;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.overlay-btn:hover {
  background: #00cc6a;
  transform: scale(1.05);
}

/* Responsive */
@media (max-width: 440px) {
  .game-header h1 {
    font-size: 1.4rem;
  }

  .board {
    padding: 6px;
    gap: 3px;
  }

  .ghost-row {
    gap: 3px;
    height: 32px;
    padding: 0 4px;
  }

  .ghost-cell .ghost-disc {
    width: 28px;
    height: 28px;
  }

  .scoreboard {
    gap: 8px;
  }

  .score-item {
    padding: 8px 10px;
    min-width: 60px;
  }

  .overlay-content h2 {
    font-size: 1.6rem;
  }
}

@media (max-height: 600px) {
  body {
    padding: 8px 8px;
  }

  .game-container {
    gap: 8px;
  }

  .ghost-row {
    height: 28px;
  }
}
