/* Stage: the WebGL view sits behind every screen on wide layouts and becomes
   a framed band at the top of the page on phones. */
.stage { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
.stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline-offset: -4px; }
.stage-shade {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(11, 17, 21, 0.9) 0, rgba(11, 17, 21, 0) 170px),
    linear-gradient(90deg, rgba(11, 17, 21, 0.78) 0, rgba(11, 17, 21, 0) 36%),
    linear-gradient(0deg, rgba(11, 17, 21, 0.85) 0, rgba(11, 17, 21, 0) 34%);
}
body[data-screen="bench"] .stage-shade {
  background:
    radial-gradient(ellipse 620px 360px at 0 60px, rgba(11, 17, 21, 0.9), rgba(11, 17, 21, 0) 100%),
    linear-gradient(0deg, rgba(11, 17, 21, 0.85) 0, rgba(11, 17, 21, 0) 34%);
}
body[data-screen="sector"] .stage-shade { background: linear-gradient(180deg, rgba(6, 11, 14, 0.8) 0, rgba(6, 11, 14, 0) 150px); }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 50; background: var(--amber); color: var(--amber-ink); padding: 10px 14px; font-weight: 600; }
.skip-link:focus { top: 12px; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 40px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 17, 21, 0.92), rgba(11, 17, 21, 0.72));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.wordmark { display: inline-flex; align-items: center; gap: 12px; font: 700 22px/1 var(--font-display); letter-spacing: 0.16em; }
.wordmark svg { width: 26px; height: 26px; fill: var(--amber); }
.primary-nav { display: flex; align-self: stretch; gap: 8px; }
.primary-nav a {
  position: relative; display: inline-flex; align-items: center; gap: 10px; padding: 0 14px;
  font: 700 17px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
  transition: color var(--fast);
}
.primary-nav a:hover { color: var(--ink); }
.primary-nav a[aria-current="page"] { color: var(--ink); }
.primary-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; background: var(--amber); }
.primary-nav .icon { width: 20px; height: 20px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--amber); color: var(--amber-ink); font: 700 11px/18px var(--font-text); text-align: center; }
a.icon-button[aria-current="page"] { color: var(--amber); border-color: var(--amber); }
@media (max-width: 1280px) and (min-width: 761px) {
  .topbar { gap: 20px; }
  .primary-nav a { padding: 0 9px; font-size: 15px; }
  .primary-nav a .icon { display: none; }
  .primary-nav a[aria-current="page"]::after { left: 9px; right: 9px; }
}
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 20px; }
@keyframes gain { 0% { color: var(--amber); } 100% { color: var(--ink); } }
.lang-switch { display: inline-flex; border: 1px solid var(--line); }
.lang-switch button { min-width: 40px; height: 38px; font: 700 14px/1 var(--font-display); letter-spacing: 0.08em; color: var(--ink-3); transition: color var(--fast), background var(--fast); }
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { color: #121719; background: var(--ink); }

main { position: relative; z-index: 5; }
.screen { position: fixed; inset: var(--topbar) 0 var(--tabbar) 0; pointer-events: none; }
.screen :is(a, button, input, [tabindex], ol, .panel, .scroll) { pointer-events: auto; }

/* 3D-anchored overlays (hardpoint callout, map markers). */
.anchors { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
/* Script sets transform: screen position, then the pin offset (label right or flipped left). */
.anchor { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; transition: opacity var(--fast) var(--ease); }
.anchor.is-hidden { opacity: 0; pointer-events: none; }

.hardpoint-callout {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0 12px 0 0; min-height: 36px; color: var(--ink);
}
.hardpoint-callout .pin { width: 12px; height: 12px; border: 2px solid var(--amber); border-radius: 50%; background: rgba(11, 17, 21, 0.6); box-shadow: 0 0 0 4px rgba(255, 180, 79, 0.18); }
.hardpoint-callout .tag { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line-strong); padding: 7px 10px; font: 500 13px/1 var(--font-text); white-space: nowrap; }
.hardpoint-callout .tag b { font: 700 15px/1 var(--font-display); letter-spacing: 0.04em; }
.hardpoint-callout .tag span { color: var(--amber); }
.hardpoint-callout:hover .tag { border-color: var(--amber); }
.hardpoint-callout.flip { flex-direction: row-reverse; padding: 0 0 0 12px; }

.map-marker { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.map-marker .pin { position: relative; width: 18px; height: 18px; flex: none; border: 2px solid var(--ink-2); border-radius: 50%; background: rgba(6, 11, 14, 0.7); transition: border-color var(--fast), transform var(--fast) var(--ease); }
.map-marker .pin::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: transparent; }
.map-marker .tag { display: grid; gap: 3px; padding: 6px 9px; background: rgba(8, 13, 16, 0.82); border: 1px solid var(--line); white-space: nowrap; transition: border-color var(--fast), background var(--fast); }
.map-marker .tag b { font: 700 15px/1 var(--font-display); letter-spacing: 0.04em; }
.map-marker .tag-sub { display: inline-flex; align-items: center; gap: 5px; font: 500 13px/1 var(--font-text); color: var(--ink-2); }
.map-marker .tag-sub .icon { width: 14px; height: 14px; }
.map-marker.flip { flex-direction: row-reverse; }
.map-marker:hover .tag { border-color: var(--line-strong); background: rgba(8, 13, 16, 0.94); }
.map-marker[aria-pressed="true"] .pin { border-color: var(--amber); transform: scale(1.15); box-shadow: 0 0 0 5px rgba(255, 180, 79, 0.18); }
.map-marker[aria-pressed="true"] .tag { border-color: var(--amber); }
.map-marker.is-active .pin::after { background: var(--amber); }
.map-marker.is-blocked .tag b, .map-marker.is-closed .tag b { color: var(--ink-3); }
.map-marker.is-blocked .tag-sub, .map-marker.is-closed .tag-sub { color: var(--ink-3); }
.map-marker.is-home { pointer-events: none; }
.map-marker.is-home .pin { border-radius: 2px; border-color: var(--ink-2); }
.map-marker.is-home .tag { background: transparent; border-color: transparent; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--tabbar)); z-index: 40; transform: translate(-50%, 12px);
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 16px; background: var(--panel-solid); border: 1px solid var(--line-strong); border-left: 3px solid var(--amber);
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity var(--medium) var(--ease), transform var(--medium) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-ok { border-left-color: var(--ok); }

