:root {
  color-scheme: light dark;
  --gold: #d7a900;
  --gold-bright: #f0c43b;
  --paper: #f6f2e8;
  --ink: #171918;
  --focus: #f4c732;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0e0f10;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select { font: inherit; }

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

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

.skip-link {
  position: fixed;
  z-index: 3000;
  top: 8px;
  left: 8px;
  padding: 8px 11px;
  border-radius: 4px;
  background: #151718;
  color: #f4c732;
  font-size: 12px;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell,
.engine-stage,
.engine-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.engine-stage {
  --prairie-turn-duration: 900ms;
  --prairie-turn-ease: cubic-bezier(0.62, 0.02, 0.18, 1);
  --prairie-turn-intensity: 0.86;
  isolation: isolate;
  overflow: hidden;
  background: #f6f2e8;
}

.engine-frame {
  z-index: 0;
  display: block;
  border: 0;
  background: #f6f2e8;
}

.engine-frame.is-active {
  z-index: 0;
  visibility: visible;
  opacity: 1;
  clip-path: inset(0);
  pointer-events: auto;
}

.engine-frame.is-standby {
  z-index: 1;
  visibility: hidden;
  opacity: 1;
  clip-path: inset(0 100% 0 0);
  pointer-events: none;
}

.engine-stage.prairie-turn-staging .engine-frame {
  pointer-events: none;
  will-change: clip-path, opacity;
}

.engine-stage.prairie-turn-staging .engine-frame.is-standby,
.engine-stage.prairie-turn-revealing .engine-frame.is-standby {
  visibility: visible;
}

.engine-stage.prairie-turn-revealing .engine-frame.is-standby {
  z-index: 2;
  animation: prairie-turn-frame-reveal var(--prairie-turn-duration) var(--prairie-turn-ease) both;
}

.worldline-transition {
  position: absolute;
  z-index: 390;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-100%, 0, 0);
  transform-origin: right center;
}

.engine-stage.prairie-turn-revealing .worldline-transition {
  animation: prairie-turn-worldline-sweep var(--prairie-turn-duration) var(--prairie-turn-ease) both;
  will-change: transform, opacity;
}

.worldline-wake {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(150px, 28vw, 360px);
  overflow: hidden;
  opacity: var(--prairie-turn-intensity);
  background: linear-gradient(90deg, transparent 0%, rgba(215, 169, 0, 0.018) 54%, rgba(240, 196, 59, 0.13) 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.28) 24%, #000 66%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.28) 24%, #000 66%);
}

.worldline-contour {
  position: absolute;
  right: -16%;
  display: block;
  width: 116%;
  height: 31%;
  border-top: 1px solid rgba(19, 18, 14, 0.72);
  border-radius: 50%;
  filter: drop-shadow(0 -1px 0 rgba(240, 196, 59, 0.66));
  transform-origin: right center;
}

.worldline-contour:nth-child(1) {
  top: 5%;
  transform: rotate(-7deg) scaleY(0.74);
}

.worldline-contour:nth-child(2) {
  top: 29%;
  right: -7%;
  width: 108%;
  transform: rotate(5deg) scaleY(1.08);
}

.worldline-contour:nth-child(3) {
  top: 55%;
  right: -20%;
  width: 125%;
  transform: rotate(-4deg) scaleY(0.86);
}

.worldline-contour:nth-child(4) {
  top: 78%;
  right: -11%;
  width: 112%;
  transform: rotate(8deg) scaleY(0.62);
}

.worldline-seam {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: block;
  width: 2px;
  opacity: clamp(0.78, var(--prairie-turn-intensity), 1);
  background: linear-gradient(180deg, transparent 0%, #d7a900 5%, #f0c43b 48%, #d7a900 95%, transparent 100%);
  box-shadow:
    -1px 0 0 rgba(23, 25, 24, 0.72),
    1px 0 0 rgba(246, 242, 232, 0.68),
    0 0 11px rgba(240, 196, 59, 0.78),
    -12px 0 28px rgba(215, 169, 0, 0.18);
}

@keyframes prairie-turn-frame-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}

@keyframes prairie-turn-worldline-sweep {
  0% { opacity: 0; transform: translate3d(-100%, 0, 0); }
  4% { opacity: 1; }
  96% { opacity: 1; }
  100% { opacity: 0.92; transform: translate3d(0, 0, 0); }
}

@keyframes prairie-turn-frame-dissolve {
  from { opacity: 0.08; }
  to { opacity: 1; }
}

.simulation-ui {
  --simulation-clearance: clamp(48px, 11vh, 104px);
  position: fixed;
  z-index: 400;
  left: 50%;
  bottom: var(--simulation-clearance);
  width: min(790px, calc(100vw - 48px));
  color: #171918;
  transform: translateX(-50%);
}

.simulation-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(35, 32, 25, 0.4);
  border-radius: 6px;
  background: rgba(246, 242, 232, 0.96);
  box-shadow:
    0 8px 26px rgba(35, 32, 25, 0.16),
    inset 0 0 0 3px rgba(246, 242, 232, 0.82),
    inset 0 0 0 4px rgba(138, 122, 92, 0.16);
  backdrop-filter: blur(4px);
}

.simulation-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
  width: 100%;
  margin: 0;
}

.simulation-input,
.simulation-button {
  height: 44px;
  min-height: 44px;
  margin: 0;
  border: 1px solid #232019;
  border-radius: 3px;
  color: #171918;
  font-family: "Times New Roman", Times, serif;
}

.simulation-input {
  appearance: none;
  min-width: 0;
  padding: 0 13px;
  background: rgba(246, 242, 232, 0.34) !important;
  color-scheme: light;
  font-size: 17px;
  -webkit-text-fill-color: #171918;
}

.simulation-input::placeholder {
  color: rgba(23, 25, 24, 0.58);
  font-style: italic;
}

.simulation-input:hover:not(:disabled),
.simulation-input:focus,
.simulation-button:hover:not(:disabled) {
  border-color: #000;
}

.simulation-input:focus {
  outline: 2px solid rgba(122, 92, 46, 0.64);
  outline-offset: 2px;
}

.simulation-button {
  min-width: 76px;
  padding: 0 15px;
  background: rgba(246, 242, 232, 0.98);
  cursor: pointer;
  font-size: 14px;
}

.advance-button {
  background: rgba(239, 233, 218, 0.98);
  font-style: italic;
}

.simulation-input:disabled,
.simulation-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.simulation-narrative {
  grid-column: 1 / -1;
  min-height: 1.4em;
  max-height: min(92px, calc(var(--simulation-clearance) + 24px));
  margin: 0;
  padding: 9px 12px 3px 16px;
  border-top: 1px solid rgba(35, 32, 25, 0.18);
  border-left: 3px solid rgba(183, 137, 0, 0.58);
  overflow-x: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  color: #000;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(13px, 1.45vw, 16px);
  font-style: normal;
  line-height: 1.35;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.engine-help {
  z-index: 405;
  display: flex;
  align-items: center;
}

.title-help {
  position: fixed;
  top: calc(50% + 87px);
  left: calc(50% + 312px);
  transform: translateY(-50%);
}

.world-help {
  position: relative;
  justify-self: center;
}

.help-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(35, 32, 25, 0.62);
  border-radius: 50%;
  background: rgba(246, 242, 232, 0.58);
  color: #171918;
  cursor: help;
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(35, 32, 25, 0.09);
  backdrop-filter: blur(3px);
}

