:root {
  --bg: #eef4ff;
  --surface: #ffffff;
  --surface-soft: #f4f7fd;
  --line: #d9e2f0;
  --text: #132238;
  --muted: #5f6d82;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --board: #1e40af;
  --board-dark: #1e3a8a;
  --slot: #1e3a8a;
  --x: #ef4444;
  --x-deep: #dc2626;
  --o: #f59e0b;
  --o-deep: #d97706;
}

* {
  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(29, 78, 216, 0.1), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(245, 158, 11, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, #f8fbff 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(29, 78, 216, 0.18);
  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;
  background: linear-gradient(180deg, #1f4ed8 0%, var(--board-dark) 100%);
}

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

.cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.14), rgba(15, 23, 42, 0.38) 68%, rgba(15, 23, 42, 0.5) 100%);
  box-shadow: inset 0 8px 18px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.cell:hover:not(:disabled),
.cell:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: inset 0 8px 18px rgba(15, 23, 42, 0.18), 0 10px 18px rgba(15, 23, 42, 0.12);
}

.cell:disabled {
  cursor: default;
}

.cell.is-x {
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.35), var(--x) 60%, var(--x-deep) 100%);
}

.cell.is-o {
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.35), #fcd34d 58%, var(--o) 100%);
}

.cell.is-win {
  box-shadow: inset 0 8px 18px rgba(15, 23, 42, 0.18), 0 0 0 3px rgba(255, 255, 255, 0.26);
}

.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: 50%;
  }

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