.fallback { position: fixed; left: 50%; top: 45%; z-index: 30; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); display: grid; gap: 10px; padding: 20px; background: var(--panel-solid); border: 1px solid var(--line-strong); }
.fallback b { font: 700 20px/1 var(--font-display); text-transform: uppercase; }
.fallback p { color: var(--ink-2); }

.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid var(--line-strong); background: var(--panel-solid); color: var(--ink); overflow: auto; }
.dialog::backdrop { background: rgba(4, 8, 10, 0.72); backdrop-filter: blur(3px); }
.dialog[open] { animation: enter var(--medium) var(--ease); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-body { display: grid; gap: 22px; padding: 22px 24px 24px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; padding: 0 24px 24px; }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; align-items: center; }
.setting > span { display: grid; gap: 4px; }
.setting b { font-weight: 500; font-size: 16px; }
.setting small { font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); }
.segmented button { min-height: 40px; padding: 0 14px; font: 500 14px/1 var(--font-text); color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #121719; }
.segmented button:hover:not([aria-pressed="true"]) { color: var(--ink); background: var(--raise); }
.switch { position: relative; width: 48px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line-strong); transition: background var(--fast); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink-2); transition: transform var(--fast) var(--ease), background var(--fast); }
.switch[aria-checked="true"] { background: var(--amber); border-color: var(--amber); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--amber-ink); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; color: var(--ink-2); }
.keys dt { font: 700 14px/1.4 var(--font-display); letter-spacing: 0.04em; color: var(--ink); white-space: nowrap; }

