/* Daily Sudoku — Editorial Print Aesthetic */

:root {
  /* Editorial Color Palette (Light Theme) */
  --bg: #fdfcf9;
  /* Soft newspaper off-white */
  --bg-soft: #f4f1eb;
  /* Slightly darker newsprint */
  --fg: #1a1a1a;
  /* Deep ink black */
  --fg-soft: #54514d;
  /* Faded ink */

  --accent: #d9381e;
  /* Editorial vermilion / editorial red */
  --accent-soft: rgba(217, 56, 30, 0.1);
  --accent-hover: #b92b15;
  --accent-fg: #ffffff;
  /* Always reads on top of --accent */

  --border: #d4cfc5;
  /* Soft pencil line */
  --border-strong: #1a1a1a;
  /* Thick ink line */
  --cell-border: #c9c2b3;
  /* Slightly stronger than --border for the puzzle grid */

  --given-bg: transparent;
  /* No background for givens in print, we'll use font weight/style */
  --error-bg: #ffeded;
  --error-fg: #d9381e;
  --highlight: #fcf1cd;
  /* Yellow highlighter */
  --warn: #d97706;
  /* Amber for callout.warn */

  --shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  --radius: 0px;
  /* Sharp corners for editorial feel */

  /* Typography */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "DM Sans", -apple-system, sans-serif;
  --font-numbers: "Lora", Georgia, serif;
  --mono: "DM Sans", ui-monospace, monospace;
}

/* Dark Theme Variables */
[data-theme='dark'] {
  --bg: #111111;
  /* Charcoal, not pure black */
  --bg-soft: #1a1a1a;
  --fg: #eae8e1;
  --fg-soft: #a8a49c;
  --accent: #f0533a;
  /* Brighter vermilion for dark mode */
  --accent-soft: rgba(240, 83, 58, 0.15);
  --border: #333333;
  --border-strong: #eae8e1;
  --cell-border: #444444;
  --error-bg: #4a1c1c;
  --error-fg: #ff8a8a;
  --highlight: #453b1b;
  --warn: #f59e0b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111111;
    --bg-soft: #1a1a1a;
    --fg: #eae8e1;
    --fg-soft: #a8a49c;
    --accent: #f0533a;
    --accent-soft: rgba(240, 83, 58, 0.15);
    --border: #333333;
    --border-strong: #eae8e1;
    --cell-border: #444444;
    --error-bg: #4a1c1c;
    --error-fg: #ff8a8a;
    --highlight: #453b1b;
    --warn: #f59e0b;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -19px -19px;
}

/* Subtle page wrapper for the main content to sit on */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem;
}

