:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel-strong: #0f1013;
  --ink: #f5f6f7;
  --muted: #9aa3b2;
  --accent: #c7d2fe;
  --accent-strong: #e0e7ff;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --success: #9ae6b4;
  --danger: #fca5a5;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --board-bg: #0f1013;
  --cell-bg: #f3f4f6;
  --cell-given: #ffffff;
  --cell-peer: #e5e7eb;
  --cell-match: #dbeafe;
  --cell-selected: #c7d2fe;
  --cell-ink: #111827;
  --cell-note: #6b7280;
  --cell-error: #fecaca;
  --cell-check: #fecaca;
  --radius: 1rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

a {
  color: inherit;
}

button,
select {
  font: inherit;
}

button,
.cell,
.keypad,
.keypad button,
.desktop-keypad button,
.mode-toggle-btn,
.floating-action {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 18px 18px 54px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
  background: var(--panel-strong);
  padding: 0.7rem 0.9rem;
  border-radius: 0.8rem;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: calc(3.2rem + env(safe-area-inset-top, 0px));
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--panel);
  backdrop-filter: saturate(120%) blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}

.ecosystem-nav {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ecosystem-nav a,
.ecosystem-nav .active {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 0.45rem;
}

.ecosystem-nav a {
  color: var(--muted);
}

.ecosystem-nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.ecosystem-nav .active {
  color: #9ae6b4;
  background: rgba(72, 187, 120, 0.16);
  border: 1px solid rgba(72, 187, 120, 0.35);
}

.shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.2rem;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.hero > * {
  min-width: 0;
}

.hero-header {
  margin-bottom: 1.15rem;
}

.playfield {
  display: grid;
  grid-template-columns: minmax(148px, 176px) minmax(0, 1fr) minmax(170px, 220px);
  gap: 1rem;
  align-items: start;
}

.playfield-rail {
  min-width: 0;
}

.hero-copy-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.9rem;
}