.help-button:hover,
.help-button:focus-visible,
.engine-help.is-open .help-button {
  border-color: #232019;
  background: rgba(246, 242, 232, 0.86);
}

.help-card {
  position: absolute;
  width: min(290px, calc(100vw - 92px));
  padding: 14px 16px;
  border: 1px solid rgba(35, 32, 25, 0.32);
  border-radius: 4px;
  background: rgba(246, 242, 232, 0.94);
  color: #171918;
  box-shadow: 0 8px 24px rgba(35, 32, 25, 0.13);
  backdrop-filter: blur(5px);
}

.title-help .help-card {
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
}

.world-help .help-card {
  right: 0;
  bottom: 46px;
}

.help-card p {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.42;
}

.program-controls {
  position: fixed;
  z-index: 420;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  isolation: isolate;
  transform: translateZ(0);
}

.model-control {
  position: static;
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(244px + 2ch);
  min-width: 0;
  min-height: 36px;
  padding: 0 7px 0 10px;
  border: 1px solid rgba(122, 92, 46, 0.34);
  border-radius: 4px;
  background: rgba(246, 242, 232, 0.94);
  color: #232019;
  font-family: "Hoefler Text", "Iowan Old Style", Baskerville, "Palatino", "Book Antiqua", Georgia, serif;
  box-shadow: 0 1px 4px rgba(35, 32, 25, 0.12);
}

.home-button {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid rgba(246, 242, 232, 0.34);
  border-radius: 3px;
  background: rgba(14, 15, 16, 0.88);
  color: #dadbd4;
  cursor: pointer;
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 4px rgba(14, 15, 16, 0.24);
}

.home-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--gold-bright);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.45;
}

.home-button:hover:not(:disabled),
.model-control:hover {
  border-color: rgba(122, 92, 46, 0.58);
}

.home-button:hover:not(:disabled) { background: #171918; }
.model-control:hover { background: #f6f2e8; }

.home-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.model-control label {
  color: #8a7a5c;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.model-control .model-input-wrap select {
  height: 34px;
  border: 0;
  border-left: 1px solid rgba(138, 122, 92, 0.34);
  border-radius: 0;
  background: transparent;
  color: #232019;
  color-scheme: light;
  font: inherit;
  font-size: 13px;
  box-shadow: none;
  cursor: pointer;
}

.model-control .model-input-wrap select:focus {
  border-left-color: rgba(122, 92, 46, 0.68);
  outline: 0;
  background: rgba(215, 169, 0, 0.07);
  box-shadow: inset 0 0 0 1px rgba(183, 137, 0, 0.34);
}

.model-control .select-caret { color: #8a7a5c; }

.model-control option {
  background: #f6f2e8;
  color: #232019;
  font-family: "Hoefler Text", "Iowan Old Style", Baskerville, "Palatino", "Book Antiqua", Georgia, serif;
}

.world-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(185px, 18vw, 220px);
  aspect-ratio: 2500 / 750;
  border: 0;
  background: transparent;
  opacity: 0.96;
  pointer-events: none;
  transform: translateY(-10px);
  user-select: none;
}

.world-stamp img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.world-stamp.is-working { animation: stamp-breathe 2.6s ease-in-out infinite; }

@keyframes stamp-breathe {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .world-stamp.is-working { animation: none; opacity: 0.94; }
}

.model-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.model-input-wrap select {
  appearance: none;
  width: 100%;
  height: 25px;
  padding: 0 28px 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 4px;
  outline: 0;
  background: #151718;
  color: #dedfd7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 9px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.52);
}

.model-input-wrap select:focus { border-color: rgba(224, 170, 0, 0.65); }

.model-input-wrap select:disabled {
  cursor: default;
  opacity: 0.58;
}

.select-caret {
  position: absolute;
  top: 50%;
  right: 9px;
  color: var(--gold);
  font-size: 13px;
  pointer-events: none;
  transform: translateY(-60%);
}

.operation-lock {
  position: fixed;
  z-index: 410;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: default;
  background: rgba(246, 242, 232, 0.18);
  color: #171918;
  backdrop-filter: blur(1.5px);
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 178px;
  padding: 22px 28px 20px;
  border: 1px solid rgba(35, 32, 25, 0.34);
  border-radius: 6px;
  background: rgba(246, 242, 232, 0.92);
  box-shadow: 0 10px 34px rgba(35, 32, 25, 0.2);
}

.engine-stage.prairie-turn-revealing .operation-lock {
  background: transparent;
  backdrop-filter: none;
}

.engine-stage.prairie-turn-revealing .loading-card {
  visibility: hidden;
  opacity: 0;
}

.loading-mechanism {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 36px;
}

.loading-mechanism span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #171918;
  animation: prairie-loading-pulse 1.2s ease-in-out infinite;
}

.loading-mechanism span:nth-child(2) { animation-delay: 0.15s; }
.loading-mechanism span:nth-child(3) { animation-delay: 0.3s; }

.operation-label {
  font-family: "Times New Roman", Times, serif;
  font-size: 27px;
  font-style: italic;
  letter-spacing: 0.02em;
}

@keyframes prairie-loading-pulse {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.connection-wall {
  position: fixed;
  z-index: 1500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 46%, #35383a 0%, #1a1c1d 34%, #0b0c0d 78%),
    #0b0c0d;
}

.connection-wall::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.012) 4px);
  opacity: 0.35;
}

.connection-wall.is-hidden { display: none; }

.connection-panel {
  position: relative;
  z-index: 1;
  width: min(410px, calc(100vw - 48px));
  max-height: calc(100vh - 40px);
  padding: 30px 34px 27px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: linear-gradient(145deg, #292c2e, #1b1d1f 48%, #141617);
  color: #ddd9cb;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -2px 8px rgba(0, 0, 0, 0.55),
    0 35px 90px rgba(0, 0, 0, 0.62);
}

.connection-panel::after {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: 6px;
  pointer-events: none;
  content: "";
}

.connection-mark {
  float: right;
  width: 62px;
  height: 62px;
  margin: -5px -5px 10px 16px;
  object-fit: contain;
  filter: drop-shadow(0 7px 16px rgba(0, 0, 0, 0.42));
}

.eyebrow {
  margin: 0;
  color: var(--gold-bright);
  font-size: 9px;
  font-weight: 720;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.connection-panel h1 {
  margin: 8px 0 9px;
  color: #f0ede3;
  font-size: 28px;
  font-weight: 370;
  letter-spacing: -0.035em;
}

.connection-message {
  max-width: 310px;
  margin: 0 0 24px;
  color: #b7bab3;
  font-size: 13px;
  line-height: 1.55;
}

.connection-form {
  display: grid;
  gap: 8px;
}

.connection-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.connection-form label,
.advanced-field label {
  margin-top: 4px;
  color: #bfc0b9;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.045em;
}

.connection-form > input,
.wall-model-wrap select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  outline: 0;
  background: #101213;
  color: var(--paper);
  font-size: 12px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.66);
}

.connection-form > input:focus,
.wall-model-wrap select:focus {
  border-color: rgba(228, 177, 17, 0.8);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.66), 0 0 0 1px rgba(228, 177, 17, 0.15);
}

