@font-face {
  font-family: Silkscreen;
  src: url("./fonts/silkscreen.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("./fonts/plex-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/plex-mono.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --font-display: Silkscreen, "Courier New", monospace;
  --font-body: "IBM Plex Sans", Verdana, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
  --color-bg: #14231f;
  --color-bg: oklch(0.22 0.022 168);
  --color-surface: #21332c;
  --color-surface: oklch(0.28 0.025 168);
  --color-surface-high: #2b4035;
  --color-surface-high: oklch(0.33 0.029 163);
  --color-fg: #f1ead5;
  --color-fg: oklch(0.94 0.025 91);
  --color-muted: #b4c1a9;
  --color-muted: oklch(0.76 0.028 142);
  --color-border: #405849;
  --color-border: oklch(0.39 0.034 161);
  --color-accent: #ecb86f;
  --color-accent: oklch(0.81 0.115 73);
  --color-accent-fg: #14231d;
  --color-accent-fg: oklch(0.21 0.021 163);
  --color-success: #a1bf82;
  --color-success: oklch(0.77 0.109 138);
  --color-warning: #ecb86f;
  --color-warning: oklch(0.81 0.115 73);
  --color-error: #df8b79;
  --color-error: oklch(0.72 0.114 29);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-control: 2px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
}

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

[hidden] {
  display: none !important;
}

.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;
}

html {
  background: var(--color-bg);
  scroll-behavior: smooth;
}

body {
  min-width: 300px;
  min-height: 100dvh;
  margin: 0;
  color: var(--color-fg);
  background: var(--color-bg);
  font: 400 1rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent);
  position: relative;
  z-index: 3;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

p,
h1,
h2,
h3,
h4,
dl,
dd,
ol {
  margin: 0;
}

.app {
  min-height: 100dvh;
  isolation: isolate;
  display: flex;
  flex-direction: column;
}

.site-header {
  width: 100%;
  min-height: 72px;
  padding: 0 clamp(16px, 2.5vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  border-bottom: 1px solid color-mix(in oklch, var(--color-border) 75%, transparent);
}

.brand-group,
.brand,
.header-actions {
  display: flex;
  align-items: center;
}

.brand-group {
  min-width: 0;
  gap: var(--space-8);
}

.brand {
  flex: none;
  gap: var(--space-3);
  color: var(--color-fg);
  text-decoration: none;
  font: 400 1rem/1 var(--font-display);
  white-space: nowrap;
}

.brand:hover {
  color: var(--color-accent);
}

.brand-mark {
  width: 26px;
  height: 26px;
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 3px;
  transform: rotate(-8deg);
}

.brand-mark span {
  display: block;
  background: var(--color-accent);
}

.brand-mark span:nth-child(2) {
  background: var(--color-muted);
  transform: translateY(-3px);
}

.brand-mark span:nth-child(3) {
  background: var(--color-surface-high);
}

.brand-mark span:nth-child(4) {
  background: var(--color-success);
  transform: translate(2px, 1px);
}

.header-edition,
.header-chapter,
.text-button,
.eyebrow,
.intro-controls,
.intro-side-note,
.world-label,
.world-goal,
.world-prompt,
.toolbelt-labels,
.slot,
.tool-action,
.touch-controls p,
.guide-overline,
.section-rule,
.chapter-tag,
.requirements,
.journal-index,
.map-caption,
.guide-bottom,
.site-footer,
.dialog-footer,
.ending-credit,
.quiet-link {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.header-edition,
.header-chapter {
  font-size: 0.7rem;
  letter-spacing: 0.045em;
  color: var(--color-muted);
  white-space: nowrap;
}

.header-edition span,
.site-footer span span {
  color: var(--color-accent);
  padding: 0 3px;
}

.header-actions {
  gap: clamp(10px, 1.65vw, 24px);
}

.header-chapter {
  padding-right: clamp(8px, 1.3vw, 20px);
  border-right: 1px solid var(--color-border);
}

.text-button {
  min-height: 44px;
  flex: none;
  padding: 7px 2px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-muted);
  background: transparent;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.text-button:hover,
.text-button[aria-pressed="true"] {
  color: var(--color-accent);
}

.notes-toggle {
  display: none;
}

.button-plus {
  padding-left: 3px;
  color: var(--color-accent);
  font-size: 1rem;
}

.play-layout {
  width: 100%;
  max-width: 1660px;
  margin: 0 auto;
  padding: clamp(16px, 2.2vw, 34px) clamp(16px, 2.5vw, 42px) 20px;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: clamp(20px, 2.3vw, 38px);
  align-items: start;
}

.game-column {
  min-width: 0;
}

.world-frame {
  position: relative;
  height: clamp(470px, 66svh, 700px);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: #25484a;
  isolation: isolate;
}

.world-frame:has(#world:focus-visible) {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent);
}

#world {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  cursor: crosshair;
}

#world:focus-visible {
  outline: none;
}

