/* Global UI tokens: palette -> semantic roles -> components. See DESIGN.md. */
:root {
  --icon-mask: none;
  --color-charcoal-950: #050504;
  --color-charcoal-900: #201e1b;
  --color-charcoal-800: #292722;
  --color-charcoal-700: #38342e;
  --color-charcoal-600: #454238;
  --color-charcoal-500: #575046;
  --ui-canvas: var(--brand-ink);
  --ui-panel: var(--color-charcoal-900);
  --ui-surface: var(--color-charcoal-800);
  --ui-hover: var(--color-charcoal-700);
  --ui-active: var(--color-charcoal-600);
  --ui-border: var(--brand-secondary);
  --ui-focus: var(--color-amber-200);

  --color-ink-900: #231f1b;
  --color-ink-800: #322d28;
  --color-wood-500: #665c52;
  --color-wood-100: #ccb8a3;
  --color-paper-200: #dfc9b2;
  --color-paper-100: #f3efea;
  --color-tea-500: #868c5f;
  --color-tea-300: #c2ba86;
  --color-clay-700: #8c423a;
  --color-clay-500: #ed655f;
  --color-clay-300: #ffb2a6;
  --color-amber-700: #826f3e;
  --color-amber-500: #e7b55d;
  --color-amber-200: #ffe78d;
  --color-sage-700: #477a63;
  --color-sage-400: #75ba8c;
  --color-sage-200: #a7d589;
  --color-slate-500: #93978e;
  --surface-paper: var(--color-paper-100);
  --text-primary: var(--brand-paper);
  --text-secondary: var(--color-paper-200);
  --text-muted: var(--color-wood-100);
  --text-inverse: var(--color-ink-800);
  --text-accent: var(--brand-accent);
  --status-danger: var(--color-clay-500);
  --status-danger-text: var(--color-clay-300);
  --status-danger-bg: var(--color-clay-700);
  --status-warning: var(--color-amber-500);
  --status-warning-text: var(--color-amber-200);
  --status-warning-bg: var(--color-amber-700);
  --status-success: var(--color-sage-400);
  --status-success-text: var(--color-sage-200);
  --brand-primary: var(--color-tea-500);
  --brand-secondary: var(--color-charcoal-500);
  --brand-paper: var(--color-paper-100);
  --brand-ink: var(--color-charcoal-950);
  --brand-accent: var(--color-tea-300);
  --schedule-work: var(--color-amber-700);
  --schedule-break: var(--color-sage-700);
  --material-mineral: #b4ad86;
  --material-coal: #817467;
  --material-algae: #6c9f5d;
  --material-water: #e7c19a;
  --science-basic: #d6c1ab;
  --science-advanced: #dec0a1;
  --science-space: #e7b55d;
  --schedule-sleep: #8c765f;
  --schedule-bath: #7d8262;
  --priority-low: #d9a491;
  --surface-overlay: color-mix(in srgb, var(--ui-panel) 85%, transparent);
  --surface-tooltip: color-mix(in srgb, var(--ui-panel) 95%, transparent);
  --surface-scrim: color-mix(in srgb, var(--brand-ink) 55%, transparent);
  --surface-art-shade: color-mix(in srgb, var(--brand-ink) 25%, transparent);
  --font-ui: 'Galmuri11', sans-serif;
  --font-title: 'DOSMyungjo', serif;
  --font-weight-ui: 400;
  --radius-control: 2px;
  --control-padding-y: 6px;
  --control-padding-x: 9px;
  --opacity-disabled: 0.4;
  --hud-action-height: 78px;
  --line-height-ui: 1.5;
  --font-size-8: 10px;
  --font-size-9: 10px;
  --font-size-10: 12px;
  --font-size-11: 12px;
  --font-size-12: 12px;
  --font-size-13: 13px;
  --font-size-14: 14px;
  --font-size-15: 15px;
  --font-size-16: 16px;
  --font-size-17: 17px;
  --font-size-18: 18px;
  --font-size-20: 20px;
  --font-size-21: 21px;
  --font-size-23: 23px;
  --font-size-24: 24px;
  --font-size-25: 25px;
  --font-size-28: 28px;
  --font-size-30: 30px;
  --font-size-40: 40px;
  --font-size-48: 48px;
  --font-size-58: 58px;
  --font-size-90: 90px;
}

