* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at top, #1b2735, #090a0f);
  color: #f5f5f5;
  font-family: Arial, sans-serif;
  text-align: center;
  padding: 24px 12px 40px;
}

h1 {
  margin-bottom: 6px;
  letter-spacing: 1px;
  font-size: 1.7rem;
}

.tagline {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-bottom: 18px;
}

#game-wrapper {
  display: inline-block;
  padding: 18px 16px 24px;
  border-radius: 18px;
  background: rgba(10, 10, 22, 0.95);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 234, 255, 0.2);
  max-width: 420px;
  width: 100%;
}

/* Board area */
#board {
  width: min(80vw, 320px);
  height: min(80vw, 320px);
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
}

.cell {
  background: linear-gradient(145deg, #15161c, #10111a);
  color: #00eaff;
  font-size: clamp(2.5rem, 10vw, 3.5rem);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: 14px;
  user-select: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  box-shadow: 0 0 12px rgba(0, 234, 255, 0.09);
  text-shadow: 0 0 12px rgba(0, 234, 255, 0.45);
}

.cell:hover {
  background: #1c1d27;
  box-shadow: 0 0 16px rgba(0, 234, 255, 0.25);
  transform: translateY(-1px);
}

.cell.filled-x {
  color: #00eaff;
  text-shadow: 0 0 18px rgba(0, 234, 255, 0.9);
}

.cell.filled-o {
  color: #ff4d9a;
  text-shadow: 0 0 18px rgba(255, 77, 154, 0.9);
}

.cell.placed {
  animation: pop-in 0.18s ease-out;
}

.cell.fade-out {
  animation: fade-out 0.2s ease-out;
}

.cell.win {
  box-shadow: 0 0 22px rgba(0, 255, 140, 0.9);
  background: radial-gradient(circle at center, #009f6b, #07160f);
}

/* Animations */
@keyframes pop-in {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }

  70% {
    transform: scale(1.08);
    opacity: 1;
  }

  100% {
    transform: scale(1);
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(0.75);
  }
}

#status {
  font-size: 0.85rem;
  margin-bottom: 10px;
  opacity: 0.95;
}

#scoreboard {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.8rem;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

#scoreboard div {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

/* Mode buttons */
#modes {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 6px 16px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 234, 255, 0.4);
  background: transparent;
  color: #00eaff;
  cursor: pointer;
  transition: 0.12s ease;
}

.mode-btn:hover {
  background: rgba(0, 234, 255, 0.1);
}

.mode-btn.active {
  background: linear-gradient(135deg, #00eaff, #00bcd4);
  color: #000;
  border: none;
  box-shadow: 0 6px 16px rgba(0, 234, 255, 0.35);
}

/* Controls */
#controls {
  margin-top: 4px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  padding: 8px 18px;
  background: linear-gradient(135deg, #00eaff, #00bcd4);
  border: none;
  color: #000;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: .3px;
  box-shadow: 0 6px 16px rgba(0, 234, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 22px rgba(0, 234, 255, 0.5);
}

button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 12px rgba(0, 234, 255, 0.3);
}

button.secondary {
  background: transparent;
  color: #00eaff;
  border: 1px solid rgba(0, 234, 255, 0.4);
  box-shadow: none;
}

button.secondary:hover {
  background: rgba(0, 234, 255, 0.08);
  box-shadow: 0 6px 16px rgba(0, 234, 255, 0.25);
}

/* Extra small devices tweaks */
@media (max-width: 360px) {
  #game-wrapper {
    padding: 16px 10px 20px;
  }

  #board {
    gap: 4px;
  }
}

.flash-remove {
  animation: flashRemove 0.8s infinite;
}

@keyframes flashRemove {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 red;
  }

  50% {
    opacity: 0.3;
    box-shadow: 0 0 18px red;
  }

  100% {
    opacity: 1;
    box-shadow: 0 0 0 red;
  }
}
/* Win line */
#win-line {
  position: absolute;
  width: 0;
  height: 4px;
  background: linear-gradient(90deg, #00ffae, #00eaff);
  box-shadow: 0 0 12px rgba(0, 255, 174, 0.9);
  transform-origin: left center;
  transition: width 0.35s ease;
  border-radius: 4px;
  pointer-events: none;
}

#board-wrapper {
  position: relative;
  display: inline-block;
}