.hero-back-link {
  width: 2.4rem;
  min-width: 2.4rem;
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(157, 167, 187, 0.24);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 1.3rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero-back-link:hover,
.hero-back-link:focus-visible {
  color: #f4f7ff;
  border-color: rgba(111, 152, 255, 0.44);
  background: rgba(111, 152, 255, 0.1);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  line-height: 0.92;
}

.hero-text {
  margin: 0.85rem 0 0;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 1.03rem;
}

.card,
.hero-stats {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

select,
button {
  min-height: 2.45rem;
  border-radius: 0.78rem;
  border: 1px solid var(--border);
  color: var(--ink);
}

select {
  background: var(--panel-strong);
  padding: 0 0.8rem;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #111214;
  cursor: pointer;
  padding: 0.52rem 0.7rem;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.ghost {
  background: var(--panel-strong);
  border-color: var(--border);
  color: var(--ink);
}

button.ghost:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.hero-stats {
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.hero-stats-rail {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
}

.hero-stats-rail .stat {
  min-height: 5.45rem;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-stats-rail .stat-label {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}

.hero-stats-rail .stat-value {
  font-size: clamp(1.2rem, 1.8vw, 1.9rem);
}

.stat {
  min-height: 0;
  padding: 0.48rem 0.55rem;
  border-radius: 0.78rem;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.stat-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--panel-strong);
  border-color: var(--border);
  color: var(--ink);
}

.stat-button:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--ink);
}

.stat-button:hover:not(:disabled) .stat-label,
.stat-button:hover:not(:disabled) .stat-meta {
  color: var(--accent-strong);
}

.stat-label {
  display: block;
  margin-bottom: 0.12rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.stat-value {
  display: block;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.stat-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.board-card {
  position: relative;
  overflow: visible;
  padding: 0.95rem;
}

.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.board-shell {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 1.8vw, 1.2rem);
  background: var(--board-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: min(100%, 44.5rem);
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #64748b;
  border-radius: 0.75rem;
  background: #64748b;
}

.cell {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  border-radius: 0;
  background: var(--cell-bg);
  color: var(--cell-ink);
  font-size: clamp(1.45rem, 2.55vw, 2.15rem);
  font-weight: 700;
}

.cell:nth-child(9n) {
  border-right-width: 0;
}

.cell.row-break {
  border-bottom: 3px solid #64748b;
}

.cell.col-break {
  border-right: 3px solid #64748b;
}

.cell:focus-visible {
  z-index: 2;
  outline: 3px solid rgba(59, 130, 246, 0.45);
  outline-offset: -3px;
}

.cell.is-given {
  background: var(--cell-given);
}

.cell.is-peer {
  background: var(--cell-peer);
}

.cell.is-match {
  background: var(--cell-match);
}

.cell.is-selected {
  background: var(--cell-selected);
}

.cell.is-entry {
  color: #1e3a8a;
}

.cell.is-conflict {
  background: var(--cell-error);
  color: #7f1d1d;
}

.cell.is-wrong {
  background: var(--cell-check);
  color: #991b1b;
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.35);
}

.cell.is-checked-error {
  background: var(--cell-check);
  color: #991b1b;
}

.cell.is-entry.is-wrong,
.cell.is-entry.is-conflict,
.cell.is-entry.is-checked-error {
  color: #991b1b;
}

.cell.is-match.is-wrong,
.cell.is-match.is-conflict,
.cell.is-match.is-checked-error,
.cell.is-peer.is-wrong,
.cell.is-peer.is-conflict,
.cell.is-peer.is-checked-error {
  background: var(--cell-check);
  color: #991b1b;
}

.cell.is-selected.is-wrong,
.cell.is-selected.is-conflict,
.cell.is-selected.is-checked-error {
  background: var(--cell-check);
  color: #991b1b;
}

.cell.is-hint {
  animation: hintPulse 1200ms ease;
}

.cell-value {
  position: relative;
  z-index: 1;
}

.cell-clear-fab {
  position: absolute;
  z-index: 12;
  width: 1.45rem;
  min-width: 1.45rem;
  min-height: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.24);
}

.cell-clear-fab[hidden] {
  display: none;
}

.cell-clear-fab:hover:not(:disabled) {
  background: #ffffff;
  border-color: rgba(99, 102, 241, 0.32);
  color: #1f2937;
}

.cell-notes {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  padding: 0.25rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.5rem, 1vw, 0.8rem);
  font-weight: 600;
  line-height: 1;
}

.cell-note {
  display: grid;
  place-items: center;
  color: rgba(107, 114, 128, 0.18);
}

.cell-note.is-active {
  color: var(--cell-note);
}

.cell.has-highlighted-note {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(240, 244, 255, 0.78)),
    var(--cell-bg);
}

.cell-note.is-match {
  color: #1d4ed8;
  font-weight: 800;
  background: rgba(29, 78, 216, 0.12);
  border-radius: 999px;
}

.status-message {
  min-height: 1.5em;
  margin: 0.95rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.keypad {
  display: none;
}

.keypad button {
  min-height: 3rem;
  background: var(--panel-strong);
  border-color: var(--border);
  color: var(--ink);
  font-size: 1.05rem;
}

.keypad-mode-toggle.is-note-mode {
  background: rgba(224, 231, 255, 0.12);
  border-color: rgba(199, 210, 254, 0.55);
  color: var(--accent-strong);
}

.keypad-mode-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.keypad-mode-value {
  font-size: 0.96rem;
  font-weight: 700;
}

.keypad button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--panel-strong);
}

.toast-message {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  z-index: 12000;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.floating-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7rem;
  position: sticky;
  top: 5.35rem;
  z-index: 14;
}

.desktop-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  gap: 0.38rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.desktop-keypad button {
  min-width: 0;
  min-height: 2.45rem;
  padding: 0;
  border-radius: 0.7rem;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1;
}

.desktop-keypad button:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.desktop-keypad button:disabled {
  opacity: 0.45;
}

.desktop-keypad button.is-complete,
.keypad button.is-complete {
  color: #6b7280;
  border-color: rgba(107, 114, 128, 0.32);
  background: rgba(148, 163, 184, 0.08);
}