@font-face {
  font-family: 'DOSMyungjo';
  src: url('assets/fonts/DOSMyungjo.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Galmuri11';
  src: url('assets/fonts/Galmuri11.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Galmuri11';
  src: url('assets/fonts/Galmuri11-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  line-height: var(--line-height-ui);
  font-synthesis: none;
  color: var(--text-primary);
  font-size: var(--font-size-12);
  background: var(--ui-canvas);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
button,
select,
input,
textarea {
  font: inherit;
  color: inherit;
}
h1, h2, h3, h4, h5, h6, b, strong {
  font-weight: var(--font-weight-ui);
}
h1, h2, h3, h4, h5, h6, button, summary {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  cursor: pointer;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  border-radius: var(--radius-control);
  padding: var(--control-padding-y) var(--control-padding-x);
}
button:hover:not(:disabled) {
  background: var(--ui-hover);
  outline: 1px solid var(--ui-border);
}
button.active {
  background: var(--ui-active);
}
button:disabled {
  opacity: var(--opacity-disabled);
  cursor: default;
}
button:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}
.pixel-icon {
  width: 28px;
  height: 28px;
  display: block;
  mask: var(--icon-mask) center / contain no-repeat;
  -webkit-mask: var(--icon-mask) center / contain no-repeat;
  background: currentColor;
  flex-shrink: 0;
}
[data-icon] {
  display: inline-flex;
  color: var(--text-primary);
}
button b {
  font-weight: var(--font-weight-ui);
}
button small {
  display: block;
  color: var(--text-muted);
}
[hidden] {
  display: none !important;
}
#game-screen,
#viewport {
  position: fixed;
  inset: 0;
}
#world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: 0;
}
.time-hud,
.management-nav,
.notifications,
.overlay-strip,
.resource-panel,
.selection,
.build-window,
.build-categories,
.command-toolbar,
.zoom-controls,
.map-status,
.overlay-legend {
  position: absolute;
  z-index: 2;
}
.time-hud {
  left: 12px;
  top: 9px;
  display: flex;
  gap: 9px;
}
.cycle-clock {
  width: 73px;
  height: 73px;
  background: var(--ui-surface);
  border: 3px solid var(--ui-border);
  clip-path: polygon(22% 0, 78% 0, 100% 22%, 100% 78%, 78% 100%, 22% 100%, 0 78%, 0 22%);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.cycle-clock small {
  font-size: var(--font-size-10);
  z-index: 1;
}
.cycle-clock b {
  font-size: var(--font-size-24);
  z-index: 1;
  line-height: 25px;
}
.cycle-clock .pixel-icon {
  position: absolute;
  inset: 2px;
  width: 63px;
  height: 63px;
}
.colony-readout {
  padding-top: 1px;
}
.vital-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 30px;
}
.vital-strip > span,
.vital-strip > button {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vital-strip button {
  border: 0;
  background: none;
  padding: 0;
}
.vital-strip .pixel-icon {
  width: 20px;
  height: 20px;
}
.simulation-controls {
  display: flex;
  gap: 1px;
  margin-top: 3px;
}
.simulation-controls button {
  font-size: var(--font-size-12);
  padding: 2px 6px;
  min-width: 26px;
  height: 22px;
}
.simulation-controls .pixel-icon {
  width: 16px;
  height: 16px;
}
.colony-name {
  display: block;
  font-size: var(--font-size-11);
  margin-top: 6px;
  color: var(--text-secondary);
}
.management-nav {
  right: 10px;
  top: 8px;
  display: flex;
  gap: 1px;
}
.management-nav button {
  height: 36px;
  padding: 3px 8px;
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: var(--font-size-11);
}
.management-nav .pixel-icon {
  width: 21px;
  height: 21px;
}
.overlay-strip {
  top: 52px;
  right: 10px;
  display: flex;
  gap: 1px;
  align-items: center;
}
.overlay-strip > b {
  font-size: var(--font-size-10);
  margin-right: 6px;
}
.overlay-strip button {
  padding: 3px;
  background: var(--surface-overlay);
  width: 29px;
  height: 29px;
}
.overlay-strip .pixel-icon {
  width: 21px;
  height: 21px;
  color: var(--status-danger);
}
.overlay-strip button.active {
  background: var(--ui-active);
}
.notifications {
  top: 105px;
  left: 13px;
  width: 220px;
  display: grid;
  gap: 4px;
}
.tutorial-notice {
  text-align: left;
  border: 0;
  background: var(--surface-overlay);
  padding: 6px;
}
.tutorial-notice span {
  color: var(--text-secondary);
  margin-right: 7px;
}
.alert {
  padding: 5px 7px;
  background: var(--status-danger-bg);
  border-left: 3px solid var(--status-danger);
  font-weight: var(--font-weight-ui);
}
.notifications #queue-count {
  font-size: var(--font-size-10);
  color: var(--text-muted);
  margin: 4px;
}
.resource-panel {
  --resource-panel-top: 95px;
  right: 10px;
  top: var(--resource-panel-top);
  max-height: calc(100% - var(--resource-panel-top) - var(--hud-action-height) - 104px);
  overflow-y: auto;
  width: 215px;
  font-size: var(--font-size-11);
}
.resource-panel details {
  background: var(--surface-overlay);
  margin-bottom: 7px;
  border: 1px solid var(--ui-border);
}
.resource-panel summary {
  background: var(--ui-surface);
  padding: var(--control-padding-y) var(--control-padding-x);
  cursor: pointer;
  font-weight: var(--font-weight-ui);
}
.resource-panel .mineral-details {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--ui-border);
  background: transparent;
}
.resource-panel .mineral-details summary {
  background: transparent;
}
.resource-panel .mineral-details summary span:last-child {
  float: right;
  color: var(--text-secondary);
}
.resource-panel .mineral-details dl {
  padding-left: calc(var(--control-padding-x) + 14px);
}
.resource-panel dl {
  margin: 0;
  padding: var(--control-padding-y) var(--control-padding-x);
}
.resource-panel dl > div {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding: 4px 0;
}
.resource-panel dd {
  margin: 0;
  color: var(--text-secondary);
}
.material {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  transform: rotate(-15deg);
  background: var(--material-mineral);
}
.material.coal {
  background: var(--material-coal);
}
.material.algae {
  background: var(--material-algae);
}
.material.water {
  background: var(--material-water);
}
.build-categories {
  bottom: 23px;
  left: 12px;
  display: flex;
  gap: 1px;
  max-width: calc(100% - 440px);
  overflow-x: auto;
  padding: 3px 1px;
  scrollbar-width: thin;
}
.build-categories button {
  width: 49px;
  min-width: 49px;
  height: 59px;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: space-between;
  background: var(--ui-surface);
}
.build-categories button.active {
  background: var(--ui-active);
}
.build-categories .pixel-icon {
  width: 31px;
  height: 31px;
}
.build-categories b {
  font-size: var(--font-size-10);
  white-space: nowrap;
}
.build-window {
  z-index: 3;
  left: 12px;
  bottom: calc(var(--hud-action-height) + 37px);
  width: 274px;
  max-height: calc(100% - 200px);
  background: var(--ui-surface);
  border: 2px solid var(--ui-border);
  overflow: auto;
}
.window-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ui-active);
  border-bottom: 2px solid var(--ui-border);
  padding: 3px 7px;
}
.window-title h2 {
  font-size: var(--font-size-14);
  margin: 0;
}
.window-title button {
  background: var(--ui-active);
  padding: 0 6px;
  font-size: var(--font-size-20);
}
.build-window #buildings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
  gap: 1px;
}
.tool {
  min-height: 92px;
  padding: 5px 2px;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
}
.tool .pixel-icon {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
}
.wallpaper-icon {
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background-color: var(--wallpaper);
  background-size: 40px 40px;
  image-rendering: pixelated;
  box-sizing: border-box;
}
.tool b {
  font-size: var(--font-size-10);
}
.tool small {
  font-size: var(--font-size-9);
}
.build-description {
  background: var(--ui-panel);
  padding: 10px;
  min-height: 52px;
  font-size: var(--font-size-11);
  line-height: 1.5;
  border-top: 1px solid var(--ui-border);
}
.selection {
  right: 10px;
  top: 95px;
  width: 290px;
  max-height: calc(100% - 220px);
  overflow: auto;
  background: var(--ui-surface);
  border: 2px solid var(--ui-border);
}
.inspector-tabs {
  display: flex;
  padding: 5px 5px 0;
  gap: 1px;
}
.inspector-tabs button {
  flex: 1;
}
.selection-body {
  padding: 10px;
  background: var(--ui-surface);
  margin: 5px;
}
.selection-body p {
  line-height: 1.6;
  color: var(--text-secondary);
}
.selection-body small {
  color: var(--text-accent);
}
#selection-details {
  display: grid;
  gap: 8px;
  font-size: var(--font-size-11);
}
#selection-details > span {
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 7px;
}
#selection-details button {
  padding: 3px 5px;
  font-size: var(--font-size-10);
}
.inspector-actions {
  display: flex;
  gap: 1px;
  padding: 6px;
}
.inspector-actions button {
  flex: 1;
}
.command-toolbar {
  right: 12px;
  bottom: 25px;
}
.priority-control {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  font-size: var(--font-size-10);
}
.priority-control select {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  padding: 2px 10px;
}
.command-buttons {
  display: flex;
  gap: 1px;
}
.command-buttons button {
  width: 47px;
  height: 53px;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--surface-overlay);
}
.command-buttons .pixel-icon {
  color: var(--status-danger);
  width: 29px;
  height: 29px;
}
.command-buttons b {
  font-size: var(--font-size-9);
  margin-top: 4px;
  white-space: nowrap;
}
.command-buttons button.active {
  background: var(--ui-active);
}
.zoom-controls {
  bottom: calc(var(--hud-action-height) + 64px);
  right: 15px;
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: var(--font-size-10);
}
.zoom-controls button {
  padding: 2px 6px;
}
.map-status {
  bottom: 4px;
  left: 13px;
  right: 13px;
  display: flex;
  gap: 15px;
  color: var(--text-accent);
  font-size: var(--font-size-9);
  pointer-events: none;
}
.map-status #save-status {
  margin-left: auto;
}
.overlay-legend {
  right: 236px;
  top: 95px;
  width: 225px;
  background: var(--surface-tooltip);
  border: 1px solid var(--ui-border);
}
.overlay-legend header {
  background: var(--ui-hover);
  padding: 7px;
}
.overlay-legend p {
  padding: 0 10px;
  line-height: 1.6;
}
#tooltip {
  position: absolute;
  z-index: 4;
  background: var(--surface-tooltip);
  border: 1px solid var(--ui-border);
  padding: 8px 11px;
  pointer-events: none;
  max-width: 220px;
  line-height: 1.6;
}
#pause-banner {
  position: absolute;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--font-size-20);
  letter-spacing: 5px;
  pointer-events: none;
}
#gameover {
  position: absolute;
  inset: 30%;
  z-index: 8;
  background: var(--surface-tooltip);
  padding: 30px;
  text-align: center;
}
#toast {
  position: fixed;
  bottom: 135px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  padding: 12px 20px;
  max-width: 90vw;
  text-align: center;
}
dialog {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--text-primary);
  width: min(850px, 92vw);
  max-height: 85vh;
  padding: 26px;
  overflow: auto;
}
dialog::backdrop {
  background: var(--surface-scrim);
}
dialog h1 {
  font-size: var(--font-size-28);
}
dialog h2 {
  margin-top: 0;
}
dialog p {
  line-height: 1.7;
  color: var(--text-secondary);
}
.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
  font-size: var(--font-size-20);
  padding: 0 7px;
}
.primary {
  background: var(--ui-active);
  padding: 10px 20px;
}
.eyebrow {
  font-size: var(--font-size-10);
  letter-spacing: 2px;
  color: var(--text-accent);
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
#reset-dialog {
  width: 460px;
}
#game-menu {
  width: 290px;
  text-align: center;
  padding: 30px;
}
#game-menu > button {
  display: block;
  width: 100%;
  margin: 1px 0;
  padding: 10px;
}
#game-menu small {
  display: block;
  margin-top: 20px;
  color: var(--text-accent);
}
.management-tabs {
  display: flex;
  gap: 1px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.person-settings {
  padding: 12px;
  background: var(--ui-surface);
  margin-bottom: 12px;
}
.person-settings h3 {
  margin: 0 0 12px;
}
.person-settings h3 small {
  font-weight: normal;
  font-size: var(--font-size-10);
  color: var(--text-muted);
}
.work-priorities {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.work-priorities label {
  display: grid;
  gap: 5px;
}
.work-priorities select {
  padding: 5px;
  background: var(--ui-surface);
}
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
}
.schedule-grid button {
  padding: 6px 1px;
  font-size: var(--font-size-10);
}
.schedule-grid small {
  font-size: var(--font-size-9);
  margin-top: 3px;
}
.schedule-work {
  background: var(--schedule-work);
}
.schedule-break {
  background: var(--schedule-break);
}
.schedule-sleep {
  background: var(--schedule-sleep);
}
.schedule-bath {
  background: var(--schedule-bath);
}
.schedule-grid .now {
  outline: 2px solid var(--ui-focus);
}
.vitals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-12);
}
.vitals-table td,
.vitals-table th {
  padding: 12px 7px;
  text-align: left;
  border-bottom: 1px solid var(--ui-border);
}
.research-tree {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.research-tree button {
  padding: 20px;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.research-tree .pixel-icon {
  width: 44px;
  height: 44px;
}
.event,
.objective {
  padding: 10px;
  background: var(--ui-surface);
  margin: 4px 0;
  display: flex;
  gap: 12px;
}
.objective i {
  color: var(--text-accent);
}
.objective.done i {
  color: var(--status-success-text);
}
.event time {
  color: var(--text-muted);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (min-width: 1500px) {
  .build-categories button {
    width: 58px;
    min-width: 58px;
    height: 66px;
  }
  .build-window {
    bottom: calc(var(--hud-action-height) + 37px);
  }
  .management-nav button {
    padding: 4px 12px;
  }
}
@media (max-width: 1100px) {
  .management-nav button {
    padding: 4px 7px;
  }
  .management-nav b {
    display: none;
  }
  .overlay-strip > b {
    display: none;
  }
  .resource-panel {
    width: 190px;
  }
  .overlay-legend {
    right: 210px;
  }
  .build-categories {
    max-width: calc(100% - 440px);
  }
}
@media (max-width: 650px) {
  .cycle-clock {
    width: 57px;
    height: 57px;
  }
  .cycle-clock .pixel-icon {
    width: 47px;
    height: 47px;
  }
  .cycle-clock b {
    font-size: var(--font-size-18);
  }
  .time-hud {
    left: 7px;
    gap: 5px;
  }
  .vital-strip {
    gap: 5px;
    font-size: var(--font-size-10);
  }
  .vital-strip .pixel-icon {
    width: 16px;
    height: 16px;
  }
  .management-nav {
    top: 86px;
    left: 7px;
    right: auto;
    gap: 1px;
  }
  .management-nav button {
    height: 28px;
    padding: 3px 5px;
  }
  .management-nav .pixel-icon {
    width: 19px;
    height: 19px;
  }
  .overlay-strip {
    top: 7px;
    right: 5px;
    max-width: 150px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .overlay-strip button {
    width: 24px;
    height: 24px;
    padding: 2px;
  }
  .overlay-strip .pixel-icon {
    width: 18px;
    height: 18px;
  }
  .notifications {
    top: 125px;
    left: 7px;
    width: 165px;
  }
  .resource-panel {
    --resource-panel-top: 124px;
    width: 155px;
    right: 6px;
    font-size: var(--font-size-9);
  }
  .resource-panel dl {
    padding: 5px;
  }
  .build-categories {
    left: 6px;
    bottom: calc(var(--hud-action-height) + 42px);
    max-width: calc(100% - 12px);
  }
  .build-categories button {
    height: 50px;
    min-width: 44px;
    width: 44px;
  }
  .build-categories .pixel-icon {
    width: 25px;
    height: 25px;
  }
  .build-window {
    bottom: calc(var(--hud-action-height) * 2 + 56px);
    left: 6px;
    max-height: calc(100% - 260px);
  }
  .command-toolbar {
    bottom: 22px;
    right: 7px;
  }
  .priority-control {
    position: absolute;
    right: 0;
    top: -30px;
    white-space: nowrap;
  }
  .zoom-controls {
    bottom: calc(var(--hud-action-height) * 2 + 60px);
    right: auto;
    left: 7px;
  }
  .zoom-controls #center {
    display: none;
  }
  .selection {
    top: 124px;
    right: 6px;
    width: 265px;
    max-height: calc(100% - 280px);
  }
  .overlay-legend {
    right: 6px;
    top: 215px;
    width: 180px;
  }
  .map-status #state-label {
    display: none;
  }
  .schedule-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  dialog {
    padding: 18px;
  }
  .vitals-table {
    font-size: var(--font-size-10);
  }
  .vitals-table td,
  .vitals-table th {
    padding: 9px 3px;
  }
  #pause-banner {
    top: 65px;
    font-size: var(--font-size-15);
  }
  .colony-name {
    font-size: var(--font-size-9);
  }
}
/* Wabi-sabi sanctuary: existing menu composition and crew selection. */
.front-screen {
  position: fixed;
  inset: 0;
  z-index: 12;
  background: var(--ui-panel);
  overflow: auto;
}
.front-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: url("assets/scenes/title/sanctuary.png") center / cover no-repeat;
  image-rendering: pixelated;
}
.front-art:after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface-art-shade);
}
#front-character {
  position: absolute;
  left: 37%;
  bottom: 10%;
  width: 15%;
  transform: rotate(-5deg);
}
.title-page {
  position: relative;
  min-height: 100vh;
}
.title-menu {
  position: absolute;
  right: 9%;
  top: 7%;
  width: 360px;
  text-align: center;
}
.title-menu h1 {
  margin: 0 0 16px;
  line-height: 0;
}
.title-logo {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.title-menu > button {
  display: block;
  width: 100%;
  min-height: 35px;
  margin: 1px 0;
  font-weight: var(--font-weight-ui);
  font-size: var(--font-size-14);
  border: 2px solid var(--ui-border);
  background: var(--ui-surface);
}
.title-menu > button:hover:not(:disabled) {
  background: var(--ui-active);
}
.title-menu > button small {
  font-size: var(--font-size-10);
  padding-top: 4px;
  font-weight: normal;
  color: var(--text-secondary);
}
.title-menu > p {
  font-size: var(--font-size-11);
  color: var(--text-secondary);
}
.title-news {
  --skin-padding: 14px 12px;
  position: absolute;
  left: 4%;
  top: 8%;
  width: 240px;
  background: var(--surface-overlay);
  border: 2px solid var(--ui-border);
  padding: 18px;
  text-align: center;

}
.title-news > span {
  font-size: var(--font-size-9);
  letter-spacing: 2px;
  color: var(--text-muted);
}
.title-news h2 {
  font-size: var(--font-size-25);
  color: var(--text-secondary);
}
.title-news p {
  color: var(--text-secondary);
  font-size: var(--font-size-12);
  line-height: 1.8;
}
.title-news button {
  width: 100%;
  font-size: var(--font-size-11);
}
.front-version {
  position: absolute;
  bottom: 14px;
  left: 18px;
  font-size: var(--font-size-10);
  color: var(--text-secondary);
}
.choosing-crew {
  background: var(--ui-surface);
}
.choosing-crew .front-art {
  opacity: 0.1;
  filter: grayscale(1);
  pointer-events: none;
}
.choosing-crew:before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: none;
  background-size: 113px 97px,
    73px 139px;
  background-position: 12px 37px,
    50px 2px;
}
.setup-page {
  position: relative;
  width: min(900px, 94vw);
  margin: 0 auto;
  padding: 7vh 0 35px;
  min-height: 100vh;
}
.setup-page > h1 {
  font-size: var(--font-size-21);
  text-align: center;
  margin: 0 0 28px;
}
.setup-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-top: -14px;
}
.setup-page footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
  margin-top: 16px;
}
.setup-page footer button {
  min-width: 110px;
}
.setup-page footer button.primary {
  background: var(--ui-active);
}
.setup-page input,
#world-mode {
  color: var(--text-primary);
  background: var(--ui-surface);
  border: 2px solid var(--ui-border);
  padding: var(--control-padding-y) var(--control-padding-x);
  font: inherit;
  min-width: 0;
}
.setup-page input:focus {
  outline: 2px solid var(--ui-focus);
}
.world-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  max-width: 730px;
  margin: 30px auto 50px;
  border: 3px solid var(--ui-border);
  background: var(--ui-surface);
}
.asteroid {
  padding: 25px;
  text-align: center;
  background: var(--ui-panel);
}
.world-preview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  margin: 0 auto 20px;
  border: 2px solid var(--ui-border);
  image-rendering: pixelated;
}
.asteroid h2 {
  color: var(--text-secondary);
}
.asteroid p {
  line-height: 1.8;
  color: var(--text-muted);
}
.asteroid > span {
  display: block;
  background: var(--ui-active);
  padding: 7px;
}
.world-settings {
  padding: 26px;
}
.world-settings h2 {
  font-size: var(--font-size-17);
  margin-bottom: 25px;
}
.world-settings label {
  display: grid;
  gap: 9px;
}
.world-settings button {
  margin-top: 10px;
}
.world-settings dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 32px;
}
.world-settings dd {
  text-align: right;
  margin: 0;
  color: var(--text-secondary);
}
.world-settings p {
  color: var(--text-muted);
  line-height: 1.7;
  font-size: var(--font-size-11);
}
.crew-page {
  width: min(810px, 94vw);
  padding-top: 10vh;
}
.crew-page > h1 {
  font-size: var(--font-size-18);
  margin-bottom: 25px;
}
.crew-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.dupe-card {
  min-width: 0;
  position: relative;
  padding-top: 34px;
}
.reroll-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 1px;
}
.reroll-row button {
  padding: 4px 10px;
  white-space: nowrap;
  min-width: 95px;
  font-size: var(--font-size-11);
}
.reroll-row select {
  min-width: 0;
  width: 100%;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  font-size: var(--font-size-10);
}
.dupe-name {
  display: flex;
  align-items: center;
  background: var(--ui-active);
  border: 2px solid var(--ui-border);
  border-bottom: 0;
  height: 31px;
}
.dupe-name input {
  width: 100%;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  padding: 4px 8px;
  font-size: var(--font-size-16);
  font-weight: var(--font-weight-ui);
  line-height: 20px;
}
.dupe-name span {
  background: var(--ui-surface);
  margin-right: 4px;
  padding: 0 3px;
  font-size: var(--font-size-18);
}
.printing-chamber {
  height: 150px;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ui-border);
  background: var(--ui-hover);
}
.chamber-grid {
  position: absolute;
  inset: 0;
  background: transparent;
}
.chamber-grid:after {
  content: '';
  position: absolute;
  inset: 84% 15% -20%;
  border: 2px solid var(--ui-border);
  transform: perspective(60px) rotateX(40deg);
}
.dupe-portrait {
  display: block;
  width: 100%;
  height: 100%;
}
.printing-chamber .dupe-portrait {
  position: absolute;
  left: 15%;
  bottom: 3px;
  width: 70%;
  height: 137px;
  animation: none;
}
.dupe-card:nth-child(2) .dupe-portrait {
  animation-delay: -1s;
}
.dupe-card:nth-child(3) .dupe-portrait {
  animation-delay: -2s;
}
.dupe-data {
  background: var(--ui-surface);
  border: 2px solid var(--ui-border);
  border-top: 0;
  padding: 12px;
  min-height: 277px;
}
.dupe-data h2 {
  font-size: var(--font-size-14);
  margin: 0 0 10px;
  color: var(--text-primary);
}
.dupe-data h2:not(:first-child) {
  border-top: 2px solid var(--ui-border);
  margin: 13px -12px 10px;
  padding: 12px 12px 0;
}
.interest-line {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: var(--font-size-11);
  margin-bottom: 5px;
}
.interest-line span {
  color: var(--text-muted);
  font-size: var(--font-size-10);
}
.dupe-data > small {
  color: var(--text-muted);
  font-size: var(--font-size-10);
}
.trait {
  margin-bottom: 10px;
}
.trait b {
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-ui);
}
.trait small {
  display: block;
  padding: 4px 0 0 10px;
  color: var(--text-muted);
  font-size: var(--font-size-10);
}
.positive b {
  color: var(--status-success);
}
.negative b {
  color: var(--status-danger);
}
.dupe-attributes {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--ui-border);
  padding-top: 10px;
  font-size: var(--font-size-10);
  color: var(--text-muted);
}
.dupe-attributes b {
  color: var(--text-primary);
}
.dupe-bio {
  font-size: var(--font-size-10);
  line-height: 1.6;
  color: var(--text-secondary);
  font-style: italic;
  margin: 10px 0 0;
}
.crew-page footer {
  flex-wrap: wrap;
}
.crew-page footer label {
  font-size: var(--font-size-12);
}
.crew-page footer input {
  width: 230px;
}
.crew-page footer #random-colony-name {
  min-width: 35px;
}
.embark-actions {
  flex-basis: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}