@media (max-width: 760px) {
  :root { --gutter: 16px; --topbar: 56px; --tabbar: calc(62px + env(safe-area-inset-bottom)); }
  body { overflow-y: auto; }
  /* No backdrop-filter here: it would become the containing block of the fixed tab bar. */
  .topbar { gap: 12px; backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(11, 17, 21, 0.97); }
  .wordmark { font-size: 19px; gap: 9px; }
  .wordmark svg { width: 22px; height: 22px; }
  .topbar-end { gap: 10px; }
  .lang-switch button { min-width: 36px; height: 36px; font-size: 13px; }
  .icon-button { width: 38px; height: 38px; }
  /* Primary sections move to a thumb-reach tab bar. */
  .primary-nav { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom); gap: 0; z-index: 25; background: rgba(11, 17, 21, 0.96); border-top: 1px solid var(--line); }
  .primary-nav a { flex: 1; flex-direction: column; justify-content: center; gap: 4px; padding: 0 2px; font-size: 12px; letter-spacing: 0.02em; position: relative; }
  .primary-nav .badge { position: absolute; top: 6px; left: calc(50% + 6px); }
  .primary-nav a[aria-current="page"]::after { top: -1px; bottom: auto; left: 30%; right: 30%; }
  body[data-sub="true"] .primary-nav { display: none; }
  body[data-sub="true"] { --tabbar: 0px; }
  .stage { position: absolute; inset: var(--topbar) 0 auto 0; height: var(--band); }
  .stage-shade { position: absolute; inset: var(--topbar) 0 auto 0; height: var(--band); background: linear-gradient(0deg, rgba(15, 23, 27, 1) 0, rgba(15, 23, 27, 0) 40%) !important; }
  .anchors { position: absolute; }
  .map-marker .tag { padding: 4px 7px; }
  .map-marker .tag-sub { display: none; }
  .map-marker .tag b { font-size: 14px; }
  .screen { position: relative; inset: auto; min-height: calc(100dvh - var(--tabbar)); padding: calc(var(--topbar) + var(--band)) var(--gutter) calc(var(--tabbar) + 24px); pointer-events: auto; }
  .toast { left: var(--gutter); right: var(--gutter); max-width: none; transform: translateY(12px); bottom: calc(16px + var(--tabbar) + var(--action-bar, 0px)); }
  .toast.is-visible { transform: none; }
}

/* ---- Goal, "now" line, hints ----------------------------------------------------- */
.buyout { display: flex; flex-direction: column; gap: 7px; width: 290px; }
.goal-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.goal-label { font: 500 13px/1 var(--font-text); color: var(--ink-3); white-space: nowrap; }
.buyout .goal-bar { width: 100%; }
.goal-bar { position: relative; width: 120px; height: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.goal-bar i { position: absolute; inset: 0 auto 0 0; background: var(--amber); transition: width 900ms var(--ease); }
.goal-value { font: 700 17px/1 var(--font-display); white-space: nowrap; }
.goal-value .unit { font: 400 12px/1 var(--font-text); color: var(--ink-3); margin-left: 3px; }
.buyout.is-changed .goal-value { animation: gain 900ms var(--ease); }

.objective { position: fixed; z-index: 15; top: calc(var(--topbar) + 14px); left: var(--gutter); max-width: min(620px, calc(100vw - 2 * var(--gutter))); pointer-events: auto; }
.objective-link { display: flex; align-items: baseline; gap: 12px; padding: 9px 16px 10px 14px; background: linear-gradient(90deg, rgba(9, 14, 17, 0.92), rgba(9, 14, 17, 0.7)); border-left: 3px solid var(--amber); color: var(--ink); text-align: left; font-size: 15px; line-height: 1.35; transition: background var(--fast); }
.objective-link:hover { background: rgba(9, 14, 17, 0.96); }
.objective-link .icon { align-self: center; color: var(--amber); }
.objective-label { font: 700 12px/1 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); white-space: nowrap; }
.objective-link.is-action { border-left-color: var(--ok); }

