:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3fb;
  --line: #d9e2f0;
  --text: #122033;
  --muted: #5d6b80;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --x: #0f766e;
  --o: #b45309;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(16, 185, 129, 0.08), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, #f8fafc 100%);
}

button,
select {
  font: inherit;
}

.shell {
  width: min(1040px, calc(100% - 20px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  box-shadow: var(--shadow);
}

.hero {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.lede {
  max-width: 44rem;
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.8;
}

.hero-meta {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.game-card {
  margin-top: 16px;
  padding: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: end;
}

.toolbar-group {
  display: grid;
  gap: 8px;
}

.toolbar-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.mode-btn {
  border: 0;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.mode-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.difficulty-select {
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

.primary-btn {
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

.status-card {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.status-line {
  font-size: 1.08rem;
  font-weight: 700;
}

.support-line,
.level-note,
.info-panel li {
  color: var(--muted);
  line-height: 1.6;
}

.playfield {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.board-panel,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.board-panel {
  padding: 14px;
}

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

.cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, rgba(219, 234, 254, 0.45) 100%);
  color: var(--text);
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.cell:hover:not(:disabled),
.cell:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.06);
}

.cell:disabled {
  cursor: default;
}

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

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

.cell.is-win {
  border-color: rgba(37, 99, 235, 0.4);
  background: linear-gradient(180deg, #f8fbff 0%, rgba(219, 234, 254, 0.8) 100%);
}

.info-panel {
  padding: 16px;
}

.info-panel h2 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.info-panel ul {
  margin: 0 0 14px 18px;
  padding: 0;
}

.level-note {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

@media (max-width: 820px) {
  .hero-top {
    display: grid;
  }

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

  .toolbar-group,
  .primary-btn,
  .difficulty-select {
    width: 100%;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-btn {
    flex: 1 1 0;
  }

  .hero-meta {
    justify-items: start;
  }

  .playfield {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 14px, 1040px);
    padding: 12px 0 24px;
  }

  .hero,
  .game-card {
    padding: 16px;
    border-radius: 18px;
  }

  .board-panel {
    padding: 12px;
  }

  .board {
    gap: 8px;
  }

  .cell {
    border-radius: 16px;
    font-size: clamp(2rem, 15vw, 3.2rem);
  }

  .difficulty-select {
    min-width: 100%;
  }
}
