:root {
  --space-3xs: 2px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
  --space-3xl: 96px;
  --space-4xl: 144px;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.2rem;
  --text-xl: 1.44rem;
  --text-2xl: 1.728rem;
  --text-3xl: 2.074rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 120ms;
  --dur-short: 220ms;
  --dur-long: 420ms;
  --container: 1440px;
  --gutter: 64px;
  --gap-columns: 32px;
  --z-base: 1;
  --z-raised: 10;
  --z-modal: 400;
  --color-paper: #83e7b0;
  --color-paper-2: #ffdd48;
  --color-paper-3: #fff4d6;
  --color-ink: #183b32;
  --color-ink-2: #194d38;
  --color-muted: #244d3b;
  --color-rule: #285843;
  --color-accent: #ff885b;
  --color-accent-ink: #183b32;
  --color-focus: #194d38;
  --font-display: 'Manrope', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius-card: 28px;
  --radius-control: 16px;
  --radius-small: 10px;
  --radius-pill: 999px;
  --tracking-display: -0.02em;
  --color-accent-hover: #ffa67a;
  --color-selected: #8bbcff;
  --color-on-brand: #fff4d6;
  --color-disabled: #b4cfaa;
  --color-backdrop: #183b3266;
  --color-error: #9a292e;
  --color-success: #315e48;
  --accent: var(--color-ink-2);
  --ink: var(--color-ink);
  --muted: var(--color-muted);
  --line: var(--color-rule);
  --canvas-arrow: #183b32;
  --canvas-hover: #1f5a40;
  --canvas-hint: #923d00;
  --canvas-failure: #9b1c33;
  --canvas-escape: #1e563f;
  --canvas-hint-glow: #e8a44d;
  --canvas-escape-glow: #9ab576;
  --canvas-face-0: #ffb84d;
  --canvas-face-1: #79b2ff;
  --canvas-face-2: #ffb84d;
  --canvas-face-3: #79b2ff;
  --canvas-face-4: #bbf247;
  --canvas-face-5: #bbf247;
  --canvas-edge: #285843;
  --canvas-grid: #285843;
  --canvas-light: #fff4d6;
  --canvas-shade: #0d241b;
  --control-size: 48px;
  --hit-size: 48px;
  --button-size: 52px;
  --button-edge: 2px;
  --button-depth: 5px;
  --button-shadow: 0 var(--button-depth) 0 var(--color-ink-2);
  --button-shadow-pressed: 0 1px 0 var(--color-ink-2);
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/dm-sans-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin.woff2') format('woff2');
}

/* Hallmark · shape: app screen · genre: playful · theme: brand · redesign: full · posture: Full palette · v2.0.0 */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  overflow-x: clip;
}
html {
  scrollbar-color: var(--color-ink-2) var(--color-paper);
  scroll-padding-top: var(--space-lg);
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  font-synthesis: none;
  caret-color: var(--color-ink-2);
}
::selection {
  background: var(--color-ink-2);
  color: var(--color-on-brand);
}
button,
input {
  font: inherit;
}
button,
a,
input,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  white-space: nowrap;
  font-weight: 700;
}
:where(.nav-button, .icon-button, .reset-view, .tool-button, .primary-button, .chapter-nav button) {
  transition:
    transform var(--dur-micro) var(--ease-out),
    background-color var(--dur-micro) var(--ease-out);
}
:is(
    .nav-button,
    .icon-button,
    .reset-view,
    .tool-button,
    .primary-button,
    .chapter-nav button
  ):active:not(:disabled) {
  transform: translateY(calc(var(--button-depth) - 1px));
  box-shadow: var(--button-shadow-pressed);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}
svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  line-height: 1.2;
  overflow-wrap: break-word;
  min-width: 0;
  text-wrap: balance;
}
h1 {
  font-size: var(--text-2xl);
}
h2 {
  font-size: var(--text-xl);
}
h3 {
  font-size: var(--text-lg);
}
p {
  text-wrap: pretty;
}
strong,
b {
  font-weight: 700;
}
[hidden] {
  display: none !important;
}
main,
footer,
.site-header {
  width: min(calc(100% - var(--gutter) * 2), var(--container));
  margin-inline: auto;
}
main {
  padding-block: var(--space-lg);
}
.startup-notice {
  margin-block: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-control);
  color: var(--color-error);
  background: var(--color-paper-3);
}
.startup-notice a {
  text-decoration: underline;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.site-header {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  text-decoration: none;
  white-space: nowrap;
}
.brand-light {
  font-weight: 400;
}
.brand small {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: normal;
}
.brand-mark {
  display: grid;
  place-items: center;
  background: var(--color-ink-2);
  color: var(--color-on-brand);
  border-radius: var(--radius-control);
  width: 48px;
  height: 48px;
}
.brand-mark svg {
  width: 30px;
  height: 30px;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.nav-button {
  min-height: var(--hit-size);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-md);
  color: var(--color-ink);
  border-radius: var(--radius-control);
  font-weight: 700;
  background: var(--color-paper-3);
  border: var(--button-edge) solid var(--color-ink-2);
  box-shadow: var(--button-shadow);
}
.nav-button.active {
  background: var(--color-selected);
}
.nav-button:hover {
  background: var(--color-paper-2);
}
.tiny-question {
  display: none;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.saved-label {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-right: var(--space-md);
}
.saved-label > span {
  display: none;
}
.saved-label[data-saved='false'] {
  color: var(--color-error);
}
.icon-button,
.reset-view {
  position: relative;
  width: var(--control-size);
  height: var(--control-size);
  display: inline-grid;
  place-items: center;
  border: var(--button-edge) solid var(--color-ink-2);
  border-radius: var(--radius-control);
  flex-shrink: 0;
  background: var(--color-paper-3);
  box-shadow: var(--button-shadow);
}
.icon-button::before,
.reset-view::before {
  content: '';
  position: absolute;
  inset: -2px;
  min-width: var(--hit-size);
  min-height: var(--hit-size);
}
.icon-button:hover,
.reset-view:hover {
  background: var(--color-selected);
}
.icon-button svg,
.reset-view svg {
  width: 20px;
  height: 20px;
}

.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.game-heading h1 {
  font-size: var(--text-3xl);
}
.heading-copy {
  display: grid;
  gap: var(--space-xs);
}
.heading-copy > p {
  color: var(--color-muted);
}
.eyebrow,
.eyebrow-line,
.mini-cube,
.ambient-ring,
.stage-caption > span,
.hint-dot {
  display: none;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--space-lg);
  align-items: start;
}
.play-area {
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
  background: var(--color-paper-2);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  container-type: inline-size;
  outline: 3px solid var(--color-ink-2);
}
.board-top,
.board-stats,
.level-heading,
.lives {
  display: flex;
  align-items: center;
}
.board-top {
  justify-content: space-between;
  gap: var(--space-md);
}
.level-heading {
  gap: var(--space-sm);
  flex-wrap: wrap;
  min-width: 0;
}
.level-pill {
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
}
.level-name {
  font-size: var(--text-lg);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.lives {
  gap: var(--space-2xs);
  color: var(--color-ink-2);
  flex-shrink: 0;
}
.lives svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke-width: 0;
}
.lives .lost {
  fill: none;
  stroke-width: 1.8;
}
.board-stats {
  gap: var(--space-md);
  margin-top: var(--space-md);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.board-stats > span:first-child {
  white-space: nowrap;
}
.board-stats strong {
  color: var(--color-ink);
}
.stat-arrow {
  display: none;
}
.mini-progress {
  height: 8px;
  background: var(--color-on-brand);
  flex: 1;
  border-radius: var(--radius-pill);
  overflow: clip;
}
.mini-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--color-ink-2);
}
.progress-label {
  white-space: nowrap;
}
.cube-stage {
  position: relative;
  height: 480px;
  isolation: isolate;
}
.cube-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
  z-index: var(--z-base);
}
.cube-stage canvas.dragging {
  cursor: grabbing;
}
.stage-caption {
  position: absolute;
  z-index: var(--z-raised);
  bottom: var(--space-xs);
  left: 0;
  right: var(--space-xl);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-muted);
  pointer-events: none;
}
.reset-view {
  position: absolute;
  bottom: var(--space-2xs);
  right: 0;
  z-index: var(--z-raised);
  color: var(--color-ink);
}
.rotate-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-top: var(--space-md);
}
.rotate-hint > span:first-child svg {
  width: 20px;
  height: 20px;
}
.game-tools {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  margin-top: var(--space-lg);
}
.tool-button {
  position: relative;
  height: var(--button-size);
  border: var(--button-edge) solid var(--color-ink-2);
  border-radius: var(--radius-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  font-size: var(--text-md);
  padding: var(--space-xs) var(--space-lg);
  background: var(--color-paper-3);
  box-shadow: var(--button-shadow);
}
.tool-button::before {
  content: '';
  position: absolute;
  inset: -2px;
  min-height: var(--hit-size);
}
.tool-button:hover:not(:disabled) {
  background: var(--color-selected);
}
.tool-button svg {
  width: 20px;
  height: 20px;
}
.tool-button kbd {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-muted);
}
.hint-button {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-color: var(--color-ink-2);
}
.hint-button:hover:not(:disabled) {
  background: var(--color-accent-hover);
}
.hint-badge {
  font-size: var(--text-sm);
  border-left: 1px solid currentColor;
  padding-left: var(--space-xs);
  font-variant-numeric: tabular-nums;
}
.view-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  color: var(--color-ink);
}
.view-controls > span {
  font-size: var(--text-sm);
  margin-inline: var(--space-xs);
}
.view-controls .icon-button {
  border-color: var(--color-rule);
}
.journey {
  grid-column: 2;
  grid-row: 1;
  padding: var(--space-md) 0 0 var(--space-xs);
}
.section-label {
  font-size: var(--text-sm);
  font-weight: 700;
}
.journey-track {
  display: grid;
  gap: var(--space-xs);
  margin-block: var(--space-lg);
}
.journey-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 52px;
  text-align: left;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  white-space: normal;
  width: 100%;
}
.journey-step.current {
  background: var(--color-selected);
  border-color: var(--color-ink-2);
  box-shadow: 0 3px 0 var(--color-ink-2);
}
.journey-step:hover:not(:disabled):not(.current) {
  border-color: var(--color-rule);
}
.step-circle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-small);
  flex-shrink: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.journey-step.current .step-circle {
  background: var(--color-ink-2);
  color: var(--color-on-brand);
  border-color: var(--color-ink-2);
}
.step-circle svg {
  width: 16px;
  height: 16px;
}
.step-description {
  min-width: 0;
  line-height: 1.2;
}
.step-description b {
  display: block;
  font-size: var(--text-md);
}
.step-description small {
  display: block;
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 400;
}
.text-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-size);
  font-size: var(--text-md);
  color: var(--color-ink-2);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  padding: var(--space-xs) 0;
}
.text-button:hover {
  color: var(--color-ink);
}
.text-button > span {
  display: none;
}
.journey-note {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-top: 1px solid var(--color-rule);
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.journey-note svg {
  width: 24px;
  height: 24px;
}
.right-rail {
  grid-column: 1 / -1;
  min-width: 0;
}
.how-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-lg) var(--space-xl);
  padding-block: var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
}
.how-intro {
  display: grid;
  gap: var(--space-sm);
  align-content: start;
}
.how-icon {
  display: none;
}
.how-tagline,
.how-intro > p {
  color: var(--color-muted);
  font-size: var(--text-md);
}
.how-intro br {
  display: none;
}
.rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-lg);
  list-style: none;
  padding: 0;
  margin: 0;
}
.rules li {
  display: grid;
  gap: var(--space-md);
  align-content: start;
}
.rule-symbol svg {
  width: 28px;
  height: 28px;
}
.rules strong {
  font-size: var(--text-md);
  display: block;
  margin-bottom: var(--space-xs);
}
.rules li div > span {
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.rule-line {
  display: none;
}
.how-card > .text-button {
  grid-column: 2;
  justify-self: start;
}
.calm-note {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.calm-note br {
  display: none;
}
.accessible-play {
  font-size: var(--text-md);
  color: var(--color-ink);
  margin-top: var(--space-lg);
}
.accessible-play summary {
  width: fit-content;
  min-height: var(--hit-size);
  display: list-item;
  cursor: pointer;
  padding-block: var(--space-xs);
}
.accessible-play p {
  margin-block: var(--space-md);
  max-width: 70ch;
}
.arrow-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.arrow-list button {
  border: 1px solid var(--color-rule);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-small);
  font-size: var(--text-sm);
  min-height: var(--hit-size);
}
.arrow-list button:hover {
  background: var(--color-selected);
}
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  padding-block: var(--space-lg);
  color: var(--color-muted);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}
