/* ============================================================
   Sudoku — Game Styles
   ============================================================ */

/* ── Layout ── */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* Header → see .game-header in global.css */

/* ── Difficulty Tabs ── */
.diff-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.diff-tab {
  padding: 0.28em 0.75em;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 200ms ease;
  white-space: nowrap;
}

.diff-tab:hover:not(.active) {
  color: var(--text);
}

.diff-tab.active[data-diff="easy"] {
  background: rgba(74, 222, 128, 0.18);
  color: var(--easy);
}

.diff-tab.active[data-diff="medium"] {
  background: rgba(251, 191, 36, 0.18);
  color: var(--medium);
}

.diff-tab.active[data-diff="hard"] {
  background: rgba(248, 113, 113, 0.18);
  color: var(--hard);
}

/* ── Stats Bar ── */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  max-width: 520px;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.stat-divider {
  width: 1px;
  height: 2rem;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Digit Font-Size Control Bar ── */
.fs-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  max-width: 520px;
  padding: 0.32rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.fs-bar-lbl {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  white-space: nowrap;
}

.fs-a-small {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.fs-a-large {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.fs-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  min-width: 0;
}
.fs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}
.fs-slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
}

.fs-size-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 46px;
  text-align: right;
  white-space: nowrap;
}

/* ── Game Container ── */
.game-container {
  width: 100%;
  max-width: 520px;
  padding: 0 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

/* ── Board ── */
.board-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 2.5px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  /* Responsive sizing: fill available width, keep square */
  width: min(100%, 468px);
  aspect-ratio: 1 / 1;
  background: var(--border-strong);
  gap: 1px;
  box-shadow: var(--shadow-md);
}

/* ── Cell ── */
.cell {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  font-size: var(--cell-fs, clamp(0.9rem, 3.8vmin, 1.35rem));
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  transition: background 100ms ease, color 100ms ease;
  -webkit-tap-highlight-color: transparent;
}

.cell:focus {
  outline: none;
}

/* Box border classes — right edge of box columns (col index 2, 5) */
.cell.box-right {
  border-right: 2px solid var(--border-strong);
}

/* Box border classes — bottom edge of box rows (row index 2, 5) */
.cell.box-bottom {
  border-bottom: 2px solid var(--border-strong);
}

/* Given (pre-filled) cells */
.cell.given {
  color: var(--text);
  font-weight: 700;
  cursor: default;
}

/* Selected cell */
.cell.selected {
  background: rgba(99, 102, 241, 0.28) !important;
  color: #fff !important;
}

.cell.selected.given {
  color: #fff !important;
}

/* Highlighted (same row/col/box) */
.cell.highlight {
  background: var(--surface-2);
}

/* Same number as selected */
.cell.same-num {
  background: rgba(129, 140, 248, 0.1);
}

/* Error cell */
.cell.error {
  color: var(--error) !important;
  background: rgba(248, 113, 113, 0.1) !important;
  animation: shake 300ms ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-3px); }
  40%       { transform: translateX(3px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(2px); }
}

/* Hint reveal animation */
.cell.hint-reveal {
  animation: hint-flash 500ms ease;
}

@keyframes hint-flash {
  0%   { background: rgba(251, 191, 36, 0.5); }
  100% { background: var(--surface); }
}

/* ── Notes grid inside cell ── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
}

.note-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.38rem, 1.25vmin, 0.55rem);
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
  visibility: hidden;
}

.note-num.visible {
  visibility: visible;
  color: var(--accent);
}

/* ── Action Row ── */
.action-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  justify-content: center;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.6rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.action-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.action-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.action-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.action-label {
  font-size: 0.72rem;
}

/* ── Numpad ── */
.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0.4rem;
  width: 100%;
}

.num-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1.15;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.num-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.num-btn:active:not(:disabled) {
  transform: scale(0.93);
}

.num-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Numpad digit tapped with no cell selected — highlights matching digits on board */
.num-btn.numpad-active {
  background: rgba(99, 102, 241, 0.14);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.22);
}
.num-btn.numpad-active .num-digit {
  color: var(--accent);
}

.num-btn .num-digit {
  font-size: var(--numpad-fs, clamp(0.85rem, 3.5vmin, 1.3rem));
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.num-btn .num-count {
  font-size: clamp(0.52rem, 1.5vmin, 0.65rem);
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 1px;
}

.num-btn:disabled .num-digit,
.num-btn:disabled .num-count {
  color: var(--text-dim);
}

/* ── Modals ── */
.modal-emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.modal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.modal-stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

.modal-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.modal-msg {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .diff-tab {
    padding: 0.25em 0.55em;
    font-size: 0.72rem;
  }

  .game-container {
    padding: 0 0.5rem;
    gap: 0.65rem;
  }

  .action-btn {
    padding: 0.5rem 0.25rem;
  }

  .numpad {
    gap: 0.3rem;
  }
}


/* ── Mistake error flash on stat ── */
.stat-value.flash-error {
  animation: stat-flash 400ms ease;
  color: var(--error);
}

@keyframes stat-flash {
  0%   { transform: scale(1.25); color: var(--error); }
  100% { transform: scale(1); }
}

/* ── Win sparkle ── */
@keyframes sparkle-in {
  0%   { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.modal-overlay.active .modal-emoji {
  animation: sparkle-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