@media (max-width: 600px) {
  .container {
    padding: 0 0.75rem;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-top: 0;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease, text-decoration-thickness 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: .5rem 1rem;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
}

/* ---- Header ---- */
.site-header {
  background: var(--bg);
  border-bottom: 2px solid var(--border-strong);
  margin-bottom: 1.5rem;
  /* Reduced from 3rem */
  padding: 0.5rem 0;
  /* Reduced from 1rem */
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo-group {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.5rem;
  /* Reduced from 2rem */
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--fg);
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.header-archive-link {
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
  margin-left: auto;
}

.header-archive-link:hover,
.header-archive-link:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.home-hero {
  margin-top: -0.75rem;
  margin-bottom: 0.5rem !important;
  padding-bottom: 0.25rem !important;
}

.home-hero .hero-header {
  gap: 0.5rem;
  padding-bottom: 0.125rem;
}

.home-puzzle .sudoku-wrap {
  gap: 1rem;
  margin-bottom: 1rem;
}

.lang-switcher {
  display: flex;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
}

.lang-switcher a {
  color: var(--fg-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.lang-switcher a:hover {
  color: var(--accent);
}

.lang-switcher a.active {
  color: var(--fg);
  font-weight: 700;
  border-bottom-color: var(--fg);
}

.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

/* Reduced gap */
.primary-nav a {
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  /* Reduced from 0.85rem */
  color: var(--fg);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.primary-nav a:hover,
.primary-nav a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  padding: 0.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: var(--radius);
}

.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.theme-toggle .sun {
  display: block;
}

.theme-toggle .moon {
  display: none;
}

[data-theme='dark'] .theme-toggle .sun {
  display: none;
}

[data-theme='dark'] .theme-toggle .moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .sun {
    display: none;
  }

  :root:not([data-theme='light']) .theme-toggle .moon {
    display: block;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.lang-toggle:hover,
.lang-toggle:focus-visible {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.lang-toggle[aria-current="page"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  cursor: default;
}

.lang-toggle[aria-current="page"]:hover,
.lang-toggle[aria-current="page"]:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.lang-toggle .lang-short {
  display: none;
}

@media (max-width: 480px) {
  .lang-picker {
    gap: 0.25rem;
  }
  .lang-toggle {
    padding: 0.3rem 0.45rem;
    font-size: 0.8rem;
  }
  .lang-toggle .lang-full {
    display: none;
  }
  .lang-toggle .lang-short {
    display: inline;
  }
}

@media (max-width: 768px) {
  .header-actions {
    order: 1;
  }
}

.logo {
  font-size: 1.25rem;
}

.site-header {
  margin-bottom: 1rem;
}

.nav-toggle {
  display: inline-block;
  min-height: 36px;
  padding: .25rem .75rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: uppercase;
}

.primary-nav {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin-top: 1rem;
}

.primary-nav a {
  width: 100%;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.primary-nav.open {
  display: flex;
}
}

/* ---- Hero & copy ---- */
.hero {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  position: relative;
}

.hero.compact-hero {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.hero.compact-hero::after {
  display: none;
  /* Remove underline for compactness */
}

.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 768px) {
  .hero-header {
    flex-direction: column;
    justify-content: center;
  }
}

.hero h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  /* Significantly reduced */
  font-style: italic;
  font-weight: 400;
  margin-bottom: 0;
  /* Removed margin */
  text-align: left;
}

.hero h1 span {
  font-style: normal;
  color: var(--border);
}

.hero h1 em {
  font-style: normal;
  font-weight: 700;
}

/* Label + difficulty selector wrapper */
.diff-row {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-soft);
}

@media (max-width: 600px) {
  .diff-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
  }

  .diff-label {
    text-align: center;
  }
}

/* Redesigned Difficulty Pills (Editorial Style) */
.diff-pills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--border-strong);
  width: fit-content;
}

.diff-pills li {
  border-right: 1px solid var(--border-strong);
}

.diff-pills li:last-child {
  border-right: none;
}

.diff-pills a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  /* Reduced from 44px */
  padding: 0 1rem;
  /* Reduced from 1.5rem */
  text-decoration: none;
  color: var(--fg);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.75rem;
  /* Reduced */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.diff-pills a:hover {
  background: var(--bg-soft);
  color: var(--accent);
  text-decoration: none;
}

.diff-pills .current a {
  background: var(--fg);
  color: var(--bg);
}

@media (max-width: 600px) {
  .diff-pills {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .diff-pills li {
    border-right: none;
    border-bottom: 1px solid var(--border-strong);
  }

  .diff-pills li:last-child {
    border-bottom: none;
  }

  .diff-pills a {
    width: 100%;
    min-height: 44px;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
  }
}

/* ---- Sudoku grid - The Star of the Show ---- */
.sudoku-wrap {
  display: grid;
  gap: 1.5rem;
  /* Reduced from 3rem */
  grid-template-columns: 1fr;
  align-items: start;
  margin-bottom: 2rem;
  /* Reduced from 4rem */
}

@media (min-width: 900px) {
  .sudoku-wrap {
    grid-template-columns: minmax(350px, 500px) 250px;
    /* Tighter layout */
    justify-content: center;
  }
}

.sudoku {
  display: grid;
  grid-template: repeat(9, 1fr) / 1fr;
  width: 100%;
  max-width: 500px;
  /* Reduced max-width slightly to ensure it fits vertically */
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--border-strong);
  background: var(--bg);
  user-select: none;
}

.sudoku-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4vw, 1.75rem);
  /* Slightly smaller numbers */
  background: transparent;
  border: 1px solid var(--cell-border);
  border-top: none;
  border-left: none;
  color: var(--fg);
  cursor: pointer;
  font-family: var(--font-numbers);
  font-weight: 400;
  padding: 0;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  transition: background-color 0.15s ease;
}