.inline-link {
  width: fit-content;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid rgba(255, 216, 95, 0.5);
  background: transparent;
  color: #f0ca57;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.35;
}

.inline-link:hover:not(:disabled) {
  border-color: var(--focus);
  color: #ffe38a;
}

.wall-model-wrap {
  position: relative;
  width: 100%;
}

.wall-model-wrap select {
  padding-right: 34px;
  border-left: 2px solid var(--gold);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.wall-model-wrap select:hover {
  border-color: rgba(255, 255, 255, 0.24);
  border-left-color: var(--gold-bright);
  background: #12191a;
}

.wall-model-wrap .select-caret {
  right: 13px;
  color: var(--gold-bright);
  font-size: 15px;
}

.model-row-label { margin-top: 2px; }

.roster-count {
  color: #8b8f88;
  font-size: 10px;
  font-weight: 620;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 42px;
  border-radius: 5px;
  cursor: pointer;
}

.primary-button {
  margin-top: 12px;
  border: 1px solid #b28500;
  background: linear-gradient(180deg, #e7b500 0%, #b48600 52%, #8a6600 100%);
  color: #171309;
  font-size: 12px;
  font-weight: 710;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.36),
    inset 0 -2px rgba(83, 57, 0, 0.38),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

.primary-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #f5c41c 0%, #c69500 54%, #936e00 100%);
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.055);
  color: #e1e2da;
  font-size: 11px;
  font-weight: 640;
}

.secondary-button:hover:not(:disabled) {
  border-color: rgba(255, 216, 95, 0.58);
  background: rgba(255, 255, 255, 0.09);
}

.primary-button:disabled,
.secondary-button:disabled,
.inline-link:disabled {
  cursor: default;
  opacity: 0.48;
}

.recovery-actions {
  display: grid;
  gap: 9px;
}

.recovery-actions .primary-button { margin-top: 0; }

.forget-key-button {
  justify-self: center;
  margin-top: 4px;
}

.connection-error {
  margin: 15px 0 0;
  padding: 10px 11px;
  border: 1px solid rgba(241, 138, 114, 0.25);
  border-radius: 4px;
  background: rgba(89, 33, 24, 0.23);
  color: #f0a18e;
  font-size: 11px;
  line-height: 1.45;
}

