*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Sora', system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 0%, #1a2a4a 0%, #0c1018 55%, #060810 100%);
  color: #e8e8f0;
}

#scale-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-stage {
  transform-origin: center center;
  will-change: transform;
}

#game-root {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
  padding: 1rem;
  flex-shrink: 0;
}

.panel {
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex-shrink: 0;
}

.panel h1 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #38bdf8, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.6rem 0.7rem;
}

.stat-block.small { flex: 1; }

.stat-row {
  display: flex;
  gap: 0.5rem;
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.accent { color: #38bdf8; }

.stat-value.mistakes { color: #f87171; }

.difficulty-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0.65rem;
  padding: 0.55rem;
}

.diff-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.45rem;
}

.diff-btns {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.diff-btn {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.diff-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
}

.diff-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #fff;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.btn {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8f0;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover { background: rgba(255, 255, 255, 0.1); }

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: rgba(167, 139, 250, 0.5);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.btn-wide {
  width: 100%;
}

.btn.notes-on {
  background: rgba(167, 139, 250, 0.25);
  border-color: #a78bfa;
  color: #e9d5ff;
}

.hint-btn {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
}

.controls-hint {
  font-size: 0.58rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.38);
}

.board-frame {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 1rem;
  padding: 0.85rem;
  box-shadow: 0 0 32px rgba(56, 189, 248, 0.12), inset 0 0 24px rgba(0, 0, 0, 0.4);
}

.board-wrap {
  position: relative;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 420px;
  height: 420px;
  background: #0f1520;
  border: 2px solid #38bdf8;
  border-radius: 0.35rem;
  overflow: hidden;
  user-select: none;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 700;
  cursor: pointer;
  background: #141c28;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.1s;
}

.cell.thick-right { border-right: 2px solid rgba(56, 189, 248, 0.55); }
.cell.thick-bottom { border-bottom: 2px solid rgba(56, 189, 248, 0.55); }
.cell.thick-left { border-left: 2px solid rgba(56, 189, 248, 0.55); }
.cell.thick-top { border-top: 2px solid rgba(56, 189, 248, 0.55); }

.cell.fixed {
  color: #38bdf8;
  background: #121a26;
  cursor: default;
}

.cell.user { color: #f8fafc; }

.cell.selected {
  background: rgba(56, 189, 248, 0.22);
  box-shadow: inset 0 0 0 2px #38bdf8;
}

.cell.peer {
  background: rgba(56, 189, 248, 0.08);
}

.cell.same-num {
  background: rgba(167, 139, 250, 0.18);
}

.cell.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.18);
}

.cell.hint-flash {
  animation: hintPulse 0.6s ease;
}

@keyframes hintPulse {
  0%, 100% { background: rgba(56, 189, 248, 0.22); }
  50% { background: rgba(167, 139, 250, 0.45); }
}

.notes {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}

.note {
  font-size: 0.42rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.num-btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e8e8f0;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}

.num-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
}

.num-btn:active { transform: scale(0.94); }

.num-btn.complete {
  opacity: 0.35;
  pointer-events: none;
}

.info-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.6rem 0.7rem;
  text-align: center;
}

.info-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
}

.info-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #a78bfa;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(6, 8, 16, 0.88);
  border-radius: 0.35rem;
  z-index: 10;
  padding: 1.5rem;
  text-align: center;
}

.overlay.hidden { display: none; }

.overlay h2 {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.overlay p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
}

@media (max-width: 720px) {
  #game-root {
    flex-direction: column;
    align-items: center;
  }

  .panel {
    width: 100%;
    max-width: 420px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .panel-left > * { flex: 1 1 45%; }
  .panel-right { flex-direction: row; flex-wrap: wrap; }
  .numpad { flex: 1; min-width: 180px; }
}