/* Given numbers are heavy black */
.cell.given {
  color: var(--fg);
  font-weight: 700;
  cursor: default;
}

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}

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

.cell.related {
  background: var(--accent-soft);
}

.cell.error {
  background: var(--error-bg);
  color: var(--error-fg);
  font-weight: 700;
}

.cell.hint {
  background: var(--highlight);
  color: var(--accent);
  font-weight: 700;
}

/* The 3x3 Box Borders - Thick Ink */
.cell.border-right {
  border-right: 2px solid var(--border-strong);
}

.cell.border-bottom {
  border-bottom: 2px solid var(--border-strong);
}

.sudoku-row .cell:nth-child(9n) {
  border-right: none;
}

.sudoku-row:last-child .cell {
  border-bottom: none;
}

/* Scale animation when user places a number */
@keyframes placeNumber {
  0% {
    transform: scale(1.5);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.cell:not(.given) span.val {
  display: block;
  animation: placeNumber 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Pencil marks */
.cell .pencil {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: 0.35em;
  color: var(--fg-soft);
  pointer-events: none;
  font-family: var(--font-body);
  font-weight: 500;
}

.cell.has-value .pencil {
  display: none;
}

/* ---- Controls Panel ---- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* Tightened gap */
  padding: 1rem;
  /* Tightened padding */
  background: var(--bg);
  border: 1px solid var(--border-strong);
  position: relative;
}

/* Decorative pin lines */
.controls::before,
.controls::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 1px;
  background: var(--border);
  left: 0;
}

.controls::before {
  top: 4px;
}

.controls::after {
  bottom: 4px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--border-strong);
}

.keypad .key {
  min-height: 48px;
  /* Reduced from 60px */
  padding: 0;
  font-size: 1.25rem;
  font-family: var(--font-numbers);
  font-weight: 400;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.1s ease;
}

.keypad .key:hover,
.keypad .key:focus-visible {
  background: var(--fg);
  color: var(--bg);
}

.keypad .key:active {
  transform: scale(0.95);
}

.keypad .key-erase {
  grid-column: span 3;
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--accent);
  min-height: 36px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Made actions a 2-col grid to save vertical space */
.actions button {
  min-height: 36px;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.actions button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

#btn-pencil {
  justify-content: flex-start;
  gap: 0.4rem;
}

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

.pencil-action-label {
  flex: 1;
  text-align: left;
}

.pencil-action-state {
  min-width: 2.4rem;
  padding: 0.18rem 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  font-size: 0.65rem;
  line-height: 1;
  text-align: center;
  letter-spacing: 0.08em;
}

.actions button:hover,
.actions button:focus-visible {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.solved-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  border-left: 4px solid var(--accent);
}

.solved-banner strong {
  font-weight: 700;
}

.solved-banner span {
  font-family: var(--mono);
  letter-spacing: 0;
}

.check-banner {
  padding: 0.6rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-left: 4px solid;
}

.check-banner.check-clean {
  background: var(--bg-soft);
  color: var(--fg);
  border-left-color: var(--fg);
}

.check-banner.check-errors {
  background: var(--error-bg);
  color: var(--error-fg);
  border-left-color: var(--error-fg);
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-family: var(--mono);
  color: var(--fg);
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 0.65rem;
  margin-top: 0.5rem;
}

.timer-card {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: var(--fg);
  line-height: 1;
}

