:root {
  --x-color: #ff5d8f;
  --o-color: #4dd0ff;
  --bg1: #1a0b2e;
  --bg2: #0f1b3d;
}

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

body {
  font-family: 'Segoe UI', 'Poppins', Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg1), var(--bg2), #3d0f2e);
  background-size: 300% 300%;
  animation: bgShift 12s ease infinite;
  color: #fff;
}

@keyframes bgShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  width: 100%;
  max-width: 460px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title {
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 20px;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.title span {
  background: linear-gradient(90deg, var(--o-color), #b06aff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 16px;
  gap: 12px;
}

.player {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.player-x { background: rgba(255, 93, 143, 0.15); color: var(--x-color); }
.player-o { background: rgba(77, 208, 255, 0.15); color: var(--o-color); }

.player.active {
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
}

.player-x.active { background: var(--x-color); color: #fff; box-shadow: 0 0 20px var(--x-color); }
.player-o.active { background: var(--o-color); color: #0a0a2a; box-shadow: 0 0 20px var(--o-color); }

.scores {
  display: flex;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  border-radius: 14px;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.1rem;
}

.badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 900;
}

.x-badge { background: var(--x-color); color: #fff; }
.o-badge { background: var(--o-color); color: #0a0a2a; }
.tie-badge { background: #b06aff; color: #fff; }

.turn-indicator {
  margin-bottom: 18px;
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
}

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

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  aspect-ratio: 1;
  padding: 12px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.cell {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 14px;
  font-size: 3.4rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.25s ease;
  user-select: none;
}

.cell:hover:not(.taken):not(.disabled) {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.04);
}

.cell.x {
  color: var(--x-color);
  text-shadow: 0 0 18px var(--x-color);
  animation: pop 0.3s ease;
}

.cell.o {
  color: var(--o-color);
  text-shadow: 0 0 18px var(--o-color);
  animation: pop 0.3s ease;
}

.cell.win {
  background: rgba(255, 215, 0, 0.18);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.55);
  animation: glow 1s ease infinite alternate;
}

.cell.disabled { cursor: default; }
.taken { cursor: default; }

@keyframes pop {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes glow {
  from { box-shadow: 0 0 12px rgba(255, 215, 0, 0.4); }
  to { box-shadow: 0 0 30px rgba(255, 215, 0, 0.8); }
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  border: none;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  color: #fff;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-restart {
  background: linear-gradient(90deg, #b06aff, var(--x-color));
  box-shadow: 0 4px 16px rgba(176, 106, 255, 0.4);
}

.btn-reset {
  background: rgba(255, 255, 255, 0.15);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  z-index: 10;
}

.hidden { display: none !important; }

.modal {
  background: linear-gradient(135deg, #2a1050, #1a2a5e);
  padding: 40px 48px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.6);
  animation: modalPop 0.35s ease;
}

.modal h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #ffd700, #b06aff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal p {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 22px;
}

@keyframes modalPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 14px;
  top: -20px;
  z-index: 20;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}
