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

body {
  background-color: #0C0D14;
  color: #E0E0E0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 20px;
}

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

@media (max-height: 600px), (max-width: 500px) {
  body {
    padding: 10px 12px;
  }

  .game-container {
    gap: 14px;
  }
}

/* Header */
.game-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.game-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.02em;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 4px;
  background: #1A1B26;
  border-radius: 10px;
  padding: 4px;
}

.mode-btn {
  padding: 8px 24px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #888;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: #BBB;
}

.mode-btn.active {
  background: #7C4DFF;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(124, 77, 255, 0.4);
}

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

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

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

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

.x-score .score-value {
  color: #7C4DFF;
}

.o-score .score-value {
  color: #FF6B6B;
}

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

/* Status */
.status {
  font-size: 1.1rem;
  font-weight: 600;
  color: #AAA;
  min-height: 28px;
  transition: color 0.3s ease;
}

.status.x-turn {
  color: #7C4DFF;
}

.status.o-turn {
  color: #FF6B6B;
}

.status.win {
  font-size: 1.25rem;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1;
  position: relative;
}

.cell {
  background: #1A1B26;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.cell:hover:not(.taken) {
  background: #22233A;
  transform: scale(1.03);
}

.cell.taken {
  cursor: default;
}

.cell.x-cell {
  color: #7C4DFF;
}

.cell.o-cell {
  color: #FF6B6B;
}

/* Mark placement animation */
@keyframes markPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.cell .mark {
  display: inline-block;
  animation: markPop 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Winning cells */
.cell.winner {
  background: #1E1F33;
}

.cell.winner.x-cell {
  box-shadow:
    0 0 16px rgba(124, 77, 255, 0.4),
    inset 0 0 16px rgba(124, 77, 255, 0.15);
  border: 2px solid rgba(124, 77, 255, 0.5);
}

.cell.winner.o-cell {
  box-shadow:
    0 0 16px rgba(255, 107, 107, 0.4),
    inset 0 0 16px rgba(255, 107, 107, 0.15);
  border: 2px solid rgba(255, 107, 107, 0.5);
}

@keyframes winPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.cell.winner .mark {
  animation: winPulse 0.8s ease-in-out 2;
}

/* Win Line Overlay (hidden by default) */
.win-line-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

/* Reset Button */
.reset-btn {
  padding: 8px 22px;
  border: 2px solid #333;
  border-radius: 10px;
  background: transparent;
  color: #666;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

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

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

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

  .board {
    gap: 6px;
  }

  .cell {
    font-size: 2.4rem;
    border-radius: 10px;
  }

  .scoreboard {
    gap: 12px;
  }

  .score-item {
    padding: 10px 12px;
    min-width: 64px;
  }
}
