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

body {
  background: #202124;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  user-select: none;
  -webkit-user-select: none;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #5f6368;
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: #80868b;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 560px;
  padding: 0 4px;
}

.toolbar-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

#timer-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 64px;
}

#mistakes-display {
  font-size: 16px;
  font-weight: 600;
  color: #9aa0a6;
  font-variant-numeric: tabular-nums;
}

#mistakes-display .mistake-active {
  color: #e53935;
}

#new-game-btn {
  background: #3c4043;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #e8eaed;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#new-game-btn:hover {
  background: #5f6368;
}

#new-game-btn:active {
  transform: scale(0.95);
}

/* Difficulty */
#difficulty-bar {
  display: flex;
  gap: 6px;
  background: #292a2d;
  padding: 4px;
  border-radius: 12px;
}

.diff-btn {
  padding: 8px 22px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #9aa0a6;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.diff-btn:hover {
  color: #e8eaed;
}

.diff-btn.active {
  background: #5c6bc0;
  color: #fff;
}

/* Board */
#board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(560px, calc(100vw - 40px));
  height: min(560px, calc(100vw - 40px));
  background: #5f6368;
  gap: 1px;
  padding: 1px;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
  background: #303134;
  border: none;
  outline: none;
  color: #e8eaed;
  transition: background 0.1s;
  position: relative;
  padding: 0;
}

/* Thicker borders at 3x3 box boundaries */
.cell.border-right { border-right: 2px solid #5c6bc0; }
.cell.border-bottom { border-bottom: 2px solid #5c6bc0; }

.cell:hover {
  background: #3c4043;
}

.cell.selected {
  background: #3d4570;
}

.cell.highlighted {
  background: #35373b;
}

.cell.same-number {
  background: #3d4570;
}

.cell.given {
  color: #e8eaed;
}

.cell.filled {
  color: #8ab4f8;
}

.cell.error {
  color: #e53935;
  background: rgba(229, 57, 53, 0.15);
}

.cell.error.selected {
  background: rgba(229, 57, 53, 0.25);
}

/* Notes (pencil marks) */
.cell .notes {
  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 span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #8ab4f8;
  opacity: 0.7;
}

/* Numpad */
#numpad {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.num-btn {
  width: 54px;
  height: 58px;
  border: none;
  border-radius: 8px;
  background: #3c4043;
  color: #e8eaed;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.num-btn:hover {
  background: #5f6368;
}

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

.num-btn.completed {
  opacity: 0.25;
  pointer-events: none;
}

/* Actions bar */
#actions-bar {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #9aa0a6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.action-btn:hover {
  background: #3c4043;
  color: #e8eaed;
}

.action-btn.active {
  color: #5c6bc0;
}

.action-btn.active svg path {
  fill: #5c6bc0;
}

#hint-text {
  font-size: 13px;
  color: #5f6368;
  margin-top: 4px;
}

/* Win overlay */
#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

#win-overlay .win-box {
  background: #303134;
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#win-overlay h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: #5c6bc0;
}

#win-overlay p {
  font-size: 16px;
  color: #9aa0a6;
  margin-bottom: 20px;
}

#win-overlay button {
  background: #5c6bc0;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

#win-overlay button:hover {
  background: #7986cb;
}

@media (max-width: 480px) {
  .cell {
    font-size: 18px;
  }

  .cell .notes span {
    font-size: 8px;
  }

  .num-btn {
    width: 34px;
    height: 44px;
    font-size: 18px;
  }

  .diff-btn {
    padding: 6px 16px;
    font-size: 13px;
  }

  .action-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}
