:root {
  color-scheme: dark;
  --night-0: #100d18;
  --night-1: #1a1422;
  --wood-0: #24151a;
  --wood-1: #3b241f;
  --wood-2: #513329;
  --brass-0: #8d6a3d;
  --brass-1: #d2a24c;
  --paper: #f1e4c5;
  --muted: #b9a989;
  --supply: #72c58b;
  --brew: #5ea7d8;
  --memory: #a878e6;
  --fire: #d98745;
  --danger: #d45c6d;
  --disabled: #5a4d5e;
  --ink: #08070d;
  --font-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --step-corner: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px));
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: #08070d;
  color: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px dashed var(--brass-1);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-140%);
  padding: 8px 12px;
  background: var(--paper);
  color: var(--night-0);
}

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

.game-app {
  width: min(100vw, 430px);
  height: 100vh;
  height: 100dvh;
  max-height: 932px;
  min-height: 620px;
  overflow: hidden;
  background: var(--night-0);
  border-inline: 1px solid #07050a;
  font-size: calc(14px * var(--font-scale));
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: calc(48px + var(--safe-top)) minmax(0, 1fr) calc(58px + var(--safe-bottom));
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--night-0);
  box-shadow: 0 0 0 1px #08070d, 0 0 36px #000;
}

.status-rail {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 4px;
  min-width: 0;
  padding: calc(var(--safe-top) + 4px) clamp(6px, 2vw, 10px) 4px;
  background: var(--night-1);
  border-bottom: 2px solid var(--brass-0);
  box-shadow: inset 0 -3px 0 #0d0a12;
}

.resource-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.resource-strip:hover,
.resource-strip:active {
  background: var(--wood-1);
  box-shadow: inset 0 -2px 0 var(--brass-0);
}

.resource-main {
  min-width: 0;
}

.resource-label,
.eyebrow,
.meta,
.status-note,
.route-cost,
.row-note,
.field-label {
  color: var(--muted);
  font-size: calc(10px * var(--font-scale));
  line-height: 1.25;
}

.resource-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

.resource-value strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate {
  color: var(--supply);
  font-size: calc(10px * var(--font-scale));
  white-space: nowrap;
}

.chapter-chip {
  max-width: 104px;
  overflow: hidden;
  color: var(--brass-1);
  font-size: calc(10px * var(--font-scale));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:active,
.icon-button[aria-pressed="true"] {
  background: var(--wood-1);
  box-shadow: inset 0 -2px 0 var(--brass-0);
}

.icon-glyph {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  font-size: 19px;
  line-height: 1;
}

.screen {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--night-0);
}

.screen-scroll {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--brass-0) var(--night-1);
}

.page {
  min-height: 100%;
  padding: 8px clamp(6px, 2vw, 10px) 20px;
  background: var(--night-0);
}

.page-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid var(--brass-0);
}

.page-header h1 {
  min-width: 0;
  margin: 0;
  font-size: calc(18px * var(--font-scale));
  line-height: 1.15;
  text-align: center;
}

.page-header .header-side {
  display: grid;
  place-items: center;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
}

.section-heading h2,
.focus-copy h2,
.sheet h2,
.sheet h3 {
  margin: 0;
  font-size: calc(14px * var(--font-scale));
  line-height: 1.2;
}

.home-view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  background: #0c0910;
}

.world-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background-color: var(--night-0);
  background-image: var(--world-image);
  background-position: center center;
  background-size: cover;
  image-rendering: pixelated;
}

.world-stage::after {
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  height: 18%;
  background: rgba(16, 13, 24, 0.82);
  border-top: 2px solid rgba(141, 106, 61, 0.55);
  content: "";
  pointer-events: none;
}

.scene-opening { --world-image: url("phase6/assets/world-opening.png"); }
.scene-manual,
.scene-automation,
.scene-recovery,
.scene-choice { --world-image: url("phase6/assets/world-busy.png"); }
.scene-bottleneck,
.scene-error { --world-image: url("phase6/assets/world-starved.png"); }
.scene-reward,
.scene-transformation { --world-image: url("phase6/assets/world-reward.png"); }
.scene-next-cycle { --world-image: url("phase6/assets/world-opening.png"); }

