* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg-1: #0f0c29;
  --bg-2: #302b63;
  --bg-3: #24243e;
  --x-color: #4dd0e1;
  --o-color: #ff7043;
  --cell-bg: rgba(255,255,255,0.06);
  --cell-border: rgba(255,255,255,0.12);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  color: #f0f0f5;
  padding: 20px;
  overflow: hidden;
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin: 0 0 1.2rem;
  background: linear-gradient(90deg, var(--x-color), #ba68c8, var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#turn-indicator {
  margin-bottom: 1.2rem;
  transition: transform .2s;
}

#status {
  font-size: 1.15rem;
  font-weight: 700;
  padding: .5rem 1.4rem;
  border-radius: 100px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  display: inline-block;
}

#status.x { color: var(--x-color); border-color: var(--x-color); }
#status.o { color: var(--o-color); border-color: var(--o-color); }

#board {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 8px;
  margin-bottom: 1.4rem;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.cell {
  width: 100px;
  height: 100px;
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .3s;
}

.cell:active { transform: scale(0.94); background: rgba(255,255,255,0.12); }

.cell.x { color: var(--x-color); text-shadow: 0 0 20px rgba(77,208,225,0.6); }
.cell.o { color: var(--o-color); text-shadow: 0 0 20px rgba(255,112,67,0.6); }

.cell .mark { animation: pop .25s ease-out; display: inline-block; }

.cell.win {
  background: rgba(255,255,255,0.18);
  box-shadow: 0 0 24px rgba(255,255,255,0.35);
  animation: pulse 0.8s ease-in-out infinite alternate;
}

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

@keyframes pulse {
  from { box-shadow: 0 0 16px rgba(255,255,255,0.25); }
  to   { box-shadow: 0 0 40px rgba(255,255,255,0.6); }
}

#scores {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}

.score .label { font-size: .75rem; font-weight: 700; opacity: .7; text-transform: uppercase; letter-spacing: 1px; }
.score .label.x { color: var(--x-color); }
.score .label.o { color: var(--o-color); }
.score span:last-child { font-size: 1.5rem; font-weight: 800; }

#reset {
  padding: .8rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7e57c2, #5e35b1);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(94,53,179,0.4);
  transition: transform .1s, box-shadow .2s;
}
#reset:active { transform: scale(0.95); box-shadow: 0 3px 10px rgba(94,53,179,0.4); }

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

main { position: relative; z-index: 1; }