.timer-face {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 auto;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--accent) 0 0.16rem, transparent 0.18rem),
    conic-gradient(from -90deg, var(--accent) 0 8deg, transparent 8deg 30deg, var(--border) 30deg 32deg, transparent 32deg 60deg, var(--border) 60deg 62deg, transparent 62deg 90deg, var(--border-strong) 90deg 93deg, transparent 93deg 120deg, var(--border) 120deg 122deg, transparent 122deg 150deg, var(--border) 150deg 152deg, transparent 152deg 180deg, var(--border-strong) 180deg 183deg, transparent 183deg 210deg, var(--border) 210deg 212deg, transparent 212deg 240deg, var(--border) 240deg 242deg, transparent 242deg 270deg, var(--border-strong) 270deg 273deg, transparent 273deg 300deg, var(--border) 300deg 302deg, transparent 302deg 330deg, var(--border) 330deg 332deg, transparent 332deg 360deg),
    var(--bg);
  box-shadow: inset 0 0 0 0.28rem var(--bg-soft);
}

.timer-hand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 0.74rem;
  background: var(--accent);
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
  animation: timerSweep 60s steps(60, end) infinite;
}

.timer-hand::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.timer-card.paused .timer-hand {
  animation-play-state: paused;
}

.timer {
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

@keyframes timerSweep {
  to {
    transform: translate(-50%, -100%) rotate(360deg);
  }
}

.print-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1;
  width: fit-content;
  margin-top: -0.25rem;
}

.print-link svg {
  flex: none;
}

.print-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---- Archive / Typography Content ---- */
.copy {
  max-width: 65ch;
  margin: 0 auto;
  font-size: 1.1rem;
}

.copy h2 {
  font-size: 2rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 0.5rem;
  margin-top: 3rem;
}

.archive-list {
  list-style: none;
  padding: 0;
  columns: 1;
  column-gap: 2rem;
}

@media (min-width: 600px) {
  .archive-list {
    columns: 2;
  }
}

@media (min-width: 900px) {
  .archive-list {
    columns: 3;
  }
}

.archive-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  break-inside: avoid;
}

.archive-list a {
  display: block;
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--fg);
  text-decoration: none;
}

.archive-list a:hover {
  color: var(--accent);
  padding-left: 0.5rem;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}

.month-nav h1 {
  margin: 0;
  font-size: 2rem;
}

.day-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-top: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
}

.day-grid li {
  aspect-ratio: 1;
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-numbers);
  font-size: 1.25rem;
}

.day-grid li.has {
  background: var(--bg-soft);
}

.day-grid li.has:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.day-grid li.has:hover a {
  color: var(--accent-fg);
}

.day-grid li a {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--fg);
}

.day-difficulties {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 3rem;
}

@media (min-width: 720px) {
  .day-difficulties {
    grid-template-columns: repeat(2, 1fr);
  }
}

.day-difficulties li {
  border-top: 4px solid var(--border-strong);
  padding-top: 1rem;
}

.day-difficulties h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  text-transform: capitalize;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  min-height: 48px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  border: 1px solid var(--fg);
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
}