.world-badge {
  position: absolute;
  z-index: 4;
  top: 8px;
  left: 8px;
  display: inline-flex;
  max-width: calc(100% - 72px);
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  clip-path: var(--step-corner);
  background: rgba(16, 13, 24, 0.9);
  border-inline: 1px solid var(--brass-0);
  color: var(--paper);
  font-size: calc(10px * var(--font-scale));
}

.world-badge .signal {
  width: 8px;
  height: 8px;
  background: var(--supply);
  box-shadow: 0 0 0 2px var(--night-0);
}

.scene-bottleneck .world-badge .signal,
.scene-error .world-badge .signal {
  background: var(--danger);
}

.scene-transformation .world-badge .signal,
.scene-next-cycle .world-badge .signal {
  background: var(--memory);
}

.npc-marker {
  position: absolute;
  z-index: 4;
  right: 10px;
  bottom: 28%;
  display: grid;
  width: 44px;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
}

.npc-sprite {
  position: relative;
  width: 24px;
  height: 32px;
  background: var(--wood-1);
  box-shadow: inset 6px 0 var(--memory), inset -4px 0 #1d1425, 0 2px 0 #07050a;
  clip-path: polygon(6px 0, 18px 0, 18px 4px, 22px 4px, 22px 14px, 24px 14px, 24px 32px, 0 32px, 0 14px, 2px 14px, 2px 4px, 6px 4px);
  image-rendering: pixelated;
}

.npc-sprite::before {
  position: absolute;
  top: 4px;
  left: 7px;
  width: 10px;
  height: 10px;
  background: #d6a96b;
  box-shadow: 0 -3px 0 #2b1b22, 3px 3px 0 #784c43;
  content: "";
}

.npc-name {
  padding: 1px 4px;
  background: rgba(16, 13, 24, 0.85);
  color: var(--muted);
  font-size: calc(9px * var(--font-scale));
}

.cauldron-hit {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 20%;
  width: min(52vw, 180px);
  height: min(28vh, 190px);
  min-width: 144px;
  min-height: 144px;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.cauldron-hit::after {
  position: absolute;
  right: 50%;
  bottom: 2px;
  min-width: 92px;
  transform: translateX(50%);
  padding: 5px 8px;
  clip-path: var(--step-corner);
  background: rgba(16, 13, 24, 0.94);
  border-top: 1px solid var(--brass-1);
  color: var(--paper);
  content: attr(data-action-label);
  font-size: calc(11px * var(--font-scale));
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.cauldron-hit:active {
  transform: translate(-50%, 2px);
}

.cauldron-hit:disabled {
  cursor: default;
}

.cauldron-hit:disabled::after {
  color: var(--muted);
  border-color: var(--disabled);
}

.flow-pips {
  position: absolute;
  z-index: 4;
  top: 28%;
  left: 50%;
  display: grid;
  gap: 5px;
  transform: translateX(-50%);
  pointer-events: none;
}

.flow-pips i {
  width: 7px;
  height: 7px;
  background: var(--brew);
  box-shadow: 7px 0 0 color-mix(in srgb, var(--brew) 55%, transparent);
  animation: flow-step 900ms steps(3, end) infinite;
}

.flow-pips i:nth-child(2) { animation-delay: 180ms; }
.flow-pips i:nth-child(3) { animation-delay: 360ms; }

.scene-opening .flow-pips,
.scene-bottleneck .flow-pips,
.scene-error .flow-pips,
.scene-reward .flow-pips,
.scene-transformation .flow-pips,
.scene-next-cycle .flow-pips {
  display: none;
}

.world-float {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 44%;
  transform: translateX(-50%);
  color: var(--fire);
  font-size: calc(16px * var(--font-scale));
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
}

.world-float.show {
  animation: award-float 620ms steps(5, end);
}

.memory-mark {
  position: absolute;
  z-index: 4;
  top: 32%;
  left: 50%;
  display: none;
  width: 58px;
  height: 58px;
  transform: translateX(-50%);
  border: 4px solid var(--memory);
  box-shadow: inset 0 0 0 4px var(--night-0), 0 0 0 2px var(--night-0);
  clip-path: polygon(30% 0, 70% 0, 70% 12%, 88% 12%, 88% 30%, 100% 30%, 100% 70%, 88% 70%, 88% 88%, 70% 88%, 70% 100%, 30% 100%, 30% 88%, 12% 88%, 12% 70%, 0 70%, 0 30%, 12% 30%, 12% 12%, 30% 12%);
}

.scene-transformation .memory-mark,
.scene-next-cycle .memory-mark {
  display: block;
}

.responsibility-shelf {
  position: relative;
  z-index: 8;
  min-height: 184px;
  padding: 7px 8px 8px;
  background: var(--night-1);
  border-top: 2px solid var(--brass-0);
  box-shadow: inset 0 3px 0 #0c0910;
}

.objective-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  margin-bottom: 7px;
}

.objective-line strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: calc(12px * var(--font-scale));
  line-height: 1.22;
}

