* {
  box-sizing: border-box;
}

:root {
  --bg: #070b14;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-strong: #121a2a;
  --panel-2: #182235;
  --text: #f8fafc;
  --muted: #9aa7bd;
  --line: rgba(148, 163, 184, 0.16);
  --accent: #60a5fa;
  --accent-2: #8b5cf6;
  --accent-3: #22d3ee;
  --active: #22324d;
  --won-x: rgba(96, 165, 250, 0.16);
  --won-o: rgba(139, 92, 246, 0.16);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.12), transparent 32%),
    linear-gradient(180deg, #05070d 0%, #09101c 35%, #060912 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.site-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: white;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  transition: color 0.18s ease;
}

.nav a:hover {
  color: white;
}

.nav-play-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white !important;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(96, 165, 250, 0.18);
}

.hero {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 42px;
  padding: 28px 0 40px;
}

.page-main {
  padding-top: 8px;
}

.page-hero.compact {
  max-width: 760px;
  margin-bottom: 28px;
}

.hero-badge,
.section-kicker,
.mode-tag {
  display: inline-block;
  color: var(--accent-3);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.18);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  margin-bottom: 16px;
}

.hero h1,
.game-headline h1,
.page-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.page-hero h1,
.game-headline h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.hero-text,
.section-heading p,
.feature-card p,
.step-card p,
.cta-card p,
.subtitle,
.mode-card p,
.lobby-card p,
.join-hint {
  color: var(--muted);
  line-height: 1.7;
}

.hero-text {
  max-width: 640px;
  font-size: 1.06rem;
}

.hero-text.narrow {
  max-width: 720px;
}

.hero-actions,
.game-actions,
.stack-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.primary-btn,
.secondary-btn,
.button-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.16s ease, opacity 0.16s ease, border-color 0.16s ease;
  cursor: pointer;
}

.primary-btn:hover,
.secondary-btn:hover,
.button-reset:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  padding: 14px 20px;
  border: none;
}

.secondary-btn {
  padding: 14px 20px;
  border: 1px solid var(--line);
  color: white;
  background: rgba(255, 255, 255, 0.02);
}