footer > span {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.footer-center > span {
  display: none;
}
.footer-cube svg {
  width: 18px;
  height: 18px;
}
.board-message {
  position: absolute;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-raised);
  background: var(--color-paper-3);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-control);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
  text-align: center;
  width: max-content;
  max-width: calc(100% - var(--space-lg));
  pointer-events: none;
}
.board-message:not(.show) {
  clip-path: inset(50%);
}
.board-message.error {
  color: var(--color-error);
}
.board-message.hint {
  color: var(--color-ink);
}

/* Hallmark · answered F4 · Chapter fills mark the selected range of levels; the orange dialog action remains primary */
dialog {
  border: 3px solid var(--color-ink-2);
  background: var(--color-paper-3);
  color: var(--color-ink);
  border-radius: var(--radius-card);
  padding: var(--space-xl);
  width: min(640px, calc(100% - var(--space-lg)));
  max-height: calc(100dvh - var(--space-xl));
  overflow: auto;
}
dialog::backdrop {
  background: var(--color-backdrop);
}
.dialog-close {
  position: absolute;
  right: var(--space-md);
  top: var(--space-md);
}
.dialog-emblem {
  margin-bottom: var(--space-lg);
  color: var(--color-ink-2);
}
.dialog-emblem svg {
  width: 36px;
  height: 36px;
}
dialog h2 {
  font-size: var(--text-xl);
  padding-right: var(--space-lg);
}
dialog > .section-label {
  display: none;
}
.help-steps {
  list-style: none;
  margin-block: var(--space-lg);
  padding: 0;
  display: grid;
  gap: var(--space-lg);
}
.help-steps li {
  display: flex;
  align-items: start;
  gap: var(--space-md);
}
.help-steps b {
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}
.help-steps strong {
  font-size: var(--text-md);
}
.help-steps p,
.dialog-intro {
  font-size: var(--text-md);
  color: var(--color-muted);
  margin-top: var(--space-xs);
  line-height: 1.5;
}
.primary-button {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-radius: var(--radius-control);
  min-height: var(--button-size);
  border: var(--button-edge) solid var(--color-ink-2);
  box-shadow: var(--button-shadow);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: var(--text-md);
}
.primary-button:hover {
  background: var(--color-accent-hover);
}
.primary-button > span {
  display: none;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}
