:root {
  --bg: #dfe5eb;
  --text: #233946;
  --dim: #5f7786;
  --accent: #2a7fa4;
  --accent-soft: rgba(42, 127, 164, 0.2);
  --border: rgba(66, 93, 108, 0.26);
  --surface: rgba(247, 250, 252, 0.78);
  --warn: #9d6330;
  --danger: #8b3f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Inter", "Helvetica Neue", sans-serif;
  overflow: hidden;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.memory-prelude-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(248, 252, 255, 1);
  z-index: 30;
  transition: opacity 1.2s ease;
}

.memory-prelude-overlay p {
  margin: 0;
  color: #567487;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.memory-prelude-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

body.memory-prelude .intro-overlay {
  opacity: 0;
  pointer-events: none;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(226, 233, 239, 0.44);
  backdrop-filter: blur(2px);
  z-index: 20;
  transition: opacity 0.6s ease;
}

.intro-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.intro-card {
  width: min(760px, 92vw);
  border: 1px solid rgba(66, 93, 108, 0.32);
  border-radius: 16px;
  padding: 20px 22px;
  background: rgba(248, 252, 254, 0.88);
  box-shadow: 0 14px 42px rgba(39, 56, 68, 0.16);
}

.intro-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
}

.intro-line {
  margin: 0 0 8px;
  color: #2f4959;
  font-size: 14px;
  line-height: 1.44;
  opacity: 0;
  transform: translateY(7px);
  animation: intro-line-fade 0.8s ease forwards;
}

.intro-line-1 {
  animation-delay: 0.12s;
}

.intro-line-2 {
  animation-delay: 0.44s;
}

.intro-line-3 {
  animation-delay: 0.76s;
}

#introStartBtn {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  background: rgba(249, 252, 253, 0.98);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 11px;
  font-family: inherit;
  opacity: 0;
  animation: intro-line-fade 0.8s ease forwards;
  animation-delay: 1.12s;
}

@keyframes intro-line-fade {
  from {
    opacity: 0;
    transform: translateY(7px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.hud-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.top-ribbon {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.control-strip {
  pointer-events: auto;
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, 92vw);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(248, 251, 253, 0.8);
  box-shadow: 0 7px 22px rgba(40, 58, 70, 0.12);
  padding: 8px 10px;
  z-index: 8;
}

.control-strip.is-tutorial-focus,
.demand-strip.is-tutorial-focus {
  position: fixed;
  isolation: isolate;
}

.control-strip.is-tutorial-focus::after,
.demand-strip.is-tutorial-focus::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 16px;
  border: 1px solid rgba(42, 127, 164, 0.52);
  box-shadow: 0 0 0 1px rgba(42, 127, 164, 0.2), 0 0 18px rgba(42, 127, 164, 0.2);
  opacity: 0.34;
  pointer-events: none;
  animation: tutorial-focus-pulse 2.2s ease-in-out infinite;
  z-index: -1;
}

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

.priority-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
}

.priority-item span {
  color: #4e6777;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.priority-item input {
  grid-column: 1 / 2;
  width: 100%;
  accent-color: var(--accent);
}

.priority-item strong {
  grid-column: 2 / 3;
  color: #2e4858;
  font-size: 11px;
  min-width: 3ch;
  text-align: right;
}

.policy-row {
  margin-top: 7px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.policy-row button {
  pointer-events: auto;
  border: 1px solid rgba(67, 95, 109, 0.38);
  background: rgba(249, 252, 253, 0.96);
  color: #304957;
  border-radius: 8px;
  padding: 6px 5px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: inherit;
}

.policy-row button.is-active {
  border-color: rgba(42, 127, 164, 0.5);
  background: rgba(42, 127, 164, 0.14);
  color: #2e6782;
}

#policyHint {
  margin: 7px 0 0;
  color: #507082;
  font-size: 11px;
  text-align: center;
}

#priorityHint {
  margin: 8px 0 0;
  color: #4f6f80;
  font-size: 10px;
  text-align: center;
  letter-spacing: 0.01em;
}