.btn-secondary:hover {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-print {
  gap: 0.6rem;
}

.btn-print svg {
  flex: none;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 4px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
  margin-top: 5rem;
  padding: 3rem 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.site-footer a {
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-footer p {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--fg-soft);
}

/* ---- Cookie consent ---- */
.cookie-banner {
  position: fixed;
  inset: auto 1rem 1rem 1rem;
  z-index: 90;
  color: var(--fg);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner__body {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--bg);
  border: 2px solid var(--border-strong);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.cookie-banner h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.cookie-banner p {
  margin: 0;
  color: var(--fg-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.cookie-banner__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cookie-banner__actions .btn {
  min-height: 40px;
  padding: 0 1rem;
  cursor: pointer;
}

@media (max-width: 760px) {
  .cookie-banner {
    inset: auto 0.75rem 0.75rem 0.75rem;
  }

  .cookie-banner__body {
    grid-template-columns: 1fr;
  }

  .cookie-banner__actions {
    justify-content: stretch;
  }

  .cookie-banner__actions .btn {
    flex: 1 1 100%;
  }
}

/* ---- Content pages ---- */
.content-page {
  padding: 2rem 0;
  max-width: 70ch;
  margin: 0 auto;
  font-size: 1.1rem;
}

.content-page h1 {
  font-size: 3rem;
  margin: 0 0 1.5rem;
  text-align: center;
}

.content-page h2 {
  margin-top: 3rem;
  font-size: 2rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 0.5rem;
}

.content-page h3 {
  margin-top: 2rem;
  font-size: 1.5rem;
}

.content-page p {
  margin-bottom: 1.5rem;
}

.content-page li {
  margin-bottom: 0.5rem;
}

.callout {
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  padding: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
}

.callout h3 {
  margin-top: 0;
  font-style: normal;
  font-size: 1.25rem;
}

.callout.warn {
  border-left-color: var(--warn);
}

/* ---- Page headers (shared across content/puzzle pages) ---- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-strong);
  text-align: center;
}

.page-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.5rem;
}

.page-header p {
  color: var(--fg-soft);
  margin: 0;
}

.page-header .subtitle {
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  color: var(--fg-soft);
  margin: 0;
}

/* ---- Prose (long-form text inside content pages) ---- */
.prose {
  font-size: 1.1rem;
  line-height: 1.7;
}

.prose h2 {
  margin-top: 3rem;
  font-size: 1.75rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 0.5rem;
}

.prose h3 {
  margin-top: 2rem;
  font-size: 1.25rem;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose strong {
  font-weight: 700;
  color: var(--fg);
}

/* ---- Card grid (techniques, variants hubs) ---- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 2rem 0;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  text-decoration: none;
  color: var(--fg);
  transition: all 0.15s ease;
  position: relative;
}

.card:hover,
.card:focus-visible {
  background: var(--bg-soft);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--accent);
  text-decoration: none;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--fg);
}

.card p {
  margin: 0;
  color: var(--fg-soft);
  font-size: 0.95rem;
}

/* ---- FAQ ---- */
.faq-list {
  margin: 2rem 0;
}

.faq-item {
  border-top: 1px solid var(--border-strong);
  padding: 1rem 0;
}

.faq-item:last-child {
  border-bottom: 1px solid var(--border-strong);
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item summary h2 {
  display: inline;
  margin: 0;
  font-size: 1.1rem;
  font-family: var(--font-body);
  font-weight: 600;
}

.faq-item p {
  margin: 1rem 0 0;
  color: var(--fg-soft);
  font-size: 1rem;
  line-height: 1.6;
}

/* ---- Puzzle page chrome ---- */
.puzzle-container {
  margin: 0 auto;
}

.puzzle-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.puzzle-header h1 {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-style: italic;
  font-weight: 400;
  margin: 0 0 0.75rem;
}

/* Difficulty pill (single badge for current puzzle) */
.difficulty-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
}

.difficulty-badge.badge-very-easy {
  background: var(--bg-soft);
}

.difficulty-badge.badge-easy {
  background: var(--bg-soft);
}

.difficulty-badge.badge-medium {
  background: var(--fg);
  color: var(--bg);
}

.difficulty-badge.badge-hard {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.difficulty-badge.badge-very-hard {
  background: var(--fg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Difficulty selector (segmented control, used on /daily/[date]) */
.difficulty-controls {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-strong);
  margin-top: 0.5rem;
}

.difficulty-controls a {
  padding: 0.4rem 0.9rem;
  border-right: 1px solid var(--border-strong);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--fg);
  background: var(--bg);
  transition: background 0.15s ease;
}

.difficulty-controls a:last-child {
  border-right: none;
}

.difficulty-controls a:hover {
  background: var(--bg-soft);
  color: var(--accent);
}

.difficulty-controls a.active {
  background: var(--fg);
  color: var(--bg);
}

@media (max-width: 600px) {
  .difficulty-controls {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .difficulty-controls a {
    border-right: none;
    border-bottom: 1px solid var(--border-strong);
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    text-align: center;
  }

  .difficulty-controls a:last-child {
    border-bottom: none;
  }
}

/* ---- Archive (used by archive/index and month pages) ---- */
.archive-month {
  margin-bottom: 2.5rem;
  break-inside: avoid;
}

.archive-month h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 0.4rem;
  margin: 0 0 0.75rem;
}

.archive-month h2 a {
  color: var(--fg);
  text-decoration: none;
}

.archive-month h2 a:hover {
  color: var(--accent);
}

.date-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.date-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.date-list li:last-child {
  border-bottom: none;
}

.date-list a {
  display: block;
  color: var(--fg);
  text-decoration: none;
}

.date-list a:hover {
  color: var(--accent);
  padding-left: 0.5rem;
}

/* ---- Print page (screen view) ---- */
.print-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 0;
}

.print-head {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-strong);
}

.print-head h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 0.5rem;
}

.print-head p {
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-soft);
  margin: 0;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--border-strong);
}

.print-grid .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-numbers);
  font-size: clamp(1rem, 4vw, 2rem);
  color: var(--fg);
  border: 1px solid var(--border);
  border-top: none;
  border-left: none;
  aspect-ratio: 1 / 1;
}

