/* ============================================================
   SUDOKU.BY — Design System
   Clean, trustworthy, blue-accent UI inspired by Sudoku.com
   ============================================================ */

:root {
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --blue-border: #bfdbfe;
  --accent: #f59e0b;
  --accent-light: #fffbeb;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --nav-height: 62px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }
body { overflow-x: hidden; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
img, video, iframe, embed, object { max-width: 100%; display: block; }

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
p { margin-bottom: 1rem; color: var(--text-muted); }
p:last-child { margin-bottom: 0; }

/* ---- LAYOUT ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 0 1.5rem; }
.container-lg { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; }
.page-wrap { padding: 2.5rem 0; }

/* ---- NAVIGATION ---- */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.nav-inner {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.5px;
  margin-right: 2rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo:hover { color: var(--blue-dark); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  list-style: none;
}
.nav-links a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover,
.nav-links a.active { background: var(--blue-light); color: var(--blue); }

/* ---- NAV DROPDOWN ---- */
.nav-has-dropdown { position: relative; }
.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.nav-dropdown-trigger:hover,
.nav-has-dropdown:hover .nav-dropdown-trigger { background: var(--blue-light); color: var(--blue); }
.nav-dropdown-trigger svg { flex-shrink: 0; transition: transform .15s; }
.nav-has-dropdown:hover .nav-dropdown-trigger svg { transform: rotate(180deg); }
.nav-mega {
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.14);
  width: 640px;
  padding: .75rem 0 .5rem;
  display: none;
  z-index: 300;
}
.nav-has-dropdown:hover .nav-mega { display: block; }
.nav-mega-cols { display: grid; grid-template-columns: 1fr 1fr; }
.nav-mega-col { padding: 0 .25rem; }
.nav-mega-heading {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .6rem 1rem .2rem;
}
.nav-mega a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem 1rem;
  font-size: .84rem;
  color: var(--text);
  border-radius: 4px;
  transition: background .1s, color .1s;
}
.nav-mega a:hover { background: var(--blue-light); color: var(--blue); }
.nav-mega-footer {
  border-top: 1px solid var(--border);
  margin-top: .5rem;
  padding: .5rem 1rem 0;
  display: flex;
  justify-content: flex-end;
}
.badge-soon {
  font-size: .6rem;
  padding: .1rem .35rem;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
  margin-left: .4rem;
  letter-spacing: .02em;
}
/* ---- SOLVER GRID ---- */
.solver-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-size: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  caret-color: var(--blue);
}
.solver-input:focus { cursor: text; }
.solver-cell { cursor: text; }
.solver-cell:has(.solver-input:focus) { background: var(--blue-light) !important; }
.solver-cell.solver-given { color: var(--text); font-weight: 800; }
.solver-cell.solver-solved { color: var(--blue); }
.solver-cell.solver-conflict { background: #fef2f2 !important; }
.solver-cell.solver-conflict .solver-input { color: #ef4444; }
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.nav-divider { width: 1px; height: 20px; background: var(--border); }

/* ---- HAMBURGER / MOBILE NAV ---- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 6px;
  transition: background .15s;
  flex-shrink: 0;
  margin-left: .25rem;
}
.nav-hamburger:hover { background: var(--blue-light); }
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .22s, opacity .22s, width .22s;
  transform-origin: center;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; width: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile-panel {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  padding: .75rem 0 2rem;
  transform: translateY(-6px);
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.nav-mobile-panel.open { opacity: 1; transform: translateY(0); }
.nav-mobile-panel .mob-link {
  display: block;
  padding: .65rem 1.25rem;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
  border-radius: 0;
  transition: background .1s, color .1s;
}
.nav-mobile-panel .mob-link:hover,
.nav-mobile-panel .mob-link.active { background: var(--blue-light); color: var(--blue); }
.nav-mobile-section { border-top: 1px solid var(--border); margin-top: .4rem; padding-top: .4rem; }
.nav-mobile-acc-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .65rem 1.25rem;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .1s, color .1s;
}
.nav-mobile-acc-btn:hover { background: var(--blue-light); color: var(--blue); }
.nav-mobile-acc-btn svg { transition: transform .2s; flex-shrink: 0; }
.nav-mobile-acc-btn.open svg { transform: rotate(180deg); }
.nav-mobile-acc-body { display: none; padding: 0 0 .4rem; }
.nav-mobile-acc-body.open { display: block; }
.nav-mobile-acc-body .mob-sub-link {
  display: block;
  padding: .45rem 1.25rem .45rem 2.25rem;
  font-size: .87rem;
  color: var(--text-muted);
  transition: background .1s, color .1s;
}
.nav-mobile-acc-body .mob-sub-link:hover { background: var(--blue-light); color: var(--blue); }
.nav-mobile-acc-heading {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .6rem 1.25rem .2rem 2.25rem;
}
.nav-mobile-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1rem 1.25rem .5rem;
  border-top: 1px solid var(--border);
  margin-top: .75rem;
}

/* Difficulty tabs in nav */
.diff-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
}
.diff-tab {
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  border: none;
  background: none;
}
.diff-tab:hover { background: var(--surface); color: var(--blue); }
.diff-tab.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-light); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #d97706; border-color: #d97706; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-xl { padding: 1rem 2.5rem; font-size: 1.1rem; border-radius: var(--radius); }
.btn-full { width: 100%; }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 1.5rem; }
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.4rem; color: var(--text); }
.form-control {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-control.is-invalid { border-color: #ef4444; }
.form-error { font-size: 0.8rem; color: #ef4444; margin-top: 0.25rem; }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { cursor: pointer; }

/* ---- ALERTS / FLASH ---- */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-danger { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: var(--accent-light); border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: var(--blue-light); border: 1px solid var(--blue-border); color: #1e40af; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-green { background: #f0fdf4; color: #166534; }
.badge-yellow { background: var(--accent-light); color: #92400e; }
.badge-red { background: #fef2f2; color: #991b1b; }
.badge-gray { background: var(--surface-3); color: var(--text-muted); }

/* ---- DIFFICULTY COLORS ---- */
.diff-easy { color: #16a34a; }
.diff-medium { color: #2563eb; }
.diff-hard { color: #d97706; }
.diff-expert { color: #dc2626; }
.diff-master { color: #7c3aed; }
.diff-extreme { color: #0f172a; }

/* ---- GAME BOARD ---- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
}
.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 3px solid var(--text);
  border-radius: 4px;
  width: min(100%, 480px);
  aspect-ratio: 1;
  background: var(--surface);
  user-select: none;
  position: relative;
}
.sudoku-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: background 0.1s;
  aspect-ratio: 1;
}
.sudoku-cell:hover { background: #e0f2fe; }
.sudoku-cell.selected { background: #bfdbfe !important; }
.sudoku-cell.highlighted { background: #eff6ff; }
.sudoku-cell.same-number { background: #dbeafe; }
.sudoku-cell.given { color: var(--text); font-weight: 800; }
.sudoku-cell.entered { color: var(--blue); }
.sudoku-cell.error { color: #ef4444; background: #fef2f2; }
.sudoku-cell.notes-cell { font-size: clamp(0.4rem, 1vw, 0.6rem); color: var(--text-muted); }

/* Box borders */
.sudoku-cell:nth-child(3n) { border-right: 2px solid #64748b; }
.sudoku-cell:nth-child(9n) { border-right: 3px solid var(--text); }
.sudoku-board .row-3, .sudoku-board .row-6 { border-top: 2px solid #64748b; }
.sudoku-cell.box-border-bottom { border-bottom: 2px solid #64748b; }
.sudoku-cell.box-border-right { border-right: 2px solid #64748b; }

/* ---- KILLER SUDOKU LAYOUT ---- */
.killer-page { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

.killer-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 2rem;
  align-items: start;
}

.killer-board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.killer-board-col .sudoku-board {
  width: min(100%, 520px);
}

.killer-board-col .killer-stats-row {
  width: min(100%, 520px);
}

.killer-controls-col {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

/* Stats row */
.killer-stats-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.killer-stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; margin-bottom: .1rem; }
.killer-stat-value { font-size: 1rem; font-weight: 700; }

/* Action buttons row */
.killer-actions {
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .25rem;
}
.killer-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .4rem .5rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all .12s;
  color: var(--text-muted);
}
.killer-action-btn:hover { background: var(--surface-3); color: var(--blue); }
.killer-action-btn.active { color: var(--blue); background: var(--blue-light); }
.killer-action-btn svg { width: 22px; height: 22px; }
.killer-action-btn span { font-size: .65rem; font-weight: 500; }

/* Numpad in right panel */
.killer-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.killer-numpad .killer-numpad-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  background: var(--surface-3);
  cursor: pointer;
  color: var(--blue);
  transition: all .12s;
}
.killer-numpad .killer-numpad-btn:hover { background: var(--blue-light); transform: translateY(-1px); }
.killer-numpad .killer-numpad-btn:active { transform: translateY(0); }

/* Mobile: stack layout — board col first (stats+board), then controls col */
@media (max-width: 680px) {
  .killer-layout { grid-template-columns: 1fr; }
  /* board-col stacks first naturally (it's first in HTML) */
  .killer-numpad { grid-template-columns: repeat(9, 1fr); gap: 0.2rem; width: 100%; }
  .killer-numpad .killer-numpad-btn {
    aspect-ratio: auto;
    height: 62px;
    font-size: 1.9rem;
    font-weight: 800;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
  }
  .killer-numpad .killer-numpad-btn:active { background: var(--blue); color: white; transform: scale(.93); }
  .killer-actions { padding: .4rem .25rem; }
  .killer-action-btn { padding: .65rem .5rem; }
  .killer-action-btn svg { width: 28px; height: 28px; }
  .killer-action-btn span { font-size: .74rem; }
  .killer-stats-row { font-size: 1rem; }
  .killer-stat-value { font-size: 1.1rem; }
  .killer-stat-value.timer { font-size: 1.6rem; }
}

/* ---- KILLER SUDOKU BOARD ---- */
.killer-board { position: relative; }

/* Cage boundary borders override cell defaults */
.killer-cell { border: 1px solid #d1d5db; font-size: clamp(.9rem, 2.2vw, 1.35rem); }
.killer-cell.kc-top    { border-top:    2px dashed #475569; }
.killer-cell.kc-right  { border-right:  2px dashed #475569; }
.killer-cell.kc-bottom { border-bottom: 2px dashed #475569; }
.killer-cell.kc-left   { border-left:   2px dashed #475569; }

/* Box borders win over cage dash on 3x3 lines */
.killer-cell.box-border-bottom { border-bottom: 2px solid #64748b !important; }
.killer-cell.box-border-right  { border-right:  2px solid #64748b !important; }

/* Cage sum label */
.cage-sum {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: clamp(7px, 1vw, 10px);
  font-weight: 700;
  color: #374151;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Cage state colours */
.killer-cell.cage-complete { background: #f0fdf4; }
.killer-cell.cage-complete.selected { background: #bfdbfe !important; }
.killer-cell.cage-error    { background: #fff0f0; }
.killer-cell.cage-highlighted { background: #fef9c3; }

/* SVG cage boundary overlay */
.cage-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.cage-svg line {
  stroke: #475569;
  stroke-width: 0.055;
  stroke-dasharray: 0.18 0.12;
}

/* ---- DIAGONAL SUDOKU ---- */
.diag-main { background: #eff6ff; }
.diag-anti { background: #eff6ff; }
/* center cell is on both diagonals */
.diag-main.diag-anti { background: #dbeafe; }

.diag-main.given, .diag-anti.given { background: #dbeafe; }
.diag-main.selected, .diag-anti.selected { background: #bfdbfe !important; }
.diag-main.highlighted, .diag-anti.highlighted { background: #bfdbfe80; }
.diag-main.error, .diag-anti.error { background: #fee2e2; }
.diag-main.same-number, .diag-anti.same-number { background: #93c5fd; }

/* ---- HYPER SUDOKU ---- */
.hyper-cell { background: #f0fdf4; }
.hyper-cell.given { background: #dcfce7; }
.hyper-cell.selected { background: #bfdbfe !important; }
.hyper-cell.highlighted { background: #bfdbfe80; }
.hyper-cell.error { background: #fee2e2; }
.hyper-cell.same-number { background: #86efac; }

/* ---- ODD/EVEN SUDOKU ---- */
.odd-cell { background: #f5f3ff; }
.even-cell { background: #fefce8; }
.odd-cell.given, .even-cell.given { background: #ede9fe; }
.odd-cell::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1.5px solid #a78bfa;
  pointer-events: none;
  z-index: 2;
}
.even-cell::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: rgba(234,179,8,.15);
  pointer-events: none;
  z-index: 2;
}
.odd-cell.selected, .even-cell.selected { background: #bfdbfe !important; }

/* ---- ANTI-KNIGHT / ANTI-KING (no extra visual needed, constraint-only) ---- */

/* ---- IRREGULAR / JIGSAW SUDOKU ---- */
.irr-cell { border: 1px solid rgba(0,0,0,.1); }
.irr-cell.irr-top    { border-top:    2.5px solid #334155; }
.irr-cell.irr-right  { border-right:  2.5px solid #334155; }
.irr-cell.irr-bottom { border-bottom: 2.5px solid #334155; }
.irr-cell.irr-left   { border-left:   2.5px solid #334155; }
.irr-cell.given { filter: brightness(.93); }

/* Notes grid in cell */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  gap: 0;
}
.note-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.35rem, 0.8vw, 0.55rem);
  color: #64748b;
  font-weight: 500;
}

/* ---- GAME CONTROLS ---- */
.game-controls {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.game-pause-row {
  display: flex;
  gap: .75rem;
  justify-content: center;
  padding: .5rem 0;
}
.game-stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}
.game-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
.game-stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.game-stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.timer { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.15s;
}
.control-btn:hover { background: var(--surface-3); color: var(--blue); }
.control-btn.active { color: var(--blue); background: var(--blue-light); }
.control-btn svg { width: 22px; height: 22px; }

.controls-row {
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  width: 100%;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
}
.numpad-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--blue);
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
}
.numpad-btn:hover { background: var(--blue-light); border-color: var(--blue); transform: translateY(-1px); }
.numpad-btn:active { transform: translateY(0); }

/* ---- LEADERBOARD ---- */
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
}
.lb-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.lb-table tr:hover td { background: var(--surface-2); }

/* Generic content table used on variant / rules pages */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead tr { background: var(--surface-2); }
.data-table th { padding: .65rem 1rem; font-weight: 700; color: var(--text); text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; line-height: 1.55; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
.data-table tbody tr:hover td { background: var(--blue-50, #eff6ff); }
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}
.rank-1 { background: #fef9c3; color: #854d0e; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #fef3c7; color: #92400e; }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 60%, #60a5fa 100%);
  color: white;
  padding: 4rem 0 3rem;
  text-align: center;
}
.hero h1 { color: white; font-size: 2.8rem; margin-bottom: 1rem; }
.hero p { color: rgba(255,255,255,0.85); font-size: 1.1rem; max-width: 600px; margin: 0 auto 2rem; }

/* =============================================
   BLOG INDEX
   ============================================= */
.blog-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.blog-header h1 { margin-bottom: .25rem; }

/* Featured article card */
.blog-featured {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  margin-bottom: 2rem;
  transition: box-shadow .2s, transform .2s;
}
.blog-featured:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.blog-featured-body {
  padding: 2rem 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .75rem;
}
.blog-featured-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--blue);
}
.blog-featured-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
}
.blog-featured-excerpt {
  font-size: .95rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-featured-meta {
  font-size: .82rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.blog-featured-cta {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--blue);
  margin-top: .25rem;
}
.blog-featured-cta:hover { color: var(--blue-dark); }

/* Blog article grid */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.blog-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.09);
  transform: translateY(-2px);
}
.blog-card-accent {
  height: 4px;
  flex-shrink: 0;
}
.blog-card-body {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: .5rem;
}
.blog-card-category {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.blog-card-title {
  font-size: .97rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.blog-card-excerpt {
  font-size: .83rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .76rem;
  color: var(--text-light);
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.blog-read-time {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

@media (max-width: 900px) {
  .blog-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .blog-grid { grid-template-columns: 1fr; }
  .blog-featured-body { padding: 1.25rem; }
  .blog-featured-title { font-size: 1.2rem; }
}

/* ---- GRID SECTION LAYOUTS ---- */
.section { padding: 3rem 0; }
.section-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.5rem; }
.section-subtitle { color: var(--text-muted); margin-bottom: 2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }

/* Difficulty card */
.diff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--border);
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
}
.diff-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  color: var(--text);
}
.diff-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}
.diff-card-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.25rem; }
.diff-card-desc { font-size: 0.8rem; color: var(--text-muted); }

/* Feature card */
.feature-card {
  padding: 1.75rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.feature-card-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card-icon svg { width: 40px; height: 40px; color: var(--blue); display: block; }
.feature-card h3 { margin-bottom: 0.4rem; }

/* ---- FOOTER ---- */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; margin-bottom: 2.5rem; }
.footer-brand { font-size: 1.5rem; font-weight: 800; color: #60a5fa; margin-bottom: 0.75rem; }
.footer-desc { font-size: 0.875rem; line-height: 1.6; margin-bottom: 0; }
.footer-heading { font-weight: 700; color: #e2e8f0; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 1rem; }
.footer-links { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.footer-links a { color: #94a3b8; font-size: 0.875rem; transition: color 0.15s; }
.footer-links a:hover { color: #60a5fa; }
.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}
/* Footer mobile overrides — must be here so media queries at end of file can still override */
.footer-locales { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.footer-locale-link {
  font-size: 0.75rem;
  color: #64748b;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #1e293b;
  transition: all 0.15s;
}
.footer-locale-link:hover { color: #60a5fa; border-color: #60a5fa; }

/* ---- BREADCRUMB ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--blue); }
.breadcrumb .sep { color: var(--text-light); }

/* ---- PAGINATION ---- */
.pagination { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  color: var(--text);
}
.page-link:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.page-link.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ---- ADMIN SIDEBAR ---- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 0; min-height: calc(100vh - var(--nav-height)); }
.admin-sidebar {
  background: #0f172a;
  padding: 1.5rem 0;
  border-right: 1px solid #1e293b;
}
.admin-sidebar-section { padding: 0.5rem 0; border-bottom: 1px solid #1e293b; }
.admin-sidebar-heading {
  padding: 0.5rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  color: #94a3b8;
  transition: all 0.15s;
}
.admin-nav-link:hover, .admin-nav-link.active { background: #1e293b; color: #e2e8f0; }
.admin-nav-link.active { border-left: 3px solid var(--blue); padding-left: calc(1.25rem - 3px); }
.admin-content { padding: 2rem; background: var(--surface-2); }
.admin-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.admin-stat-num { font-size: 1.75rem; font-weight: 800; color: var(--text); }
.admin-stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ---- DASHBOARD SIDEBAR ---- */
.dash-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; }
.dash-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: fit-content;
}
.dash-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: all 0.15s;
}
.dash-nav-link:last-child { border-bottom: none; }
.dash-nav-link:hover, .dash-nav-link.active { background: var(--blue-light); color: var(--blue); }
.dash-nav-link.active { font-weight: 600; }

/* ---- PRINTABLE ---- */
@media print {
  body { background: white; margin: 0; padding: 0; }
  /* Default: hide UI chrome */
  .site-nav, .site-footer, .no-print { display: none !important; }
  /* Printable Sudoku page: hide everything except the puzzle grids */
  body.print-page > * { visibility: hidden; }
  body.print-page #print-area,
  body.print-page #print-area * { visibility: visible; }
  body.print-page #print-area {
    position: fixed;
    top: 0; left: 0;
    width: 100%; margin: 0; padding: 1cm;
    box-sizing: border-box;
  }
  .print-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5cm; }
  .print-board { border: 3px solid #000; display: grid; grid-template-columns: repeat(9, 1fr); }
  .print-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #666;
    font-size: 1rem;
    font-weight: 700;
  }
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
  /* Hard-stop horizontal overflow */
  html { overflow-x: hidden; }
  body { overflow-x: hidden; max-width: 100vw; }
  .container, .container-sm, .container-lg { padding: 0 1rem; max-width: 100%; }
  .page-wrap { padding: 1.5rem 0; }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .hero { padding: 2.5rem 0 2rem; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  /* Footer mobile: brand full-width, 3 link columns in 2-col pairs */
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
  .footer-grid > div:first-child { grid-column: 1 / -1; padding-bottom: 1rem; border-bottom: 1px solid #1e293b; }
  .site-footer { padding: 2rem 0 1rem; margin-top: 2rem; }
  .footer-brand { font-size: 1.25rem; margin-bottom: .5rem; }
  .footer-desc { font-size: .82rem; }
  .footer-heading { font-size: .75rem; margin-bottom: .6rem; }
  .footer-links { gap: .35rem; }
  .footer-links a { font-size: .82rem; }
  .footer-bottom { flex-direction: column; gap: .3rem; text-align: center; padding-top: 1rem; font-size: .75rem; }
  .dash-layout, .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .game-layout { grid-template-columns: 1fr; }
  .game-controls { width: 100%; display: none; }  /* sidebar hidden on mobile */
  /* Large Sudoku.com-style numpad on mobile */
  .numpad { grid-template-columns: repeat(9, 1fr); gap: 0.2rem; padding: 0.3rem 0; }
  .numpad-btn {
    aspect-ratio: auto;
    height: 62px;
    font-size: 1.9rem;
    font-weight: 800;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--blue);
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
  }
  .numpad-btn:active { background: var(--blue); color: white; transform: scale(.93); }
  /* Controls row on mobile: spread out, bigger touch targets */
  .controls-row {
    border-radius: var(--radius);
    padding: .4rem .25rem;
    margin: .25rem 0;
  }
  .control-btn { padding: .65rem .5rem; font-size: .74rem; }
  .control-btn svg { width: 28px; height: 28px; }
  /* Pause/New row on mobile */
  .game-pause-row { display: flex; gap: .75rem; justify-content: center; padding: .5rem 0; }
  /* Stats: make timer prominent */
  .timer { font-size: 1.6rem; }
  .nav-links { display: none; }
  .nav-actions .btn { display: none; }
  .nav-actions { margin-left: auto; }
  .nav-hamburger { display: flex; }
  .nav-mobile-panel { display: block; pointer-events: none; overflow-x: hidden; max-width: 100vw; }
  .nav-mobile-panel.open { pointer-events: all; }
  .admin-stat-grid { grid-template-columns: repeat(2, 1fr); }
  /* Grid layout: collapse sidebar, prevent items from overflowing column */
  .hub-layout { grid-template-columns: 1fr !important; gap: 1.5rem !important; }
  .hub-layout > * { min-width: 0; max-width: 100%; }
  .hub-sidebar { position: static !important; }
  /* Tables */
  .table-wrap { overflow-x: auto; }
  .card { border-radius: var(--radius-sm); max-width: 100%; }
  .card-body { overflow-x: auto; }
  .section { padding: 2rem 0; }
  .section-title { font-size: 1.4rem; }
  .mb-8 { margin-bottom: 1.25rem; }
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-icon { font-size: 3rem; margin-bottom: 1rem; display: flex; align-items: center; justify-content: center; }
.modal-icon svg { width: 60px; height: 60px; }
.modal-title { font-size: 1.75rem; margin-bottom: 0.5rem; }
.modal-score { font-size: 2.5rem; font-weight: 800; color: var(--blue); margin: 0.5rem 0; }
.modal-stats { display: flex; justify-content: center; gap: 2rem; margin: 1rem 0 1.5rem; }
.modal-stat { text-align: center; }
.modal-stat-val { font-size: 1.25rem; font-weight: 700; }
.modal-stat-lbl { font-size: 0.75rem; color: var(--text-muted); }

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-blue { color: var(--blue); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.1rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.btn-full { width: 100%; }
.flex-wrap { flex-wrap: wrap; }

/* ---- HOME GAME SECTION ---- */
.home-game-wrap {
  padding: 1.5rem 0 2rem;
}
.home-game-wrap .game-layout {
  max-width: 860px;
}
.home-game-wrap .game-controls {
  width: 220px;
}

/* Desktop numpad (shown in controls panel on home/game pages) */
.numpad-desktop { display: block; }
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.numpad-btn-lg {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--blue);
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
}
.numpad-btn-lg:hover {
  background: var(--blue-light);
  border-color: var(--blue);
  transform: translateY(-1px);
}
.numpad-btn-lg:active { transform: translateY(0); }

/* On home page, hide the mobile numpad + pause row on desktop; show desktop sidebar */
@media (min-width: 769px) {
  .home-game-wrap .numpad { display: none; }
  .home-mobile-only { display: none !important; }
}

@media (max-width: 768px) {
  .home-game-wrap .game-controls { display: none; }  /* hide sidebar on mobile */
  .numpad-desktop { display: none; }
  .home-game-wrap .numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 0.2rem; }
}

/* ---- GAME ACTIONS ROW — mobile wrap ---- */
@media (max-width: 480px) {
  .game-actions { flex-wrap: wrap; gap: .4rem; justify-content: center; }
  .game-action-btn { padding: .4rem .6rem; font-size: .75rem; }
  .game-action-btn span { font-size: .65rem; }
  /* Keep numpad-btn large on small phones — do NOT shrink it */
  .timer-display, .mistakes-display { font-size: .85rem; }
}

/* =============================================
   BLOG ARTICLE LAYOUT
   ============================================= */
.article-layout {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 2rem;
  align-items: start;
}
.article-toc-sidebar { position: sticky; top: 5rem; }
.article-related-sidebar { position: sticky; top: 5rem; }

/* TOC nav */
.article-toc-nav { padding: .25rem 0; }
.article-toc-nav a {
  display: block;
  padding: .4rem .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  text-decoration: none;
  line-height: 1.4;
  transition: color .15s, border-color .15s, background .15s;
}
.article-toc-nav a:hover,
.article-toc-nav a.active {
  color: var(--blue);
  border-left-color: var(--blue);
  background: var(--blue-light);
}
.article-toc-nav a.toc-h3 { padding-left: 1.5rem; font-size: .77rem; }

/* Key Points box */
.key-points {
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}
.key-points .kp-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--blue-dark);
  margin-bottom: .6rem;
}
.key-points ul { margin: 0; padding-left: 1.2rem; }
.key-points ul li {
  font-size: .88rem;
  color: var(--text);
  margin-bottom: .3rem;
  line-height: 1.55;
}

/* Article body typography */
.article-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2.25rem;
  margin-bottom: .75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 5.5rem;
}
.article-body h2:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.article-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: .5rem;
  scroll-margin-top: 5.5rem;
}
.article-body p {
  font-size: .97rem;
  line-height: 1.85;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.article-body ul,
.article-body ol {
  padding-left: 1.4rem;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
  font-size: .94rem;
  line-height: 1.75;
}
.article-body li { margin-bottom: .35rem; }
.article-body strong { color: var(--text); }
.article-body em { font-style: italic; }

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.75rem;
  font-size: .88rem;
}
.article-body table th {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
  padding: .6rem .9rem;
  text-align: left;
  border: 1px solid var(--border);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.article-body table td {
  padding: .55rem .9rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
  line-height: 1.5;
}
.article-body table tr:nth-child(even) td { background: var(--surface-2); }

/* Blockquote / callout */
.article-body blockquote {
  border-left: 4px solid var(--blue);
  background: var(--blue-light);
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-size: .95rem;
  font-style: normal;
}
.article-body .callout {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: .9rem 1.2rem;
  margin: 1.25rem 0;
  font-size: .88rem;
  color: #166534;
  line-height: 1.6;
}
.article-body .callout-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* Stat bars (horizontal bar chart) */
.article-body .stat-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .6rem;
}
.article-body .stat-bar-label {
  font-size: .82rem;
  color: var(--text-muted);
  min-width: 110px;
}
.article-body .stat-bar-track {
  flex: 1;
  height: 10px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.article-body .stat-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .3s;
}
.article-body .stat-bar-val {
  font-size: .8rem;
  color: var(--text);
  font-weight: 600;
  min-width: 52px;
  text-align: right;
}

/* Responsive article layout */
@media (max-width: 1100px) {
  .article-layout { grid-template-columns: 1fr 260px; }
  .article-toc-sidebar { display: none; }
}
@media (max-width: 768px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-related-sidebar { position: static; }
}

/* ---- SMALL PHONES (≤ 480px) — must come last to win cascade ---- */
@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  .hero h1 { font-size: 1.65rem; }
  .page-wrap { padding: 1rem 0; }
  .container { padding: 0 .75rem; }
  .nav-logo { font-size: 1.15rem; margin-right: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .diff-card { padding: 1.25rem .75rem; }
  .diff-card-icon { width: 44px; height: 44px; font-size: 1.2rem; }
  .diff-card-name { font-size: .9rem; }
  .card-body { padding: .875rem; }
  .card-header { padding: .75rem .875rem; font-size: .85rem; }
  .btn-lg { padding: .6rem 1.25rem; font-size: .9rem; }
  .lb-table th, .lb-table td { padding: .5rem .6rem; font-size: .8rem; }
  .data-table th { white-space: normal; font-size: .8rem; padding: .5rem .75rem; }
  .data-table td { font-size: .82rem; padding: .5rem .75rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .footer-links a { font-size: .78rem; }
  .site-footer { padding: 1.5rem 0 1rem; }
  .breadcrumb { font-size: .8rem; flex-wrap: wrap; }
  /* Modal — higher specificity (.modal-overlay .modal) beats base .modal */
  .modal-overlay {
    align-items: flex-start;
    padding: 1.25rem .75rem 2rem;
  }
  .modal-overlay .modal {
    padding: 1.25rem 1rem;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: var(--radius);
    transform: none !important;
  }
  .modal-title { font-size: 1.3rem; }
  .modal-score { font-size: 2rem; }
  .modal-stats { gap: 1rem; margin: .75rem 0 1.25rem; flex-wrap: wrap; justify-content: center; }
  .modal-stat-val { font-size: 1.1rem; }
  .modal-icon { font-size: 2.25rem; margin-bottom: .75rem; }
  .modal-icon svg { width: 48px; height: 48px; }
}