.priority-guide {
  margin-top: 6px;
  border: 1px solid rgba(66, 93, 108, 0.24);
  border-radius: 10px;
  background: rgba(246, 250, 252, 0.78);
  padding: 6px 8px;
}

.priority-guide summary {
  cursor: pointer;
  color: #426171;
  font-size: 11px;
  letter-spacing: 0.03em;
  list-style: none;
}

.priority-guide summary::-webkit-details-marker {
  display: none;
}

.priority-guide p {
  margin: 6px 0 0;
  color: #4f6c7c;
  font-size: 11px;
  line-height: 1.35;
}

.debug-panel {
  display: none;
  pointer-events: auto;
  position: fixed;
  top: 62px;
  left: 10px;
  min-width: 224px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(248, 251, 253, 0.8);
  box-shadow: 0 7px 22px rgba(40, 58, 70, 0.12);
  padding: 8px;
  z-index: 8;
}

body.debug-enabled .debug-panel {
  display: block;
}

.debug-title {
  margin: 0 0 6px;
  color: #446375;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.debug-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 9px;
}

.debug-stats p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.debug-stats span {
  color: #5a7383;
}

.debug-stats strong {
  color: #2d4655;
}

.debug-buttons {
  margin-top: 7px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.debug-buttons button {
  pointer-events: auto;
  border: 1px solid rgba(67, 95, 109, 0.38);
  background: rgba(249, 252, 253, 0.96);
  color: #304957;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: inherit;
}

.resource-mini {
  position: fixed;
  top: 62px;
  right: 10px;
  display: flex;
  gap: 5px;
  pointer-events: auto;
  z-index: 8;
}

.resource-mini p {
  position: relative;
  margin: 0;
  border: 1px solid var(--border);
  background: rgba(248, 251, 253, 0.78);
  border-radius: 999px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: default;
}

.resource-mini p::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  max-width: 240px;
  border: 1px solid rgba(66, 93, 108, 0.26);
  border-radius: 9px;
  padding: 6px 8px;
  background: rgba(247, 251, 253, 0.96);
  box-shadow: 0 8px 20px rgba(34, 56, 68, 0.12);
  color: #3f5c6d;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 12;
}

.resource-mini p:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.resource-mini strong {
  color: #324d5c;
  font-size: 11px;
  min-width: 2ch;
  text-align: right;
}

.res-glyph {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid rgba(58, 87, 103, 0.6);
}

.res-glyph.water {
  border-radius: 50%;
  background: rgba(52, 120, 154, 0.22);
}

.res-glyph.iron {
  border-radius: 1px;
  background: rgba(103, 116, 124, 0.2);
}

.res-glyph.silicates {
  transform: rotate(45deg);
  border-radius: 1px;
  background: rgba(122, 128, 136, 0.18);
}

.res-glyph.volatiles {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background: rgba(131, 101, 71, 0.18);
}

.res-glyph.energy {
  border-radius: 50% 50% 45% 45%;
  background: rgba(42, 127, 164, 0.26);
}

