:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5e6975;
  --line: #d7dde4;
  --panel: #ffffff;
  --page: #f4f6f2;
  --accent: #087f8c;
  --accent-strong: #075f68;
  --x: #d94343;
  --o: #1e67c6;
  --win: #f2c94c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(8, 127, 140, 0.16), transparent 36%),
    linear-gradient(315deg, rgba(242, 201, 76, 0.24), transparent 40%),
    var(--page);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-shell {
  width: min(100%, 520px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(23, 33, 43, 0.1);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.14);
  padding: clamp(18px, 4vw, 28px);
}

.game-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.icon-button,
.new-game,
.cell {
  border: 0;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 1.35rem;
  line-height: 1;
}

.controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
}

.mark-picker {
  display: grid;
  grid-template-columns: repeat(2, 54px);
  gap: 8px;
  padding: 0;
  margin: 0;
  border: 0;
}

.mark-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.mark-picker label {
  position: relative;
}

.mark-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.mark-picker span {
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 1.35rem;
  font-weight: 900;
}

.mark-picker input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.mark-picker input:focus-visible + span,
.new-game:focus-visible,
.icon-button:focus-visible,
.cell:focus-visible {
  outline: 3px solid rgba(8, 127, 140, 0.35);
  outline-offset: 3px;
}

.new-game {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.new-game:hover,
.icon-button:hover {
  filter: brightness(0.94);
}

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

.scoreboard div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  text-align: center;
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.scoreboard strong {
  display: block;
  margin-top: 2px;
  font-size: 1.45rem;
}

.status {
  min-height: 28px;
  margin: 18px 0 12px;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

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

.cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #eef1f5;
  color: var(--ink);
  font-size: clamp(2.5rem, 18vw, 5.5rem);
  font-weight: 950;
  line-height: 1;
  transition: transform 140ms ease, background 140ms ease;
}

.cell:not(:disabled):hover {
  transform: translateY(-2px);
  background: #e1e8ee;
}

.cell:disabled {
  cursor: default;
}

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

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

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

@media (max-width: 420px) {
  .app {
    padding: 14px;
  }

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

  .mark-picker {
    grid-template-columns: repeat(2, 1fr);
  }

  .new-game {
    width: 100%;
  }
}