.print-grid .cell:nth-child(9n) {
  border-right: none;
}

.print-grid .cell:nth-child(n+73) {
  border-bottom: none;
}

.print-grid .cell.border-right {
  border-right: 2px solid var(--border-strong);
}

.print-grid .cell.border-bottom {
  border-bottom: 2px solid var(--border-strong);
}

.print-footer {
  text-align: center;
  margin-top: 2rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-soft);
}

.print-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ---- Print ---- */
@page {
  size: letter;
  margin: 0.6in;
}

@media print {
  body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
  }

  .site-header,
  .site-footer,
  .cookie-banner,
  .controls,
  .no-print,
  .hero,
  .diff-row,
  .difficulty-controls,
  .puzzle-nav,
  .puzzle-controls {
    display: none !important;
  }

  .container {
    padding: 0;
    margin: 0;
    max-width: 100%;
  }

  /* Grid: explicit size so we never rely on aspect-ratio in print */
  .sudoku,
  .print-grid {
    display: grid !important;
    grid-template: repeat(9, 1fr) / 1fr !important;
    width: 6in !important;
    height: 6in !important;
    max-width: 6in !important;
    margin: 0 auto !important;
    border: 2.5pt solid #000 !important;
    box-shadow: none !important;
    background: #fff !important;
    aspect-ratio: auto !important;
  }

  .sudoku-row {
    display: grid !important;
    grid-template-columns: repeat(9, 1fr) !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }

  .print-grid {
    grid-template: repeat(9, 1fr) / repeat(9, 1fr) !important;
  }

  .sudoku .cell,
  .print-grid .cell {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    aspect-ratio: auto !important;
    border: 0.5pt solid #555 !important;
    border-top: none !important;
    border-left: none !important;
    color: #000 !important;
    background: #fff !important;
    font-family: "Lora", Georgia, serif !important;
    font-weight: 500 !important;
    font-size: 20pt !important;
    cursor: default !important;
    padding: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    transition: none !important;
  }

  .sudoku .cell.border-right,
  .print-grid .cell.border-right {
    border-right: 1.5pt solid #000 !important;
  }

  .sudoku .cell.border-bottom,
  .print-grid .cell.border-bottom {
    border-bottom: 1.5pt solid #000 !important;
  }

  .sudoku-row .cell:nth-child(9n),
  .print-grid .cell:nth-child(9n) {
    border-right: none !important;
  }

  .sudoku-row:last-child .cell,
  .print-grid .cell:nth-child(n+73) {
    border-bottom: none !important;
  }

  /* Pencil marks: hide in print */
  .cell .pencil {
    display: none !important;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  .print-page {
    padding: 0;
  }

  .print-head {
    text-align: center;
    margin: 0 0 0.4in;
    border-bottom: 0.5pt solid #000;
    padding-bottom: 0.15in;
  }

  .print-head h1 {
    font-size: 24pt;
    margin: 0 0 0.1in;
    font-family: "Playfair Display", Georgia, serif;
  }

  .print-head p {
    font-family: "DM Sans", sans-serif;
    font-size: 10pt;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
  }

  .print-footer {
    text-align: center;
    margin-top: 0.3in;
    font-size: 9pt;
    letter-spacing: 0.15em;
  }
}