.nav-link {
  pointer-events: auto;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill-group {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pill {
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 10px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  box-shadow: 0 4px 14px rgba(41, 60, 72, 0.08);
}

.pill span {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pill strong {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.pill strong.warn {
  color: var(--warn);
}

.pill strong.danger {
  color: var(--danger);
}

.war-pill {
  display: none;
}

.hud-root.war-active .war-pill {
  display: flex;
}

.hud-root.act2-red .pill,
.hud-root.act2-red .demand-strip,
.hud-root.act2-red .memory-log,
.hud-root.act2-red .context-card,
.hud-root.act2-red .debug-panel,
.hud-root.act2-red .control-strip {
  border-color: rgba(141, 79, 79, 0.35);
}

.hud-root.act2-red #demandLabel {
  color: #9b4e4e;
}

.hud-root.act2-red #causalLine {
  color: #915f5f;
}

.hud-root.act2-red .demand-scope,
.hud-root.act2-red .contract-offer,
.hud-root.act2-red .contract-timer {
  color: #8c5a5a;
}

.hud-root.act3-red .pill,
.hud-root.act3-red .demand-strip,
.hud-root.act3-red .memory-log,
.hud-root.act3-red .context-card,
.hud-root.act3-red .debug-panel,
.hud-root.act3-red .control-strip {
  border-color: rgba(150, 64, 64, 0.44);
  background: rgba(248, 244, 244, 0.82);
}

.hud-root.act3-red #demandLabel,
.hud-root.act3-red #eventLine,
.hud-root.act3-red #causalLine,
.hud-root.act3-red .demand-scope,
.hud-root.act3-red .context-title,
.hud-root.act3-red .debug-title,
.hud-root.act3-red #policyHint {
  color: #873f3f;
}

.hud-root.act3-red .contract-offer,
.hud-root.act3-red .contract-timer,
.hud-root.act3-red #actBannerText {
  color: #7e3e3e;
}

.hud-root.act2-red .debug-buttons button {
  border-color: rgba(142, 75, 75, 0.4);
  color: #844848;
}

.hud-root.act3-red .debug-buttons button {
  border-color: rgba(146, 59, 59, 0.5);
  background: rgba(248, 241, 241, 0.86);
  color: #7d3a3a;
}

.hud-root.act2-red .resource-mini p {
  border-color: rgba(141, 79, 79, 0.34);
}

.hud-root.act2-red .policy-row button {
  border-color: rgba(142, 75, 75, 0.4);
  color: #844848;
}

.hud-root.act2-red .policy-row button.is-active {
  border-color: rgba(160, 72, 72, 0.56);
  background: rgba(160, 72, 72, 0.16);
  color: #8e4545;
}

.hud-root.act3-red .resource-mini p {
  border-color: rgba(150, 64, 64, 0.44);
  background: rgba(248, 243, 243, 0.82);
}

.hud-root.act3-red .policy-row button {
  border-color: rgba(146, 59, 59, 0.5);
  background: rgba(248, 241, 241, 0.86);
  color: #7d3a3a;
}

.hud-root.act3-red .policy-row button.is-active {
  border-color: rgba(172, 68, 68, 0.62);
  background: rgba(172, 68, 68, 0.19);
  color: #8d3f3f;
}

