:root {
  --bg-1: #0f1226;
  --bg-2: #191f43;
  --card: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.25);
  --text-main: #f8f9ff;
  --text-soft: #d8dbff;
  --x-color: #55e6c1;
  --o-color: #ff9ecf;
  --accent: #ffd166;
  --shadow: 0 20px 50px rgba(6, 9, 29, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Montserrat", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 10% 20%, #2f2e62 0%, transparent 40%),
    radial-gradient(circle at 85% 10%, #59336f 0%, transparent 35%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(35px);
  opacity: 0.4;
  z-index: -1;
}

.orb-1 {
  width: 250px;
  height: 250px;
  background: #4ef0c2;
  top: -80px;
  left: -80px;
}

.orb-2 {
  width: 280px;
  height: 280px;
  background: #ff8fc4;
  bottom: -90px;
  right: -90px;
}

.app {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.app-header {
  grid-column: span 2;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 1px;
  font-weight: 800;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-weight: 500;
}

.controls {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-buttons,
.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-mode {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-main);
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-mode.active {
  background: linear-gradient(135deg, #49eec2, #67b5ff);
  color: #0f1330;
  box-shadow: 0 10px 24px rgba(88, 215, 255, 0.28);
}

.btn-primary {
  background: var(--accent);
  color: #36260a;
  font-weight: 700;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.score-box {
  background: rgba(4, 7, 27, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.score-box .label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.score-box .value {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 800;
}

.status-wrap {
  padding: 14px;
  border-radius: 14px;
  background: rgba(4, 7, 27, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.status {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.game-panel {
  padding: 22px;
  display: grid;
  place-items: center;
}

.board {
  width: min(420px, 100%);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cell {
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 800;
  cursor: pointer;
  color: var(--text-main);
  transition: transform 0.18s ease, background 0.2s ease;
}

.cell:hover {
  transform: scale(1.03);
  background: rgba(255, 255, 255, 0.2);
}

.cell.x {
  color: var(--x-color);
  text-shadow: 0 0 18px rgba(85, 230, 193, 0.25);
}

.cell.o {
  color: var(--o-color);
  text-shadow: 0 0 18px rgba(255, 158, 207, 0.25);
}

.cell:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
  }

  .app-header {
    grid-column: span 1;
  }
}

@media (max-width: 460px) {
  body {
    padding: 14px;
  }

  .controls,
  .game-panel {
    padding: 16px;
  }
}