.small-btn {
  padding: 12px 16px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.stat-card,
.info-card,
.step-card,
.feature-card,
.mode-card,
.lobby-card {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.stat-card {
  border-radius: 18px;
  padding: 18px;
}

.stat-label,
.label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat-value,
.value {
  font-size: 1.08rem;
  font-weight: 800;
}

.hero-visual {
  display: flex;
  justify-content: center;
}

.preview-board {
  width: min(90vw, 500px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px;
  border-radius: 30px;
  background: rgba(14, 21, 36, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.preview-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 8px;
  border-radius: 18px;
  background: #121b2d;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.preview-mini.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.2);
}

.preview-mini.won-x {
  background: rgba(96, 165, 250, 0.12);
}

.preview-mini.won-o {
  background: rgba(139, 92, 246, 0.14);
}

.preview-mini span {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0c1322;
  font-weight: 800;
  color: white;
  font-size: 1rem;
}

.content-section {
  padding: 72px 0 18px;
}

.content-section.slim {
  padding-top: 48px;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 26px;
}

.section-heading h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.steps-grid,
.feature-grid,
.mode-grid,
.lobby-grid {
  display: grid;
  gap: 18px;
}

.steps-grid,
.feature-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lobby-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.step-card,
.feature-card,
.mode-card,
.lobby-card {
  border-radius: 22px;
  padding: 24px;
}

.mode-card.featured {
  border-color: rgba(96, 165, 250, 0.35);
}

.disabled-card {
  opacity: 0.8;
}

.disabled-pill {
  display: inline-block;
  margin-top: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--line);
}

.mode-list {
  margin: 18px 0 22px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.step-number {
  display: inline-block;
  color: var(--accent-3);
  font-weight: 800;
  margin-bottom: 14px;
}

.step-card h3,
.feature-card h3,
.mode-card h2,
.lobby-card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.cta-section {
  padding: 72px 0 0;
}

.cta-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.14), rgba(139, 92, 246, 0.16));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.cta-card h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.room-code-box {
  margin: 20px 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.room-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.room-code {
  display: block;
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.input-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
}

.room-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: white;
}

.join-hint {
  display: inline-block;
  margin-top: 6px;
}

.game-layout {
  padding-top: 8px;
}

.game-headline {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
}

.info-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.info-panel.four-cols {
  grid-template-columns: repeat(4, 1fr);
}

.info-card {
  border-radius: 18px;
  padding: 18px;
}

.game-board-section {
  display: flex;
  justify-content: center;
}

.ultimate-board {
  width: min(92vw, 780px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  background: rgba(14, 21, 36, 0.86);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.mini-board {
  background: var(--panel-2);
  border: 2px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  position: relative;
  transition: 0.18s ease;
}

.mini-board.active {
  border-color: var(--accent);
  background: var(--active);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.12);
}

.mini-board.won-x {
  background: var(--won-x);
  border-color: rgba(96, 165, 250, 0.5);
}

.mini-board.won-o {
  background: var(--won-o);
  border-color: rgba(139, 92, 246, 0.52);
}

.mini-board.drawn {
  opacity: 0.78;
}

.cell {
  border: none;
  border-radius: 10px;
  background: #0b1220;
  color: white;
  font-size: clamp(1.2rem, 2vw, 2rem);
  font-weight: 800;
  cursor: pointer;
  transition: 0.15s ease;
}

.cell:hover:enabled {
  background: #111a2d;
  transform: scale(1.03);
}

.cell:disabled {
  cursor: not-allowed;
}

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

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

.board-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  border-radius: 16px;
  pointer-events: none;
}

.board-overlay.x {
  color: var(--accent);
  background: rgba(7, 11, 20, 0.2);
}

.board-overlay.o {
  color: var(--accent-2);
  background: rgba(7, 11, 20, 0.2);
}

.board-overlay.draw {
  color: #d2d9e5;
  background: rgba(7, 11, 20, 0.16);
  font-size: clamp(1rem, 2vw, 1.4rem);
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 10px;
  }

  .cta-card,
  .game-headline,
  .lobby-grid,
  .mode-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .lobby-grid {
    display: grid;
  }
}

@media (max-width: 720px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav,
  .hero-stats,
  .info-panel,
  .steps-grid,
  .feature-grid,
  .mode-grid,
  .lobby-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .preview-board,
  .ultimate-board {
    width: 100%;
  }

  .site-shell {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.mini-board.active-board {
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow:
    0 0 0 2px rgba(96, 165, 250, 0.22),
    0 0 22px rgba(96, 165, 250, 0.18);
  background: linear-gradient(180deg, rgba(26, 40, 66, 0.96), rgba(18, 30, 49, 0.96));
}

.cell.playable-cell {
  border: 1px solid rgba(96, 165, 250, 0.5);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.18);
  background: linear-gradient(180deg, rgba(15, 24, 40, 0.98), rgba(11, 19, 31, 0.98));
}

.cell.playable-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.75);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.22),
    0 0 14px rgba(34, 211, 238, 0.16);
}

.mini-board.won-x {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.45);
}

.mini-board.won-o {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.45);
}

.mini-board.draw-board {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.35);
}

.mini-board {
  overflow: hidden;
}

.mini-board-winner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.25);
}

.mini-board-winner.show {
  opacity: 1;
  transform: scale(1);
}

.mini-board-winner.winner-x {
  color: rgba(96, 165, 250, 0.95);
}

.mini-board-winner.winner-o {
  color: rgba(216, 180, 254, 0.95);
}

.mini-board-winner.winner-draw {
  color: rgba(226, 232, 240, 0.9);
}

.mini-board .cell {
  position: relative;
  z-index: 1;
}