.demand-strip {
  pointer-events: auto;
  position: fixed;
  right: 14px;
  top: 336px;
  left: auto;
  transform: none;
  width: min(520px, 36vw);
  min-width: min(420px, 92vw);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 6px 22px rgba(36, 58, 72, 0.11);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.demand-core p {
  margin: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
}

.demand-scope {
  color: #5b7382;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

#demandLabel {
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#demandProgress,
#demandTimer,
#demandReward {
  color: var(--dim);
  font-size: 11px;
}

.contract-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.contract-preview.is-hidden {
  display: none;
}

.contract-offer {
  pointer-events: auto;
  border: 1px solid rgba(67, 95, 109, 0.4);
  background: rgba(249, 252, 253, 0.96);
  color: #355162;
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 10px;
  letter-spacing: 0.02em;
  text-align: left;
  min-height: 66px;
  max-height: 66px;
  white-space: normal;
  overflow: hidden;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.contract-offer:disabled {
  opacity: 0.52;
}

.contract-offer.is-auto {
  border-color: rgba(42, 127, 164, 0.5);
}

.contract-offer.is-selected {
  border-color: rgba(42, 127, 164, 0.6);
  background: rgba(42, 127, 164, 0.13);
}

.contract-timer {
  grid-column: 1 / -1;
  margin: 0;
  color: #5a7483;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.contract-timer.is-hidden {
  display: none;
}

.memory-log {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  min-width: min(680px, 92vw);
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(247, 250, 252, 0.66);
  box-shadow: 0 6px 16px rgba(40, 58, 70, 0.08);
  display: grid;
  gap: 2px;
  transition: box-shadow 0.28s ease, border-color 0.28s ease, background 0.28s ease;
}

.galaxy-feed {
  position: fixed;
  left: 12px;
  top: 302px;
  width: min(380px, 30vw);
  border: 1px solid rgba(66, 93, 108, 0.26);
  border-radius: 12px;
  background: rgba(247, 250, 252, 0.68);
  box-shadow: 0 6px 16px rgba(40, 58, 70, 0.08);
  padding: 8px 10px;
  pointer-events: none;
  z-index: 7;
}

body.debug-enabled .galaxy-feed {
  top: 316px;
}

.galaxy-kicker {
  margin: 0;
  color: #4a6879;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 10px;
}

.galaxy-headline {
  margin: 4px 0 0;
  color: #3a5667;
  font-size: 12px;
  line-height: 1.34;
}

.act-banner {
  position: fixed;
  top: 238px;
  left: 50%;
  transform: translateX(-50%);
  min-width: min(620px, 90vw);
  border: 1px solid rgba(66, 93, 108, 0.28);
  border-radius: 999px;
  background: rgba(247, 251, 253, 0.9);
  box-shadow: 0 9px 24px rgba(32, 55, 68, 0.14);
  padding: 8px 14px;
  opacity: 1;
  transition: opacity 0.28s ease;
  z-index: 9;
}

.act-banner.is-hidden {
  opacity: 0;
  pointer-events: none;
}

#actBannerText {
  margin: 0;
  color: #2f6078;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.03em;
}

.memory-log.is-pulse {
  animation: memory-log-pulse 0.56s ease;
}

.memory-log.is-pulse-positive {
  border-color: rgba(58, 138, 172, 0.52);
  box-shadow: 0 10px 24px rgba(38, 106, 132, 0.2);
}

.memory-log.is-pulse-negative {
  border-color: rgba(156, 73, 73, 0.52);
  box-shadow: 0 10px 24px rgba(128, 52, 52, 0.2);
}

@keyframes memory-log-pulse {
  0% {
    transform: translateX(-50%) scale(1);
  }
  45% {
    transform: translateX(-50%) scale(1.01);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

#eventLine {
  margin: 0;
  color: #3f5a69;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.02em;
}

#causalLine {
  margin: 0;
  color: #5a7483;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}

.resource-fx {
  position: fixed;
  left: 0;
  top: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(18, 26, 32, 0.22);
  will-change: transform, opacity;
}

.resource-fx.is-gain {
  color: rgba(45, 142, 82, 0.95);
}

.resource-fx.is-spend {
  color: rgba(162, 58, 58, 0.94);
}

.context-card {
  pointer-events: auto;
  position: fixed;
  right: 14px;
  bottom: 66px;
  width: min(340px, 86vw);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(247, 250, 252, 0.86);
  box-shadow: 0 10px 26px rgba(33, 54, 66, 0.15);
  padding: 10px;
}

.context-card.is-hidden {
  display: none;
}

.tutorial-card {
  pointer-events: auto;
  position: fixed;
  left: 14px;
  bottom: 74px;
  width: min(380px, 84vw);
  border: 1px solid rgba(66, 93, 108, 0.32);
  border-radius: 14px;
  background: rgba(248, 252, 254, 0.9);
  box-shadow: 0 10px 24px rgba(34, 54, 66, 0.12);
  padding: 10px;
  display: grid;
  gap: 6px;
  z-index: 12;
}

.tutorial-card.is-hidden {
  display: none;
}

.tutorial-title {
  margin: 0;
  color: #2f6d89;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.tutorial-body {
  margin: 0;
  color: #385566;
  font-size: 12px;
  line-height: 1.38;
}

.tutorial-hint {
  margin: 0;
  color: #5a7584;
  font-size: 11px;
}

.tutorial-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tutorial-actions #tutorialSkipBtn {
  color: #567282;
}

.tutorial-actions #tutorialMuteBtn {
  color: #7e3f3f;
}

