/* Layout and theme. Colors are defined as variables so they are easy to adjust. */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --x: #38bdf8;
  --o: #f472b6;
  --win: #22c55e;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
}

* {
  box-sizing: border-box;
}

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

.container {
  width: min(92vw, 360px);
  text-align: center;
  padding: 24px;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.status {
  min-height: 1.5em;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* 3x3 grid. Gaps show the background, which forms the board lines. */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  aspect-ratio: 1;
  margin-bottom: 20px;
}

.cell {
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

/* Hover and press effects only apply to empty, playable cells */
.cell:not(.X):not(.O):not(:disabled):hover {
  background: #273449;
}

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

.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: rgba(34, 197, 94, 0.18);
  border-color: var(--win);
  color: var(--win);
}

/* Scoreboard */
.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
}

.score {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 6px;
  background: var(--panel);
  border-radius: 10px;
}

.score .label {
  font-size: 0.8rem;
  color: var(--muted);
}

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

/* Buttons */
.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--panel);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

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