:root {
  color-scheme: dark;
  --bg: #080a12;
  --panel: rgba(17, 22, 37, 0.78);
  --panel-strong: rgba(24, 31, 52, 0.94);
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(226, 232, 240, 0.62);
  --text: #f8fafc;
  --muted: #9ca3af;
  --accent: #22d3ee;
  --accent-2: #a78bfa;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --cell: rgba(15, 23, 42, 0.86);
  --cell-given: rgba(30, 41, 59, 0.96);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  font-family:
    "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(34, 211, 238, 0.18), transparent 28rem),
    radial-gradient(circle at 90% 0%, rgba(167, 139, 250, 0.16), transparent 26rem),
    linear-gradient(135deg, #070914 0%, #0d1224 52%, #050711 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  filter: blur(44px);
  opacity: 0.38;
}

.page-glow-a {
  left: -8rem;
  top: 14rem;
  background: rgba(34, 211, 238, 0.35);
}

.page-glow-b {
  right: -6rem;
  bottom: 6rem;
  background: rgba(168, 85, 247, 0.28);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

.glass-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.site-header,
.game-topbar,
.section-heading,
.result-actions,
.action-row,
.score-form-row {
  display: flex;
  align-items: center;
}

.site-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(167, 139, 250, 0.18));
  color: #e0faff;
  font-weight: 900;
}

.eyebrow {
  display: block;
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.api-pill {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.7);
  font-size: 13px;
}

.api-pill.is-online {
  color: var(--good);
  border-color: rgba(52, 211, 153, 0.35);
}

.api-pill.is-offline {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: clamp(24px, 5vw, 46px);
  border-radius: 32px;
}

.hero-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(36px, 7vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.hero-copy p:not(.eyebrow) {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.hero-stat {
  min-width: 180px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(8, 13, 28, 0.68);
}

.hero-stat span,
.hero-stat small,
.stats-grid span,
.result-stats span {
  color: var(--muted);
  font-size: 12px;
}

.hero-stat strong {
  display: block;
  margin: 8px 0;
  color: var(--accent);
  font-size: 34px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.mode-card {
  display: flex;
  min-height: 210px;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border-radius: 28px;
  cursor: pointer;
  text-align: left;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  border-color: rgba(34, 211, 238, 0.52);
  background: rgba(21, 30, 52, 0.9);
  transform: translateY(-3px);
  outline: none;
}

.mode-kicker {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.mode-card strong {
  font-size: 28px;
}

.mode-card span:not(.mode-kicker) {
  color: var(--muted);
  line-height: 1.65;
}

.mode-card em {
  margin-top: auto;
  color: var(--good);
  font-style: normal;
}

.leaderboard-section {
  padding: 24px;
  border-radius: 28px;
}

.section-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading h2,
.control-panel h2 {
  margin: 0;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 13, 28, 0.7);
}

.leaderboard-tab {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.leaderboard-tab.is-active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(167, 139, 250, 0.2));
  color: var(--text);
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 28, 0.52);
}

.leaderboard-rank {
  color: var(--accent);
  font-weight: 900;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-meta {
  color: var(--muted);
  font-size: 13px;
}

.muted-state,
.control-hint,
.rule-card p,
.submit-status {
  color: var(--muted);
  line-height: 1.65;
}

.muted-state {
  margin: 14px 0 0;
}

.game-topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.game-topbar h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 18px;
  cursor: pointer;
}

.ghost-button,
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.72);
}

.ghost-button.danger {
  color: var(--warn);
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, #22d3ee, #a78bfa);
  color: #06111f;
  font-weight: 900;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 18px;
  align-items: start;
}

.board-panel,
.control-panel {
  padding: clamp(16px, 3vw, 24px);
  border-radius: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid div,
.result-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 28, 0.58);
}

.stats-grid strong,
.result-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.status-banner {
  min-height: 46px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 16px;
  background: rgba(8, 145, 178, 0.11);
  color: #dffaff;
}

