:root {
  color-scheme: dark;
  --bg: #020202;
  --ink: #f5f3ee;
  --line: rgba(255, 255, 255, 0.86);
  --muted: rgba(245, 243, 238, 0.72);
  --accent: #d0aa68;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  --cell: min(16vw, 86px);
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(208, 170, 104, 0.12), transparent 28%),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.06), transparent 22%),
    linear-gradient(180deg, #0d0d0d 0%, var(--bg) 58%, #000 100%);
  color: var(--ink);
  font-family: inherit;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
}

.home-screen {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.home-blur-stage {
  position: absolute;
  inset: 0;
  filter: blur(18px);
  opacity: 0.72;
  transform: scale(1.04);
  pointer-events: none;
}

.preview-title {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.2rem, 1.7vw, 1.6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.preview-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.preview-hud strong {
  font-size: 1.9rem;
  color: var(--ink);
  letter-spacing: 0;
}

.preview-controls {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
}

.preview-pill,
.preview-dot {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  color: var(--ink);
}

.preview-pill {
  padding: 10px 16px;
  font-size: 0.78rem;
}

.preview-dot {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.preview-board {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -54%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 92px));
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
}

.preview-board span {
  width: 92px;
  height: 92px;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  font-weight: 700;
}

.preview-footer {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.95rem;
}

.home-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.home-title {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.home-subtitle {
  margin: 18px 0 34px;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  letter-spacing: 0.02em;
}

.mode-grid {
  display: grid;
  gap: 14px;
}

.mode-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.mode-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: white;
  padding: 14px 24px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 148px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.86rem;
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease;
}

.mode-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  border-color: rgba(255, 255, 255, 0.28);
}

.mode-button.normal {
  background: linear-gradient(135deg, rgba(39, 92, 178, 0.94), rgba(58, 139, 240, 0.94));
}

.mode-button.hard {
  background: linear-gradient(135deg, rgba(158, 45, 45, 0.94), rgba(222, 72, 72, 0.94));
}

.mode-button.neutral {
  background: rgba(255, 255, 255, 0.08);
}

.mode-button.wide {
  min-width: 220px;
}

.game-screen {
  position: relative;
}

.game-title {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  margin: 0;
  font-size: clamp(1.25rem, 1.8vw, 1.7rem);
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
}

.hud {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 9;
  min-width: 120px;
}

.score-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
}

.score-value,
.best-score-value {
  margin: 4px 0 0;
  font-size: 1.7rem;
  line-height: 1;
  font-weight: 700;
}

.best-label {
  margin-top: 12px;
}

.app-shell {
  width: min(1000px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 90px 0 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ghost-button,
.icon-button,
.modal-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.icon-button,
.ghost-button {
  position: fixed;
  top: 18px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.ghost-button {
  right: 68px;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  text-transform: none;
  display: grid;
  place-items: center;
}

#info-btn {
  right: 192px;
}

.leave-button {
  right: 18px;
}

.ghost-button:hover,
.icon-button:hover,
.modal-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-frame {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 12px 0 10px;
}

.board {
  display: grid;
  gap: 0;
  justify-content: center;
  width: max-content;
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
  position: relative;
  transition: transform 260ms ease, filter 260ms ease;
}

.board.expanding {
  animation: board-expand-pulse 620ms ease;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.cell.new-cell {
  animation: cell-materialize 560ms ease;
}

.cell.highlighted-line {
  background: rgba(208, 170, 104, 0.22);
  box-shadow: inset 0 0 28px rgba(208, 170, 104, 0.18);
}

.cell:not([disabled]):hover {
  background: rgba(255, 255, 255, 0.045);
}

.cell[disabled] {
  cursor: default;
  opacity: 1;
}

.cell.bot-thinking {
  cursor: wait;
}

.turn-status {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}

.expansion-picker {
  margin-top: 18px;
  text-align: center;
}

.expansion-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.expansion-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.expansion-button {
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(58, 139, 240, 0.14);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.expansion-button:hover {
  transform: translateY(-1px);
  background: rgba(58, 139, 240, 0.24);
  border-color: rgba(255, 255, 255, 0.26);
}

.rules {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 24px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.96) 42%);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.modal-card {
  width: min(440px, 100%);
  border-radius: 28px;
  padding: 28px 28px 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at top, rgba(208, 170, 104, 0.18), transparent 45%),
    rgba(14, 14, 14, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.modal-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

.modal-card h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1;
}

.modal-copy {
  margin: 14px 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-button {
  padding: 12px 20px;
  border-radius: 999px;
  min-width: 150px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}

.info-card {
  max-width: 420px;
}

@keyframes board-expand-pulse {
  0% {
    transform: scale(0.96);
    filter: brightness(0.9);
  }

  45% {
    transform: scale(1.03);
    filter: brightness(1.16);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes cell-materialize {
  0% {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.12);
  }

  100% {
    background: transparent;
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0);
  }
}

@media (max-width: 640px) {
  .home-title {
    font-size: clamp(1.9rem, 9vw, 3rem);
  }

  .home-subtitle {
    margin-bottom: 26px;
    padding: 0 18px;
  }

  .mode-button {
    min-width: 132px;
    padding: 13px 18px;
  }

  .mode-button.wide {
    min-width: 200px;
  }

  .game-title {
    top: 16px;
    width: calc(100vw - 170px);
  }

  .hud {
    top: 16px;
    left: 12px;
    min-width: 84px;
  }

  .score-value,
  .best-score-value {
    font-size: 1.2rem;
  }

  .app-shell {
    width: min(100vw - 20px, 980px);
    padding-top: 90px;
    justify-content: center;
  }

  .icon-button,
  .ghost-button {
    top: 12px;
    padding: 9px 13px;
  }

  .ghost-button {
    right: 56px;
  }

  #info-btn {
    right: 154px;
  }

  .leave-button {
    right: 12px;
    width: 36px;
    height: 36px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    padding: 0;
  }

  .rules {
    font-size: 0.88rem;
  }
}