.level-tile {
  border: var(--button-edge) solid var(--color-rule);
  border-radius: var(--radius-control);
  padding: var(--space-md);
  min-height: 100px;
  text-align: left;
  position: relative;
  white-space: normal;
}
.level-tile b {
  display: block;
  font-size: var(--text-xl);
  font-variant-numeric: tabular-nums;
}
.level-tile small {
  font-size: var(--text-sm);
  color: var(--color-muted);
  display: block;
  margin-top: var(--space-xs);
  line-height: 1.5;
}
.level-tile .tile-status {
  position: absolute;
  right: var(--space-sm);
  top: var(--space-md);
}
.tile-status svg {
  width: 18px;
  height: 18px;
}
.level-tile.selected {
  background: var(--color-selected);
  border-color: var(--color-ink-2);
}
.level-tile:hover:not(:disabled):not(.selected) {
  background: var(--color-paper-2);
}
.chapter-nav {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  overflow-x: auto;
  padding-block: var(--space-2xs);
}
.chapter-nav button {
  border: var(--button-edge) solid var(--color-ink-2);
  border-radius: var(--radius-small);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  min-height: var(--hit-size);
  flex: 1;
  background: var(--color-paper-3);
  box-shadow: var(--button-shadow);
}
.chapter-nav button[aria-pressed='true'] {
  background: var(--color-selected);
  color: var(--color-ink);
  border-color: var(--color-ink-2);
}
.chapter-nav button:hover:not([aria-pressed='true']) {
  background: var(--color-paper-2);
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  padding-block: var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
  cursor: pointer;
  min-height: var(--hit-size);
}
.setting-row strong {
  font-size: var(--text-md);
}
.setting-row small {
  font-size: var(--text-sm);
  color: var(--color-muted);
  display: block;
  margin-top: var(--space-xs);
}
.setting-row input {
  accent-color: var(--color-ink-2);
  width: 24px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.settings-note {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-top: var(--space-lg);
}
#result-dialog {
  text-align: center;
}
#result-dialog h2 {
  padding-right: 0;
}
.result-star {
  font-size: var(--text-3xl);
  color: var(--color-ink-2);
  margin-bottom: var(--space-lg);
}
#result-eyebrow {
  display: block;
  margin-bottom: var(--space-md);
}
#result-copy {
  color: var(--color-muted);
  font-size: var(--text-md);
  margin-top: var(--space-md);
}
.result-stat {
  padding-block: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
#result-dialog .text-button {
  margin-top: var(--space-sm);
}

