* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

body {
  background: #0C0D14;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #E0E0E0;
  padding: 12px 8px;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 460px;
}

/* ── Toolbar ─────────────────────────────────────── */
#toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
}

#difficulty {
  display: flex;
  gap: 4px;
}

.diff-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #aaa;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-btn:hover { background: rgba(255,255,255,0.1); color: #ddd; }
.diff-btn.active {
  background: rgba(79,195,247,0.15);
  border-color: #4FC3F7;
  color: #4FC3F7;
}

#new-game-btn {
  background: rgba(79,195,247,0.12);
  border: 1px solid rgba(79,195,247,0.3);
  color: #4FC3F7;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
#new-game-btn:hover { background: rgba(79,195,247,0.25); }

/* ── Header ──────────────────────────────────────── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #13141D;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 14px;
}

.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 10px; text-transform: uppercase; color: #666; letter-spacing: 0.5px; }
.stat-value { font-size: 16px; font-weight: 700; font-family: 'Courier New', monospace; color: #4FC3F7; }
#mistakes .stat-value, #header .stat:nth-child(2) .stat-value { color: #FF8A65; }

#notes-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #888;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
#notes-btn.active {
  background: rgba(174,213,129,0.15);
  border-color: #AED581;
  color: #AED581;
}

/* ── Grid ────────────────────────────────────────── */
#grid-container {
  width: 100%;
  aspect-ratio: 1;
  background: #1a1b26;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 0 30px rgba(79,195,247,0.05);
}

#grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  height: 100%;
  gap: 1px;
  background: rgba(255,255,255,0.04);
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #2A2B38;
  font-size: clamp(16px, 4.5vw, 26px);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.cell:hover { background: #333448; }

/* 3x3 box borders */
.cell.box-right { border-right: 2px solid rgba(255,255,255,0.2); }
.cell.box-bottom { border-bottom: 2px solid rgba(255,255,255,0.2); }

/* Cell states */
.cell.given { color: #E0E0E0; background: #252636; cursor: default; }
.cell.user-input { color: #4FC3F7; }
.cell.selected { background: #3D3E5A !important; }
.cell.highlighted { background: #2E2F45; }
.cell.same-number { background: #2A3A50; }
.cell.error { color: #FF5252 !important; animation: shake 0.3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Notes (pencil marks) */
.cell .notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0;
}
.cell .notes-grid span {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(7px, 1.5vw, 11px);
  font-weight: 400;
  color: #777;
  line-height: 1;
}

/* ── Numpad ───────────────────────────────────────── */
#numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
}

.num-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1E1F2E;
  border: 1px solid rgba(255,255,255,0.08);
  color: #ccc;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  padding: 12px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.num-btn:hover { background: #2A2B3D; }
.num-btn:active { transform: scale(0.94); }
.num-btn.erase-btn { font-size: clamp(12px, 2.5vw, 15px); color: #FF8A65; }
.num-btn.completed { opacity: 0.25; pointer-events: none; }

/* ── Overlay ─────────────────────────────────────── */
#overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(12, 13, 20, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}
#overlay.hidden { display: none; }

#overlay-content {
  background: #1a1b26;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  max-width: 320px;
}
#overlay-title {
  font-size: 28px;
  margin-bottom: 8px;
  color: #4FC3F7;
}
#overlay-message {
  color: #aaa;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}
#overlay-btn {
  background: #4FC3F7;
  color: #0C0D14;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
#overlay-btn:hover { background: #81D4FA; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 360px) {
  .diff-btn { padding: 5px 8px; font-size: 11px; }
  #new-game-btn { padding: 5px 10px; font-size: 11px; }
  .num-btn { padding: 10px 0; }
}
