:root {
  --paper: #f3ead7;
  --paper-deep: #ded0b6;
  --ink: #171711;
  --red: #ef3f2f;
  --yellow: #f6c945;
  --green: #1f5a46;
  --tile: #fff8e9;
  --line: 2px solid var(--ink);
  --shadow: 7px 7px 0 var(--ink);
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(23, 23, 17, 0.035) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(rgba(23, 23, 17, 0.035) 1px, transparent 1px) 0 0 / 26px 26px,
    var(--paper);
}
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.site-header {
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 34px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Archivo Black", sans-serif;
  font-size: 0.78rem;
  line-height: 0.9;
  text-decoration: none;
  letter-spacing: -0.04em;
}
.wordmark-number {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  background: var(--red);
  border: var(--line);
  color: var(--paper);
  font-size: 1.45rem;
}
.site-header nav { display: flex; gap: 30px; }
.site-header nav a {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

main, footer { max-width: 1320px; margin: 0 auto; }
.hero {
  min-height: 720px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.88fr);
  gap: clamp(44px, 7vw, 110px);
  align-items: center;
  padding: clamp(60px, 8vw, 110px) 34px;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.eyebrow span { width: 30px; height: 3px; background: var(--red); }
h1, h2, h3 { font-family: "Archivo Black", sans-serif; text-transform: uppercase; }
h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3.5rem, 7.2vw, 7.25rem);
  line-height: 0.84;
  letter-spacing: -0.075em;
}
h1 em { color: var(--red); font-style: normal; }
.intro {
  max-width: 620px;
  margin: 32px 0 36px;
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.75;
}
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 620px;
  border: var(--line);
  box-shadow: 5px 5px 0 var(--ink);
}
.mode-switch button {
  padding: 16px;
  border: 0;
  background: var(--tile);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.mode-switch button + button { border-left: var(--line); }
.mode-switch button.is-active { background: var(--yellow); }
.mode-switch small { display: block; margin-top: 5px; font-size: 0.63rem; font-weight: 400; }
.size-switch { display: flex; align-items: center; gap: 8px; margin-top: 22px; }
.size-switch span { margin-right: 8px; font-size: 0.72rem; text-transform: uppercase; font-weight: 600; }
.size-switch button {
  min-width: 54px;
  padding: 8px 10px;
  border: var(--line);
  background: transparent;
  cursor: pointer;
}
.size-switch button.is-active { background: var(--ink); color: var(--paper); }

.game-shell { position: relative; }
.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 12px;
  border: var(--line);
  background: var(--ink);
  color: var(--paper);
}
.scoreboard div { padding: 11px 14px; }
.scoreboard div + div { border-left: 1px solid rgba(243, 234, 215, 0.3); }
.scoreboard span, .win-stats span { display: block; font-size: 0.6rem; text-transform: uppercase; opacity: 0.72; }
.scoreboard strong { display: block; margin-top: 3px; font-size: clamp(0.95rem, 2vw, 1.22rem); }
.board-frame {
  position: relative;
  padding: clamp(10px, 1.3vw, 16px);
  border: 3px solid var(--ink);
  background: var(--red);
  box-shadow: var(--shadow);
}
.puzzle-board {
  --size: 4;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: clamp(5px, 0.8vw, 9px);
  aspect-ratio: 1;
  padding: clamp(6px, 1vw, 10px);
  background: var(--ink);
  overflow: hidden;
}
.tile, .empty-tile { min-width: 0; aspect-ratio: 1; }
.tile {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 1px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.7), transparent 40%),
    var(--tile);
  box-shadow: inset -4px -4px 0 var(--paper-deep);
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(1.15rem, calc(4.2rem / var(--size) * 2), 3rem);
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}
.tile:hover { filter: brightness(1.05); transform: translateY(-2px); }
.tile:focus-visible { outline: 4px solid var(--yellow); outline-offset: -6px; }
.empty-tile { background: rgba(255,255,255,0.05); }
.pause-screen {
  position: absolute;
  inset: 16px;
  display: none;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(2rem, 6vw, 5rem);
  letter-spacing: -0.05em;
}
.puzzle-board.is-paused + .pause-screen { display: grid; }
.puzzle-board.nudge { animation: nudge 180ms linear; }
@keyframes nudge { 30% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }

.game-actions { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: 8px; margin-top: 20px; }
.game-actions button, .action-primary {
  min-height: 44px;
  padding: 10px;
  border: var(--line);
  background: var(--tile);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
}
.game-actions button:hover, .action-primary:hover { background: var(--yellow); }
.game-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.game-actions .action-primary, .action-primary { background: var(--green); color: white; }
.keyboard-hint { margin: 14px 0 0; font-size: 0.67rem; line-height: 1.5; opacity: 0.72; }

.ad-slot {
  margin: 0 34px;
  border: 1px dashed rgba(23, 23, 17, 0.35);
  display: grid;
  place-items: center;
  align-content: center;
  color: rgba(23, 23, 17, 0.55);
  text-align: center;
}
.ad-slot-wide { min-height: 118px; }
.ad-slot span { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.12em; }
.ad-slot p { margin: 5px 0 0; font-size: 0.64rem; }

