@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600&family=Nunito:wght@400;700;800&family=DM+Mono:wght@400;500&display=swap");

:root {
  --ink: #262420;
  --paper: #fffdf6;
  --bg: #f6efe1;
  --muted: #6e6759;
  --line: #e6dfcb;
  --soft: #f4efe0;
  --cube-stage: #eeece5;
  --edge: rgba(38, 36, 32, .15);
  --blue: #2f5fe0;
  --blue-soft: #e4ecff;
  --yellow: #ffd21c;
  --yellow-soft: #fff3c2;
  --red: #ef3b33;
  --red-soft: #ffe4e0;
  --orange: #ff8a1e;
  --orange-soft: #ffe9d1;
  --green: #0aa968;
  --green-soft: #def4e8;
  --shadow-soft: none;
  --shadow-lift: none;
  --display: "Fredoka", "Nunito", sans-serif;
  --body: "Nunito", "Trebuchet MS", sans-serif;
  --mono: "DM Mono", "Courier New", monospace;
}

/* Layer tones: --tile is the sticker color of the layer being solved,
   --accent drives buttons and highlights, --accent-text stays readable on light backgrounds. */
[data-tone="start"] { --tile: var(--blue); --tile-ink: #fff; --accent: var(--blue); --accent-ink: #fff; --accent-soft: var(--blue-soft); --accent-text: var(--blue); }
[data-tone="white"] { --tile: #fff; --tile-ink: var(--ink); --accent: var(--blue); --accent-ink: #fff; --accent-soft: var(--blue-soft); --accent-text: var(--blue); }
[data-tone="flip"] { --tile: #fff; --tile-ink: var(--ink); --accent: var(--orange); --accent-ink: #fff; --accent-soft: var(--orange-soft); --accent-text: #cf6607; }
[data-tone="green"] { --tile: var(--green); --tile-ink: #fff; --accent: var(--green); --accent-ink: #fff; --accent-soft: var(--green-soft); --accent-text: #078252; }
[data-tone="yellow"] { --tile: var(--yellow); --tile-ink: var(--ink); --accent: var(--yellow); --accent-ink: var(--ink); --accent-soft: var(--yellow-soft); --accent-text: #93760a; }
[data-tone="finish"] { --tile: var(--ink); --tile-ink: #fff; --accent: var(--ink); --accent-ink: var(--paper); --accent-soft: #ece5d3; --accent-text: var(--ink); }

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button { color: inherit; font: inherit; }
a { color: inherit; }
::selection { background: var(--yellow); color: var(--ink); }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Header + step track ---------- */

.site-top {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid var(--edge);
  background: rgba(255, 253, 246, .94);
  backdrop-filter: blur(10px);
  transition: transform .2s ease;
}

/* The step tracker is for orientation, not for reading — once you're
   partway down a step actually solving, it's just competing for space.
   Scrolling down hides it; scrolling up (checking where you are) brings
   it right back. See the scroll listener in app.js. */
.site-top.is-hidden { transform: translateY(-100%); }

.site-header {
  display: flex;
  width: min(1160px, 100%);
  min-height: 52px;
  margin: 0 auto;
  padding: 6px 18px 0;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.wordmark {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
}

.wordmark__name {
  font: 600 19px/1 var(--display);
  letter-spacing: .01em;
}

.mini-cube {
  display: grid;
  width: 24px;
  height: 24px;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
  padding: 2.5px;
  border-radius: 6px;
  background: var(--ink);
  transform: rotate(-8deg);
}

.mini-cube i { border-radius: 1.5px; background: var(--green); }
.mini-cube i:nth-child(1), .mini-cube i:nth-child(6) { background: var(--yellow); }
.mini-cube i:nth-child(2), .mini-cube i:nth-child(7) { background: var(--red); }
.mini-cube i:nth-child(4), .mini-cube i:nth-child(9) { background: var(--blue); }
.mini-cube i:nth-child(5) { background: #fff; }
.mini-cube i:nth-child(8) { background: var(--orange); }

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.puzzle-select, .language-select {
  padding: 7px 26px 7px 12px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--paper);
  cursor: pointer;
  font: 800 12px/1 var(--body);
}

.puzzle-select { color: var(--blue); }

.track {
  display: flex;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 10px 18px 14px;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.track[hidden] { display: none; }

.track > :first-child { margin-left: auto; }
.track > :last-child { margin-right: auto; }

.chip {
  display: grid;
  flex: 0 0 auto;
  gap: 5px;
  justify-items: center;
  text-decoration: none;
}

.chip__tile {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--edge), 0 1px 3px rgba(38, 36, 32, .14);
  color: var(--ink);
  font: 600 15px/1 var(--display);
}

/* A quiet hint of which phase a step belongs to, echoing the hero fact
   pills — not a full-color fill, just enough to place it at a glance. */
.chip[data-tone="start"] .chip__tile { background: var(--blue-soft); }
.chip[data-tone="green"] .chip__tile { background: var(--green-soft); }
.chip[data-tone="yellow"] .chip__tile { background: var(--yellow-soft); }
.chip[data-tone="flip"] .chip__tile { background: var(--orange-soft); }
.chip__tile--flag {
  background: var(--paper);
}

.chip__tile--flag::before {
  content: "≡";
  font-size: 22px;
  line-height: 1;
}

.chip__label {
  max-width: 76px;
  color: var(--muted);
  font: 800 9.5px/1.25 var(--body);
  letter-spacing: .05em;
  text-align: center;
  text-transform: uppercase;
}

.chip[data-state="current"] .chip__tile {
  background: var(--ink);
  box-shadow: 0 0 0 4px #e5e0d5;
  color: var(--paper);
}

.chip[data-state="current"] .chip__label { color: var(--ink); }

.chip[data-state="done"] .chip__tile::after {
  content: "✓";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 800 8px/1 var(--body);
}

/* ---------- Panels ---------- */

main { padding: 26px 18px 90px; }

.panel {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.panel[hidden] { display: none !important; }

.kicker {
  margin: 0;
  color: var(--accent-text);
  font: 800 11px/1.4 var(--body);
  letter-spacing: .13em;
  text-transform: uppercase;
}

/* ---------- Start panel ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 30px;
  align-items: center;
  padding: 26px 0 14px;
}

.hero h1 {
  margin: 14px 0 18px;
  font: 600 clamp(44px, 7vw, 76px)/0.95 var(--display);
  letter-spacing: -.015em;
}

.hero h1 em { color: var(--accent-text); font-style: normal; }

.hero-summary {
  width: min(470px, 100%);
  margin: 0;
  color: var(--muted);
  font-size: 17.5px;
}

.hero-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

.fact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  font: 800 12px/1 var(--body);
}

.fact i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.hero-visual { position: relative; min-width: 0; }
.hero-visual svg { display: block; width: 100%; }

.hero-label {
  position: absolute;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  font: 800 10px/1 var(--body);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.hero-label--top { top: 5%; left: 44%; }
.hero-label--bottom { right: 3%; bottom: 9%; }

.learn {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 18px;
  margin-top: 28px;
}

.learn-card {
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.learn-card--net { grid-row: 1 / 3; }
.learn-card h2 { margin: 0 0 8px; font: 600 21px/1.1 var(--display); }
.learn-card > p { margin: 0; color: var(--muted); font-size: 14.5px; }

.two-intro {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 28px;
}

.two-recipes { display: grid; gap: 10px; margin-top: 12px; }
.two-recipes div { display: grid; gap: 4px; }
.two-recipes code { color: var(--blue); font: 500 15px/1.4 var(--mono); }
.two-recipes span { color: var(--muted); font-size: 13px; }

.net {
  display: grid;
  grid-template-areas: ". u . ." "l f r b" ". d . .";
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.net-card {
  position: relative;
  display: grid;
  min-height: 92px;
  align-content: end;
  padding: 12px 12px 10px;
  border-radius: 12px;
  background: var(--soft);
  overflow: hidden;
}

.net-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--face-color);
  box-shadow: inset 0 -1px 0 var(--edge);
}

.net-card b { font: 600 26px/1 var(--display); }
.net-card span { color: var(--muted); font: 800 10px/1.4 var(--body); letter-spacing: .08em; text-transform: uppercase; }
.net-card small { color: var(--muted); font-size: 11px; }
.net-card[data-face="u"] { grid-area: u; --face-color: var(--yellow); }
.net-card[data-face="l"] { grid-area: l; --face-color: var(--orange); }
.net-card[data-face="f"] { grid-area: f; --face-color: var(--green); }
.net-card[data-face="r"] { grid-area: r; --face-color: var(--red); }
.net-card[data-face="b"] { grid-area: b; --face-color: var(--blue); }
.net-card[data-face="d"] { grid-area: d; --face-color: #fff; }

.twists { display: grid; margin-top: 4px; }
.twists div {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 2px dashed var(--line);
}

.twists div:first-child { border-top: 0; }
.twists code { color: var(--blue); font: 500 24px/1 var(--mono); }
.twists p { margin: 0; color: var(--muted); font-size: 14px; }

.rules {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rule;
}

.rules li {
  position: relative;
  padding: 10px 0 10px 41px;
  border-top: 2px dashed var(--line);
  color: var(--muted);
  counter-increment: rule;
  font-size: 14px;
}

.rules li:first-child { border-top: 0; }

.rules li::before {
  content: counter(rule);
  position: absolute;
  top: 12px;
  left: 0;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  font: 600 13px/1 var(--display);
  color: var(--ink);
}

.rules b { color: var(--ink); }

/* ---------- Step panels ---------- */

.step-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin: 8px 0 20px;
}

.step-badge {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 16px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--edge), var(--shadow-soft);
  color: var(--tile-ink);
  font: 600 26px/1 var(--display);
}

.step-badge--flag {
  background: var(--ink);
  color: var(--paper);
}

.step-badge--flag::before {
  content: "≡";
  font-size: 32px;
  line-height: 1;
}

.step-title .kicker { margin-bottom: 4px; }
.step-title h2 {
  margin: 0;
  font: 600 clamp(27px, 4.4vw, 42px)/1.02 var(--display);
  letter-spacing: -.01em;
}

.hold-pill {
  display: inline-flex;
  margin: 0;
  padding: 10px 17px;
  gap: 9px;
  align-items: center;
  border-radius: 999px;
  background: var(--soft);
  font: 700 13.5px/1.2 var(--body);
}

.hold-pill b { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; }

.hold-cube {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px var(--edge);
}

.hold-cube[data-hold="white-up"] { background: linear-gradient(180deg, #fff 50%, #c9c2ae 50%); }
.hold-cube[data-hold="yellow-up"] { background: linear-gradient(180deg, var(--yellow) 50%, #fff 50%); }

.step-body {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: 22px;
  align-items: start;
}

.guide-card {
  padding: 18px 20px 20px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.do-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: doer;
}

.do-list li {
  position: relative;
  padding: 11px 0 11px 42px;
  border-top: 2px dashed var(--line);
  color: var(--muted);
  counter-increment: doer;
  font-size: 15px;
  line-height: 1.5;
}

.do-list li:first-child { border-top: 0; padding-top: 2px; }

.do-list li::before {
  content: counter(doer);
  position: absolute;
  top: 12px;
  left: 0;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font: 600 13px/1 var(--display);
}

.do-list li:first-child::before { top: 3px; }

.do-list b, .do-list strong { color: var(--ink); }
.do-list em { color: var(--accent-text); font-style: normal; font-weight: 800; }

.check {
  display: block;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
  font-size: 14.5px;
  line-height: 1.5;
}

.check span {
  display: inline-block;
  margin: 0 8px 2px 0;
  padding: 4px 11px 5px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 800 10.5px/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.rescue { margin-top: 14px; }

.rescue summary {
  display: inline-flex;
  padding: 9px 17px;
  gap: 8px;
  align-items: center;
  border-radius: 999px;
  background: var(--soft);
  cursor: pointer;
  font: 800 13px/1 var(--body);
  list-style: none;
  user-select: none;
}

.rescue summary::-webkit-details-marker { display: none; }
.rescue summary::after { content: "+"; font: 600 15px/1 var(--display); }
.rescue[open] summary::after { content: "–"; }
.rescue summary:hover { box-shadow: var(--shadow-soft); }
.rescue p { margin: 12px 4px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.rescue strong { color: var(--ink); }

.heads-up {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
}

.heads-up b { display: block; color: var(--ink); font-size: 14.5px; line-height: 1.4; }
.heads-up p { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.pattern-key {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
}

.pattern-key > b { color: var(--muted); font: 600 15px/1 var(--display); }
.pattern-step { display: grid; gap: 5px; justify-items: center; }
.pattern-step small { color: var(--muted); font: 800 9.5px/1 var(--body); letter-spacing: .07em; text-transform: uppercase; }

.pattern {
  display: grid;
  width: 42px;
  height: 42px;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--ink);
}

.pattern i { border-radius: 2px; background: #cbc4af; }
.pattern[data-shape="dot"] i:nth-child(5),
.pattern[data-shape="l"] i:nth-child(2), .pattern[data-shape="l"] i:nth-child(4), .pattern[data-shape="l"] i:nth-child(5),
.pattern[data-shape="line"] i:nth-child(4), .pattern[data-shape="line"] i:nth-child(5), .pattern[data-shape="line"] i:nth-child(6),
.pattern[data-shape="cross"] i:nth-child(2), .pattern[data-shape="cross"] i:nth-child(4), .pattern[data-shape="cross"] i:nth-child(5),
.pattern[data-shape="cross"] i:nth-child(6), .pattern[data-shape="cross"] i:nth-child(8) { background: var(--yellow); }

.demo { min-width: 0; }

.example-note {
  margin: 11px 6px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.example-note code { font: 500 12px/1 var(--mono); }

/* ---------- Cube player ---------- */

.cube-example {
  padding: 13px 13px 15px;
  border-radius: 18px;
  background: var(--paper);
}

.cube-example__head {
  display: flex;
  min-height: 30px;
  margin-bottom: 7px;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.cube-example__variants { display: flex; flex-wrap: wrap; gap: 6px; }

.cube-example__variants button {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--edge);
  cursor: pointer;
  font: 800 12px/1 var(--body);
}

.cube-example__variants button[aria-pressed="true"] { background: var(--accent); box-shadow: none; color: var(--accent-ink); }
.cube-example__variants button:disabled { cursor: default; }

.cube-example__recipe {
  padding: 0;
  color: var(--accent-text);
  font: 800 11px/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cube-example__count { color: var(--muted); font: 500 12px/1 var(--mono); white-space: nowrap; }

.cube-example__algorithm {
  margin-bottom: 14px;
  padding: 10px 12px 11px;
  border-radius: 14px;
  background: rgba(255, 253, 246, .72);
}

.cube-example__algorithm-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--accent-text);
  font: 800 9px/1 var(--body);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.cube-example__algorithm-meta .cube-example__count {
  color: var(--muted);
  letter-spacing: 0;
}

.cube-example__moves {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 58px;
  margin-top: 7px;
}

.cube-example__moves button {
  display: grid;
  min-width: 54px;
  min-height: 58px;
  padding: 8px 11px 7px;
  gap: 2px;
  justify-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.cube-example__moves button b { font: 600 24px/1 var(--display); }
.cube-example__moves button i { color: var(--muted); font: 800 10px/1 var(--body); font-style: normal; }
.cube-example__moves button:hover:not(:disabled) { background: var(--soft); }
.cube-example__moves button:disabled { cursor: default; }
.cube-example__moves button[data-state="done"] { background: var(--ink); }
.cube-example__moves button[data-state="done"] b { color: var(--paper); }
.cube-example__moves button[data-state="done"] i { color: #b5ae9c; }

.cube-example__moves button[data-state="next"] {
  background: var(--accent-soft);
}

.cube-example__stage {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: var(--cube-stage);
}

.cube-example__stage svg {
  position: relative;
  display: block;
  width: 100%;
}

.cube-sticker {
  stroke: var(--cube-stage);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.turn-cue {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 10px;
  display: grid;
  gap: 3px;
  padding: 0;
  background: transparent;
}

.turn-cue b { font: 600 20px/1 var(--display); }
.turn-cue span { max-width: 150px; color: var(--muted); font: 800 9.5px/1.35 var(--body); letter-spacing: .04em; text-transform: uppercase; }

.face-inspect {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
  padding: 0;
  background: transparent;
}

.face-inspect > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font: 800 8.5px/1 var(--body);
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.face-inspect > div {
  display: grid;
  width: 58px;
  height: 58px;
  grid-template-columns: repeat(var(--face-size, 3), 1fr);
  gap: 2px;
  padding: 2px;
  border-radius: 7px;
  background: var(--ink);
}

.face-inspect i { display: block; border-radius: 2px; }

.face-key {
  position: absolute;
  z-index: 3;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  font: 600 11px/1 var(--display);
}

.face-key--u { top: 7%; left: 48%; }
.face-key--f { bottom: 9%; left: 13%; }
.face-key--r { right: 13%; bottom: 9%; }

.cube-example__transport {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  margin-top: 12px;
}

.cube-example__transport button {
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--soft);
  cursor: pointer;
  font: 600 16px/1 var(--display);
}

.cube-example__transport button:hover:not(:disabled) { background: #ebe4d0; }
.cube-example__transport button:disabled { cursor: default; opacity: .35; }
.cube-example__transport .player-play {
  background: var(--ink);
  box-shadow: var(--shadow-soft);
  color: var(--paper);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.cube-example__transport .player-play:hover:not(:disabled) { background: var(--ink); filter: brightness(1.08); }

.cube-example__caption { margin: 12px 3px 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cube-example__caption small { color: #9d9581; font-size: 11.5px; }

/* ---------- Flip panel ---------- */

.flip-card {
  width: min(720px, 100%);
  margin: 14px auto 0;
  padding: 30px clamp(18px, 5vw, 44px);
  border-radius: 22px;
  background: var(--paper);
  text-align: center;
}

.flip-card h2 {
  margin: 12px 0 14px;
  font: 600 clamp(32px, 5.5vw, 48px)/0.98 var(--display);
  letter-spacing: -.015em;
}

.flip-illustration {
  width: min(520px, 100%);
  margin: 24px auto 0;
}

.flip-illustration svg {
  display: block;
  width: 100%;
}

.flip-illustration figcaption {
  margin-top: 4px;
  color: var(--muted);
  font: 800 11px/1 var(--body);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.panel--flip .panel-nav { width: min(720px, 100%); margin-left: auto; margin-right: auto; }

/* ---------- Finish panel ---------- */

.cheat-card {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-lift);
}

.cheat-title {
  display: flex;
  padding-bottom: 12px;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid var(--ink);
  font: 800 12px/1.4 var(--body);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.cheat-title span { color: var(--ink); }
.cheat-card ol { margin: 0; padding: 0; list-style: none; }

.cheat-card li {
  display: grid;
  grid-template-columns: 40px 158px 1fr;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 2px dashed var(--line);
}

.cheat-card li:last-child { border-bottom: 0; }

.cheat-card li i {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--edge);
  color: var(--ink);
  font: 600 14px/1 var(--display);
  font-style: normal;
}

.cheat-card li[data-tone="flip"] i { background: var(--soft); }
.cheat-card li span { font: 800 13px/1.35 var(--body); }
.cheat-card li code { font: 500 14px/1.4 var(--mono); letter-spacing: -.02em; }

.finish-actions { margin-top: 22px; text-align: center; }

.print-button {
  padding: 12px 21px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  cursor: pointer;
  font: 600 15px/1 var(--display);
}

/* ---------- Panel navigation ---------- */

.panel-nav {
  display: flex;
  margin-top: 30px;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-nav--center { justify-content: center; margin-top: 34px; }

.panel-nav__next, .panel-nav__back {
  display: inline-block;
  text-decoration: none;
}

.panel-nav__next {
  padding: 14px 25px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 17px/1.2 var(--display);
}

/* Plain text, not a second pill — it only needs to be legible next to the
   one real button, not compete with it (or with the fixed bar behind it
   on mobile, which a paper-on-paper pill would disappear into). */
.panel-nav__back {
  padding: 12px 20px;
  color: var(--muted);
  font: 600 14.5px/1.2 var(--display);
}

.panel-nav__next:hover { filter: brightness(1.1); }
.panel-nav__back:hover { color: var(--ink); }

/* ---------- Responsive ---------- */

@media (max-width: 940px) {
  .step-body { grid-template-columns: 1fr; }
  /* Read the instructions once, then you're back for the cube every time —
     put the thing you actually use each visit first, with the explanation
     one scroll away instead of in front of it every single time. */
  .demo { order: -1; }
  .step-head { grid-template-columns: auto 1fr; }
  .hold-pill { grid-column: 1 / -1; justify-self: start; }
  .learn { grid-template-columns: 1fr; }
  .learn-card--net { grid-row: auto; }
  .two-intro { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 12px; text-align: center; }
  .hero-summary, .hero-facts { margin-left: auto; margin-right: auto; }
  .hero-facts { justify-content: center; }
  .hero-visual { width: min(400px, 100%); margin: 0 auto; }
  .chip__label { display: none; }
  .track { padding: 10px 14px 12px; gap: 11px; }
  .chip__tile { width: 42px; height: 42px; }

  /* Dock the primary back/next action at the thumb, instead of making it
     the reward for scrolling past the whole step. Only one panel is ever
     un-hidden at a time, so exactly one .panel-nav renders here. */
  main { padding-bottom: 108px; }

  .panel-nav {
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    background: rgba(255, 253, 246, .94);
    backdrop-filter: blur(10px);
    box-shadow: 0 -1px 0 var(--edge);
  }

  .panel-nav__back, .panel-nav__next {
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .panel-nav__next { flex-grow: 1; }
}

@media (max-width: 560px) {
  body { font-size: 15.5px; }
  main { padding: 18px 12px 104px; }
  .site-header { padding: 6px 12px 0; }
  .step-badge { width: 47px; height: 47px; border-radius: 13px; font-size: 21px; }
  .step-head { gap: 12px; }
  .hold-pill { font-size: 12.5px; }
  .guide-card { padding: 15px 15px 17px; }
  .do-list li { font-size: 14px; }
  .net { gap: 5px; }
  .net-card { min-height: 78px; padding: 9px 9px 8px; }
  .net-card b { font-size: 21px; }
  .net-card small { display: none; }
  .face-key { display: none; }
  .turn-cue b { font-size: 17px; }
  .cheat-card { padding: 15px; }
  .cheat-title b { display: none; }
  .cheat-card li { grid-template-columns: 34px 1fr; }
  .cheat-card li i { grid-row: 1 / 3; }
  .cheat-card li code { grid-column: 2; font-size: 12px; }
  .panel-nav__next { padding: 12px 19px; font-size: 15px; }
  .panel-nav__back { padding: 10px 16px; font-size: 13.5px; }
}

@media (max-width: 420px) {
  .wordmark__name { display: none; }
  .site-header { gap: 8px; }
  .header-controls { gap: 5px; }
  .puzzle-select, .language-select { padding-left: 10px; padding-right: 21px; }
}

/* ---------- Motion and print ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  body { background: #fff; }
  .site-top, .panel-nav, .finish-actions { display: none !important; }
  .panel { display: none !important; }
  body[data-puzzle="3x3"] #finish,
  body[data-puzzle="2x2"] #two-finish { display: block !important; }
  .step-badge--flag { box-shadow: none; }
  .cheat-card { box-shadow: none; }
}