.eta-block {
  color: var(--brew);
  font-size: calc(11px * var(--font-scale));
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.chain {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 -2px 7px;
}

.chain-node {
  position: relative;
  min-width: 0;
  min-height: 52px;
  padding: 5px 3px;
  border: 0;
  border-bottom: 2px solid var(--disabled);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.chain-node + .chain-node::before {
  position: absolute;
  top: 21px;
  left: -4px;
  color: var(--brass-0);
  content: ">";
}

.chain-node .node-icon {
  display: block;
  width: 18px;
  height: 18px;
  margin-bottom: 2px;
  color: currentColor;
  font-size: 16px;
  line-height: 18px;
}

.chain-node b,
.chain-node small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chain-node b {
  color: var(--paper);
  font-size: calc(9px * var(--font-scale));
}

.chain-node small {
  font-size: calc(8px * var(--font-scale));
}

.chain-node.running { color: var(--supply); border-color: var(--supply); }
.chain-node.brewing { color: var(--brew); border-color: var(--brew); }
.chain-node.blocked { color: var(--danger); border-color: var(--danger); }
.chain-node.complete { color: var(--fire); border-color: var(--fire); }
.chain-node.memory { color: var(--memory); border-color: var(--memory); }

.shelf-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.bottleneck-copy {
  min-width: 0;
  color: var(--muted);
  font-size: calc(10px * var(--font-scale));
  line-height: 1.25;
}

.bottleneck-copy strong {
  color: var(--paper);
}

.button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  clip-path: var(--step-corner);
  border: 0;
  background: var(--wood-1);
  box-shadow: inset 0 0 0 1px var(--brass-0), inset 0 -3px 0 var(--wood-0);
  color: var(--paper);
  cursor: pointer;
  font-size: calc(11px * var(--font-scale));
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.button:hover {
  box-shadow: inset 0 0 0 1px var(--brass-1), inset 0 -3px 0 var(--wood-0);
}

.button:active,
.button.is-pressed {
  transform: translateY(2px);
  box-shadow: inset 0 3px 0 #120c10, inset 0 0 0 1px var(--brass-1);
}

.button.primary {
  min-height: 48px;
  min-width: 104px;
  background: #253a36;
  box-shadow: inset 0 0 0 2px var(--brass-1), inset 0 -4px 0 #172621;
  color: #f7edcf;
}

.button.brew-primary { background: #233947; }
.button.memory-primary { background: #392c4c; }
.button.danger { background: #4a222d; color: #ffd9dc; }
.button.quiet { background: transparent; box-shadow: inset 0 0 0 1px var(--brass-0); }
.button.full { width: 100%; }
.button.compact { min-height: 44px; padding: 6px 9px; }

.button:disabled,
.button[aria-disabled="true"] {
  transform: none;
  background: #201a24;
  box-shadow: inset 0 0 0 1px var(--disabled);
  color: #84798a;
  cursor: not-allowed;
}

.bottom-nav {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-width: 0;
  padding: 2px 4px var(--safe-bottom);
  background: var(--night-1);
  border-top: 2px solid var(--brass-0);
}

.nav-item {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 54px;
  place-items: center;
  align-content: center;
  gap: 1px;
  padding: 2px 1px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-item .nav-icon {
  font-size: 18px;
  line-height: 20px;
}

.nav-item .nav-label {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: calc(9px * var(--font-scale));
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.selected {
  color: var(--paper);
}

.nav-item.selected::after {
  position: absolute;
  right: 14%;
  bottom: 1px;
  left: 14%;
  height: 3px;
  background: var(--supply);
  content: "";
}

.nav-item.locked {
  color: var(--disabled);
}

.nav-item.locked .nav-icon::after {
  position: absolute;
  margin: 10px 0 0 -3px;
  color: var(--muted);
  content: "x";
  font-size: 9px;
}

.nav-item.has-notice::before {
  position: absolute;
  top: 7px;
  right: 25%;
  width: 5px;
  height: 5px;
  background: var(--fire);
  content: "";
}

.tabs {
  display: flex;
  min-height: 44px;
  overflow-x: auto;
  border-bottom: 1px solid var(--brass-0);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(10px * var(--font-scale));
  font-weight: 700;
}

.tab.active {
  color: var(--paper);
}

.tab.active::after {
  position: absolute;
  right: 8px;
  bottom: 0;
  left: 8px;
  height: 3px;
  background: var(--brass-1);
  content: "";
}

.focus-workbench,
.order-focus,
.gear-bench,
.codex-focus,
.settings-panel {
  position: relative;
  margin-top: 8px;
  padding: 10px;
  background: var(--wood-0);
  border-block: 2px solid var(--brass-0);
  box-shadow: inset 0 3px 0 #351f1e, inset 0 -3px 0 #140c10;
}

.focus-grid {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.pixel-object {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  background: var(--night-1);
  box-shadow: inset 0 0 0 2px var(--brass-0), 3px 3px 0 #0c0910;
  color: var(--supply);
  font-size: 25px;
  image-rendering: pixelated;
}

.pixel-object.brew { color: var(--brew); }
.pixel-object.fire { color: var(--fire); }
.pixel-object.memory { color: var(--memory); }
.pixel-object.danger { color: var(--danger); }

.focus-copy {
  min-width: 0;
}

.focus-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: calc(10px * var(--font-scale));
  line-height: 1.35;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 9px;
  background: var(--brass-0);
  border: 1px solid var(--brass-0);
}

.metric {
  min-width: 0;
  padding: 7px;
  background: var(--night-1);
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: calc(9px * var(--font-scale));
}

.metric strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-size: calc(11px * var(--font-scale));
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 10px;
  margin: 8px 0;
  overflow: hidden;
  background: #0d0a12;
  border: 1px solid var(--brass-0);
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: var(--supply);
}

.progress-fill.brew { background: var(--brew); }
.progress-fill.memory { background: var(--memory); }
.progress-fill.fire { background: var(--fire); }

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.ledger-list {
  border-top: 1px solid var(--brass-0);
}

.ledger-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 58px;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid #5e4730;
}

button.ledger-row {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.row-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  background: var(--wood-0);
  box-shadow: inset 0 0 0 1px var(--brass-0);
  color: var(--supply);
  font-size: 20px;
}

.row-copy {
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  font-size: calc(11px * var(--font-scale));
  font-weight: 800;
}

.row-title span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-value {
  color: var(--paper);
  font-size: calc(11px * var(--font-scale));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.state-mark {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  padding: 2px 5px;
  background: var(--night-1);
  color: var(--muted);
  font-size: calc(9px * var(--font-scale));
  white-space: nowrap;
}

.state-mark.running { color: var(--supply); }
.state-mark.brew { color: var(--brew); }
.state-mark.blocked { color: var(--danger); }
.state-mark.complete { color: var(--fire); }
.state-mark.memory { color: var(--memory); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(44px, 1fr);
  min-height: 46px;
  background: var(--night-1);
  border: 1px solid var(--brass-0);
}

.segment {
  min-height: 44px;
  padding: 5px 7px;
  border: 0;
  border-right: 1px solid var(--brass-0);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(10px * var(--font-scale));
}

.segment:last-child { border-right: 0; }
.segment.active { background: var(--wood-1); color: var(--paper); box-shadow: inset 0 -3px 0 var(--brass-1); }

.option-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option-block {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 9px;
  background: var(--night-1);
  border: 1px solid var(--brass-0);
  box-shadow: inset 3px 0 0 var(--supply);
}

.option-block.brew-route { box-shadow: inset 3px 0 0 var(--brew); }
.option-block.memory-route { box-shadow: inset 3px 0 0 var(--memory); }
.option-block.locked { box-shadow: inset 3px 0 0 var(--disabled); opacity: 0.72; }

.option-block h3 {
  margin: 0;
  font-size: calc(12px * var(--font-scale));
  line-height: 1.2;
}

.option-block p {
  margin: 5px 0;
  color: var(--muted);
  font-size: calc(10px * var(--font-scale));
  line-height: 1.3;
}

.option-block .button {
  margin-top: auto;
}

.queue-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 8px 0;
}

.queue-slot {
  display: grid;
  min-height: 52px;
  place-items: center;
  padding: 5px;
  background: var(--night-1);
  border: 1px dashed var(--disabled);
  color: var(--muted);
  font-size: calc(9px * var(--font-scale));
  text-align: center;
}

.queue-slot.running { border-style: solid; border-color: var(--brew); color: var(--brew); }
.queue-slot.blocked { border-color: var(--danger); color: var(--danger); }
.queue-slot.complete { border-style: solid; border-color: var(--fire); color: var(--fire); }

.requirement-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  background: var(--night-1);
  border-block: 1px solid var(--brass-0);
}

.requirement-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 7px;
  border-bottom: 1px solid #493426;
  font-size: calc(10px * var(--font-scale));
}

.requirement-list li:last-child { border-bottom: 0; }
.requirement-list .ok { color: var(--supply); }
.requirement-list .bad { color: var(--danger); }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.gear-slot {
  position: relative;
  display: grid;
  min-height: 88px;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 7px;
  background: var(--night-1);
  border: 1px solid var(--brass-0);
  color: var(--muted);
  font-size: calc(9px * var(--font-scale));
  text-align: center;
}

.gear-slot.active { border-color: var(--supply); color: var(--paper); }
.gear-slot.staged { border-color: var(--memory); color: var(--paper); box-shadow: inset 0 0 0 2px #3a2750; }
.gear-slot .slot-symbol { font-size: 28px; }

.compare-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 8px;
  background: var(--night-1);
  font-size: calc(10px * var(--font-scale));
}

.compare-strip strong { display: block; color: var(--paper); }
.compare-arrow { color: var(--brass-1); text-align: center; }

.codex-paper {
  background: #332b25;
  border-color: #9d7d50;
}

.codex-paper .focus-copy p,
.codex-paper .meta { color: #d0bd96; }

.tree-branches {
  display: grid;
  gap: 7px;
}

.tree-node {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 7px;
  background: var(--night-1);
  border-left: 3px solid var(--memory);
}

.tree-node.locked { border-color: var(--disabled); opacity: 0.68; }
.tree-node.maxed { border-color: var(--supply); }

.settings-list {
  border-top: 1px solid var(--brass-0);
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(116px, 44%);
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 7px 2px;
  border-bottom: 1px solid #5e4730;
}

.setting-label strong,
.setting-label small {
  display: block;
}

.setting-label strong { font-size: calc(11px * var(--font-scale)); }
.setting-label small { margin-top: 2px; color: var(--muted); font-size: calc(9px * var(--font-scale)); }

.toggle {
  position: relative;
  width: 48px;
  height: 44px;
  justify-self: end;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.toggle::before {
  position: absolute;
  top: 8px;
  left: 0;
  width: 48px;
  height: 28px;
  border: 1px solid var(--brass-0);
  background: var(--night-1);
  content: "";
}

.toggle::after {
  position: absolute;
  top: 12px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: var(--disabled);
  box-shadow: 2px 2px 0 #050408;
  content: "";
}

.toggle[aria-checked="true"] {
  color: var(--supply);
}

.toggle[aria-checked="true"]::before {
  border-color: var(--supply);
}

.toggle[aria-checked="true"]::after {
  left: 24px;
  background: var(--supply);
}

.range-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--brass-1);
}

.modal-root {
  position: absolute;
  z-index: 70;
  inset: 0;
  display: none;
  pointer-events: none;
}

.modal-root.open {
  display: grid;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 5, 10, 0.7);
}

.sheet {
  position: relative;
  z-index: 2;
  display: flex;
  width: calc(100% - 16px);
  max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 24px);
  align-self: end;
  justify-self: center;
  flex-direction: column;
  overflow: hidden;
  clip-path: var(--step-corner);
  background: var(--night-1);
  border-top: 2px solid var(--brass-1);
  box-shadow: inset 0 0 0 1px var(--brass-0), 0 -8px 0 rgba(7, 5, 10, 0.5);
}

.sheet.centered {
  width: min(calc(100% - 24px), 380px);
  max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 60px);
  align-self: center;
}

.sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 52px;
  padding-left: 12px;
  border-bottom: 1px solid var(--brass-0);
}

.sheet-body {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
}

.sheet-body > p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: calc(10px * var(--font-scale));
  line-height: 1.4;
}

.sheet-footer {
  display: flex;
  min-height: 60px;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: var(--wood-0);
  border-top: 1px solid var(--brass-0);
}

.sheet-footer .button {
  min-width: 0;
  flex: 1 1 0;
}

.choice-sheet {
  max-height: 75%;
}

.choice-sheet .option-pair {
  margin-bottom: 8px;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.scenario-button {
  min-height: 52px;
  padding: 7px;
  border: 1px solid var(--brass-0);
  background: var(--wood-0);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.scenario-button strong,
.scenario-button small { display: block; }
.scenario-button strong { color: var(--paper); font-size: calc(10px * var(--font-scale)); }
.scenario-button small { margin-top: 2px; font-size: calc(9px * var(--font-scale)); }
.scenario-button.active { border-color: var(--supply); box-shadow: inset 3px 0 0 var(--supply); }

.reward-list {
  display: grid;
  gap: 1px;
  margin: 10px 0;
  background: var(--brass-0);
  border: 1px solid var(--brass-0);
}

.reward-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  background: var(--night-1);
}

.reward-item strong { color: var(--fire); font-variant-numeric: tabular-nums; }

.toast-root {
  position: absolute;
  z-index: 90;
  right: 8px;
  bottom: calc(70px + var(--safe-bottom));
  left: 8px;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 8px 12px;
  clip-path: var(--step-corner);
  background: var(--night-1);
  border: 1px solid var(--brass-0);
  color: var(--paper);
  font-size: calc(10px * var(--font-scale));
  box-shadow: 4px 4px 0 #07050a;
}

.toast.error { border-color: var(--danger); color: #ffd9dc; }
.toast.success { border-color: var(--supply); }

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state .empty-symbol {
  font-size: 34px;
  color: var(--disabled);
}

.footer-spacer { height: 10px; }
.hidden { display: none !important; }

@keyframes flow-step {
  0% { transform: translateY(-2px); opacity: 0.35; }
  50% { opacity: 1; }
  100% { transform: translateY(7px); opacity: 0.35; }
}

@keyframes award-float {
  0% { transform: translate(-50%, 0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -34px); opacity: 0; }
}

@media (max-width: 374px) {
  .game-app { width: 100vw; }
  .chapter-chip { display: none; }
  .responsibility-shelf { min-height: 188px; padding-inline: 6px; }
  .chain-node { padding-inline: 2px; }
  .chain-node small { font-size: calc(7.5px * var(--font-scale)); }
  .option-pair { gap: 5px; }
  .option-block { padding: 7px; }
  .setting-row { grid-template-columns: minmax(0, 1fr) minmax(108px, 42%); }
}

@media (min-width: 431px) {
  .game-app { width: 430px; }
}

.game-app.text-130 {
  --font-scale: 1.3;
}

.game-app.text-130 .responsibility-shelf {
  min-height: 218px;
}

.game-app.text-130 .world-stage {
  min-height: 250px;
}

.game-app.text-130 .nav-label {
  font-size: 10px;
}

.game-app.text-130 .option-pair {
  grid-template-columns: 1fr;
}

.game-app.reduced-motion *,
.game-app.low-power * {
  scroll-behavior: auto !important;
}

.game-app.reduced-motion .flow-pips i,
.game-app.low-power .flow-pips i,
.game-app.reduced-motion .world-float,
.game-app.low-power .world-float {
  animation: none !important;
}

.game-app.low-power .npc-marker {
  opacity: 0.72;
}

.game-app.reduced-flashes .world-float {
  color: var(--paper);
}

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