.tutorial-actions #tutorialMuteBtn.is-hidden {
  display: none;
}

.context-title {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.context-meta {
  margin: 4px 0 8px;
  color: var(--dim);
  font-size: 12px;
}

.context-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.context-actions button,
.tutorial-actions button,
.choice-options button,
.end-buttons a,
#restartBtn {
  pointer-events: auto;
  position: relative;
  border: 1px solid rgba(67, 95, 109, 0.4);
  background: rgba(249, 252, 253, 0.96);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  letter-spacing: 0.03em;
  font-family: inherit;
  text-align: left;
}

.context-actions button::after {
  content: attr(data-tip);
  display: block;
  margin-top: 0;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  max-width: 240px;
  border: 1px solid rgba(66, 93, 108, 0.26);
  border-radius: 9px;
  padding: 6px 8px;
  background: rgba(247, 251, 253, 0.96);
  box-shadow: 0 8px 20px rgba(34, 56, 68, 0.12);
  color: #3f5c6d;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 12;
}

.context-actions button::before {
  content: attr(data-cost);
  display: block;
  margin-top: 2px;
  color: #587383;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.context-actions button.is-missing::before {
  color: #a24747;
}

.context-actions button:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.context-actions button:disabled {
  opacity: 0.56;
  border-color: rgba(122, 134, 142, 0.5);
}

.choice-overlay,
.end-overlay {
  position: fixed;
  inset: 0;
  transition: opacity 0.45s ease;
}

.choice-overlay {
  display: grid;
  place-items: center;
  background: rgba(230, 236, 242, 0.72);
}

.choice-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.choice-card {
  width: min(700px, 92vw);
  border: 1px solid rgba(65, 94, 108, 0.33);
  border-radius: 14px;
  background: rgba(248, 252, 254, 0.96);
  box-shadow: 0 16px 44px rgba(38, 55, 67, 0.18);
  padding: 16px;
}

#choiceKicker {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#choiceTitle {
  margin: 8px 0 8px;
  font-size: 18px;
}

#choiceBody {
  margin: 0 0 10px;
  color: #3f5a69;
  font-size: 13px;
}

#choiceTimer {
  margin: 0 0 10px;
  color: #567584;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.choice-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.choice-options button {
  display: grid;
  gap: 5px;
  min-height: 110px;
}

.choice-options strong {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.choice-options em {
  font-style: normal;
  color: #4f6877;
  font-size: 12px;
}

.end-overlay {
  display: block;
  background: #030204;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.end-overlay:not(.is-hidden) {
  opacity: 1;
  pointer-events: auto;
}

body.prestart .top-ribbon,
body.prestart .control-strip,
body.prestart .debug-panel,
body.prestart .demand-strip,
body.prestart .act-banner,
body.prestart .memory-log,
body.prestart .context-card,
body.prestart .tutorial-card,
body.prestart .resource-mini {
  opacity: 0;
  pointer-events: none;
}

#endEyeCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #050406;
  pointer-events: none;
}

.end-copy {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(760px, 94vw);
  border: 1px solid rgba(145, 54, 54, 0.54);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(14, 7, 9, 0.62), rgba(8, 5, 7, 0.84));
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(1px);
  padding: 14px 16px;
  z-index: 2;
  max-height: 92vh;
  overflow: auto;
}

.end-overlay:not(.is-hidden) .end-copy {
  animation: end-copy-rise 0.5s ease both;
}

.end-overlay.is-prelude .end-copy {
  opacity: 0;
  pointer-events: none;
}

@keyframes end-copy-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
    filter: blur(0);
  }
}

.end-copy h2 {
  margin: 0;
  color: #cf6d6d;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.12em;
}