/* Focused / selected digit — highlights the matching keypad button */
.desktop-keypad button.is-focus-digit,
.keypad button.is-focus-digit {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(199, 210, 254, 0.10);
  position: relative;
}

/* Pencil-mode indicator: small ✏ badge in the top-right corner of the focused button */
.desktop-keypad.is-note-mode button.is-focus-digit::after,
.keypad.is-note-mode button.is-focus-digit::after {
  content: "✏";
  position: absolute;
  top: 0.13rem;
  right: 0.18rem;
  font-size: 0.52rem;
  line-height: 1;
  color: var(--accent-strong);
  pointer-events: none;
}

.floating-action {
  min-width: 0;
  width: 100%;
  min-height: 2.7rem;
  padding: 0.56rem 0.82rem;
  border-radius: 0.85rem;
  box-shadow: var(--shadow);
}

.floating-action.ghost-action {
  background: var(--panel-strong);
  border-color: var(--border);
  color: var(--ink);
}

.floating-action.ghost-action:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.check-status-action {
  min-width: 3rem;
  padding-inline: 0.5rem;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1;
}

.check-status-action.is-pending {
  color: var(--muted);
}

.check-status-action.is-pending:hover:not(:disabled) {
  color: var(--accent-strong);
}

.check-status-action.is-complete {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(74, 222, 128, 0.42);
  color: #86efac;
}

.check-status-action.is-complete:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(134, 239, 172, 0.5);
  color: #dcfce7;
}

.check-status-action.is-invalid {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(248, 113, 113, 0.42);
  color: #fca5a5;
}

.check-status-action.is-invalid:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(252, 165, 165, 0.5);
  color: #fee2e2;
}

.mode-toggle-btn {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 0.12rem;
  justify-items: start;
  text-align: left;
  padding-inline: 0.9rem;
  background: var(--panel-strong);
  border-color: var(--border);
  color: var(--ink);
}

.mode-toggle-btn:hover:not(:disabled) {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--ink);
}

.mode-toggle-btn.is-note-mode {
  background: rgba(224, 231, 255, 0.12);
  border-color: rgba(199, 210, 254, 0.55);
  color: var(--accent-strong);
}

.mode-toggle-label {
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mode-toggle-value {
  font-size: 1.06rem;
  font-weight: 700;
}

.mode-toggle-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.mode-shortcuts {
  margin: -0.12rem 0 0;
  padding: 0.55rem 0.68rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 0.85rem;
  background: rgba(15, 23, 42, 0.34);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
  display: grid;
  gap: 0.3rem;
}

.mode-shortcuts span {
  display: block;
}

.mode-shortcuts kbd {
  display: inline-block;
  min-width: 1.45rem;
  padding: 0.12rem 0.36rem;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-bottom-color: rgba(148, 163, 184, 0.4);
  border-radius: 0.42rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.24);
}

.keypad-mode-toggle {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: 0.08rem;
  padding: 0.55rem 0.72rem;
  text-align: left;
}

body.has-mobile-keypad .wrap {
  padding-bottom: calc(21.5rem + env(safe-area-inset-bottom, 0px));
}

.celebration-canvas {
  position: absolute;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.celebration-canvas.active {
  opacity: 1;
}

@keyframes hintPulse {
  0% {
    box-shadow: inset 0 0 0 0 rgba(199, 210, 254, 0.8);
  }

  100% {
    box-shadow: inset 0 0 0 20px rgba(199, 210, 254, 0);
  }
}

/* ── Assisted Mode ── */

.board-labels {
  display: none;
}

.assisted-mode .board-shell {
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  place-items: normal;
}

.assisted-mode .board-labels {
  display: grid;
}

.board-labels span {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 0.7rem / 1 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  user-select: none;
}

.board-labels-cols {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: min(100%, 44.5rem);
  justify-self: center;
  padding-bottom: 0.25rem;
}

.board-labels-rows {
  grid-column: 1;
  grid-row: 2;
  grid-template-rows: repeat(9, minmax(0, 1fr));
  height: 100%;
  justify-self: end;
  padding-right: 0.35rem;
}

.board-labels-rows span {
  justify-content: flex-end;
  text-align: right;
}

.assisted-mode #boardGrid {
  grid-column: 2;
  grid-row: 2;
  place-self: center;
}