@container (max-width: 620px) {
  .level-heading {
    display: grid;
    gap: var(--space-2xs);
  }
  .cube-stage {
    height: 400px;
  }
  .game-tools {
    gap: var(--space-xs);
  }
  .tool-button {
    font-size: var(--text-sm);
    padding-inline: var(--space-sm);
  }
  .tool-button kbd {
    display: none;
  }
}
@media (min-width: 1600px) {
  .cube-stage {
    height: 560px;
  }
}
@media (min-width: 60.001rem) {
  .cube-stage {
    height: clamp(240px, calc(100dvh - 480px), 560px);
  }
}
@media (max-width: 70rem) {
  :root {
    --gutter: 32px;
  }
  .saved-label {
    display: none;
  }
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 220px;
  }
}
@media (max-width: 60rem) {
  :root {
    --gutter: 24px;
  }
  .site-header {
    gap: var(--space-md);
    flex-wrap: wrap;
    padding-block: var(--space-md);
  }
  .brand {
    font-size: var(--text-xl);
  }
  .brand small {
    font-size: var(--text-sm);
  }
  .main-nav {
    order: 3;
    width: 100%;
  }
  .nav-button {
    flex: 1;
  }
  .header-actions {
    margin-left: auto;
  }
  .game-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-sm);
  }
  .game-heading > p {
    max-width: none;
  }
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .journey {
    grid-column: 1;
    grid-row: 2;
    padding: 0;
  }
  .journey-track {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-block: var(--space-md);
  }
  .journey-note {
    padding-top: var(--space-md);
    margin-top: var(--space-md);
  }
  .right-rail {
    grid-row: 3;
  }
  .how-card {
    gap: var(--space-lg);
    padding-top: var(--space-lg);
  }
  .rules {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-lg);
  }
  .rules li {
    display: flex;
    align-items: center;
  }
  footer {
    align-items: flex-start;
  }
}
@media (max-width: 40rem) {
  :root {
    --gutter: 16px;
  }
  main {
    padding-top: var(--space-md);
  }
  .brand small {
    display: none;
  }
  .nav-button {
    padding-inline: var(--space-sm);
  }
  .brand {
    gap: var(--space-xs);
  }
  .brand-mark {
    width: 40px;
    height: 40px;
  }
  .game-heading {
    margin-bottom: var(--space-md);
  }
  .game-heading > p,
  .heading-copy > p {
    font-size: var(--text-md);
  }
  .play-area {
    padding: var(--space-md);
  }
  .board-top {
    align-items: flex-start;
    gap: var(--space-xs);
  }
  .level-name {
    font-size: var(--text-md);
  }
  .lives {
    gap: var(--space-3xs);
  }
  .lives svg {
    width: 18px;
    height: 18px;
  }
  .board-stats {
    gap: var(--space-xs);
  }
  .cube-stage {
    height: 300px;
  }
  .stage-caption {
    bottom: var(--space-md);
    left: var(--space-xs);
    right: var(--space-xl);
    font-size: var(--text-sm);
  }
  .rotate-hint {
    display: grid;
    grid-template-columns: auto 1fr;
    font-size: var(--text-sm);
    justify-content: start;
  }
  .rotate-hint > span:last-child {
    grid-column: 2;
  }
  .game-tools {
    gap: var(--space-xs);
    margin-top: var(--space-md);
  }
  .tool-button {
    flex: 1;
    padding-inline: var(--space-xs);
    gap: var(--space-2xs);
    min-height: 48px;
    font-size: var(--text-sm);
  }
  .tool-button svg {
    display: none;
  }
  .tool-button kbd {
    display: none;
  }
  .hint-button {
    font-size: var(--text-md);
  }
  .view-controls {
    margin-top: var(--space-xs);
    gap: var(--space-xs);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .view-controls .icon-button {
    width: 100%;
    min-height: 48px;
  }
  .view-controls > span {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
  }
  .journey-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .journey-step {
    gap: var(--space-xs);
    align-items: flex-start;
  }
  .step-description b {
    font-size: var(--text-sm);
  }
  .step-description small {
    font-size: var(--text-sm);
  }
  .step-circle {
    width: 28px;
    height: 28px;
  }
  .how-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .how-card > .text-button {
    grid-column: 1;
  }
  footer {
    flex-direction: column;
    gap: var(--space-sm);
  }
  dialog {
    padding: var(--space-xl) var(--space-md) var(--space-lg);
  }
  dialog h2 {
    font-size: var(--text-lg);
  }
  .chapter-nav button {
    flex: 0 0 auto;
  }
}
@media (pointer: coarse) {
  .icon-button,
  .reset-view,
  .nav-button {
    min-width: 48px;
    min-height: 48px;
  }
}

@media (forced-colors: active) {
  :root {
    --color-paper: Canvas;
    --color-paper-2: Canvas;
    --color-paper-3: Canvas;
    --color-ink: CanvasText;
    --color-ink-2: CanvasText;
    --color-muted: CanvasText;
    --color-rule: ButtonText;
    --color-accent: Highlight;
    --color-accent-hover: Highlight;
    --color-accent-ink: HighlightText;
    --color-focus: Highlight;
    --color-selected: Canvas;
    --color-on-brand: Canvas;
    --color-error: CanvasText;
  }
  .brand-mark {
    background: var(--color-paper);
    color: var(--color-ink);
  }
  .nav-button.active,
  .journey-step.current,
  .level-tile.selected,
  .chapter-nav button[aria-pressed='true'] {
    outline: 2px solid var(--color-focus);
  }
  .play-area {
    border: 1px solid var(--color-rule);
  }
  .nav-button,
  .icon-button,
  .reset-view,
  .tool-button,
  .primary-button,
  .chapter-nav button,
  .journey-step.current {
    box-shadow: none;
  }
  canvas {
    forced-color-adjust: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