.content-grid {
  display: grid;
  grid-template-columns: 100px 0.8fr 1.6fr;
  gap: 38px;
  padding: 130px 34px;
  border-bottom: var(--line);
}
.section-number { font-family: "Archivo Black", sans-serif; font-size: 3.4rem; color: var(--red); }
h2 { margin: 0; font-size: clamp(2.5rem, 5vw, 5rem); line-height: 0.95; letter-spacing: -0.06em; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps article { min-height: 260px; padding: 24px; border: var(--line); background: var(--tile); }
.steps article:nth-child(2) { transform: translateY(24px); background: var(--yellow); }
.steps strong { font-family: "Archivo Black", sans-serif; color: var(--red); }
.steps h3 { margin: 56px 0 12px; font-size: 1.15rem; }
.steps p, .strategy p, .faq p { font-size: 0.82rem; line-height: 1.7; }

.strategy {
  display: grid;
  grid-template-columns: 1.5fr 0.75fr;
  gap: 24px;
  padding: 110px 34px;
  background: var(--ink);
  color: var(--paper);
}
.strategy-card { max-width: 800px; }
.strategy-card h2 { margin-bottom: 30px; }
.strategy-card > p { max-width: 650px; }
.strategy-card ul { display: grid; gap: 10px; padding: 0; margin: 34px 0 0; list-style: none; }
.strategy-card li::before { content: "→"; margin-right: 12px; color: var(--yellow); }
.solvable-note {
  align-self: center;
  padding: 34px;
  border: 2px solid var(--paper);
  color: var(--paper);
}
.giant-number { display: block; font-family: "Archivo Black", sans-serif; font-size: clamp(3.5rem, 7vw, 7rem); color: var(--yellow); letter-spacing: -0.08em; }
.solvable-note strong { text-transform: uppercase; }

.faq { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: 70px; padding: 120px 34px; }
.faq-list { border-top: var(--line); }
details { border-bottom: var(--line); }
summary { padding: 24px 4px; font-weight: 600; cursor: pointer; }
details p { max-width: 700px; padding: 0 4px 24px; margin: 0; }
.ad-slot-footer { min-height: 220px; margin-bottom: 80px; }

footer {
  display: grid;
  grid-template-columns: 1fr 2fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 40px 34px;
  border-top: var(--line);
  font-size: 0.67rem;
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { text-underline-offset: 4px; }
.copyright { text-align: right; }
.wordmark.compact .wordmark-number { width: 38px; font-size: 1.05rem; }

.legal-page {
  min-height: calc(100vh - 190px);
  padding: clamp(64px, 9vw, 120px) 34px;
}
.legal-page article { max-width: 820px; }
.legal-page h1 { margin-bottom: 36px; font-size: clamp(3rem, 7vw, 6rem); }
.legal-page h2 { margin: 46px 0 14px; font-size: clamp(1.45rem, 3vw, 2.2rem); letter-spacing: -0.04em; }
.legal-page p, .legal-page li { font-size: 0.9rem; line-height: 1.8; }
.legal-page .updated { margin-bottom: 32px; opacity: 0.65; }

.win-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 34px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--red);
}
.win-dialog::backdrop { background: rgba(23, 23, 17, 0.72); }
.win-dialog h2 { font-size: clamp(2rem, 6vw, 3.8rem); }
.dialog-close { position: absolute; top: 12px; right: 12px; border: 0; background: none; font-size: 2rem; cursor: pointer; }
.win-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 28px 0; }
.win-stats div { padding: 18px; border: var(--line); background: var(--tile); }
.win-stats strong { display: block; margin-top: 5px; font-size: 1.3rem; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  padding: 12px 18px;
  border: var(--line);
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .game-shell { width: min(620px, 100%); }
  .content-grid { grid-template-columns: 70px 1fr; }
  .steps { grid-column: 2; }
  .strategy, .faq { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .site-header { padding: 18px; }
  .site-header nav { display: none; }
  .hero { padding: 54px 18px 74px; gap: 48px; }
  h1 { font-size: clamp(3.15rem, 17vw, 5rem); }
  .mode-switch { grid-template-columns: 1fr; }
  .mode-switch button + button { border-left: 0; border-top: var(--line); }
  .game-actions { grid-template-columns: repeat(4, 1fr); }
  .game-actions .action-primary { grid-column: 1 / -1; }
  .ad-slot { margin-inline: 18px; }
  .content-grid { grid-template-columns: 1fr; padding: 90px 18px; }
  .section-number { font-size: 2rem; }
  .steps { grid-column: auto; grid-template-columns: 1fr; }
  .steps article { min-height: 190px; }
  .steps article:nth-child(2) { transform: none; }
  .steps h3 { margin-top: 28px; }
  .strategy, .faq { padding: 84px 18px; }
  .legal-page { padding: 64px 18px; }
  footer { grid-template-columns: 1fr; padding: 32px 18px; }
  .copyright { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