.assisted-mode-btn.is-active {
  background: rgba(199, 210, 254, 0.12);
  color: var(--accent-strong);
  border-color: rgba(199, 210, 254, 0.25);
}

.technique-panel {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.technique-panel-heading {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.technique-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.2rem 1rem;
}

.technique-panel-list a {
  display: block;
  padding: 0.3rem 0.45rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.technique-panel-list a:hover {
  background: rgba(199, 210, 254, 0.08);
  color: var(--accent-strong);
}

.technique-panel-credit {
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.7;
}

.technique-panel-credit a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.technique-panel-list li.is-relevant {
  border-left: 2px solid var(--accent);
  padding-left: 0.25rem;
}

.technique-panel-list li.is-relevant a {
  color: var(--accent-strong);
}

/* ── Assisted Mode: Cell Glow + Info Icon ── */

.cell.is-assisted-hint {
  position: relative;
  background: #dde3f8 !important;
  box-shadow: inset 0 0 0 3px #5468b8, 0 0 10px rgba(84, 104, 184, 0.55);
  animation: assistedGlow 1.6s ease-in-out infinite;
  cursor: pointer;
}

.cell.is-assisted-hint::after {
  content: "\2139";
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  font: 700 10px/16px sans-serif;
  text-align: center;
  color: #fff;
  background: #4a5cb3;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 1;
}

@keyframes assistedGlow {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(84, 104, 184, 0.5), 0 0 6px rgba(84, 104, 184, 0.3); }
  50% { box-shadow: inset 0 0 0 3px #5468b8, 0 0 14px rgba(84, 104, 184, 0.6); }
}

/* ── Assisted Insight Popover ── */

.assisted-alert {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: min(90%, 28rem);
  padding: 1rem 1.1rem;
  background: rgba(12, 13, 15, 0.97);
  border: 2px solid var(--accent);
  border-radius: 0.75rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(199, 210, 254, 0.15);
  animation: alertSlideIn 0.2s ease-out;
}

.assisted-alert[hidden] {
  display: none;
}

.assisted-alert-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.assisted-alert-technique {
  font-size: 1rem;
  color: var(--accent-strong);
}

.assisted-alert-summary {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--ink);
}

.assisted-alert-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}

.assisted-alert-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assisted-alert-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.assisted-alert-dismiss:hover {
  opacity: 1;
}