.world-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 8px solid color-mix(in oklch, var(--color-bg) 16%, transparent);
  pointer-events: none;
}

.world-label,
.world-goal,
.world-prompt {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid color-mix(in oklch, var(--color-fg) 16%, transparent);
  background: color-mix(in oklch, var(--color-bg) 90%, transparent);
  color: var(--color-fg);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.world-label {
  top: 18px;
  left: 18px;
}

.world-label-mark {
  width: 8px;
  height: 8px;
  background: var(--color-accent);
  transform: rotate(45deg);
}

.world-label-divider {
  color: var(--color-accent);
}

.world-goal {
  top: 18px;
  right: 18px;
  max-width: min(350px, 47%);
}

.world-goal span:first-child {
  color: var(--color-accent);
}

.world-goal span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-prompt {
  bottom: 18px;
  left: 18px;
  max-width: calc(100% - 36px);
}

.prompt-key {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-size: 0.72rem;
  line-height: 1;
}

.world-toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 9px 13px;
  border: 1px solid var(--color-accent);
  background: var(--color-bg);
  color: var(--color-fg);
  font: 400 0.82rem/1.45 var(--font-body);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.world-toast.is-visible {
  opacity: 1;
}

.intro,
.ending {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.intro {
  display: flex;
  align-items: center;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: min(66%, 720px);
  background: #14251f;
  clip-path: polygon(0 0, 95% 0, 95% 8%, 99% 8%, 99% 19%, 93% 19%, 93% 31%, 98% 31%, 98% 44%, 91% 44%, 91% 57%, 97% 57%, 97% 71%, 90% 71%, 90% 84%, 95% 84%, 95% 100%, 0 100%);
}

.intro-copy {
  position: relative;
  z-index: 1;
  width: min(62%, 640px);
  padding: 32px clamp(26px, 3.6vw, 60px);
}

.eyebrow {
  color: var(--color-accent);
  font-size: 0.73rem;
  line-height: 1.5;
  letter-spacing: 0.085em;
}

.intro .eyebrow {
  margin-bottom: 20px;
}

.intro .eyebrow span {
  color: var(--color-muted);
  padding: 0 5px;
}

.intro h1 {
  max-width: 10ch;
  color: var(--color-fg);
  font: 400 clamp(3.45rem, 6.1vw, 6.25rem)/0.98 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.title-stop {
  color: var(--color-accent);
}

.intro-lead {
  max-width: 36ch;
  margin-top: 27px;
  color: var(--color-fg);
  font-size: clamp(1.12rem, 1.45vw, 1.35rem);
  font-weight: 500;
  line-height: 1.36;
  text-wrap: pretty;
}

.intro-detail {
  max-width: 51ch;
  margin-top: 13px;
  color: var(--color-muted);
  font-size: 0.96rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: 400 0.875rem/1.2 var(--font-mono);
  letter-spacing: 0.03em;
  text-align: center;
  text-decoration: none;
}

.button-primary {
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border-color: var(--color-accent);
}

.button-primary:hover:not(:disabled) {
  background: #f7ca86;
  color: var(--color-accent-fg);
}

.button-outline {
  background: var(--color-surface);
  color: var(--color-fg);
  border-color: var(--color-border);
}

.button-outline:hover:not(:disabled) {
  background: var(--color-surface-high);
  border-color: var(--color-muted);
}

.intro-start {
  margin-top: 26px;
  min-width: 184px;
}

.intro-controls {
  margin-top: 17px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.035em;
}

.intro-controls span {
  padding: 0 5px;
  color: var(--color-accent);
}

.intro-side-note {
  position: absolute;
  right: 27px;
  bottom: 27px;
  padding: 9px 12px;
  color: var(--color-fg);
  background: color-mix(in oklch, var(--color-bg) 92%, transparent);
  border: 1px solid color-mix(in oklch, var(--color-fg) 20%, transparent);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.intro-side-note span {
  color: var(--color-accent);
}

.ending {
  display: grid;
  align-items: center;
  padding: clamp(24px, 4vw, 60px);
  background: color-mix(in oklch, var(--color-bg) 94%, transparent);
}

.ending-copy {
  max-width: 680px;
}

.ending h2 {
  max-width: 17ch;
  margin-top: 16px;
  font: 400 clamp(2rem, 3.8vw, 3.5rem)/1.12 var(--font-display);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.ending-copy > p:not(.eyebrow, .ending-credit) {
  max-width: 54ch;
  margin-top: 20px;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--color-muted);
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.ending-credit {
  max-width: 65ch;
  margin-top: 52px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.035em;
}

.toolbelt {
  padding: 12px 16px 14px;
  border: 1px solid var(--color-border);
  border-top: 0;
  background: var(--color-surface);
}

.toolbelt-labels,
.toolbelt-row,
.slots,
.tool-actions {
  display: flex;
  align-items: center;
}

.toolbelt-labels {
  justify-content: space-between;
  gap: 16px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.055em;
}

.toolbelt-labels span:first-child {
  color: var(--color-fg);
}

.toolbelt-labels span:last-child {
  text-align: right;
}

.toolbelt-labels span span {
  color: var(--color-accent);
  padding: 0 2px;
}

.toolbelt-row {
  justify-content: space-between;
  gap: 18px;
  margin-top: 10px;
}

.slots {
  min-width: 0;
  flex: 1;
  gap: 6px;
}

.slot {
  min-width: 0;
  min-height: 46px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-muted);
  background: var(--color-bg);
  font-size: 0.75rem;
  text-align: left;
}

.slot:hover {
  color: var(--color-fg);
  border-color: var(--color-muted);
}

.slot.is-selected {
  color: var(--color-fg);
  border-color: var(--color-accent);
  background: var(--color-surface-high);
}

.slot-key {
  min-width: 17px;
  color: var(--color-accent);
  font-size: 0.7rem;
}

.block-swatch {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid #203528;
  box-shadow: inset -3px -3px 0 rgb(17 27 22 / 23%);
}

.swatch-earth {
  background: #8d7858;
}

.swatch-wood {
  background: #bc895c;
}

.swatch-stone {
  background: #a5a7a0;
}

.slot-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.slot-count {
  margin-left: auto;
  color: var(--color-fg);
}

.tool-actions {
  flex: none;
  gap: 6px;
}

.tool-action {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-fg);
  background: var(--color-bg);
  font-size: 0.75rem;
}

.tool-action:hover,
.tool-action[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-surface-high);
}

kbd {
  min-width: 18px;
  display: inline-block;
  padding: 2px 3px;
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  font: inherit;
  text-align: center;
}

.touch-controls {
  display: none;
}

.guide {
  min-width: 0;
  padding: 7px 0 0 25px;
  border-left: 1px solid var(--color-border);
}

.guide-overline,
.section-rule {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.guide-overline span:first-child,
.section-rule h3 {
  color: var(--color-accent);
}

.guide h2 {
  max-width: 20ch;
  margin-top: 21px;
  font: 400 clamp(1.1rem, 1.8vw, 1.52rem)/1.25 var(--font-display);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.guide-heading > p {
  max-width: 34ch;
  margin-top: 16px;
  color: var(--color-muted);
  font-size: 0.96rem;
  line-height: 1.55;
}

.guide-section {
  margin-top: 30px;
}

.section-rule {
  padding-top: 11px;
  border-top: 1px solid var(--color-border);
}

.section-rule h3 {
  font-size: inherit;
  font-weight: 400;
  letter-spacing: inherit;
}

.section-rule span {
  white-space: nowrap;
}

.chapter-tag {
  margin-top: 20px;
  color: var(--color-success);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.chapter-title {
  max-width: 24ch;
  margin-top: 6px;
  font-size: 1.33rem;
  font-weight: 600;
  line-height: 1.27;
  text-wrap: balance;
}

.objective-copy {
  max-width: 37ch;
  margin-top: 11px;
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.52;
}

.requirements {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 13px 0 0;
  border-top: 1px solid color-mix(in oklch, var(--color-border) 76%, transparent);
  font-size: 0.72rem;
}

.requirement {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.requirement strong {
  color: var(--color-fg);
  font-weight: 400;
}

.requirement.is-complete strong::after {
  content: " ✓";
  color: var(--color-success);
}

.journal {
  padding: 0;
  list-style: none;
}

.journal li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid color-mix(in oklch, var(--color-border) 60%, transparent);
}

.journal li:first-child {
  margin-top: 4px;
}

.journal-index {
  padding-top: 2px;
  color: var(--color-accent);
  font-size: 0.7rem;
}

.journal-text {
  color: var(--color-fg);
  font-size: 0.875rem;
  line-height: 1.45;
}

.journal-empty {
  color: var(--color-muted);
  font-size: 0.875rem;
}

.map-section {
  margin-top: 25px;
}

#mini-map {
  display: block;
  width: 100%;
  height: 112px;
  margin-top: 14px;
  border: 1px solid var(--color-border);
  background: #1b3539;
  image-rendering: pixelated;
}

.map-caption {
  margin-top: 8px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.map-dot {
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 2px;
  background: var(--color-accent);
  vertical-align: 1px;
}

.map-divider {
  padding: 0 4px;
  color: var(--color-accent);
}

.guide-bottom {
  margin-top: 26px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.025em;
}

.quiet-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
  padding: 3px 1px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-accent);
  background: transparent;
  font-size: 0.75rem;
  text-align: left;
}

.quiet-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-footer {
  width: 100%;
  max-width: 1660px;
  min-height: 45px;
  margin: 0 auto;
  padding: 10px clamp(16px, 2.5vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-muted);
  font-size: 0.7rem;
  letter-spacing: 0.035em;
}

dialog {
  color: var(--color-fg);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: 0;
}

dialog::backdrop {
  background: rgb(8 20 18 / 77%);
}

.story-dialog,
.help-dialog,
.reset-dialog {
  width: min(690px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 24px;
  padding: 35px 38px 30px;
}

#portrait {
  width: 112px;
  height: 112px;
  border: 1px solid var(--color-border);
  image-rendering: pixelated;
  background: var(--color-bg);
}

.dialog-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 44px;
  height: 44px;
  border: 0;
  color: var(--color-muted);
  background: transparent;
  font: 400 1.7rem/1 var(--font-body);
}

.dialog-close:hover {
  color: var(--color-fg);
}

.dialog-content h2,
.help-dialog h2,
.reset-dialog h2 {
  max-width: 23ch;
  margin-top: 4px;
  font: 400 clamp(1.2rem, 2.8vw, 1.65rem)/1.22 var(--font-display);
  text-wrap: balance;
}

.story-text {
  min-height: 4.4em;
  max-width: 53ch;
  margin-top: 20px;
  color: var(--color-fg);
  font-size: 1.06rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  color: var(--color-muted);
  font-size: 0.7rem;
}

.story-choices {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

.story-choices button {
  min-height: 50px;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  color: var(--color-fg);
  background: var(--color-bg);
  font-size: 0.96rem;
  text-align: left;
}

.story-choices button:first-child {
  border-color: var(--color-accent);
}

.story-choices button:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-high);
}

.help-dialog,
.reset-dialog {
  padding: 38px;
}

.help-dialog > p:not(.eyebrow, .help-note),
.reset-dialog > p:not(.eyebrow) {
  max-width: 58ch;
  margin-top: 20px;
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1.56;
}

.key-list {
  margin-top: 26px;
  border-top: 1px solid var(--color-border);
}

.key-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.68fr) 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--color-border);
}

