* {
  box-sizing: border-box;
}

:root {
  --bg: #eef3ff;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --primary: #315efb;
  --primary-dark: #244bd0;
  --line: #cbd5e1;
  --line-dark: #1f2937;
  --fixed: #f1f5f9;
  --selected: #dbeafe;
  --same: #eef6ff;
  --wrong: #fee2e2;
  --right: #dcfce7;
  --shadow: 0 20px 45px rgba(49, 94, 251, 0.12);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(49, 94, 251, 0.18), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(255, 171, 64, 0.20), transparent 25%),
    var(--bg);
}

.app {
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 34px 0 50px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1;
}

.subtitle {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.stats {
  display: flex;
  gap: 12px;
}

.stats > div,
.toolbar,
.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stats > div {
  min-width: 96px;
  padding: 14px 18px;
  text-align: center;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 22px;
}

label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
}

select,
button {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 15px;
}

select {
  background: #f8fafc;
  border: 1px solid var(--line);
}

button {
  color: white;
  background: var(--primary);
  cursor: pointer;
  font-weight: 700;
  transition: 0.18s ease;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button.secondary {
  width: 100%;
  color: var(--primary);
  background: #eef2ff;
}

.game-area {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(250px, 1fr);
  gap: 24px;
  align-items: start;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(92vw, 560px);
  aspect-ratio: 1 / 1;
  background: var(--line-dark);
  border: 3px solid var(--line-dark);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  color: var(--primary);
  font-size: clamp(18px, 4.8vw, 34px);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.cell.fixed {
  background: var(--fixed);
  color: var(--text);
  cursor: default;
}

.cell.selected {
  background: var(--selected);
}

.cell.same-number {
  background: var(--same);
}

.cell.wrong {
  background: var(--wrong);
}

.cell.correct {
  background: var(--right);
}

.cell:nth-child(3n) {
  border-right: 3px solid var(--line-dark);
}

.cell:nth-child(9n) {
  border-right: 0;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 3px solid var(--line-dark);
}

.panel {
  padding: 20px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.number-pad button {
  min-height: 56px;
  font-size: 22px;
}

.message {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 820px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-area {
    grid-template-columns: 1fr;
  }

  .panel {
    width: min(92vw, 560px);
  }
}
