:root {
  color-scheme: light dark;
  --bg: #0e0f13;
  --fg: #f5f5f5;
  --muted: #9aa0a6;
  --card: #1a1c23;
  --border: #2a2d36;
  --accent: #ffd166;
  --x-color: #4cc9f0;
  --o-color: #f72585;
  --win: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

main {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

h1 {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  margin: 0;
  letter-spacing: -0.02em;
}

.mode {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.mode-btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn:hover { color: var(--fg); }

.mode-btn.active {
  background: var(--accent);
  color: #111;
  font-weight: 600;
}

.status {
  min-height: 1.5rem;
  font-size: 1.05rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.status.win  { color: var(--accent); font-weight: 600; }
.status.draw { color: var(--fg); }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.5rem;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
}

.cell {
  font: inherit;
  font-size: clamp(2.5rem, 14vw, 4rem);
  font-weight: 700;
  line-height: 1;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.08s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 80px;
}

.cell:hover:not(:disabled) {
  background: #16181f;
  border-color: var(--accent);
}

.cell:active:not(:disabled) { transform: scale(0.97); }

.cell:disabled { cursor: default; }

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

.cell.mark {
  animation: pop 0.18s ease;
}

.cell.win {
  background: var(--win);
  color: #111 !important;
  border-color: var(--win);
  animation: none;
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0.2; }
  to   { transform: scale(1);   opacity: 1; }
}

.reset-btn {
  font: inherit;
  padding: 0.7rem 1.4rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reset-btn:hover {
  background: var(--card);
  border-color: var(--accent);
}

footer {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}