.secret-note {
  margin: 12px 0 0;
  color: #92968f;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 1800;
  right: 18px;
  bottom: 18px;
  max-width: min(390px, calc(100vw - 36px));
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(18, 20, 21, 0.92);
  color: #e4e2d8;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

@media (max-width: 620px) {
  .program-controls {
    top: 10px;
    right: 10px;
    left: 10px;
    justify-content: flex-end;
  }
  .model-control { width: min(calc(244px + 2ch), calc(100vw - 104px)); }
  .model-control label { display: none; }
  .world-stamp {
    width: min(180px, calc(100vw - 104px));
    transform: translateY(-6px);
  }
  .home-button { flex: 0 0 auto; }
  .connection-panel { padding: 26px 25px 24px; }

  .simulation-ui {
    --simulation-clearance: max(20px, env(safe-area-inset-bottom));
    bottom: var(--simulation-clearance);
    width: calc(100vw - 20px);
  }

  .simulation-panel {
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: start;
    gap: 6px;
    padding: 7px;
  }

  .simulation-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .advance-button { grid-column: 1 / -1; }
  .simulation-button { min-width: 72px; }
  .simulation-narrative { padding-top: 7px; }

  .title-help { bottom: auto; }
  .title-help .help-card { left: auto; right: 0; transform: none; }
  .help-card { width: min(270px, calc(100vw - 64px)); }
  .world-help .help-card { right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-mechanism span { animation: none; }
  .loading-mechanism span:nth-child(2) { opacity: 0.62; }
  .loading-mechanism span:nth-child(3) { opacity: 0.3; }

  .engine-stage.prairie-turn-revealing .engine-frame.is-standby {
    clip-path: none;
    animation: prairie-turn-frame-dissolve 90ms linear both;
  }

  .engine-stage.prairie-turn-revealing .worldline-transition {
    opacity: 0;
    animation: none;
    transform: translate3d(-100%, 0, 0);
  }
}

@media (forced-colors: active) {
  .home-button,
  .world-stamp,
  .model-control,
  .connection-panel { border-color: CanvasText; }

  .simulation-input,
  .simulation-button,
  .help-button,
  .help-card {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }

  .operation-lock { background: Canvas; color: CanvasText; }
  .loading-mechanism span { background: CanvasText; }
  .worldline-seam { background: CanvasText; box-shadow: none; }
  .worldline-contour { border-top-color: CanvasText; filter: none; }
}

/* Local simulation menus: compact list rows, translucent panes, no scene blur. */
body[data-scene="world"] .simulation-ui {
  left: 20px; bottom: 20px; width: min(340px, calc(100vw - 40px)); transform: none;
}
body[data-scene="world"] .simulation-panel,
.scene-menu {
  color: #fff8e9; background: rgba(17, 23, 25, .58);
  border: 1px solid rgba(247, 237, 209, .5); border-radius: 2px;
  box-shadow: 0 2px 10px #0003, inset 0 0 0 1px #0005;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  font-family: Tahoma, Verdana, sans-serif; font-size: 13px;
  text-shadow: 0 1px 2px #000;
}
body[data-scene="world"] .simulation-panel { display: flex; flex-direction: column; align-items: stretch; padding: 0; gap: 0; }
.menu-caption { display: flex; justify-content: space-between; align-items: center; min-height: 30px; padding: 5px 10px; background: #bba56b20; border-bottom: 1px solid #fff3; font-size: 11px; letter-spacing: .05em; }
.menu-caption h2 { margin: 0; font: inherit; font-weight: bold; }
.menu-caption button { color: inherit; border: 0; padding: 3px 6px; background: transparent; font: inherit; cursor: pointer; }
body[data-scene="world"] .simulation-form { display: grid; grid-template-columns: 1fr; padding: 8px 10px 0; gap: 0; }
body[data-scene="world"] .simulation-input { height: 36px; min-height: 36px; padding: 6px 8px; border: 1px solid #fff6; color: #fff8e9; -webkit-text-fill-color: #fff8e9; font: 13px Tahoma, Verdana, sans-serif; background: #0003 !important; border-radius: 1px; }
body[data-scene="world"] .simulation-input::placeholder { color: #fff9; font-style: normal; }
body[data-scene="world"] .simulation-button,
.simulation-menu button, .menu-action {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  height: auto; min-height: 31px; padding: 7px 8px; margin: 0;
  border: 0; border-bottom: 1px solid #f3e9cc26; border-radius: 0;
  background: transparent; color: #fff8e9; text-shadow: 0 1px 2px #000;
  text-align: left; font: 13px Tahoma, Verdana, sans-serif; cursor: pointer;
}
body[data-scene="world"] .simulation-button::before { content: "›"; margin-right: 8px; }
body[data-scene="world"] .simulation-button { justify-content: flex-start; }
.simulation-menu { padding: 0 10px 6px; }
.simulation-menu button:hover:not(:disabled), .menu-action:hover:not(:disabled),
body[data-scene="world"] .simulation-button:hover:not(:disabled) { background: #d9bd7950; }
.simulation-menu button:focus-visible, .scene-menu :focus-visible, .show-controls:focus-visible { outline: 2px solid #edcf8c; outline-offset: -2px; }
body[data-scene="world"] .simulation-narrative { margin: 0; padding: 11px 12px; border: 0; border-top: 1px solid #fff4; max-height: min(180px, 24vh); color: #fff8e9; background: #0001; font: 14px/1.45 Georgia, serif; }
body[data-scene="world"] .world-help { align-self: flex-end; padding-right: 10px; }
body[data-scene="world"] .world-help .help-button { width: 24px; height: 24px; min-width: 24px; background: transparent; color: #fff8e9; font: 16px Georgia, serif; border: 0; box-shadow: none; }
body[data-scene="world"] .world-stamp { opacity: .65; width: 210px; }
body[data-scene="world"] .home-button { background: #11171980; border: 1px solid #fff5; box-shadow: none; padding: 6px 12px; min-height: 34px; font-size: 12px; }
.scene-menu { position: fixed; z-index: 450; left: 372px; bottom: 20px; width: min(350px, calc(100vw - 40px)); max-height: calc(100vh - 100px); overflow-y: auto; }
.scene-menu[data-menu="load"] { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(660px, calc(100vw - 40px)); background: #111719db; }
.menu-page { padding: 14px; }
.menu-page label { display: block; margin: 0 0 6px; color: #f5d996; font-size: 12px; }
.menu-page input, .menu-page textarea, .menu-page select { width: 100%; margin: 0 0 13px; padding: 8px; border: 1px solid #fff6; border-radius: 1px; color: #fff8e9; -webkit-text-fill-color: #fff8e9; background: #10151880; font: 13px/1.4 Tahoma, Verdana, sans-serif; color-scheme: dark; }
.menu-page textarea { resize: vertical; max-height: 220px; }
.menu-page .menu-action { margin-bottom: 14px; border: 1px solid #fff5; }
.menu-note { margin: 0 0 14px; font-size: 12px; line-height: 1.5; color: #ebe5d5; }
.save-library { display: grid; gap: 6px; }
.save-library details { border: 1px solid #fff4; }
.save-library summary { padding: 11px; cursor: pointer; }
.save-library summary small { display: block; margin: 5px 0 0 14px; color: #ddd3be; }
.saved-frame { width: 100%; display: block; text-align: left; padding: 10px 12px; background: #0002; color: #fff8e9; border: 0; border-top: 1px solid #fff3; font: 12px/1.5 Tahoma, sans-serif; cursor: pointer; }
.saved-frame:hover { background: #d9bd7935; }
.saved-frame strong, .saved-frame small { display: block; }
.saved-frame small { color: #ddd3be; }
.show-controls, .title-load { position: fixed; z-index: 450; bottom: 20px; border: 1px solid #baa575; border-radius: 2px; padding: 9px 15px; cursor: pointer; font: 13px Tahoma, sans-serif; }
.show-controls { left: 20px; color: #fff8e9; background: #11171980; }
.title-load { right: 24px; color: #232019; background: #f6f2e8b8; }
body.controls-hidden .program-controls { visibility: hidden; }
body[data-scene="world"] .operation-lock { background: transparent; }
@media (max-width: 760px) { .scene-menu:not([data-menu="load"]) { left: 20px; bottom: 20px; background: #111719ed; } }

/* Both active APIs stay visible, with an explicit two-column model chooser. */
.model-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: left; }
.model-summary small { display: block; font-size: 10px; line-height: 1.6; font-weight: normal; }
.model-summary b { font-weight: normal; }
#model-control { padding: 0; background: #f6f2e8c9; border: 1px solid #8b806755; border-radius: 2px; }
#engine-model { width: 100%; padding: 8px 12px; border: 0; background: transparent; color: #232019; font: 12px Tahoma, sans-serif; cursor: pointer; }
#engine-model small { font-size: 11px; }
#engine-model small b { margin-left: 8px; font-weight: bold; }
.scene-menu[data-menu="models"] { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(760px, calc(100vw - 40px)); background: #111719d6; }
.model-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.model-columns fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.model-columns legend { padding: 0; font-size: 16px; font-family: Georgia, serif; color: #f5d996; }
.model-purpose { margin: 6px 0 12px; color: #ddd3be; font-size: 11px; }
.menu-page .model-choice { display: flex; align-items: flex-start; gap: 8px; padding: 10px 8px; margin: 0; border: 1px solid transparent; border-bottom-color: #fff2; color: #fff8e9; cursor: pointer; }
.menu-page .model-choice:has(input:checked) { border-color: #f5d99680; background: #c5ab7130; }
.menu-page .model-choice:hover { background: #fff1; }
.menu-page .model-choice input { width: 14px; height: 14px; margin: 2px 0 0; accent-color: #f5d996; flex: 0 0 auto; }
.model-choice strong, .model-choice small { display: block; line-height: 1.5; }
.model-choice strong { font-size: 12px; }
.model-choice small { font-size: 10px; color: #e4ddcc; }
.model-choice .model-route { color: #c8bfae; font-size: 9px; overflow-wrap: anywhere; }
.model-pricing-note { margin: 14px 0; color: #ddd3be; font-size: 10px; line-height: 1.5; }
.model-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid #fff3; padding-top: 12px; }
.model-footer .menu-note { margin: 0; }
.model-footer .menu-action { width: auto; min-width: 140px; margin: 0; }
body[data-scene="world"] .simulation-panel { max-height: calc(100vh - 100px); overflow-y: auto; }
@media (max-width: 620px) { .model-columns { grid-template-columns: 1fr; } }

/* Mobile browser host: preserve the complete scene and keep controls reachable. */
@supports (height: 100dvh) {
  html, body, .app-shell, .engine-stage { height: 100dvh; min-height: 100dvh; }
}
html, body { width: 100%; overscroll-behavior: none; }
body { min-height: 100svh; }
.job-notice {
  position: fixed; z-index: 700; top: calc(env(safe-area-inset-top) + 115px); left: 50%;
  pointer-events: none;
  width: min(520px, calc(100vw - 24px)); transform: translateX(-50%);
  padding: 12px 14px; border: 1px solid #fff7; border-radius: 3px;
  color: #fff8e9; background: rgba(17, 23, 25, .9); box-shadow: 0 3px 18px #0005;
  font: 16px/1.45 Tahoma, Verdana, sans-serif; text-align: center;
}
.job-notice[hidden] { display: none; }

@media (max-width: 760px) {
  .program-controls { top: calc(env(safe-area-inset-top) + 8px); right: calc(env(safe-area-inset-right) + 10px); }
  #model-control { max-width: min(58vw, 260px); }
  #engine-model { min-height: 48px; padding: 8px 10px; font-size: 14px; }
  #engine-model small, #engine-model small b { font-size: 12px; }
  .home-button, .show-controls, .title-load { min-height: 48px; padding: 10px 14px; font-size: 15px; }
  .title-load { right: calc(env(safe-area-inset-right) + 12px); bottom: calc(env(safe-area-inset-bottom) + 12px); }
  .show-controls { left: calc(env(safe-area-inset-left) + 12px); bottom: calc(env(safe-area-inset-bottom) + 12px); }
  body[data-scene="world"] .simulation-ui {
    left: calc(env(safe-area-inset-left) + 10px); right: calc(env(safe-area-inset-right) + 10px);
    bottom: calc(env(safe-area-inset-bottom) + 10px); width: auto; max-width: 440px;
  }
  body[data-scene="world"] .simulation-panel { max-height: min(58dvh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px)); }
  body[data-scene="world"] .simulation-input { min-height: 48px; height: 48px; font-size: 16px; padding: 10px 12px; }
  body[data-scene="world"] .simulation-button, .simulation-menu button, .menu-action,
  .saved-frame, .save-library summary, .menu-caption button { min-height: 44px; font-size: 15px; }
  body[data-scene="world"] .simulation-narrative { max-height: min(24dvh, 190px); font-size: 16px; }
  .scene-menu, .scene-menu[data-menu="load"], .scene-menu[data-menu="models"] {
    left: calc(env(safe-area-inset-left) + 8px); right: calc(env(safe-area-inset-right) + 8px);
    top: auto; bottom: calc(env(safe-area-inset-bottom) + 8px); transform: none;
    width: auto; max-width: 720px; max-height: min(82dvh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px));
    margin-inline: auto; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 10px 10px 2px 2px; background: rgba(17, 23, 25, .94);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .menu-caption { position: sticky; top: 0; z-index: 1; min-height: 48px; font-size: 15px; }
  .menu-page { padding: 16px; }
  .menu-page label { font-size: 15px; }
  .menu-page input, .menu-page textarea, .menu-page select { min-height: 48px; padding: 10px 12px; font-size: 16px; }
  .menu-page textarea { min-height: 112px; }
  .model-choice { min-height: 52px; }
  .model-choice strong { font-size: 15px; }
  .model-choice small { font-size: 13px; }
  .model-choice .model-route { font-size: 12px; }
  .menu-note, .model-purpose, .model-pricing-note { font-size: 14px; }
  .model-footer { align-items: stretch; flex-direction: column; }
  .model-footer .menu-action { width: 100%; }
  .job-notice { width: calc(100vw - 24px); }
}

@media (max-height: 500px) and (orientation: landscape) {
  body[data-scene="world"] .simulation-panel { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px); }
  .scene-menu, .scene-menu[data-menu="load"], .scene-menu[data-menu="models"] { max-height: 92dvh; }
  .menu-page textarea { min-height: 72px; }
}

.nine-home{position:fixed;left:max(16px,env(safe-area-inset-left));top:max(12px,env(safe-area-inset-top));font:12px Georgia,serif;color:#314333;z-index:20;background:#f5f1e8dd;padding:9px 12px;border-radius:3px;text-decoration:none}.nine-allowance{position:fixed;right:max(16px,env(safe-area-inset-right));top:max(12px,env(safe-area-inset-top));z-index:20;font:12px system-ui,sans-serif;color:#314333;background:#f5f1e8dd;padding:9px 12px;border-radius:3px;pointer-events:none}

/* Leave a dedicated row for shared account/navigation on narrow screens. */
body .program-controls{top:calc(env(safe-area-inset-top) + 54px)}
@media(max-width:700px){.nine-home{left:10px;padding:8px 9px;font-size:11px}.nine-allowance{right:10px;padding:8px 9px;font-size:11px}body .program-controls{top:calc(env(safe-area-inset-top) + 49px)}}
#engine-model small{display:flex;gap:6px;min-width:0;white-space:nowrap}
#engine-model small b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#engine-model>span:first-child{min-width:0;flex:1}
#engine-model>span:last-child{flex:0 0 auto}
#engine-model small b{margin-left:0}

/* Canonical beta readability: one landing toolbar, prominent narration. */
body[data-scene="title"] .program-controls {
  left: 50%; right: auto; top: calc(env(safe-area-inset-top) + 58px);
  transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 8px;
  padding: 8px; border: 1px solid #8b806744; border-radius: 8px; background: #f6f2e8ed;
}
.program-controls .title-load {
  position: static; min-height: 44px; padding: 10px 14px; font-size: 15px;
  background: transparent; border-color: #8b806755; white-space: nowrap;
}
body[data-scene="title"] #model-control { max-width: 270px; background: transparent; }
body[data-scene="title"] .home-button { min-height: 44px; }
body[data-scene="world"] .simulation-ui { width: min(420px, calc(100vw - 40px)); }
body[data-scene="world"] .simulation-narrative {
  order: -1; flex: 0 0 auto; padding: 18px 20px; border-top: 0; border-bottom: 1px solid #fff4;
  font: 20px/1.6 Georgia, serif; max-height: min(30dvh, 260px);
  color: #fffaf0; background: #101719ed; text-shadow: none; text-align: left;
}
body[data-scene="world"] .scene-menu:not([data-menu="load"]):not([data-menu="models"]) { left: 452px; }
@media (max-width: 760px) {
  body[data-scene="title"] .program-controls { top: calc(env(safe-area-inset-top) + 48px); gap: 6px; padding: 6px; }
  body[data-scene="title"] #model-control { flex: 1 1 100%; max-width: none; order: -1; }
  body[data-scene="title"] #engine-model { min-height: 44px; padding: 6px 10px; }
  .program-controls .title-load, body[data-scene="title"] .home-button { min-height: 44px; }
  body[data-scene="world"] .simulation-ui { width: auto; }
  body[data-scene="world"] .simulation-narrative { font-size: 19px; line-height: 1.55; padding: 16px; max-height: 28dvh; }
  body[data-scene="world"] .scene-menu:not([data-menu="load"]):not([data-menu="models"]) { left: calc(env(safe-area-inset-left) + 8px); }
}

/* Da Vinci folio: quiet chat by default, instruments on request. */
:root { --folio-paper: #f3eddc; --folio-ink: #30291e; --folio-rule: #aa91634d; --folio-brass: #846831; }
body[data-scene="world"] .simulation-panel, .scene-menu,
.scene-menu[data-menu="load"], .scene-menu[data-menu="models"] {
  color: var(--folio-ink); background: linear-gradient(115deg,#faf6e9f5,#eae0c9f5);
  border: 1px solid #a88e61; border-radius: 5px; text-shadow: none;
  box-shadow: 0 8px 32px #241d1633, inset 0 0 0 4px #faf6e980;
  font-family: Georgia, serif;
}
body[data-scene="world"] .simulation-ui { width: min(520px, calc(100vw - 40px)); }
body[data-scene="world"] .simulation-narrative {
  color: var(--folio-ink); background: transparent; border-color: var(--folio-rule);
  font-weight: 400; padding: 20px 22px; max-height: 30dvh;
}
body[data-scene="world"] .simulation-form { grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 12px 14px; }
body[data-scene="world"] .simulation-input {
  color: var(--folio-ink); -webkit-text-fill-color: var(--folio-ink); background: #fffaf066 !important;
  border: 0; border-bottom: 1px solid #9c8456; border-radius: 0;
  font: 17px/1.5 Georgia,serif; height: 46px; min-height: 46px;
}
body[data-scene="world"] .simulation-input::placeholder { color: #786b53; }
body[data-scene="world"] .simulation-button, .simulation-menu button, .menu-action {
  color: var(--folio-ink); text-shadow: none; font: 16px/1.45 Georgia,serif;
  min-height: 44px; border-color: var(--folio-rule); padding: 10px 12px;
}
body[data-scene="world"] #simulation-submit { width: auto; justify-content: center; gap: 10px; border: 1px solid #a58b57; border-radius: 3px; background: #e1d0a455; }
body[data-scene="world"] .simulation-button::before { content: none; }
.advanced-tools { border-top: 1px solid var(--folio-rule); padding: 0 14px 6px; }
.advanced-tools summary { list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 40px; cursor: pointer; color: #77603a; font: 14px Georgia,serif; letter-spacing: .04em; }
.advanced-tools summary::-webkit-details-marker { display: none; }
.advanced-tools[open] summary span { transform: rotate(45deg); }
.advanced-tools summary:focus-visible { outline: 2px solid var(--folio-brass); outline-offset: 2px; }
.advanced-tools .simulation-menu { padding: 0; }
.advanced-tools .menu-caption { border: 0; background: transparent; color: #786b53; padding: 4px 0; }
.advanced-tools .world-help { display: none; }
body[data-scene="world"] .scene-menu:not([data-menu="load"]):not([data-menu="models"]) { left: 552px; }
.scene-menu .menu-caption { background: #d7c49d55; border-color: var(--folio-rule); color: var(--folio-ink); font: 17px Georgia,serif; min-height: 48px; }
.scene-menu .menu-caption button { min-width: 44px; min-height: 44px; font-size: 24px; }
.scene-menu .menu-page label, .model-columns legend { color: #72582c; font-family: Georgia,serif; }
.scene-menu input, .scene-menu textarea, .scene-menu select {
  color: var(--folio-ink); -webkit-text-fill-color: var(--folio-ink); background: #fffbef;
  border-color: #ad9668; color-scheme: light; font: 16px/1.5 Georgia,serif;
}
.scene-menu .menu-note, .model-purpose, .model-pricing-note,
.scene-menu .model-choice small, .scene-menu .model-choice .model-route,
.save-library summary small, .saved-frame small { color: #72644d; }
.scene-menu .model-choice { color: var(--folio-ink); border-color: var(--folio-rule); }
.scene-menu .model-choice:has(input:checked) { border-color: #9b7c3e; background: #d8bd7833; }
.scene-menu .model-choice input { accent-color: #846831; }
.saved-frame { color: var(--folio-ink); background: #f8f2e4; border-color: var(--folio-rule); font: 15px/1.5 Georgia,serif; }
.save-library details, .model-footer { border-color: var(--folio-rule); }
body[data-scene="title"] #model-control { width: auto; min-width: 100px; }
body[data-scene="title"] #engine-model { min-height: 44px; font: 15px Georgia,serif; }
.program-controls .title-load, .home-button, .show-controls, body[data-scene="world"] .home-button {
  color: var(--folio-ink); background: #f3eddcf0; border: 1px solid #aa9163;
  font-family: Georgia,serif; text-shadow: none; box-shadow: none;
}
.nine-home, .nine-allowance { color: #625031; background: #f3eddce8; font-family: Georgia,serif; }
body[data-scene="world"] .world-stamp { display: none; }
@media(max-width: 940px) { body[data-scene="world"] .scene-menu:not([data-menu="load"]):not([data-menu="models"]) { left: 10px; bottom: 10px; max-width: calc(100vw - 20px); } }
@media(max-width: 760px) {
  body[data-scene="world"] .simulation-ui { width: auto; max-width: 520px; }
  body[data-scene="world"] .simulation-narrative { font-size: 19px; padding: 16px 18px; }
  body[data-scene="title"] #model-control { flex: 0 1 auto; order: 0; }
  body[data-scene="title"] .program-controls { flex-wrap: nowrap; }
  body[data-scene="title"] #engine-model, .program-controls .title-load, body[data-scene="title"] .home-button { padding: 8px 10px; font-size: 14px; }
}

/* A brief acknowledgement; generation continues without a central overlay. */
.job-notice { top: calc(env(safe-area-inset-top) + 52px); left: max(12px,env(safe-area-inset-left)); right: auto; width: auto; max-width: calc(100vw - 24px); transform: none; padding: 10px 14px; color: #4c3d25; background: #f3eddcf2; border: 1px solid #aa9163; font: 15px/1.4 Georgia,serif; text-align: left; animation: frame-notice 2.6s ease both; }
@keyframes frame-notice { 0% { opacity: 0; transform: translateY(-5px); } 12%,72% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-3px); } }
.speaker-label { grid-column: 1 / -1; color: #79623a; font: 13px Georgia,serif; letter-spacing: .04em; }
body[data-scene="world"] .simulation-narrative::before { content: "The Engine"; display: block; margin-bottom: 8px; color: #79623a; font: 13px Georgia,serif; letter-spacing: .04em; }
@media(prefers-reduced-motion:reduce) { .job-notice { animation: none; } }

/* Keep an expanded instrument card below the shared account controls on short screens. */
@media (max-height: 500px) and (orientation: landscape) {
  body[data-scene="world"] #simulation-ui:has(#advanced-tools[open]) {
    top: calc(env(safe-area-inset-top) + 96px);
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 20px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
  }
  body[data-scene="world"] #simulation-ui:has(#advanced-tools[open]) .simulation-panel {
    width: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
  }
  body[data-scene="world"] .scene-menu[data-menu="load"] {
    top: calc(env(safe-area-inset-top) + 96px);
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: none;
    margin-inline: auto;
    transform: none;
    overflow-y: auto;
  }
}

/* On portrait phones, leave the full landscape artwork visible above the controls. */
@media (max-width: 760px) and (orientation: portrait) {
  html[data-prairie-landscape-frame="true"] body[data-scene="world"] .simulation-narrative {
    max-height: max(60px, min(30dvh, calc(100dvh - 96px - var(--prairie-landscape-image-height) - 162px)));
    overflow-y: auto;
  }
}

/* Earlier folio menu layout, overridden by the central frame below. */
#landing-menu{position:fixed;top:30px;left:32px;right:32px;display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px 20px;z-index:20;font:14px Georgia,serif}#landing-menu button,#landing-menu a{font:inherit;background:none;border:0;color:#4a443a;text-decoration:none;padding:8px 0;cursor:pointer}.core-dialog{color:#232019;background:#f6f2e8;border:1px solid #a89a7c;border-radius:3px;width:min(480px,calc(100% - 48px));max-height:calc(100dvh - 64px);padding:30px;box-shadow:0 12px 80px #302a2022}.core-dialog::backdrop{background:#f6f2e877}.core-dialog h2{font:28px Georgia,serif;margin-top:32px}.core-dialog input{width:100%;padding:14px;margin:12px 0;font:24px monospace;letter-spacing:.12em;background:#fffaf0;border:1px solid #a89a7c}.core-close{display:block;margin-left:auto;background:none;border:0;color:#4a443a;cursor:pointer;padding:8px;font:14px Georgia,serif}.retail-dialog{width:min(1120px,calc(100% - 64px));height:calc(100dvh - 80px);padding:12px}.retail-dialog iframe{display:block;border:0;width:100%;height:calc(100% - 38px)}body[data-scene="world"] #landing-menu{display:none}@media(max-width:600px){#landing-menu{top:20px;left:24px;right:24px;justify-content:center;gap:2px 16px;font-size:13px}.core-dialog{padding:18px}.retail-dialog{width:calc(100% - 32px);height:calc(100dvh - 40px);max-height:calc(100dvh - 40px);padding:6px}}

/* The menu frame is the space between the title's tagline and gears. */
:root{--menu-left:50%;--menu-top:50%;--menu-width:0px;--menu-height:0px}
#landing-menu{position:fixed;left:var(--menu-left);top:var(--menu-top);right:auto;width:var(--menu-width);height:var(--menu-height);display:grid;grid-template-columns:1fr 1fr;align-content:center;gap:0 26px;padding:8px 6px;font:17px Georgia,serif;visibility:hidden;overflow:auto}
body[data-landing-ready] #landing-menu{visibility:visible}
#landing-menu button,#landing-menu a{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left;min-height:49px;padding:12px 5px;border-bottom:1px solid #a89a7c66;letter-spacing:.015em}
#landing-menu button:hover,#landing-menu a:hover{color:#7a5c2e;background:#8a7a5c09}
#landing-back{position:fixed;left:var(--menu-left);top:calc(var(--menu-top) + var(--menu-height) - 32px);z-index:25;border:0;background:none;color:#8a7a5c;font:14px Georgia,serif;cursor:pointer;padding:8px}
body[data-landing="entry"] #landing-menu,body[data-scene="world"] #landing-menu,body[data-scene="world"] #landing-back{display:none}
body:not([data-landing="entry"]) #title-help{visibility:hidden}
body[data-scene="title"] .program-controls{display:none!important}
.core-dialog,.retail-dialog,body[data-scene="title"] .scene-menu{position:fixed;inset:auto;left:var(--menu-left);top:var(--menu-top);width:var(--menu-width);height:var(--menu-height);max-width:none;max-height:var(--menu-height);margin:0;transform:none;padding:8px 6px;border:0;border-radius:0;box-shadow:none;background:#f6f2e8;overflow:auto}
.core-dialog::backdrop{background:transparent}
.core-dialog h2{font:24px Georgia,serif;margin:0 0 8px}.core-dialog p{margin:8px 0;font-size:14px}.core-dialog input{font-size:19px;padding:9px;margin:6px 0;max-width:280px;display:block}.core-close{padding:4px 0 8px;font-size:13px}
.retail-dialog{overflow:hidden}.retail-dialog iframe{height:calc(100% - 28px)}
@media(max-width:600px){#landing-menu{font-size:15px;gap:0 18px;padding:0}#landing-menu button,#landing-menu a{min-height:48px}.core-dialog,.retail-dialog{padding:4px 0}}

/* Fixed original title/gears; controls compress into the measured existing gap. */
#landing-menu{grid-template-columns:repeat(3,minmax(0,1fr));gap:0 16px;padding:0 4px;font-size:14px;align-content:center}
#landing-menu button,#landing-menu a{min-height:32px;padding:7px 3px;gap:5px;font-size:inherit;line-height:1.2}
.core-dialog,.retail-dialog,body[data-scene="title"] .scene-menu{padding:0 4px}
.core-close{font-size:12px;padding:0 0 4px;line-height:18px}
.retail-dialog iframe{height:calc(100% - 22px)}
#access-form{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:4px 10px}
#access-form .core-close{grid-column:2;grid-row:1}#access-form h2{grid-column:1;grid-row:1;font-size:17px;margin:0}
#access-form>p:first-of-type{display:none}#access-form label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
#access-form input{grid-column:1;grid-row:2;width:100%;max-width:none;min-width:0;font-size:16px;padding:5px 8px;margin:0;height:32px}
#access-form .primary-button{grid-column:2;grid-row:2;min-height:32px;padding:5px 10px;font:13px Georgia,serif;background:transparent;color:#232019;border:1px solid #a89a7c;box-shadow:none}
#access-form [data-retail]{grid-column:1;grid-row:3;width:max-content;background:none;border:0;padding:3px 0;color:#8a7a5c;font:12px Georgia,serif}
#access-status{grid-column:1/-1;margin:0!important;font-size:12px!important}#access-status:empty{display:none}
@media(max-width:600px){#landing-menu{grid-template-columns:1fr 1fr;gap:0 16px;font-size:14px}#landing-menu button,#landing-menu a{min-height:36px;padding:8px 2px}#access-form h2{font-size:16px}}

/* One direct code entry, two secondary choices; the surrounding frame stays fixed. */
#landing-menu{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:0 4px;overflow:auto}
#landing-code-form{width:min(390px,100%);margin:0;text-align:center}
#landing-code{width:100%;height:35px;padding:2px 8px 5px;border:0;border-bottom:1px solid #a89a7c;border-radius:0;background:transparent;color:#232019;text-align:center;font:24px/1.2 Georgia,serif;letter-spacing:.18em;outline-offset:3px}
#landing-code::placeholder{color:#a3967c;opacity:1}
#landing-code-status{margin:3px 0 0;color:#8a7a5c;font:11px/1.3 Georgia,serif;min-height:14px}
#landing-menu .landing-links{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:5px 22px}
#landing-menu .landing-links button{border:0;min-height:24px;padding:4px 0;font:12px Georgia,serif;color:#76664c;letter-spacing:0}
@media(max-width:600px){#landing-code-form{width:min(280px,100%)}#landing-code{height:40px;font-size:25px}#landing-menu{gap:8px}#landing-menu .landing-links button{min-height:30px;font-size:13px}}

/* One small purchase entrance; retain the original hover/focus help. */
#landing-menu .landing-links #get-a-code{border:1px solid #a89a7c99;border-radius:3px;padding:3px 12px;min-height:25px;font-size:12px;background:transparent;color:#76664c}
#landing-menu .landing-links #get-a-code:hover{background:#8a7a5c10}
body[data-scene="title"] #title-help{visibility:visible}

#landing-menu{pointer-events:none}#landing-menu form,#landing-menu .landing-links{pointer-events:auto}

/* Public entry: Get a code, code field, then the existing help at the right. */
body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){display:grid;grid-template-columns:90px minmax(0,390px);justify-content:center;align-content:center;align-items:start;column-gap:14px;row-gap:0;padding-right:48px}
#landing-code-form{grid-column:2;grid-row:1;width:100%}
#landing-menu:has(#landing-code-form:not([hidden])) .landing-links{grid-column:1;grid-row:1;align-self:start;padding-top:5px}
#landing-menu .landing-links #get-a-code{white-space:nowrap}
@media(max-width:600px){body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){grid-template-columns:77px minmax(0,1fr);column-gap:8px;padding-right:40px}#landing-code-form{width:100%;min-width:0}#landing-code{font-size:21px;letter-spacing:.08em;padding-inline:0}#landing-menu .landing-links #get-a-code{padding-inline:7px;font-size:11px}#landing-menu:has(#landing-code-form:not([hidden])) .landing-links{padding-top:8px}#landing-code-status{font-size:10px}}

/* Quiet, integrated entry controls in the fixed landing frame. */
body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){grid-template-columns:100px minmax(0,350px);column-gap:22px}
#landing-menu .landing-links #get-a-code{border:0;border-radius:0;box-shadow:none;background:transparent;padding:7px 0;min-height:35px;font:italic 14px Georgia,serif;color:#8a7a5c;letter-spacing:.01em;transition:color .18s ease}
#landing-menu .landing-links #get-a-code::after{content:'↗';font-style:normal;font-size:12px;margin-left:7px;opacity:.55;transition:opacity .18s ease,transform .18s ease}
#landing-menu .landing-links #get-a-code:hover{background:transparent;color:#4a443a}
#landing-menu .landing-links #get-a-code:hover::after{opacity:1;transform:translate(1px,-1px)}
#landing-menu:has(#landing-code-form:not([hidden])) .landing-links{padding-top:0}
#landing-code{border-bottom:1px solid #a89a7c88;color:#4a443a;font-size:23px;letter-spacing:.13em}
#landing-code::placeholder{color:#aa9e86}
#landing-code-status{color:#a3967c;font-size:10px;letter-spacing:.015em;margin-top:5px}
body[data-scene="title"] .help-button{box-shadow:none;background:transparent;border:1px solid #a89a7c88;color:#8a7a5c;width:30px;height:30px;min-width:30px;font-size:19px;transition:border-color .18s ease,color .18s ease}
body[data-scene="title"] .help-button:hover{color:#4a443a;border-color:#8a7a5c}
@media(max-width:600px){body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){grid-template-columns:82px minmax(0,1fr);column-gap:11px}#landing-menu .landing-links #get-a-code{font-size:12px;padding:8px 0;min-height:40px}#landing-menu .landing-links #get-a-code::after{font-size:10px;margin-left:4px}#landing-code{font-size:21px;letter-spacing:.08em}}
@media(prefers-reduced-motion:reduce){#landing-menu .landing-links #get-a-code,#landing-menu .landing-links #get-a-code::after,body[data-scene="title"] .help-button{transition:none}}

/* Reduce only the purchase button; preserve the established entry and help sizes. */
#landing-menu .landing-links #get-a-code{font-size:11px}
#landing-menu .landing-links #get-a-code::after{font-size:9px;margin-left:3px}
@media(max-width:600px){#landing-menu .landing-links #get-a-code{font-size:10px}}

.about-dialog{overflow:auto}.about-copy{max-width:520px;margin:0 auto;padding:0 4px 8px}.about-copy h2{font-size:18px}.about-copy p{font:13px/1.5 Georgia,serif;color:#76664c}.about-copy button{border:0;background:transparent;color:#8a7a5c;font:italic 11px Georgia,serif;padding:4px 0}

#title-help-card a{display:inline-block;margin-top:8px;color:#8a7a5c;font:italic 12px Georgia,serif;text-underline-offset:3px}

/* Public entry spans the first P through the final E of the rendered wordmark. */
body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){left:var(--entry-left,var(--menu-left));width:var(--entry-width,var(--menu-width));grid-template-columns:100px minmax(0,1fr);column-gap:22px;padding:0 44px 0 0}
#landing-menu:has(#landing-code-form:not([hidden])) .landing-links{justify-content:flex-start;width:100%}
#landing-menu .landing-links #get-a-code{border:1px solid #a89a7c99;border-radius:3px;padding:7px 10px;width:100%;justify-content:center;gap:4px}
@media(max-width:600px){body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])){grid-template-columns:75px minmax(0,1fr);column-gap:10px;padding:0 40px 0 0}#landing-menu .landing-links #get-a-code{padding:8px 5px}#landing-code{font-size:16px;letter-spacing:.06em}}

#session-actions{position:fixed;left:max(20px,env(safe-area-inset-left));top:max(18px,env(safe-area-inset-top));z-index:30;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 190px);font:12px Georgia,serif;color:#625031}#session-actions button{font:inherit;color:inherit;background:#f3eddce8;border:1px solid #a89a7c;border-radius:3px;padding:8px 12px;cursor:pointer}#session-actions button[hidden]{display:none}#session-status{max-width:230px}#session-actions button:focus-visible{outline:2px solid #765b2e;outline-offset:3px}@media(max-width:600px){#session-actions{left:12px;top:12px;gap:6px;flex-wrap:wrap;max-width:calc(100vw - 140px)}#session-status{flex-basis:100%;font-size:11px}}

/* Compact, legible entry in the prairie grass. */
body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])) { grid-template-columns:92px minmax(0,1fr); column-gap:18px; padding:0 40px 0 0; }
body[data-scene="title"] #landing-code { font-size:20px; color:#183421; border-bottom-color:#244329; text-shadow:0 1px 3px #f5ffdbaa; }
body[data-scene="title"] #landing-code::placeholder { color:#183421; opacity:1; }
body[data-scene="title"] #landing-code-status { color:#183421; font-size:11px; text-shadow:0 1px 3px #f5ffdbaa; }
body[data-scene="title"] #landing-menu .landing-links #get-a-code { color:#183421; border-color:#244329aa; background:#f5ffda66; font-size:12px; }
body[data-scene="title"] #title-help-button { color:#183421; border-color:#244329aa; background:#f5ffda66; }
@media(max-width:600px) {
 body[data-scene="title"] #landing-menu:has(#landing-code-form:not([hidden])) { grid-template-columns:80px minmax(0,1fr); column-gap:10px; padding-right:38px; }
 body[data-scene="title"] #landing-code { font-size:18px; }
 body[data-scene="title"] #landing-menu .landing-links #get-a-code { font-size:11px; }
}

body[data-scene="title"]:has(#landing-code-form:not([hidden])) #title-help { top:calc(var(--menu-top) + var(--menu-height) / 2 - 10px)!important; }

/* Keep lettering solid while only the prairie image fades. */
body[data-scene="title"] #landing-code,
body[data-scene="title"] #landing-code-status,
body[data-scene="title"] #get-a-code,
body[data-scene="title"] #landing-menu .landing-links #get-a-code::after,
body[data-scene="title"] #title-help-button { opacity:1; text-shadow:none; }

/* Match the title ink across signed-in and guest landing controls. */
body[data-scene="title"] #landing-menu .landing-links button,
body[data-scene="title"] #landing-menu .landing-links #get-a-code,
body[data-scene="title"] #landing-code,
body[data-scene="title"] #landing-code::placeholder,
body[data-scene="title"] #landing-code-status,
body[data-scene="title"] #landing-back,
body[data-scene="title"] #title-help-button,
body[data-scene="title"] #session-actions { color:#233b40; opacity:1; text-shadow:none; }

/* Embedded Stripe remains in the measured grass slot and scrolls within it. */
#stripe-checkout{width:100%;height:calc(100% - 28px);overflow:auto;overscroll-behavior:contain;min-width:0;max-width:100%}
#stripe-checkout[hidden],#retail-frame[hidden]{display:none}
#stripe-checkout iframe{min-height:520px;height:auto;max-width:100%}
#stripe-checkout-status{max-width:100%;overflow-wrap:anywhere}

/* Reserve the help column even when the authenticated entry form is hidden. */
body[data-scene="title"] #landing-menu:not(:has(#landing-code-form:not([hidden]))){box-sizing:border-box;padding-inline:4px 42px}
body[data-scene="title"] #landing-menu .landing-links{min-width:0;max-width:100%}
body[data-scene="title"] #landing-menu .landing-links button{max-width:100%}
.core-dialog img,.scene-menu img{max-width:100%;height:auto}