.crew-page #setup-error {
  color: var(--status-danger-text);
  text-align: right;
  min-height: 18px;
}
#options-dialog {
  width: 420px;
}
.sound-settings,
.palette-shader-settings {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  border: 1px solid var(--ui-border);
}
.sound-settings label,
.palette-shader-settings label {
  display: flex;
  align-items: center;
  gap: 8px;
}
#toast {
  z-index: 40;
}
@keyframes dupe-bob {
  50% {
    transform: translateY(-3px) rotate(1deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .printing-chamber .dupe-portrait {
    animation: none;
  }
}
.reduce-motion * {
  animation: none !important;
}
@media (min-width: 1600px) {
  .crew-page {
    width: 900px;
  }
  .printing-chamber {
    height: 170px;
  }
  .printing-chamber .dupe-portrait {
    height: 155px;
  }
  .dupe-data {
    min-height: 310px;
    padding: 16px;
  }
  .dupe-data h2 {
    font-size: var(--font-size-16);
  }
  .trait b {
    font-size: var(--font-size-14);
  }
  .interest-line {
    font-size: var(--font-size-13);
  }
  .setup-page > h1 {
    font-size: var(--font-size-23);
  }
}
@media (max-width: 760px) {
  .title-menu {
    right: 5%;
    width: 280px;
    top: 4%;
  }
  .title-news {
    left: 3%;
    top: 7%;
    width: 220px;
    padding: 13px;
  }
  .title-news h2 {
    font-size: var(--font-size-20);
  }
  #front-character {
    left: 29%;
    width: 22%;
  }
  .crew-page {
    padding-top: 6vh;
  }
  .crew-cards {
    gap: 8px;
  }
  .dupe-data {
    padding: 9px;
    min-height: 285px;
  }
  .reroll-row button {
    min-width: 0;
    font-size: var(--font-size-10);
    padding: 4px 6px;
  }
  .reroll-row select {
    font-size: var(--font-size-9);
  }
  .printing-chamber {
    height: 135px;
  }
  .dupe-name input {
    font-size: var(--font-size-14);
  }
  .interest-line {
    display: block;
  }
  .interest-line span {
    display: block;
    margin-top: 3px;
  }
  .world-layout {
    margin: 20px auto;
  }
  .world-settings {
    padding: 18px;
  }
  .dupe-attributes {
    font-size: var(--font-size-9);
    gap: 4px;
  }
}
@media (max-width: 480px) {
  .title-menu {
    right: 6%;
    width: min(280px, 88vw);
  }
  .title-news {
    top: auto;
    bottom: 45px;
    left: 6%;
    width: 200px;
  }
  .title-news > span,
  .title-news p {
    display: none;
  }
  .title-news h2 {
    margin: 8px 0;
  }
  #front-character {
    left: 8%;
    bottom: 28%;
    width: 35%;
  }
  .crew-cards {
    grid-template-columns: 1fr;
  }
  .dupe-card {
    max-width: 290px;
    width: 100%;
    margin: 0 auto 14px;
  }
  .dupe-data {
    min-height: 260px;
  }
  .printing-chamber {
    height: 170px;
  }
  .printing-chamber .dupe-portrait {
    height: 155px;
  }
  .crew-page > h1 {
    font-size: var(--font-size-16);
  }
  .crew-page footer input {
    width: 175px;
  }
  .world-layout {
    grid-template-columns: 1fr;
  }
  .world-settings dl {
    margin-top: 15px;
  }
  .world-preview {
    aspect-ratio: 16 / 9;
    margin-bottom: 15px;
  }
  .asteroid {
    padding: 15px;
  }
  .setup-page {
    padding-top: 25px;
  }
  .front-version {
    font-size: var(--font-size-9);
  }
}
/* Keep all three starting profiles and the embark controls visible on desktop. */
.wish-heading {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  font-style: normal;
  color: var(--text-primary);
}
@media (min-width: 761px) {
  .crew-page { width: min(1120px, 96vw); padding: 12px 0; }
  .crew-page > h1 { font-size: var(--font-size-18); margin-bottom: 12px; }
  .crew-cards { gap: 12px; align-items: stretch; }
  .dupe-card { display: flex; flex-direction: column; }
  .crew-page .printing-chamber { height: clamp(64px, 12vh, 110px); flex-shrink: 0; }
  .crew-page .printing-chamber .animal-portrait {
    width: clamp(64px, 12vh, 110px); height: clamp(64px, 12vh, 110px);
  }
  .crew-page .dupe-data { min-height: 0; padding: 10px; flex: 1; }
  .crew-page .dupe-data h2 { font-size: var(--font-size-12); margin-bottom: 5px; }
  .crew-page .dupe-data h2:not(:first-child) { margin: 7px -10px 6px; padding: 7px 10px 0; }
  .crew-page .trait { margin-bottom: 6px; }
  .crew-page .trait b, .crew-page .interest-line { font-size: var(--font-size-12); }
  .crew-page .trait small { display: inline; padding: 0 0 0 6px; }
  .crew-page .dupe-attributes { padding-top: 6px; }
  .crew-page .dupe-bio { line-height: 1.5; margin-top: 8px; font-style: normal; }
  .crew-page footer { margin-top: 10px; }
}
.job-tool-panel {
  position: absolute;
  z-index: 5;
  right: 12px;
  bottom: 124px;
  width: 286px;
  background: var(--ui-surface);
  border: 2px solid var(--ui-border);
}
.job-tool-panel p {
  font-size: var(--font-size-11);
  line-height: 1.6;
  margin: 10px;
  color: var(--text-secondary);
}
.priority-palette {
  display: flex;
  margin: 10px 8px 0;
  gap: 1px;
}
.priority-palette button {
  padding: 5px 0;
  flex: 1;
  font-size: var(--font-size-16);
  background: var(--ui-surface);
}
.priority-palette button.active {
  background: var(--ui-active);
  color: var(--text-secondary);
  outline: 1px solid var(--ui-focus);
}
.job-tool-panel fieldset {
  margin: 10px;
  border: 1px solid var(--ui-border);
  padding: 8px;
  background: var(--ui-surface);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.job-tool-panel legend {
  padding: 0 5px;
  color: var(--text-muted);
  font-size: var(--font-size-11);
}
.job-tool-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-11);
}
.job-tool-panel input {
  accent-color: var(--brand-primary);
  margin: 0;
}
.queued-job {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--ui-border);
}
.queued-job .job-number {
  background: var(--ui-active);
  border: 1px solid var(--ui-border);
  padding: 5px 7px;
  font-size: var(--font-size-16);
}
.queued-job > div {
  flex: 1;
}
.queued-job strong {
  font-size: var(--font-size-11);
}
.queued-job small {
  display: block;
  color: var(--text-muted);
  font-size: var(--font-size-9);
  margin-top: 5px;
}
.queued-job button {
  padding: 4px;
  font-size: var(--font-size-10);
}
#selected-jobs h3 {
  font-size: var(--font-size-12);
  margin-top: 20px;
}
.priority-table-scroll {
  overflow: auto;
  border: 2px solid var(--ui-border);
}
.priority-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--ui-surface);
}
.priority-table th,
.priority-table td {
  border: 1px solid var(--ui-border);
  padding: 12px;
  text-align: center;
}
.priority-table thead {
  background: var(--ui-hover);
}
.priority-table thead th {
  font-size: var(--font-size-12);
}
.priority-table thead .pixel-icon {
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 8px;
  color: var(--text-primary);
}
.priority-table tbody th {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 0;
  min-width: 130px;
}
.priority-face {
  display: block;
  width: 43px;
  height: 55px;
  overflow: hidden;
  background: var(--ui-hover);
}
.priority-face svg {
  width: 65px;
  height: 78px;
  margin-left: -10px;
  margin-top: 0;
}
.priority-table td small {
  display: block;
  color: var(--text-muted);
  font-size: var(--font-size-10);
  margin-top: 4px;
}
.priority-table .work-level {
  width: 40px;
  height: 38px;
  font-size: var(--font-size-28);
  line-height: 28px;
  padding: 0;
  background: var(--ui-panel);
  border: 2px solid var(--ui-border);
  color: var(--text-secondary);
}
.priority-table .level-0 {
  color: var(--status-danger);
}
.priority-table .level-1,
.priority-table .level-2 {
  color: var(--priority-low);
}
.priority-table .level-4,
.priority-table .level-5 {
  color: var(--status-success-text);
}
.priority-key {
  font-size: var(--font-size-11);
  text-align: center;
  color: var(--text-muted);
}
@media (max-width: 650px) {
  .job-tool-panel {
    bottom: 145px;
    right: 7px;
    width: 265px;
  }
  .priority-table th,
  .priority-table td {
    padding: 7px;
  }
  .priority-table tbody th {
    min-width: 100px;
  }
  .priority-table .work-level {
    width: 34px;
  }
  .priority-face {
    display: none;
  }
}
#colony-dialog.research-open {
  width: 98vw;
  max-width: none;
  height: 94vh;
  max-height: 94vh;
  padding: 10px 15px;
  overflow: hidden;
}
#colony-dialog.research-open > h2 {
  font-size: var(--font-size-16);
  margin: 0 0 5px;
}
#colony-dialog.research-open .management-tabs {
  margin: 5px 35px 6px 0;
}
#colony-dialog.research-open .section-sub {
  display: none;
}
#tech-interface {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 240px;
  height: calc(100% - 75px);
  gap: 2px;
  background: var(--ui-panel);
}
.tech-sidebar {
  padding: 10px;
  background: var(--ui-surface);
  overflow: auto;
}
.tech-sidebar input,
.tech-sidebar select {
  width: 100%;
  padding: 7px;
  margin-bottom: 7px;
  font: inherit;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  color: var(--text-primary);
}
.tech-sidebar button {
  width: 100%;
  text-align: left;
  margin: 1px 0;
  font-size: var(--font-size-11);
}
.tech-sidebar p {
  font-size: var(--font-size-10);
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.tech-detail {
  padding: 15px;
  background: var(--ui-surface);
  overflow: auto;
}
.tech-detail h3 {
  font-size: var(--font-size-17);
  margin: 0 0 5px;
}
.tech-detail h4 {
  border-top: 1px solid var(--ui-border);
  padding-top: 12px;
}
.tech-detail small {
  font-size: var(--font-size-10);
  color: var(--text-muted);
  line-height: 1.5;
  display: block;
}
.tech-detail p {
  font-size: var(--font-size-11);
  line-height: 1.5;
}
.tech-detail button {
  width: 100%;
  padding: 10px;
  background: var(--ui-active);
}
.tech-detail .available-unlock {
  color: var(--status-success-text);
}
#tech-viewport {
  overflow: auto;
  background: var(--ui-surface);
  overscroll-behavior: contain;
}
#tech-map {
  position: relative;
  width: 2520px;
  height: 4920px;
}
.tech-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tech-lines path {
  fill: none;
  stroke: var(--text-accent);
  stroke-width: 3;
}
.tech-lines path.queued {
  stroke: var(--status-warning);
  stroke-width: 5;
}
.tech-node {
  position: absolute;
  width: 220px;
  min-height: 115px;
  padding: 0 5px 5px;
  background: var(--ui-hover);
  border: 2px solid var(--ui-border);
  border-radius: 0;
  text-align: left;
}
.tech-node > b {
  display: block;
  background: var(--ui-panel);
  margin: 0 -5px 5px;
  padding: 4px 6px;
  font-size: var(--font-size-11);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tech-node.selected {
  outline: 3px solid var(--ui-focus);
  outline-offset: 1px;
}
.tech-node.queued {
  border-color: var(--status-warning);
}
.tech-node.complete {
  background: var(--ui-hover);
}
.tech-node.complete > b {
  background: var(--ui-surface);
}
.tech-unlocks {
  display: flex;
  gap: 3px;
  margin-bottom: 5px;
  height: 34px;
}
.tech-unlocks span {
  width: 31px;
  height: 32px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  padding: 4px;
  color: var(--text-secondary);
}
.tech-unlocks .pixel-icon {
  width: 23px;
  height: 23px;
  filter: none;
}
.tech-progress {
  position: relative;
  background: var(--color-slate-500);
  border: 1px solid var(--ui-border);
  height: 15px;
  margin: 2px 0;
  text-align: center;
  color: var(--text-inverse);
  overflow: hidden;
}
.tech-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--science-basic);
}
.tech-progress.advanced i {
  background: var(--science-advanced);
}
.tech-progress.space i {
  background: var(--science-space);
}
.tech-progress span {
  position: relative;
  font-size: var(--font-size-9);
}
.tech-progress small {
  position: absolute;
  right: 3px;
  top: 2px;
  font-size: var(--font-size-8);
  color: var(--text-inverse);
}
.tech-node.complete .tech-progress i {
  width: 100% !important;
}
@media (max-width: 1000px) {
  #tech-interface {
    grid-template-columns: 140px minmax(0, 1fr) 190px;
  }
  .tech-detail {
    padding: 10px;
  }
}
@media (max-width: 650px) {
  #tech-interface {
    grid-template-columns: 110px minmax(0, 1fr);
    grid-template-rows: 1fr 180px;
  }
  .tech-sidebar {
    grid-row: 1/3;
    padding: 6px;
  }
  .tech-detail {
    grid-column: 2;
    grid-row: 2;
    border-top: 2px solid var(--ui-border);
  }
  .tech-detail h4 {
    margin: 7px 0;
  }
  .tech-detail p {
    margin: 5px 0;
  }
  #colony-dialog.research-open {
    height: 96vh;
    max-height: 96vh;
    padding: 8px;
  }
}
/* Visible key legends share the icon button, including narrow HUD layouts. */
.build-categories button,
.overlay-strip button,
.command-buttons button,
.management-nav button,
.simulation-controls button {
  position: relative;
}
.key-hint {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font: 400 var(--font-size-9)/var(--font-size-11) var(--font-ui);
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  background: var(--surface-overlay);
  padding: 0 2px;
  border-radius: var(--radius-control);
}
.build-categories button,
.command-buttons button {
  width: max-content;
  min-width: 52px;
  flex-shrink: 0;
  height: auto;
  min-height: var(--hud-action-height);
  padding: 4px 6px;
  display: grid;
  grid-template-rows: 31px auto 15px;
  justify-content: center;
  justify-items: center;
  align-content: center;
  gap: 2px;
}
.build-categories button b,
.command-buttons button b {
  margin: 0;
  line-height: var(--line-height-ui);
}
.build-categories button .key-hint,
.command-buttons button .key-hint {
  position: static;
  justify-self: end;
  line-height: 1.5;
  min-width: 0;
}
.overlay-strip button {
  height: 39px;
  padding-bottom: 12px;
  min-width: 34px;
}
.overlay-strip button[data-overlay='automation'] {
  min-width: 60px;
}
.management-nav button {
  padding-bottom: 12px;
  min-height: 38px;
}
.simulation-controls button {
  min-height: 30px;
  padding-bottom: 12px;
}
#pause {
  min-width: 42px;
}
#art-palette-toggle {
  min-width: 44px;
  padding: 2px 4px;
  font-size: var(--font-size-10);
}
.speed-key-hint {
  font: 400 var(--font-size-9) var(--font-ui);
  color: var(--text-primary);
  align-self: flex-end;
  padding: 0 3px 2px;
}
@media (max-width: 650px) {
  .overlay-strip button {
    height: 33px;
    min-width: 27px;
  }
  .overlay-strip button[data-overlay='automation'] {
    min-width: 58px;
  }
  .management-nav button {
    height: 37px;
  }
  .key-hint {
    font-size: var(--font-size-8);
  }
  .build-categories button {
    height: auto;
  }
  .command-buttons button {
    height: auto;
  }
}