.hint { position: fixed; z-index: 45; top: 0; left: 0; width: min(300px, calc(100vw - 24px)); display: grid; gap: 10px; padding: 14px 16px; background: #ece8dd; color: #161a1b; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4); font-size: 14px; line-height: 1.45; pointer-events: none; }
.hint::before { content: ""; position: absolute; width: 12px; height: 12px; background: inherit; transform: rotate(45deg); }
.hint[data-side="left"]::before { right: -6px; top: calc(50% - 6px); }
.hint[data-side="top"]::before { bottom: -6px; right: 28px; }
.hint[data-side="bottom"]::before { top: -6px; left: calc(50% - 6px); }
.hint.is-hidden { visibility: hidden; }
.hint-close { pointer-events: auto; justify-self: start; font: 600 13px/1 var(--font-text); color: #4a5254; text-decoration: underline; text-underline-offset: 3px; }
.hint-close:hover { color: #000; }

/* ---- Launch and docking shots ------------------------------------------------------ */
.cut-caption { position: fixed; z-index: 40; left: 50%; bottom: 44px; transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; padding: 12px 22px; background: rgba(9, 14, 17, 0.72); pointer-events: none; }
.cut-caption b { font: 700 22px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.cut-caption span { font-size: 13px; color: var(--ink-3); }
body[data-cut="launch"] :is(.screen, .anchors, .hint), body[data-cut="dock"] :is(.screen, .anchors, .hint) { opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); }
body:is([data-cut="launch"], [data-cut="dock"]) .stage canvas { cursor: pointer; }

/* ---- Loading veil, graphics notice, title screen ------------------------------------ */
.veil { position: fixed; inset: 0; z-index: 55; display: grid; place-content: center; justify-items: center; gap: 22px; background: var(--bg); transition: opacity 500ms var(--ease), visibility 0s linear 500ms; }
.veil svg { width: 44px; height: 44px; fill: var(--amber); }
.veil-bar { width: 160px; height: 2px; background: rgba(255, 255, 255, 0.1); position: relative; overflow: hidden; }
.veil-bar::after { content: ""; position: absolute; inset: 0 60% 0 0; background: var(--amber); animation: veil 1.2s ease-in-out infinite; }
@keyframes veil { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
body[data-stage="live"] .veil, body[data-stage="failed"] .veil, body[data-intro="true"] .veil { opacity: 0; visibility: hidden; }

.gfx-notice { position: fixed; z-index: 35; top: calc(var(--topbar) + 14px); left: 50%; transform: translateX(-50%); padding: 8px 14px; background: var(--panel-solid); border: 1px solid var(--line-strong); font-size: 14px; }

.intro { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; padding: 48px calc(var(--gutter) * 2); overflow-y: auto; background: linear-gradient(90deg, rgba(7, 11, 14, 0.96) 0%, rgba(7, 11, 14, 0.86) 38%, rgba(7, 11, 14, 0.25) 72%, rgba(7, 11, 14, 0.1) 100%); }
.intro-card { width: min(560px, 100%); display: grid; gap: 22px; }
.intro-kicker { font: 500 14px/1 var(--font-text); color: var(--ink-3); letter-spacing: 0.02em; }
.intro-title { font: 700 clamp(72px, 8vw, 120px)/0.85 var(--font-display); letter-spacing: 0.04em; }
.intro-lead { font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 480px; }
.intro-facts { display: grid; gap: 14px; }
.intro-facts li { display: grid; grid-template-columns: 24px 1fr; gap: 14px; align-items: start; font-size: 16px; line-height: 1.45; color: var(--ink-2); }
.intro-facts .icon { width: 22px; height: 22px; margin-top: 1px; color: var(--ink-3); }
.intro-facts b { display: block; font: 700 13px/1.2 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); margin-bottom: 3px; }
.intro-goal { display: flex; align-items: center; gap: 14px; font: 700 16px/1 var(--font-display); }
.intro-goal .goal-bar { width: 220px; }
.intro-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.intro-actions .btn { min-width: 240px; min-height: 56px; font-size: 18px; }
.intro-options { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- World changes and document screens --------------------------------------------- */
.stage-snapshot { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.stage-snapshot.is-shown { opacity: 1; }
.stage-snapshot.is-clearing { opacity: 0; transition: opacity 320ms var(--ease); }
body[data-page="true"] .stage, body[data-page="true"] .stage-shade { visibility: hidden; }
body[data-page="true"] { background: radial-gradient(1400px 700px at 72% -10%, rgba(38, 56, 64, 0.42), rgba(14, 20, 24, 0) 70%), var(--bg); }

@media (max-width: 760px) {
  .buyout { width: auto; gap: 5px; }
  /* Language lives in settings and on the title screen on a phone. */
  .topbar .lang-switch { display: none; }
  .goal-label { display: none; }
  .goal-bar { width: 100%; height: 4px; }
  .goal-value { font-size: 14px; }
  .goal-value .unit { display: none; }
  .objective { position: absolute; top: calc(var(--topbar) + 8px); left: var(--gutter); right: var(--gutter); max-width: none; }
  .objective-link { font-size: 14px; padding: 8px 12px; }
  /* A full-screen detail sheet has its own title and back button. */
  body[data-sheet="true"] .objective { display: none; }
  .intro { align-items: flex-start; padding: 32px var(--gutter) 40px; background: linear-gradient(180deg, rgba(7, 11, 14, 0.7) 0%, rgba(7, 11, 14, 0.94) 36%, rgba(7, 11, 14, 0.98) 100%); }
  .intro-card { gap: 18px; padding-top: 18vh; }
  .intro-title { font-size: 64px; }
  .intro-lead { font-size: 16px; }
  .intro-actions .btn { width: 100%; }
  .cut-caption { bottom: calc(var(--tabbar) + 16px); width: calc(100vw - 2 * var(--gutter)); }
}

.anchors .leader { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.anchors .leader line { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.5; }
.anchors .leader.is-hidden { display: none; }

body[data-intro="true"] :is(.topbar, .screen, .anchors, .objective, .hint) { visibility: hidden; }
