/* phnx-sudoku styles
 *
 * Brand palette mirrors phnx2048 / games-set:
 *   Vivid Tangelo  #EE7526   Primary accent
 *   Mustard        #FBD652   Highlight (selection)
 *   Vermilion      #D74820   Hover/emphasis
 *   Persian Plum   #77161C   Borders, conflict text
 *   Rich Black     #030519   Body text strong
 *   Cream          #F5EEE5   User-entered cell bg
 *   Beige          #EFEDE9   Board interior
 *   Off-white      #F5F5F5   Soft surfaces
 *   Pastel Grey    #5C5C5C   Pencil notes
 *
 * Light theme default. No dark theme — daily puzzle reads cleaner on white.
 */

:root {
  --tangelo:     #EE7526;
  --mustard:     #FBD652;
  --vermilion:   #D74820;
  --plum:        #77161C;
  --rich-black:  #030519;
  --cream:       #F5EEE5;
  --beige:       #EFEDE9;
  --off-white:   #F5F5F5;
  --light-grey:  #F0F0F0;
  --pastel-grey: #5C5C5C;

  --bg:          #FFFFFF;
  --panel:       var(--off-white);
  --panel-2:     #FFFFFF;
  --border:      var(--plum);
  --fg:          var(--pastel-grey);
  --fg-strong:   var(--rich-black);
  --fg-muted:    #8A8A8A;
  --fg-faint:    #BFBFBF;
  --accent:      var(--tangelo);
  --accent-hover:var(--vermilion);
  --highlight:   var(--mustard);

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 6px 20px rgba(3, 5, 25, 0.06), 0 1px 2px rgba(3, 5, 25, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background:
    radial-gradient(1100px 500px at 20% -150px, rgba(238, 117, 38, 0.06) 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(251, 214, 82, 0.08) 0%, transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  min-height: 100dvh;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 14px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Header ---- */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fg-strong);
}
.title .accent { color: var(--accent); }
.subtitle {
  margin: 0;
  color: var(--fg-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stats {
  display: flex;
  gap: 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 64px;
}
.stat-label {
  color: var(--fg-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
}

/* ---- Controls ---- */
.controls {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.controls.bottom { justify-content: center; }

.btn {
  background: var(--panel-2);
  color: var(--fg-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}
.btn:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"],
.btn.active {
  background: var(--accent);
  color: #FFFFFF;
  border-color: transparent;
}
.btn[aria-pressed="true"]:hover,
.btn.active:hover { background: var(--accent-hover); color: #FFFFFF; }

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border-color: transparent;
}
.btn-primary:hover { background: var(--accent-hover); color: #FFFFFF; border-color: transparent; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-muted);
}
.btn-ghost:hover { color: var(--fg-strong); border-color: var(--accent); }

.diff-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.diff-group .btn {
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  padding: 8px 12px;
  font-size: 13px;
}
.diff-group .btn.active {
  background: var(--accent);
  color: #FFFFFF;
}

.kbd-hint {
  color: var(--fg-faint);
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}

/* ---- Board ---- */
.board-wrap {
  position: relative;
}
.board {
  position: relative;
  background: var(--beige);
  border: 2px solid var(--plum);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cell {
  position: relative;
  background: var(--panel-2);
  border-right: 1px solid var(--plum);
  border-bottom: 1px solid var(--plum);
  display: grid;
  place-items: center;
  font-size: clamp(16px, 5vw, 26px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent); /* user-entered default */
  cursor: pointer;
  transition: background 120ms ease;
  outline-offset: -2px;
}
.cell:nth-child(9n) { border-right: none; }
.cell.row-9 { border-bottom: none; }

/* thicker plum border at 3x3 box boundaries — col idx 3 and 6 */
.cell.col-3, .cell.col-6 { border-left: 2px solid var(--plum); }
.cell.row-3, .cell.row-6 { border-top: 2px solid var(--plum); }

.cell.given {
  font-weight: 800;
  color: var(--rich-black);
  background: var(--panel-2);
}
.cell.user {
  background: var(--cream);
  color: var(--accent);
}
.cell.peer {
  background: rgba(251, 214, 82, 0.18);
}
.cell.same-value {
  background: rgba(238, 117, 38, 0.10);
}
.cell.selected {
  background: var(--mustard);
  outline: 2px solid var(--vermilion);
  z-index: 1;
}
.cell.conflict { color: var(--plum); }
.cell.wrong {
  color: var(--plum);
  background: rgba(119, 22, 28, 0.10);
}

.notes {
  position: absolute;
  inset: 4%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.note {
  display: grid;
  place-items: center;
  font-size: clamp(7px, 1.6vw, 10px);
  font-weight: 500;
  color: var(--pastel-grey);
  opacity: 0.85;
  letter-spacing: -0.02em;
}

/* ---- Number pad ---- */
.numpad {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.numpad .npad {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--fg-strong);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  font-family: inherit;
}
.numpad .npad:hover { border-color: var(--accent); color: var(--accent); }
.numpad .npad:active { background: var(--mustard); }
.numpad .npad.erase {
  color: var(--plum);
  font-size: 13px;
  font-weight: 600;
}
.numpad .npad.exhausted {
  color: var(--fg-faint);
  background: var(--off-white);
}

/* ---- Overlay ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(238, 117, 38, 0.92) 0%, rgba(215, 72, 32, 0.95) 100%);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  z-index: 5;
  color: #FFFFFF;
}
.overlay.show { display: flex; }
.overlay h2 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: #FFFFFF;
}
.overlay p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- Foot ---- */
.foot {
  margin-top: 4px;
  color: var(--fg-faint);
  font-size: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.foot .hint-text { margin: 0; }
.foot .muted { margin: 0; color: var(--fg-faint); font-size: 11px; }
.foot kbd {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--fg-strong);
}

/* ---- Helpers ---- */
.hidden { display: none !important; }

@media (max-width: 420px) {
  .stats { gap: 4px; }
  .stat { padding: 4px 6px; min-width: 0; }
  .stat-value { font-size: 14px; }
  .numpad { grid-template-columns: repeat(5, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .btn, .npad { transition: none; }
}