.tutorial-notice {
  position: relative;
  padding-right: 20px;
}
/* Research reference: compact item tiles, persistent catalog, branching canvas. */
#tech-interface {
  grid-template-columns: 245px minmax(0, 1fr) 290px;
}
.tech-sidebar {
  padding: 8px;
  background: var(--ui-surface);
}
#tech-category-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  border-bottom: 2px solid var(--ui-border);
  padding-bottom: 8px;
}
#tech-category-list button {
  padding: 4px 2px;
  font-size: var(--font-size-10);
  text-align: center;
  margin: 0;
}
#tech-item-list section {
  margin: 10px 0 14px;
}
#tech-item-list .tech-list-heading {
  background: transparent;
  border: 0;
  padding: 3px 0;
  font-weight: var(--font-weight-ui);
  color: var(--text-primary);
}
#tech-item-list .tech-list-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  border: 0;
  padding: 2px 5px;
  background: var(--ui-hover);
  min-height: 25px;
  line-height: 1.25;
}
#tech-item-list .tech-list-item:nth-child(odd) {
  background: var(--ui-surface);
}
#tech-item-list img {
  width: 23px;
  height: 23px;
  object-fit: contain;
  flex-shrink: 0;
}
#tech-item-list .tech-list-item:hover {
  background: var(--ui-hover);
}
#tech-viewport {
  background: var(--ui-surface);
}
.tech-node {
  width: 240px;
  min-height: 0;
  padding: 0 5px 5px;
  background: var(--ui-hover);
  border: 2px solid var(--ui-border);
}
.tech-node .tech-heading {
  display: block;
  width: calc(100% + 10px);
  margin: 0 -5px 4px;
  padding: 4px 6px;
  background: var(--ui-panel);
  border: 0;
  border-bottom: 1px solid var(--ui-border);
  border-radius: 0;
  text-align: left;
  font-size: var(--font-size-11);
  font-weight: var(--font-weight-ui);
  line-height: 15px;
  color: var(--text-primary);
}
.tech-node.complete .tech-heading {
  background: var(--ui-surface);
}
.tech-unlocks {
  display: grid;
  grid-template-columns: repeat(5, 40px);
  gap: 4px;
  height: auto;
  min-height: 40px;
  margin: 4px 0 7px;
}
.tech-unlocks .tech-unlock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 43px;
  padding: 2px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 0;
}
.tech-unlock img {
  width: 35px;
  height: 37px;
  object-fit: contain;
}
.tech-unlocks .tech-unlock:hover,
.tech-unlocks .tech-unlock:focus-visible {
  outline: 2px solid var(--ui-focus);
  background: var(--ui-hover);
  outline-offset: 1px;
}
.tech-unlocks .unlock-symbol {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font-size: var(--font-size-30);
  width: auto;
  height: auto;
}
.tech-detail .unlock-list {
  display: grid;
  gap: 4px;
}
.tech-detail .unlock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: var(--ui-hover);
  border: 1px solid var(--ui-border);
  padding: 6px;
}
.unlock-row img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}
.unlock-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.unlock-row b {
  font-size: var(--font-size-12);
}
.unlock-row.selected {
  outline: 2px solid var(--ui-focus);
}
.unlock-inspector {
  padding: 10px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  margin: 10px 0;
}
.unlock-inspector > img {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: contain;
  background: var(--ui-surface);
  padding: 10px;
}
.unlock-inspector h4 {
  border: 0;
  margin: 8px 0 4px;
  padding: 0;
}
.unlock-inspector a {
  display: block;
  color: var(--text-secondary);
  font-size: var(--font-size-11);
  margin: 10px 0;
}
.unlock-state {
  font-size: var(--font-size-11);
  color: var(--status-warning-text);
}
.tech-detail .tech-prerequisite {
  padding: 6px;
  margin: 2px 0;
  text-align: left;
  background: var(--ui-hover);
}
.research-empty {
  padding: 20px;
  color: var(--text-primary);
}
@media (max-width: 1100px) {
  #tech-interface {
    grid-template-columns: 190px minmax(0, 1fr) 235px;
  }
}
@media (max-width: 750px) {
  #tech-interface {
    grid-template-columns: 145px minmax(0, 1fr);
    grid-template-rows: minmax(180px, 1fr) 230px;
  }
  .tech-sidebar {
    grid-row: 1/3;
  }
  .tech-detail {
    grid-column: 2;
    grid-row: 2;
  }
  #tech-category-list {
    grid-template-columns: repeat(2, 1fr);
  }
  .unlock-inspector > img {
    height: 65px;
  }
}
/* Biology uses the existing inspector and management surfaces. */
.bio-card {
  padding: 12px;
  margin: 8px 0;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--text-primary);
  overflow: hidden;
  text-align: left;
}
.bio-card > img {
  float: left;
  object-fit: contain;
  margin: 0 10px 6px 0;
  image-rendering: auto;
}
.bio-card h3 {
  margin: 2px 0 4px;
  font-size: var(--font-size-15);
}
.bio-card small {
  display: block;
  color: var(--text-muted);
}
.bio-card p {
  font-size: var(--font-size-12);
  line-height: 1.65;
  clear: both;
}
.bio-card a {
  color: var(--text-secondary);
}
.bio-status {
  display: block;
  clear: both;
  padding: 8px 0;
  color: var(--status-warning-text);
}
.bio-meter {
  display: block;
  clear: both;
  font-size: var(--font-size-12);
  margin: 7px 0;
}
.bio-meter > span {
  float: right;
}
.bio-meter progress {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 3px;
  accent-color: var(--brand-primary);
}
.bio-card select {
  max-width: 100%;
  width: 100%;
  margin: 6px 0;
}
.bio-card button {
  padding: 7px;
  margin: 1px 0;
}
.bio-actions {
  display: flex;
  flex-wrap: wrap;
}
.bio-summary {
  display: flex;
  gap: 12px;
}
.bio-summary b {
  padding: 12px 20px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}