#endSentence {
  margin: 8px 0 6px;
  color: #c86969;
  font-size: 13px;
  letter-spacing: 0.02em;
}

#endReason {
  margin: 0 0 12px;
  color: #a56262;
  font-size: 12px;
}

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

.end-grid p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed rgba(152, 64, 64, 0.32);
  padding-bottom: 3px;
}

.end-grid span {
  color: #b06c6c;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.end-grid strong {
  color: #d27c7c;
  font-size: 12px;
}

.end-hook {
  margin-top: 12px;
  border: 1px solid rgba(148, 63, 63, 0.42);
  border-radius: 10px;
  padding: 8px;
  background: rgba(12, 7, 9, 0.54);
  display: grid;
  gap: 7px;
}

.end-hook-kicker {
  margin: 0;
  color: #c57474;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.end-hook-note {
  margin: 0;
  color: #b77474;
  font-size: 12px;
  line-height: 1.35;
}

.end-hook-note a {
  color: #e09393;
}

.end-subscribe-row button {
  pointer-events: auto;
  border: 1px solid rgba(162, 66, 66, 0.48);
  background: rgba(22, 10, 12, 0.88);
  color: #db8080;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
}

.end-subscribe-row button:disabled {
  opacity: 0.6;
}

.end-subscribe {
  display: grid;
  gap: 6px;
}

.end-subscribe label {
  color: #ba7171;
  font-size: 11px;
}

.end-subscribe-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.end-subscribe-row input {
  border: 1px solid rgba(148, 63, 63, 0.42);
  border-radius: 8px;
  background: rgba(16, 8, 10, 0.85);
  color: #e19696;
  padding: 7px 9px;
  font-size: 12px;
  font-family: inherit;
}

#endSubscribeStatus {
  margin: 0;
  color: #b46f6f;
  font-size: 11px;
}

#endSubscribeStatus.is-error {
  color: #dc8a8a;
}

#endSubscribeStatus.is-ok {
  color: #a7d6aa;
}

.end-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 12px;
}

.end-buttons a {
  text-decoration: none;
  text-align: center;
}

.end-overlay .end-buttons a,
.end-overlay #restartBtn {
  border: 1px solid rgba(162, 66, 66, 0.48);
  background: rgba(22, 10, 12, 0.88);
  color: #db8080;
  text-align: center;
}

@keyframes tutorial-focus-pulse {
  0% {
    opacity: 0.22;
    transform: scale(0.995);
  }
  50% {
    opacity: 0.44;
    transform: scale(1.004);
  }
  100% {
    opacity: 0.22;
    transform: scale(0.995);
  }
}

@media (max-width: 940px) {
  .pill-group {
    justify-content: flex-start;
  }

  .top-ribbon {
    grid-template-columns: 1fr;
  }

  .demand-strip {
    left: 50%;
    right: auto;
    top: 222px;
    transform: translateX(-50%);
    width: min(640px, 94vw);
    min-width: min(640px, 94vw);
  }

  .contract-preview {
    grid-template-columns: 1fr;
  }

  .control-strip {
    top: 116px;
    width: min(700px, 94vw);
  }

  .priority-grid,
  .policy-row {
    grid-template-columns: 1fr;
  }

  .resource-mini {
    top: 84px;
    right: 10px;
    flex-wrap: wrap;
    max-width: min(320px, 80vw);
    justify-content: flex-end;
  }

  .galaxy-feed {
    display: none;
  }

  .debug-panel {
    top: 126px;
    left: 10px;
    min-width: min(280px, 78vw);
  }

  .debug-buttons {
    grid-template-columns: 1fr;
  }

  .context-card {
    right: 50%;
    transform: translateX(50%);
  }

  .tutorial-card {
    left: 50%;
    transform: translateX(-50%);
    width: min(640px, 94vw);
    bottom: 80px;
  }

  .choice-options,
  .end-buttons {
    grid-template-columns: 1fr;
  }
}
