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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
}

.container {
  width: 100%;
  max-width: 460px;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #0f172a;
  margin-bottom: 14px;
}

.difficulty-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.difficulty-btn {
  padding: 7px 15px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  outline: none;
}

.difficulty-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.difficulty-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.difficulty-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.timer {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #64748b;
}

.pause-btn {
  padding: 5px 12px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  outline: none;
}

.pause-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.pause-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.game-area {
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1;
  width: 100%;
  margin: 0 auto 18px;
  border: 2px solid #334155;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  user-select: none;
}

.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 500;
  cursor: pointer;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  transition: background-color 0.1s ease;
  position: relative;
}

.cell.col-0 { border-left: none; }
.cell.col-8 { border-right: none; }
.cell.row-0 { border-top: none; }
.cell.row-8 { border-bottom: none; }

.cell:hover {
  background-color: #f0f4ff;
}

.cell.selected {
  background-color: #dbeafe;
}

.cell.highlighted {
  background-color: #eff6ff;
}

.cell.given {
  font-weight: 700;
  color: #0f172a;
}

.cell:not(.given) {
  color: #2563eb;
}

.cell.error {
  color: #dc2626;
  background-color: #fef2f2;
}

.cell.thick-right {
  border-right: 2px solid #334155;
}

.cell.thick-bottom {
  border-bottom: 2px solid #334155;
}

.number-pad {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}

.number-btn {
  width: 38px;
  height: 38px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 8px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  outline: none;
}

.number-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

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

.number-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.number-btn.erase {
  width: 58px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  outline: none;
}

#checkBtn {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

#checkBtn:not(:disabled) {
  background: #16a34a;
  color: #fff;
  cursor: pointer;
}

#checkBtn:not(:disabled):hover {
  background: #15803d;
}

#checkBtn:not(:disabled):active {
  transform: scale(0.97);
}

#checkBtn:focus-visible {
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.4);
}

#resetBtn {
  background: #fff;
  color: #475569;
  border: 1.5px solid #cbd5e1;
}

#resetBtn:hover {
  background: #f1f5f9;
}

#resetBtn:active {
  transform: scale(0.97);
}

#resetBtn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

#newGameBtn {
  background: #3b82f6;
  color: #fff;
}

#newGameBtn:hover {
  background: #2563eb;
}

#newGameBtn:active {
  transform: scale(0.97);
}

#newGameBtn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.pause-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 16px;
  font-weight: 600;
}

.pause-icon {
  color: #64748b;
}

.message {
  text-align: center;
  margin-top: 14px;
  font-weight: 600;
  font-size: 15px;
  min-height: 24px;
  line-height: 24px;
  transition: color 0.2s ease;
}

.message.success {
  color: #16a34a;
}

.message.error {
  color: #dc2626;
}

@media (max-width: 400px) {
  body {
    padding: 12px 8px;
  }

  header h1 {
    font-size: 24px;
    margin-bottom: 10px;
  }

  .difficulty-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .number-btn {
    width: 33px;
    height: 33px;
    font-size: 15px;
  }

  .number-btn.erase {
    width: 52px;
    font-size: 12px;
  }

  .actions button {
    padding: 9px 14px;
    font-size: 13px;
  }
}