.bio-live {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.bio-live > section {
  max-height: 330px;
  overflow: auto;
}
.bio-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 7px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}
.bio-row img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}
.bio-row > span:nth-child(2) {
  flex: 1;
}
.bio-row small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
}
.bio-row > span:last-child {
  font-size: var(--font-size-11);
  color: var(--text-secondary);
}
.bio-catalog {
  margin-top: 18px;
  border-top: 1px solid var(--ui-border);
  padding-top: 14px;
}
.bio-catalog summary {
  cursor: pointer;
  font-weight: var(--font-weight-ui);
}
.bio-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.bio-limit {
  color: var(--text-muted);
  font-size: var(--font-size-12);
  line-height: 1.6;
}
.biology-manager > p {
  line-height: 1.6;
}
@media (max-width: 800px) {
  .bio-live {
    grid-template-columns: 1fr;
  }
  .bio-summary {
    gap: 5px;
  }
  .bio-summary b {
    padding: 10px;
  }
}
.catalog-shortcut,
#rotate-building {
  margin: 8px 10px;
  padding: 8px;
  border: 1px solid var(--ui-border);
  background: var(--ui-hover);
  color: var(--text-primary);
}
#buildings img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
.catalog-toolbar {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}
.catalog-toolbar label {
  display: grid;
  gap: 6px;
}
.catalog-toolbar input {
  min-width: 230px;
}
.catalog-toolbar input,
.catalog-toolbar select {
  padding: 9px;
  background: var(--ui-surface);
  color: var(--text-primary);
  border: 1px solid var(--ui-border);
}
.catalog-toolbar > span {
  font-size: var(--font-size-12);
  color: var(--text-muted);
  margin-bottom: 10px;
}
.catalog-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 310px;
  gap: 18px;
  margin-top: 16px;
  height: min(560px, 60vh);
}
#catalog-results,
#catalog-details {
  overflow: auto;
  min-height: 0;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  padding: 10px;
}
.catalog-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px;
  text-align: left;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}