.key-list dt {
  color: var(--color-accent);
  font: 400 0.75rem/1.4 var(--font-mono);
}

.key-list dd {
  color: var(--color-fg);
  font-size: 0.88rem;
}

.help-note {
  margin: 22px 0 20px;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 30px;
}

@media (prefers-reduced-motion: no-preference) {
  .story-dialog[open],
  .help-dialog[open],
  .reset-dialog[open] {
    animation: dialog-in 180ms var(--ease-out) both;
  }

  .intro-start:hover,
  .ending .button-primary:hover {
    transform: translateY(-2px);
  }

  @keyframes dialog-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 1200px) {
  .header-edition,
  .header-chapter {
    display: none;
  }

  .slot {
    gap: 5px;
  }

  .slot-key {
    display: none;
  }
}

@media (max-width: 980px) {
  .site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    background: var(--color-bg);
  }

  .notes-toggle {
    display: inline-flex;
    align-items: center;
  }

  .play-layout {
    display: block;
  }

  .world-frame {
    height: clamp(420px, 60svh, 620px);
    scroll-margin-top: 80px;
  }

  .guide {
    display: none;
    margin-top: 26px;
    padding: 24px 0 0;
    border-left: 0;
    border-top: 1px solid var(--color-border);
    scroll-margin-top: 82px;
  }

  .guide.is-open {
    display: block;
  }

  .guide-heading > p,
  .objective-copy {
    max-width: 62ch;
  }

  .guide h2 {
    font-size: 1.45rem;
  }

  .guide-section {
    max-width: 700px;
  }

  #mini-map {
    max-width: 420px;
  }
}

