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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-hover: #22223a;
  --border: #2a2a4a;
  --text: #e0e0e0;
  --text-muted: #7a7a9a;
  --x-color: #6c9eff;
  --o-color: #ff6c9e;
  --draw-color: #9a9ab0;
  --win-glow-x: rgba(108, 158, 255, 0.35);
  --win-glow-o: rgba(255, 108, 158, 0.35);
  --radius: 12px;
  --cell-size: min(28vw, 120px);
  --gap: 8px;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px;
}

/* Title */
.title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--x-color), var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  gap: 16px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 24px;
  min-width: 80px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.score-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.score-item.player-x .score-label {
  color: var(--x-color);
}

.score-item.player-o .score-label {
  color: var(--o-color);
}

.score-item.draws .score-label {
  color: var(--draw-color);
}

.score-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 4px;
}

/* Turn Indicator */
.turn-indicator {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.3s ease;
  min-height: 1.5em;
}

.turn-indicator.x-turn {
  color: var(--x-color);
}

.turn-indicator.o-turn {
  color: var(--o-color);
}

.turn-indicator.winner {
  font-weight: 700;
  font-size: 1.2rem;
}

.turn-indicator.draw {
  color: var(--draw-color);
  font-weight: 700;
  font-size: 1.2rem;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(3, var(--cell-size));
  grid-template-rows: repeat(3, var(--cell-size));
  gap: var(--gap);
  position: relative;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: calc(var(--cell-size) * 0.5);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cell:hover:not(:disabled) {
  background: var(--surface-hover);
  transform: scale(1.04);
}

.cell:active:not(:disabled) {
  transform: scale(0.97);
}

.cell:disabled {
  cursor: default;
}

/* Mark colors */
.cell.x {
  color: var(--x-color);
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell.o {
  color: var(--o-color);
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% {
    transform: scale(0) rotate(-15deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* Winning cells */
.cell.win-x {
  border-color: var(--x-color);
  box-shadow: 0 0 20px var(--win-glow-x);
  animation: winPulse 1.5s ease-in-out infinite;
}

.cell.win-o {
  border-color: var(--o-color);
  box-shadow: 0 0 20px var(--win-glow-o);
  animation: winPulse 1.5s ease-in-out infinite;
}

@keyframes winPulse {
  0%, 100% {
    box-shadow: 0 0 12px var(--win-glow-x);
  }
  50% {
    box-shadow: 0 0 28px var(--win-glow-x);
  }
}

.cell.win-o {
  animation-name: winPulseO;
}

@keyframes winPulseO {
  0%, 100% {
    box-shadow: 0 0 12px var(--win-glow-o);
  }
  50% {
    box-shadow: 0 0 28px var(--win-glow-o);
  }
}

/* Winning line overlay */
.winning-line {
  position: absolute;
  background: var(--x-color);
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.winning-line.visible {
  opacity: 0.8;
  animation: lineGrow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.winning-line.o-line {
  background: var(--o-color);
}

@keyframes lineGrow {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

/* Reset Button */
.reset-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.reset-btn:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.reset-btn:active {
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 20px 16px;
    gap: 18px;
  }

  .title {
    font-size: 1.5rem;
  }

  .scoreboard {
    gap: 10px;
  }

  .score-item {
    padding: 10px 16px;
    min-width: 65px;
  }

  .score-label {
    font-size: 0.75rem;
  }

  .score-value {
    font-size: 1.2rem;
  }

  :root {
    --cell-size: min(28vw, 100px);
    --gap: 6px;
  }
}

@media (max-width: 360px) {
  :root {
    --cell-size: min(26vw, 85px);
  }

  .score-item {
    padding: 8px 12px;
    min-width: 55px;
  }
}