@keyframes alertSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1080px) {
  .playfield {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-stats-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .playfield-rail-controls .floating-controls {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .playfield-rail-controls .floating-action,
  .playfield-rail-controls .mode-toggle-btn {
    width: 100%;
  }

  .playfield-rail-controls .mode-toggle-btn,
  .mode-shortcuts {
    grid-column: span 3;
  }

  .playfield-rail-controls .desktop-keypad {
    grid-column: span 3;
    max-width: 12rem;
  }
}

@media (max-width: 720px) {
  .wrap {
    padding: 12px 12px 36px;
  }

  .shell {
    padding: 0.55rem;
  }

  .topbar-content {
    padding: 0.65rem 0.9rem;
  }

  .board-card {
    padding: 0.8rem;
  }

  .board-labels span {
    font-size: 0.6rem;
  }

  .board-labels-rows {
    padding-right: 0.2rem;
  }

  .board-labels-cols {
    padding-bottom: 0.15rem;
  }

  .technique-panel-list {
    grid-template-columns: 1fr 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-stats-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-copy-wrap {
    align-items: center;
    gap: 0.7rem;
  }

  .hero-back-link {
    width: 2.15rem;
    min-width: 2.15rem;
    min-height: 2.15rem;
    margin-top: 0;
    font-size: 1.15rem;
  }

  .board-toolbar {
    align-items: stretch;
  }

  .panel-head {
    justify-content: space-between;
  }

  .floating-controls {
    position: static;
    margin-top: 0.8rem;
    padding: 0 0.55rem 0.55rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .desktop-keypad {
    display: none;
  }

  .mode-toggle-btn {
    min-width: 0;
    width: 100%;
    grid-column: span 2;
  }

  .mode-shortcuts {
    grid-column: span 2;
    font-size: 0.75rem;
    margin-top: -0.28rem;
  }

  .floating-action {
    min-width: 0;
  }

  .keypad {
    position: fixed;
    left: 50%;
    right: auto;
    top: auto;
    bottom: 0;
    z-index: 1200;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100vw - 0.25rem, 26rem);
    max-width: calc(100vw - 0.25rem);
    gap: 0.48rem;
    padding: 0.82rem 0.78rem calc(0.92rem + env(safe-area-inset-bottom, 0px));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-width: 0;
    border-radius: 1.15rem 1.15rem 0 0;
    background: rgba(17, 18, 20, 0.98);
    box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.38);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(100% + 1rem));
    transition: opacity 180ms ease, transform 180ms ease;
    backdrop-filter: blur(16px);
  }

  .keypad.is-compact {
    width: min(100vw - 0.2rem, 24rem);
    gap: 0.42rem;
    padding: 0.72rem 0.68rem calc(0.82rem + env(safe-area-inset-bottom, 0px));
  }

  .keypad.is-docked {
    width: min(100vw - 0.25rem, 26rem);
  }

  .keypad button {
    min-height: 3.2rem;
    font-size: 1.08rem;
  }

  .keypad.is-compact button {
    min-height: 3rem;
    font-size: 1.02rem;
  }

  .keypad .keypad-mode-toggle {
    padding: 0.62rem 0.74rem;
  }

  .keypad.is-compact .keypad-mode-toggle {
    padding: 0.56rem 0.68rem;
  }

  .keypad.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }

  .cell {
    font-size: clamp(1.1rem, 5vw, 1.5rem);
  }

  .cell-notes {
    font-size: clamp(0.44rem, 2vw, 0.74rem);
    padding: 0.14rem;
  }
}

/* ─── v2 badge ───────────────────────────────────────────────────────────── */

.v2-badge {
  display: inline-block;
  margin-left: 0.35em;
  padding: 0.12em 0.38em;
  background: rgba(199, 210, 254, 0.18);
  border: 1px solid rgba(199, 210, 254, 0.38);
  border-radius: 0.45em;
  font-size: 0.42em;
  font-weight: 700;
  vertical-align: middle;
  color: var(--accent);
  letter-spacing: 0.04em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ─── Hint button active state ───────────────────────────────────────────── */

.hint-btn.is-active {
  border-color: rgba(199, 210, 254, 0.6);
  color: var(--accent-strong);
}

/* ─── Hint overlay cell colors ───────────────────────────────────────────── */

/* Region: yellow — the relevant row/col/box */
.cell.is-hint-region:not(.is-selected):not(.is-given) {
  background: #fef9c3;
}

/* Candidate: blue — cells containing the relevant digit */
.cell.is-hint-candidate:not(.is-selected) {
  background: #dbeafe;
}

/* Elimination: soft red — cells where a candidate can be removed */
.cell.is-hint-elimination:not(.is-selected) {
  background: #fee2e2;
}

/* Target: green — the final answer cell, pulses gently */
.cell.is-hint-target {
  background: #bbf7d0 !important;
  animation: hintTargetPulse 1.4s ease-in-out infinite;
}

@keyframes hintTargetPulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(52, 211, 153, 0); }
  50%       { box-shadow: inset 0 0 0 3px rgba(52, 211, 153, 0.45); }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .cell.is-hint-target {
    animation: none;
  }
}

/* ─── Hint panel ─────────────────────────────────────────────────────────── */

.hint-panel {
  margin: 0 0 0.8rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(199, 210, 254, 0.28);
  border-radius: 0.85rem;
  background: rgba(199, 210, 254, 0.05);
}

.hint-panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.hint-stage-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.hint-stage-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

.hint-panel-footer {
  margin-top: 0.55rem;
}