@media (max-width: 680px) {
  .site-header {
    min-height: 62px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
    font-size: 0.72rem;
  }

  .brand-mark {
    width: 20px;
    height: 20px;
    grid-template-columns: repeat(2, 8px);
    grid-template-rows: repeat(2, 8px);
    gap: 2px;
  }

  .header-actions {
    gap: 7px;
  }

  .text-button {
    padding: 7px 2px;
    font-size: 0.7rem;
  }

  #sound-toggle {
    display: none;
  }

  .play-layout {
    padding-top: 12px;
  }

  .world-frame {
    height: min(61svh, 540px);
    min-height: 410px;
  }

  .world-label,
  .world-goal,
  .world-prompt {
    padding: 6px 7px;
    font-size: 0.7rem;
  }

  .world-label {
    top: 10px;
    left: 10px;
  }

  .world-goal {
    top: 42px;
    right: auto;
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .world-prompt {
    bottom: 123px;
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .world-toast {
    top: 74px;
  }

  .intro::before {
    width: 100%;
    background: rgb(20 37 31 / 93%);
    clip-path: none;
  }

  .intro {
    overflow-y: auto;
    scrollbar-color: var(--color-border) var(--color-bg);
    scrollbar-width: thin;
  }

  .world-frame:has(.intro:not([hidden])) .world-label,
  .world-frame:has(.intro:not([hidden])) .world-goal,
  .world-frame:has(.intro:not([hidden])) .world-prompt {
    display: none;
  }

  .intro-copy {
    width: 100%;
    margin: auto 0;
    padding: 22px clamp(20px, 6vw, 36px);
  }

  .intro .eyebrow {
    margin-bottom: 14px;
  }

  .intro h1 {
    font-size: clamp(3.1rem, 10.4vw, 4.45rem);
  }

  .intro-lead {
    margin-top: 18px;
    font-size: 1.14rem;
  }

  .intro-detail {
    margin-top: 10px;
    font-size: 1rem;
  }

  .intro-start {
    min-width: 176px;
    margin-top: 20px;
  }

  .intro-controls {
    font-size: 0.7rem;
  }

  .intro-side-note {
    display: none;
  }

  .toolbelt {
    padding: 10px;
  }

  .toolbelt-labels {
    font-size: 0.7rem;
  }

  .toolbelt-labels span:last-child {
    display: none;
  }

  .toolbelt-row {
    display: block;
    margin-top: 8px;
  }

  .slots,
  .tool-actions {
    width: 100%;
  }

  .slot,
  .tool-action {
    min-height: 48px;
  }

  .slot-key {
    display: inline;
    min-width: 12px;
  }

  .slot {
    gap: 5px;
    padding: 7px 6px;
    font-size: 0.7rem;
  }

  .slot-name {
    letter-spacing: -0.035em;
  }

  .block-swatch {
    width: 12px;
    height: 12px;
    border-width: 1px;
  }

  .tool-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .tool-action {
    flex: 1;
    justify-content: center;
    padding: 7px 5px;
    font-size: 0.72rem;
  }

  .touch-controls {
    display: flex;
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .world-frame:has(.intro:not([hidden])) .touch-controls,
  .world-frame:has(.ending:not([hidden])) .touch-controls {
    display: none;
  }

  .touch-directions {
    width: 164px;
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(2, 48px);
    gap: 5px;
    flex: none;
  }

  .touch-key {
    min-width: 48px;
    min-height: 48px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    color: var(--color-accent);
    background: var(--color-surface);
    font: 400 1.3rem/1 var(--font-body);
  }

  .touch-key:hover,
  .touch-key:active {
    background: var(--color-surface-high);
    border-color: var(--color-accent);
  }

  .touch-key.up { grid-column: 2; grid-row: 1; }
  .touch-key.left { grid-column: 1; grid-row: 2; }
  .touch-key.down { grid-column: 2; grid-row: 2; }
  .touch-key.right { grid-column: 3; grid-row: 2; }

  .touch-actions {
    width: 88px;
    display: grid;
    grid-template-rows: repeat(2, 48px);
    gap: 5px;
    flex: none;
  }

  .touch-act {
    width: 88px;
    color: var(--color-fg);
    font: 400 0.75rem/1 var(--font-mono);
  }

  .site-footer {
    flex-wrap: wrap;
    font-size: 0.7rem;
  }

  .guide-heading > p,
  .objective-copy,
  .journal-text,
  .journal-empty,
  .help-note,
  .key-list dd {
    font-size: 1rem;
  }

  .dialog-grid {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 14px;
    padding: 30px 18px 18px;
  }

  #portrait {
    width: 64px;
    height: 64px;
  }

  .dialog-content h2 {
    padding-right: 12px;
    font-size: 1.12rem;
  }

  .story-text {
    margin-top: 14px;
    font-size: 1rem;
  }

  .help-dialog,
  .reset-dialog {
    padding: 24px 20px;
  }

  .key-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .ending {
    padding: 20px;
  }

  .ending h2 {
    font-size: clamp(1.75rem, 7vw, 2.5rem);
  }

  .ending-credit {
    margin-top: 25px;
  }
}

@media (max-width: 390px) {
  .brand span:last-child {
    max-width: 110px;
    overflow: hidden;
    white-space: nowrap;
  }

  .world-frame {
    min-height: 430px;
  }

  .world-frame:has(.intro:not([hidden])) {
    min-height: 510px;
  }

  .intro h1 {
    font-size: 3.05rem;
  }

  .intro-detail {
    font-size: 1rem;
  }

  .slot-key,
  .block-swatch {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