.catalog-row img {
  object-fit: contain;
  flex-shrink: 0;
}
.catalog-row > span:nth-child(2) {
  flex: 1;
}
.catalog-row small {
  display: block;
  font-size: var(--font-size-11);
  color: var(--text-muted);
  margin-top: 4px;
}
.catalog-row .catalog-live {
  color: var(--status-success-text);
}
.catalog-row:hover {
  background: var(--ui-hover);
}
.catalog-count {
  color: var(--text-muted);
  font-size: var(--font-size-12);
}
.catalog-detail > img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  float: left;
  margin-right: 15px;
}
.catalog-detail h3 {
  margin: 12px 0 5px;
}
.catalog-status {
  display: block;
  clear: both;
  padding: 14px 0;
  color: var(--text-secondary);
}
.catalog-detail h4 {
  border-bottom: 1px solid var(--ui-border);
  padding-bottom: 8px;
}
.catalog-detail dl {
  display: grid;
  grid-template-columns: 85px 1fr;
  gap: 10px;
  font-size: var(--font-size-12);
  line-height: 1.5;
}
.catalog-detail dd {
  margin: 0;
}
.catalog-detail dt {
  color: var(--text-muted);
}
.catalog-detail p,
.catalog-note {
  font-size: var(--font-size-12);
  line-height: 1.7;
  color: var(--text-muted);
}
.catalog-detail button {
  padding: 9px;
  margin: 6px 0;
}
.catalog-detail a {
  display: block;
  color: var(--text-secondary);
  margin: 16px 0;
}
.door-inspector {
  padding: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
}
.door-inspector h3 {
  margin-top: 0;
}
.door-modes {
  display: flex;
  margin: 12px 0;
  gap: 1px;
}
.door-modes button {
  padding: 8px;
  flex: 1;
}
.door-modes .active {
  background: var(--ui-active);
}
.door-inspector p {
  font-size: var(--font-size-12);
  line-height: 1.6;
}
.door-inspector label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
}
.door-inspector select {
  max-width: 160px;
}
@media (max-width: 760px) {
  .catalog-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  #catalog-results {
    max-height: 280px;
  }
  #catalog-details {
    max-height: 420px;
  }
  .catalog-toolbar input {
    min-width: 180px;
  }
}

