/* Tic Tac Toe - styles
 * Light/dark via prefers-color-scheme, responsive board sized with CSS grid.
 */

:root {
  --bg: #f4f6fb;
  --fg: #1d2330;
  --muted: #5b6475;
  --cell: #ffffff;
  --line: #c9d1e0;
  --x: #2563eb;
  --o: #e11d48;
  --win: #bbf7d0;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --fg: #e6eaf2;
    --muted: #9aa4b8;
    --cell: #1a2132;
    --line: #2f3a52;
    --x: #60a5fa;
    --o: #fb7185;
    --win: #14532d;
    --accent: #60a5fa;
    --accent-fg: #0f1420;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.container {
  width: min(92vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 1.5rem 0;
}

h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
}

.status {
  margin: 0;
  min-height: 1.5em;
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 600;
}

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

.cell {
  appearance: none;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--cell);
  color: var(--fg);
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.cell:hover:not(:disabled) {
  transform: scale(1.03);
}

.cell:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cell:disabled {
  cursor: default;
}

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

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

.cell.win {
  background: var(--win);
}

.scores {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--cell);
}

.score .label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.score[data-player="X"] .label {
  color: var(--x);
}

.score[data-player="O"] .label {
  color: var(--o);
}

.controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .cell,
  .cell:hover:not(:disabled) {
    transition: none;
    transform: none;
  }
}
