:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --board-bg: #1e293b;
  --cell-bg: #0f172a;
  --cell-hover: #1e3a5f;
  --x-color: #6366f1;
  --o-color: #ec4899;
  --win-color: #fbbf24;
  --text: #f1f5f9;
  --subtext: #94a3b8;
  --border: #334155;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}

h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

#status {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--subtext);
  min-height: 2rem;
  transition: color 0.3s;
}

#score {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

#score span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

#score .score-label {
  font-size: 0.75rem;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#score .score-value {
  font-size: 1.5rem;
  font-weight: 700;
}

#score-wins {
  color: var(--x-color);
}

#score-draws {
  color: var(--subtext);
}

#score-losses {
  color: var(--o-color);
}

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--board-bg);
  padding: 12px;
  border-radius: 12px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.cell {
  aspect-ratio: 1;
  background: var(--cell-bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
  border: 2px solid var(--border);
}

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

.cell.x {
  color: var(--x-color);
  cursor: default;
  animation: pop 0.25s ease;
}

.cell.o {
  color: var(--o-color);
  cursor: default;
  animation: pop 0.25s ease;
}

.cell.win {
  border-color: var(--win-color);
  box-shadow: 0 0 12px 3px var(--win-color), inset 0 0 8px rgba(251, 191, 36, 0.15);
  animation: glow 1s ease-in-out infinite alternate;
}

.cell.shake {
  animation: shake 0.3s ease;
}

@keyframes pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  70% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes glow {
  from {
    box-shadow: 0 0 8px 2px var(--win-color);
  }
  to {
    box-shadow: 0 0 20px 6px var(--win-color);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  20%, 60% {
    transform: translateX(-6px);
  }
  40%, 80% {
    transform: translateX(6px);
  }
}

.buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

button {
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

button:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

#new-game {
  background: var(--x-color);
  color: #fff;
}

#reset-score {
  background: var(--surface);
  color: var(--subtext);
  border: 1px solid var(--border);
}