.status-banner.is-error {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(127, 29, 29, 0.26);
  color: #ffe4e6;
}

.status-banner.is-good {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(6, 78, 59, 0.24);
  color: #dcfce7;
}

.sudoku-board {
  display: grid;
  width: min(100%, 650px);
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid var(--line-strong);
  border-radius: 18px;
  background: var(--line-strong);
  touch-action: manipulation;
}

.sudoku-board.size-6 {
  width: min(100%, 520px);
}

.cell {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--cell);
  color: #e2e8f0;
  cursor: pointer;
  font-size: clamp(18px, 5.5vw, 34px);
  font-weight: 800;
}

.size-6 .cell {
  font-size: clamp(22px, 7vw, 38px);
}

.cell.wall-right {
  border-right: 2px solid var(--line-strong);
}

.cell.wall-bottom {
  border-bottom: 2px solid var(--line-strong);
}

.cell.given {
  background: var(--cell-given);
  color: #f8fafc;
}

.cell.selected {
  background: rgba(34, 211, 238, 0.24);
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.75);
}

.cell.peer {
  background: rgba(30, 41, 59, 0.82);
}

.cell.same {
  color: #67e8f9;
}

.cell.wrong {
  background: rgba(127, 29, 29, 0.54);
  color: #fecdd3;
}

.cell.hinted {
  color: #fde68a;
}

.control-panel {
  display: grid;
  gap: 18px;
}

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

.num-button {
  min-height: 58px;
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 18px;
  background: rgba(8, 13, 28, 0.72);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
}

.num-button:hover,
.num-button:focus-visible,
.secondary-button:hover,
.ghost-button:hover {
  border-color: rgba(34, 211, 238, 0.58);
  outline: none;
}

.action-row {
  gap: 10px;
}

.action-row button {
  flex: 1;
}

.rule-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 13, 28, 0.54);
}

.rule-card strong {
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 23, 0.74);
  backdrop-filter: blur(12px);
}

.result-card {
  position: relative;
  width: min(640px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  padding: clamp(22px, 4vw, 34px);
  border-radius: 30px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  cursor: pointer;
}

.result-card h2 {
  margin: 0 0 10px;
  font-size: 34px;
}

.result-card p {
  margin-top: 0;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.score-form {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.score-form label {
  color: var(--muted);
  font-size: 13px;
}

.score-form-row {
  gap: 10px;
}

.score-form input {
  min-width: 0;
  flex: 1;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(8, 13, 28, 0.82);
  color: var(--text);
  outline: none;
}

.score-form input:focus {
  border-color: rgba(34, 211, 238, 0.58);
}

.submit-status.is-error {
  color: var(--bad);
}

.submit-status.is-success {
  color: var(--good);
}

.leaderboard-list.compact {
  margin: 14px 0;
}

.result-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.instructions-content {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 28, 0.58);
  color: var(--muted);
  line-height: 1.65;
}

.instruction-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(167, 139, 250, 0.2));
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 22px, 720px);
    padding-top: 14px;
  }

  .site-header,
  .section-heading,
  .game-topbar {
    align-items: flex-start;
  }

  .hero-panel,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero-stat {
    min-width: 0;
  }

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

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

  .control-panel {
    position: sticky;
    bottom: 0;
    z-index: 5;
    border-radius: 24px 24px 0 0;
  }

  .number-pad {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .num-button {
    min-height: 50px;
  }
}

@media (max-width: 560px) {
  .site-header,
  .section-heading,
  .score-form-row,
  .result-actions {
    flex-direction: column;
  }

  .api-pill,
  .leaderboard-tabs,
  .score-form-row > *,
  .result-actions > * {
    width: 100%;
  }

  .leaderboard-tabs {
    justify-content: stretch;
    border-radius: 18px;
  }

  .leaderboard-tab {
    flex: 1;
  }

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

  .stats-grid strong,
  .result-stats strong {
    font-size: 19px;
  }

  .leaderboard-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .leaderboard-meta {
    grid-column: 2;
  }
}
