* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif;
}

:root {
  --bg1: #020617;
  --bg2: #0f172a;
  --card: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: #94a3b8;
  --cyan: #22d3ee;
  --pink: #ec4899;
  --green: #22c55e;
  --orange: #f97316;
  --border: rgba(255, 255, 255, 0.15);
}

body.light {
  --bg1: #e0f2fe;
  --bg2: #f8fafc;
  --card: rgba(255, 255, 255, 0.75);
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.15);
}

body {
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(-45deg, var(--bg1), var(--bg2), #1e3a8a, #0e7490);
  background-size: 400% 400%;
  animation: gradientMove 10s ease infinite;
  overflow-x: hidden;
}

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

.bg-orb {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  z-index: -1;
}

.orb-1 {
  background: var(--cyan);
  top: 8%;
  left: 8%;
}

.orb-2 {
  background: var(--pink);
  right: 8%;
  bottom: 8%;
}

.app {
  width: min(960px, 94%);
  margin: auto;
  padding: 40px 0;
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--cyan);
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(34px, 7vw, 70px);
  letter-spacing: 1px;
  text-shadow: 0 0 25px rgba(34, 211, 238, 0.6);
}

.subtitle {
  color: var(--muted);
  margin: 10px 0 25px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);

  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);

  border-radius: 28px;
  padding: 26px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
}

.controls {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.select-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 6px;
}

label {
  font-size: 13px;
  color: var(--muted);
}

select,
button {
  border: none;
  outline: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
}

select {
  background: rgba(255, 255, 255, 0.9);
  color: #020617;
  cursor: pointer;
}

.small-btn,
#restartBtn,
#playAgainBtn {
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  color: white;
  cursor: pointer;
  transition: 0.25s;
}

button:hover {
  transform: translateY(-2px) scale(1.03);
}

.players {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  color: var(--muted);
  margin-bottom: 18px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 18px;
}

.scoreboard div {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.scoreboard strong {
  display: block;
  font-size: 30px;
  color: var(--cyan);
}

.scoreboard span {
  font-size: 13px;
  color: var(--muted);
}

.status {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.ai-message {
  color: var(--muted);
  min-height: 24px;
  margin-bottom: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 120px));
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}

.cell {
  aspect-ratio: 1 / 1;
  font-size: clamp(42px, 8vw, 70px);
  font-weight: 900;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid rgba(34, 211, 238, 0.45);
  color: white;
  box-shadow: inset 0 0 20px rgba(34, 211, 238, 0.12);
  cursor: pointer;
  transition: 0.25s;
}

.cell:hover {
  border-color: var(--pink);
  box-shadow: 0 0 25px rgba(236, 72, 153, 0.45);
}

.cell.x {
  color: var(--green);
  text-shadow: 0 0 18px var(--green);
}

.cell.o {
  color: var(--orange);
  text-shadow: 0 0 18px var(--orange);
}

.cell.winner {
  animation: winnerGlow 0.75s infinite alternate;
}

@keyframes winnerGlow {
  from {
    transform: scale(1);
    box-shadow: 0 0 15px var(--cyan);
  }
  to {
    transform: scale(1.08);
    box-shadow: 0 0 35px var(--pink);
  }
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);

  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);

  border-radius: 26px;
  padding: 30px;
  text-align: center;
  color: var(--text);
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-card h2 {
  font-size: 34px;
  margin-bottom: 10px;
}

.modal-card p {
  color: var(--muted);
  margin-bottom: 20px;
}

.footer {
  margin-top: 22px;
  color: var(--muted);
  font-size: 14px;
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 800;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 10px;
}
@media (max-width: 768px) {
  .app {
    width: 94%;
    padding: 24px 0;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .select-group {
    width: 100%;
  }

  select,
  .small-btn {
    width: 100%;
  }

  .players {
    flex-direction: column;
    gap: 8px;
  }

  .scoreboard {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .board {
    grid-template-columns: repeat(3, minmax(72px, 1fr));
    gap: 10px;
  }

  .cell {
    width: 100%;
    max-width: 105px;
    margin: auto;
    font-size: 46px;
    border-radius: 16px;
  }

  .actions {
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }

  .modal-card {
    padding: 24px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 34px;
  }

  .subtitle {
    font-size: 14px;
  }

  .board {
    grid-template-columns: repeat(3, minmax(68px, 90px));
  }

  .cell {
    max-width: 90px;
    font-size: 40px;
  }

  .status {
    font-size: 20px;
  }

  .ai-message {
    font-size: 14px;
  }

  .footer {
    font-size: 13px;
  }
}