/* Schedule notices share one stable row per activity. */
#alerts {
  display: grid;
  gap: 4px;
}
.activity-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--ui-border);
  background: var(--surface-tooltip);
}
.activity-alert > span {
  font-size: var(--font-size-20);
  width: 24px;
  text-align: center;
  color: var(--text-primary);
}
.activity-alert > b {
  flex: 1;
}
.activity-alert > small {
  color: var(--text-primary);
  font-size: var(--font-size-12);
}
.activity-alert.idle {
  border-left-color: var(--status-warning);
  background: var(--status-warning-bg);
}
.activity-alert.idle > span {
  color: var(--status-warning-text);
}
.activity-alert:hover:not(:disabled) {
  background: var(--ui-hover);
}
.notifications {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

#printing-open.ready {
  background: var(--ui-hover);
  border-left: 3px solid var(--ui-border);
  color: var(--text-primary);
  font-weight: var(--font-weight-ui);
}
#printing-dialog {
  width: min(1080px, 96vw);
  max-height: 94vh;
  background: var(--ui-surface);
  padding: 20px;
}
#printing-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#printing-dialog h2 {
  margin: 0;
}
#printing-status {
  color: var(--text-secondary);
}
#printing-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.print-card {
  border: 2px solid var(--ui-border);
  background: var(--ui-surface);
}
.print-card.chosen {
  border-color: var(--ui-focus);
}
.print-card h3 {
  background: var(--ui-active);
  margin: 0;
  padding: 10px;
  font-size: var(--font-size-17);
}
.print-card .dupe-data {
  min-height: 250px;
}
.print-card > button {
  width: 100%;
  min-height: 38px;
}
.care-parcel {
  height: 150px;
  display: grid;
  place-content: center;
  font-size: var(--font-size-90);
  color: var(--status-warning-text);
  background: var(--ui-surface);
}
#printing-dialog footer {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}
#printing-confirm {
  min-width: 150px;
  background: var(--ui-active);
}
@media (max-width: 760px) {
  #printing-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 440px) {
  #printing-cards {
    grid-template-columns: 1fr;
  }
}

.print-card {
  display: flex;
  flex-direction: column;
}
.print-card .dupe-data {
  flex: 1;
}
.print-card > button {
  margin-top: auto;
}

#data-load-error {
  position: fixed;
  z-index: 100;
  inset: 20px 20px auto;
  padding: 18px;
  background: var(--status-danger-bg);
  border: 2px solid var(--status-danger-text);
  font-size: var(--font-size-14);
  line-height: 1.6;
}

.system-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.system-card-grid article {
  padding: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-panel);
}
.system-card-grid p,
.system-inspector p {
  margin: 6px 0;
  line-height: 1.5;
}
.system-inspector {
  display: block;
  grid-column: 1/-1;
  border-top: 1px solid var(--ui-border);
  margin-top: 10px;
  padding-top: 8px;
}
.system-inspector h4 {
  margin: 12px 0 6px;
}
.system-inspector button {
  margin: 1px 0;
  padding: 6px 8px;
  font-size: var(--font-size-13);
}
.system-inspector details {
  margin: 8px 0;
}
.system-inspector summary {
  cursor: pointer;
  padding: 4px 0;
}
.system-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  max-height: 260px;
  overflow: auto;
}
.system-store-row {
  border-bottom: 1px solid var(--ui-border);
  padding: 6px 0;
}
.system-store-row > span {
  display: block;
}
.system-card-grid button:disabled,
.system-inspector button:disabled {
  opacity: var(--opacity-disabled);
  cursor:not-allowed;
}

/* Warm charcoal surfaces retain the tea-sanctuary artwork and HUD geometry. */
:root {
  accent-color: var(--brand-primary);
  color-scheme: dark;
}
button {
  background: var(--ui-surface);
}
button:hover:not(:disabled) { background-color:var(--ui-hover); }
button.active, button[aria-pressed="true"], button.primary {
  background: var(--ui-active);
}
.front-screen { background-color:var(--ui-panel); }
.front-art:after {
  background: var(--surface-art-shade);
}
.title-news { background:var(--surface-overlay); border-color:var(--ui-border); }
.choosing-crew { background:var(--ui-panel); }
.choosing-crew .front-art { opacity:.28; filter:saturate(.6); }
.choosing-crew:before {
  background: transparent;
}
.dupe-name { background:var(--ui-active); }
.printing-chamber {
  background: var(--ui-hover);
  border-color: var(--ui-border);
}
.chamber-grid {
  background: transparent;
}
.chamber-grid:after { display:none; }
.crew-page .chamber-grid {
  background: url("assets/scenes/prologue/prologue-cloud-sanctuary.png") 0% 66% / 250% auto no-repeat;
  image-rendering: pixelated;
}
.crew-page .dupe-card:nth-child(2) .chamber-grid { background-position: 50% 86%; }
.crew-page .dupe-card:nth-child(3) .chamber-grid { background-position: 100% 60%; }

.dupe-portrait, .build-card img, .catalog-thumb, .item-icon { image-rendering:pixelated; }

/* Animal portraits share the same 48px sprites as the world. */
.portrait.animal-avatar { background:none; border:0; overflow:visible; }
.portrait.animal-avatar::before, .portrait.animal-avatar::after { display:none; }
.portrait.animal-avatar .dupe-portrait { width:100%; height:100%; }
canvas, .wabi-icon, .animal-portrait { image-rendering:pixelated; }

.printing-chamber .animal-portrait { width:137px; height:137px; left:50%; transform:translateX(-50%); }
.animal-portrait { aspect-ratio:1; position:relative; }
.fur-patch {
  position: absolute;
  inset: 0;
  background-image: inherit;
  background-size: inherit;
  background-position: inherit;
  image-rendering: pixelated;
  pointer-events: none;
}
.priority-face .animal-portrait { height:43px; }