.hint-why-btn {
  min-height: 1.7rem;
  padding: 0.18rem 0.65rem;
  border-radius: 0.55rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  box-shadow: none;
}

.hint-why-btn:hover:not(:disabled) {
  background: rgba(199, 210, 254, 0.1);
  border-color: rgba(199, 210, 254, 0.5);
  color: var(--accent-strong);
}

.hint-why-panel {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.6;
}

.cell-ref {
  display: inline-block;
  padding: 0.08em 0.35em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  font-weight: 700;
  background: rgba(199, 210, 254, 0.15);
  border: 1px solid rgba(199, 210, 254, 0.3);
  border-radius: 0.35em;
  color: var(--accent-strong);
  cursor: pointer;
  white-space: nowrap;
}

.cell-ref:hover {
  background: rgba(199, 210, 254, 0.25);
  border-color: rgba(199, 210, 254, 0.5);
}

.hint-skill-badge {
  display: inline-block;
  padding: 0.1em 0.4em;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 0.35em;
  background: rgba(154, 230, 180, 0.15);
  border: 1px solid rgba(154, 230, 180, 0.35);
  color: var(--success);
  vertical-align: middle;
}

.hint-skill-badge.is-intermediate {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fbbf24;
}

.hint-learn-link {
  display: inline-block;
  margin-top: 0.3em;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.hint-learn-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.hint-study-link {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: 0.5rem;
  color: var(--accent, #818cf8);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.hint-study-link:hover {
  background: rgba(129, 140, 248, 0.08);
  border-color: var(--accent-strong, #a5b4fc);
  color: var(--accent-strong, #a5b4fc);
}

/* ── Solver link button (sidebar) ──────────────────────────────────────────── */
.solver-link-btn {
  text-decoration: none;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}
.history-link-btn {
  display: grid;
  place-items: center;
  text-decoration: none;
  text-align: center;
  font-size: 0.88rem;
}
.solver-link-btn:hover {
  color: var(--accent-strong);
}

@media (max-width: 720px) {
  .hint-panel {
    margin: 0 0 0.55rem;
    padding: 0.7rem 0.85rem;
  }
}

/* retirement-banner — shown only when this bundle is served at /legacy-sudoku/
   (legacy-banner.js un-hides it on that route). Styles ported from the v1
   bundle's CSP cleanup pass; kept external so the route can stay on strict CSP. */
.retirement-banner[hidden] { display: none !important; }
.retirement-banner { max-width: 900px; margin: 1rem auto; padding: 1.1rem 1.25rem; background: rgba(251, 191, 36, 0.08); border: 2px solid var(--warning, #fbbf24); border-radius: 0.5rem; color: var(--text, #f5f6f7); }
.retirement-banner__title { margin: 0 0 0.5rem; font-size: 1.125rem; color: var(--warning, #fbbf24); }
.retirement-banner__content p { margin: 0.4rem 0; line-height: 1.45; font-size: 0.925rem; }
.retirement-banner__content a { color: var(--warning, #fbbf24); }
.retirement-banner__actions { display: flex; gap: 0.75rem; margin-top: 0.9rem; flex-wrap: wrap; }
.retirement-banner__btn { padding: 0.55rem 1.1rem; border-radius: 0.35rem; font-weight: 700; font-size: 0.875rem; text-decoration: none; cursor: pointer; border: 2px solid var(--warning, #fbbf24); font-family: inherit; transition: background 0.1s; }
.retirement-banner__content .retirement-banner__btn--primary { background: var(--warning, #fbbf24); color: #0c0d0f; }
.retirement-banner__btn--primary:hover { filter: brightness(1.1); }
.retirement-banner__btn--ghost { background: transparent; color: var(--warning, #fbbf24); }
.retirement-banner__btn--ghost:hover { background: rgba(251, 191, 36, 0.12); }
.account-game-gate {
  box-sizing: border-box;
  width: min(100%, 760px);
  margin: clamp(2rem, 10vh, 7rem) auto;
  padding: 2rem;
  border: 1px solid var(--line, rgba(0, 0, 0, 0.2));
  text-align: center;
  letter-spacing: 0.04em;
}