/* A wooden story board with a quiet paper reading surface. */
#prologue-page {
  text-align: center;
  width: min(1160px, 96vw);
  padding: 16px 0;
  min-height: 0;
  color: #33291f;
}
#prologue-page > h1 {
  margin: 0;
  padding: 12px 20px;
  border: 3px solid #9b7849;
  border-bottom: 0;
  background: linear-gradient(#251a12ba, #251a12ba), url("assets/world/wallpapers/wood.png") repeat;
  color: #fff0ce;
  font-family: var(--font-title);
  font-size: clamp(23px, 3vw, 28px);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .06em;
  text-shadow: 0 2px 1px #17110c;
  word-break: keep-all;
  text-wrap: balance;
}
#prologue-story {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 18px 24px;
  border: 6px solid #674a2d;
  border-image: url("assets/world/wallpapers/wood.png") 8 round;
  background: #f0e5cd;
  font-size: 14px;
  line-height: 1.65;
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 1px #c5af85;
}
#prologue-story > p { grid-column: 1 / -1; margin: 0; color: #493c2d; }
#prologue-story > p:last-child {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid #c5af85;
}
.prologue-person {
  display: grid;
  width: min(880px, 100%);
  justify-self: center;
  min-height: 230px;
  position: relative;
  isolation: isolate;
  grid-template-columns: 200px minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  column-gap: 24px;
  align-content: start;
  gap: 10px;
  padding: 14px 0 4px;
  border-top: 1px solid #c5af85;
}
.prologue-stage {
  grid-column: 1;
  grid-row: 1 / 4;
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 3px solid #95744b;
  border-radius: 70px 70px 8px 8px;
  background: linear-gradient(#f8eeda25, #44301a30), url("assets/scenes/prologue/prologue-cloud-sanctuary.png") 48% 80% / auto 100%;
}
.prologue-stage::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25px;
  border-top: 3px solid #bb945c;
  background: url("assets/world/wallpapers/wood.png") repeat;
}
.prologue-person .dupe-portrait {
  position: absolute;
  z-index: 1;
  width: 150px;
  height: 150px;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  transform-origin: center bottom;
  filter: drop-shadow(0 5px 2px #30221655);
  pointer-events: none;
}
@keyframes prologue-speaking {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); }
  50% { transform: translateX(-50%) translateY(-5px) rotate(1deg); }
}
#prologue-story[data-typing="true"] .prologue-person:not([hidden]) .dupe-portrait {
  animation: prologue-speaking .3s ease-in-out infinite;
}
.prologue-person h2 {
  grid-column: 2;
  margin: 0;
  align-self: center;
  color: #49301e;
  font-family: var(--font-title);
  font-size: 20px;
  line-height: 1.5;
}
.prologue-person p { grid-column: 2; margin: 0; }
.prologue-person .prologue-speech {
  position: relative;
  align-self: start;
  margin: 0 0 12px 16px;
  padding: 16px 20px;
  border: 2px solid #95744b;
  border-radius: 16px 16px 16px 2px;
  background: #f8eeda;
  font-size: 16px;
}
.prologue-speech::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 22px;
  width: 16px;
  height: 16px;
  border-left: 2px solid #95744b;
  border-bottom: 2px solid #95744b;
  background: #f8eeda;
  transform: rotate(45deg);
}
#prologue-story [hidden] { display: none; }
#prologue-story .wish-heading {
  color: #614323;
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 400;
}
#prologue-page footer { justify-content: center; margin-top: 12px; }
#prologue-page footer button.primary {
  min-height: 44px;
  padding: 9px 24px;
  border: 2px solid #b99b68;
  background: linear-gradient(#332218c9, #332218c9), url("assets/world/wallpapers/wood.png") repeat;
  color: #fff0ce;
  font-size: 14px;
}
#prologue-page footer button.primary:hover { filter: brightness(1.15); }
#prologue-continue:focus-visible { outline: 3px solid #fff0ce; outline-offset: 4px; }
@media (max-width: 700px) {
  #prologue-story { grid-template-columns: 1fr; gap: 10px; padding: 14px 16px; }
  .prologue-person { padding: 12px 0 2px; }
  #prologue-page footer button.primary { width: 100%; }
}

@keyframes prologue-arrive {
  from { opacity: .18; transform: translateY(-22px); }
  to { opacity: 1; transform: translateY(0); }
}
#prologue-page:not([hidden]) > h1 {
  animation: prologue-arrive 1.4s cubic-bezier(.22, .61, .36, 1) both;
}
#prologue-page:not([hidden]) #prologue-story > * {
  animation: prologue-arrive 1.6s var(--intro-delay, 0s) cubic-bezier(.22, .61, .36, 1) both;
}
#prologue-story > :nth-child(1) { --intro-delay: .25s; }
#prologue-story > :nth-child(2) { --intro-delay: .55s; }
#prologue-story > [data-prologue-step] { --intro-delay: 0s; }
#prologue-page:not([hidden]) footer {
  animation: prologue-arrive 1.2s .7s cubic-bezier(.22, .61, .36, 1) backwards;
}
#prologue-page:not([hidden]) footer:focus-within { animation: none; }
.reduce-motion #prologue-page > h1,
.reduce-motion #prologue-page #prologue-story > *,
.reduce-motion #prologue-page footer { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  #prologue-page > h1,
  #prologue-page #prologue-story > *,
  #prologue-page footer { animation: none !important; }
}

.prologue-wish { display: grid; }
.prologue-wish > span { grid-area: 1 / 1; }
.prologue-wish-space { visibility: hidden; }

#front-screen:has(#title-page:not([hidden])) .front-art {
  background-image: url("assets/ui/branding/gosanun-title-scene.png");
  background-position: left center;
}
#front-screen:has(#title-page:not([hidden])) #front-character { display: none; }
#front-screen:has(#prologue-page:not([hidden])) .front-art {
  background-image: url("assets/scenes/prologue/prologue-cloud-sanctuary.png");
}
#front-screen:has(#prologue-page:not([hidden])) #front-character { display: none; }
#prologue-story[data-step="0"]::before {
  content: '';
  height: clamp(160px, 26vh, 220px);
  border: 2px solid #95744b;
  background: url("assets/scenes/prologue/prologue-cloud-sanctuary.png") center 55% / cover;
  image-rendering: pixelated;
}

@media (max-width: 700px) {
  .prologue-person { grid-template-columns: 88px minmax(0, 1fr); column-gap: 12px; }
  .prologue-stage { min-height: 160px; border-radius: 36px 36px 6px 6px; }
  .prologue-person .dupe-portrait { width: 84px; height: 84px; bottom: 26px; }
  .prologue-person .prologue-speech { margin-left: 0; padding: 12px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  #prologue-story[data-typing="true"] .dupe-portrait { animation: none !important; }
}

#prologue-story > p,
.prologue-person > p,
.prologue-wish { white-space: pre-line; }

/* Match the title artwork's 1672 × 941 cover crop, anchored left/center. */
.title-hearth-scene {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  width: max(100%, calc(100vh * 1672 / 941));
  aspect-ratio: 1672 / 941;
  transform: translateY(-50%);
  pointer-events: none;
}
#front-screen:has(#title-page:not([hidden])) .title-hearth-scene { display: block; }
/* Eight 32px poses keep the flame base fixed beneath the kettle. */
.title-hearth {
  position: absolute;
  left: 26.85%;
  top: 71.73%;
  width: 3.83%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  overflow: hidden;
  image-rendering: pixelated;
}
.title-hearth::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 800%;
  background: url("assets/ui/branding/title-hearth-flames.svg") 0 0 / 100% 100% no-repeat;
  animation: hearth-flames .8s steps(8, end) infinite;
}
@keyframes hearth-flames {
  to { transform: translateX(-100%); }
}
.reduce-motion .title-hearth::before { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .title-hearth::before { animation: none; }
}

.parachute-equipment { display: flex; align-items: center; gap: 8px; }
.parachute-equipment img {
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(.5px 0 white) drop-shadow(-.5px 0 white) drop-shadow(0 .5px white) drop-shadow(0 -.5px white);
}
.parachute-equipment small { display: block; color: var(--text-muted); margin-top: 4px; }

/* Keep mobile browsers from zooming when a small text field receives focus. */
@media (hover: none) and (pointer: coarse) {
  body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  input, textarea, [contenteditable='true'] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }
  input, textarea, select {
    font-size: 16px !important;
  }
}

.build-color-header { display:flex; align-items:center; justify-content:space-between; gap:6px; }
#build-color-preview { width:90px; height:72px; image-rendering:pixelated; }
.item-color-swatches { display:grid; grid-template-columns:repeat(6,1fr); gap:5px; padding:6px 0; }
.item-color-swatches button { min-width:32px; min-height:32px; padding:2px; background:var(--item-color); border:2px solid var(--ui-border); color:var(--text-primary); }
.item-color-swatches button[aria-pressed="true"] { outline:2px solid var(--text-primary); outline-offset:1px; }

#build-colors button { --skin-surface: var(--item-color); }

.temple-dialog { width:min(560px,calc(100vw - 24px)); max-height:85dvh; overflow:auto; padding:20px; background:var(--panel-bg,#29271f); color:var(--text-primary,#eee3c9); border:2px solid var(--ui-border,#817457); }
.temple-dialog::backdrop { background:#10120ed0; }
.temple-dialog header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.temple-dialog h2 { margin:0; }
.temple-dialog label { display:grid; gap:6px; margin:12px 0; }
.temple-dialog input, .temple-dialog textarea, .temple-dialog select { box-sizing:border-box; width:100%; max-width:100%; padding:10px; font:inherit; font-size:16px; }
.temple-dialog textarea { resize:vertical; }
.temple-dialog button { min-height:40px; }
.temple-dialog ol { padding:0; list-style:none; }
.temple-dialog li { margin:12px 0; padding:12px; border-top:1px solid var(--ui-border,#817457); }
.temple-dialog li p { white-space:pre-wrap; overflow-wrap:anywhere; }
.temple-dialog canvas { width:100%; max-height:260px; object-fit:contain; image-rendering:pixelated; }
.temple-dialog progress { width:100%; }
.temple-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
