:root {
  color-scheme: dark;
  --bg: #071016;
  --surface: #0d1921;
  --surface-2: #12232d;
  --surface-3: #17303b;
  --line: #29434f;
  --line-strong: #416372;
  --text: #e9f2f5;
  --muted: #9db2bb;
  --accent: #73dcff;
  --accent-2: #55f0c2;
  --warning: #ffd27a;
  --danger: #ff9c9c;
  --success: #8ff2b4;
  --shadow: 0 18px 45px rgb(0 0 0 / .28);
  --radius: 14px;
  --font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: var(--font-size); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  background:
    radial-gradient(circle at 85% -10%, rgb(56 139 157 / .16), transparent 34rem),
    radial-gradient(circle at 5% 30%, rgb(42 83 119 / .12), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
}

body.large-text { --font-size: 19px; }
body.high-contrast {
  --bg: #000;
  --surface: #090909;
  --surface-2: #111;
  --surface-3: #181818;
  --line: #fff;
  --line-strong: #fff;
  --text: #fff;
  --muted: #eee;
  --accent: #00e5ff;
  --accent-2: #00ff8c;
  --danger: #ff8e8e;
  background: #000;
}

a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: #c5f3ff; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
:focus-visible { outline: 3px solid #fff36b; outline-offset: 3px; }
.sr-only {
  position: absolute !important; 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: 999; top: .7rem; left: .7rem; padding: .75rem 1rem;
  background: #fff36b; color: #071016; font-weight: 800; transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 90px; display: grid; grid-template-columns: minmax(220px, .7fr) minmax(620px, 1.7fr) auto;
  align-items: stretch; position: sticky; z-index: 20; top: 0; background: rgb(7 16 22 / .94);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .8rem; padding: .9rem 1.3rem; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--accent);
  border-radius: 50%; color: var(--accent); font-weight: 900; letter-spacing: -.05em; box-shadow: 0 0 22px rgb(115 220 255 / .16);
}
.brand strong { display: block; letter-spacing: .03em; }
.brand small { display: block; color: var(--muted); font-size: .73rem; }
.resource-bar { border-inline: 1px solid var(--line); }
.resource-bar dl { display: grid; grid-template-columns: repeat(7, minmax(92px, 1fr)); height: 100%; margin: 0; }
.resource-bar dl > div { padding: .85rem .7rem; border-right: 1px solid var(--line); }
.resource-bar dl > div:last-child { border: 0; }
.resource-bar dt, .resource-bar small { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.resource-bar dd { margin: 0; }
.resource-bar strong { display: block; margin: .1rem 0; color: var(--text); font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.resource-bar small { color: var(--accent-2); letter-spacing: .03em; }
.access-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .7rem; }
.icon-button { padding: .6rem; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: .72rem; }
.icon-button { min-width: 44px; min-height: 44px; }
.icon-button:hover, .icon-button[aria-pressed="true"] { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: calc(100vh - 90px); }
.sidebar { border-right: 1px solid var(--line); background: rgb(9 21 28 / .76); padding: 1.2rem .8rem; }
.planet-switcher { padding: .6rem .65rem 1.2rem; border-bottom: 1px solid var(--line); }
.planet-switcher label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.planet-switcher select { width: 100%; }
.sidebar nav { margin-top: 1rem; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.sidebar nav a { display: flex; align-items: center; gap: .8rem; padding: .72rem .8rem; border: 1px solid transparent; border-radius: 8px; color: var(--muted); text-decoration: none; }
.sidebar nav a > span { color: #607984; font-family: ui-monospace, monospace; font-size: .7rem; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a[aria-current="page"] { border-color: var(--line); background: linear-gradient(90deg, rgb(53 143 162 / .17), transparent); color: var(--text); box-shadow: inset 3px 0 var(--accent); }
.sidebar [data-navigation-grouped] { display: grid; gap: .5rem; }
.sidebar [data-navigation-group] {
  margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.sidebar [data-navigation-group] > summary {
  min-height: 44px; padding: .65rem .75rem; color: var(--text); list-style-position: inside;
}
.sidebar [data-navigation-group][open] > summary { border-bottom: 1px solid var(--line); color: var(--accent); }
.sidebar [data-navigation-group] ul { padding: .35rem; }
.badge { margin-left: auto; min-width: 1.4rem; padding: .05rem .38rem; border-radius: 999px; background: var(--accent); color: #031015; text-align: center; font-size: .73rem; }
.commander-card { margin: 2rem .65rem 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.commander-card span, .commander-card small { display: block; color: var(--muted); font-size: .72rem; }
.commander-card strong { display: block; }

.main-content { width: 100%; max-width: 1500px; padding: clamp(1.2rem, 3vw, 3rem); }
.page-heading { margin: .5rem 0 2rem; }
.page-heading h1 { max-width: 900px; margin: .12rem 0 .35rem; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.05; letter-spacing: -.045em; }
.page-heading p:last-child { max-width: 760px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--accent-2); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
.split-heading { min-height: 150px; display: flex; align-items: center; justify-content: space-between; overflow: hidden; }
.world-orbit { position: relative; width: 250px; height: 140px; opacity: .8; }
.world-orbit::before { content: ""; position: absolute; inset: 20px 0; border: 1px solid var(--line-strong); border-radius: 50%; transform: rotate(-14deg); }
.world-orbit span { position: absolute; top: 24px; left: 83px; width: 92px; height: 92px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #86e8e4, #246a78 42%, #08141b 72%); box-shadow: 0 0 55px rgb(81 217 218 / .25); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 1rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.metric-grid article { padding: 1.15rem 1.3rem; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border: 0; }
.metric-grid-six { grid-template-columns: repeat(6, 1fr); }
.metric-grid-eight { grid-template-columns: repeat(4, 1fr); }
.metric-grid span, .metric-grid small { display: block; color: var(--muted); font-size: .73rem; }
.metric-grid strong { display: block; margin: .2rem 0; font-size: 1.6rem; letter-spacing: -.04em; }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; }
.panel { padding: 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface), rgb(12 27 35 / .7)); box-shadow: var(--shadow); }
.panel-wide { grid-column: 1 / -1; }
.panel h2, .panel h3 { margin-top: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin: .1rem 0; }
.tab-interface {
  margin: 1rem 0; padding: 1rem; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface);
}
.tab-interface h2 { margin: 0 0 .25rem; font-size: 1.35rem; }
.tab-interface > p:not(.sr-only) { margin: 0 0 .8rem; color: var(--muted); }
.tab-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.tab-button {
  min-height: 44px; padding: .65rem .85rem; border: 1px solid var(--line-strong);
  border-bottom: 4px solid transparent; border-radius: 7px 7px 3px 3px;
  background: var(--surface-2); color: var(--text); font-weight: 750; text-align: left;
}
.tab-button:hover { border-color: var(--accent); }
.tab-button[aria-selected="true"] {
  border-bottom-color: var(--accent-2); background: var(--surface-3);
  text-decoration: underline; text-decoration-thickness: .16em; text-underline-offset: .35em;
}
.tab-button:focus-visible { outline-color: #fff36b; border-color: #fff36b; }
.tab-interface { grid-column: 1 / -1; }
.tab-panel-stack { display: contents; }
.cheat-editor-tabs { margin-top: 1rem; }
.cheat-tab-panel { min-width: 0; padding-top: .35rem; }
.cheat-tab-panel > h3:first-child { margin-bottom: 1rem; }
body.tabbed-navigation .tab-panel-stack {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem;
}
body.tabbed-navigation [data-tab-panel] { min-width: 0; width: 100%; grid-column: 1 / -1; }
body.tabbed-navigation [data-tab-panel]:focus { scroll-margin-top: 7rem; }
.dashboard-section { margin-bottom: 1rem; }
.collapsible-heading { margin: 0; }
.collapsible-heading button {
  display: flex; width: 100%; min-height: 48px; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .35rem 0; border: 0; background: transparent; color: var(--text); text-align: left; font-weight: 800;
}
.collapsible-heading button:hover { color: var(--accent); }
.collapsible-heading small { display: block; color: var(--accent-2); font-size: .68rem; letter-spacing: .16em; }
.collapsible-heading [data-panel-indicator] { color: var(--accent); font-size: 1.6rem; line-height: 1; }
.collapsible-panel > [data-panel-content] { margin-top: 1rem; }
.dashboard-section > [data-panel-content] { margin-top: .4rem; }
.activity-list, .report-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; align-items: center; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.activity-list li:last-child { border-bottom: 0; }
.activity-list li > div:first-child { min-width: 0; flex: 1; }
.activity-list strong, .activity-list span { display: block; }
.activity-list span { color: var(--muted); font-size: .82rem; }
.countdown { color: var(--accent-2); font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.report-list li { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.report-list p { margin: .2rem 0 0; color: var(--muted); }
.report-category { color: var(--accent-2); font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.empty-state { padding: 1.2rem; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); }
.button-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .58rem .9rem;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); color: var(--text);
  text-decoration: none; font-weight: 750; line-height: 1.2;
}
.button:hover { border-color: var(--accent); background: var(--surface-3); color: var(--text); }
.button-primary { border-color: #55d8dc; background: linear-gradient(135deg, #45cfc4, #51bde8); color: #041419; }
.button-primary:hover { background: #91f2e7; color: #031014; }
.button-secondary { background: transparent; }
.button-danger { border-color: #8f545b; background: transparent; color: var(--danger); }
.button-large { min-height: 50px; padding-inline: 1.3rem; }
.notice { margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid var(--line-strong); border-left-width: 5px; border-radius: 6px; background: var(--surface-2); }
.notice-error { border-left-color: var(--danger); }
.notice-success { border-left-color: var(--success); }
.notice-warning { border-left-color: var(--warning); }

.active-queue { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.2rem; border: 1px solid var(--accent); border-radius: var(--radius); background: rgb(39 116 130 / .12); }
.active-queue div { flex: 1; }
.active-queue span, .active-queue strong { display: block; }
.active-queue span { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; }
.queue-time { flex: 0 0 auto !important; font-variant-numeric: tabular-nums; }
.queue-time time { display: block; white-space: nowrap; }
.activity-list .queue-time { text-align: right; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.tech-card { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tech-card > form { grid-column: 2; justify-self: start; }
.card-number { display: grid; place-items: center; align-self: start; width: 58px; height: 58px; border: 1px solid #4e9eac; border-radius: 50%; color: var(--accent); font-family: ui-monospace, monospace; background: radial-gradient(circle, rgb(83 204 216 / .17), transparent 70%); }
.card-number.science { border-style: dashed; color: var(--accent-2); }
.card-number.defense { border-radius: 8px; color: var(--warning); }
.card-copy h2, .card-copy h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.card-copy h2 span, .card-copy h3 span { display: block; margin-top: .15rem; color: var(--accent); font-size: .75rem; font-weight: 600; }
.card-copy > p { margin: .2rem 0 .7rem; color: var(--muted); font-size: .85rem; }
.card-copy .requirement { color: var(--warning); }
.cost-list { display: flex; flex-wrap: wrap; gap: .9rem; margin: .7rem 0; }
.cost-list div { min-width: 68px; }
.cost-list dt { color: var(--muted); font-size: .65rem; text-transform: uppercase; }
.cost-list dd { margin: 0; font-size: .86rem; font-variant-numeric: tabular-nums; }
.compact-list { margin: .45rem 0 .8rem; padding-left: 1.25rem; color: var(--muted); font-size: .86rem; }
.compact-list li + li { margin-top: .25rem; }
.project-state { grid-column: 2; align-self: end; justify-self: start; margin: 0; padding: .5rem .75rem; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); background: rgb(39 116 130 / .12); }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; }
.inline-form label { width: 105px; }
.section-title { margin: 2rem 0 1rem; }

label { color: var(--text); font-weight: 650; }
label small { display: block; color: var(--muted); font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: 44px; margin-top: .3rem; padding: .55rem .65rem;
  border: 1px solid var(--line-strong); border-radius: 5px; background: #07141b; color: var(--text);
}
textarea { min-height: 6rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; margin: 0; accent-color: var(--accent); }
input[type="range"] { min-height: 32px; padding-inline: 0; accent-color: var(--accent); }
output { color: var(--accent-2); font-variant-numeric: tabular-nums; font-weight: 850; }
fieldset { margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 .5rem; color: var(--accent); font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.coords { grid-template-columns: .6fr 1fr .7fr 1.2fr; }
.mission-form { display: grid; gap: 1rem; }
.mission-panel { margin-top: 1rem; }
.system-jump { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.system-jump label { max-width: 190px; }
.system-jump .pager { display: flex; gap: .5rem; margin-left: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
caption { padding: 1rem; color: var(--muted); text-align: left; }
th, td { padding: .75rem; border-bottom: 1px solid var(--line); text-align: left; }
thead th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.is-player { box-shadow: inset 4px 0 var(--accent); background: rgb(76 190 201 / .08); }
.faction-dot { display: inline-block; width: .65rem; height: .65rem; margin-right: .45rem; border-radius: 50%; background: var(--faction-color); }
.muted { color: var(--muted); }

.message-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.message-list article { padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.message-list header { display: grid; grid-template-columns: 8rem 1fr auto; align-items: baseline; gap: .8rem; }
.message-list h2, .message-list h3 { margin: 0; font-size: 1.05rem; }
.message-list time { color: var(--muted); font-size: .72rem; }
.message-list p { margin-bottom: 0; white-space: pre-line; }
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.stacked-actions, .stacked-form { display: flex; align-items: flex-start; flex-direction: column; gap: .75rem; }
.stacked-form label { width: min(100%, 420px); }
.settings-list { margin: 0 0 1rem; }
.settings-list div { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.settings-list dd { margin: 0; }
.danger-zone { border-color: #6e4148; }
.portable-path { overflow-wrap: anywhere; }
.portable-path code { color: var(--accent-2); }
.sound-catalog-details { margin-top: 1.2rem; }
.sound-preview-status { min-height: 1.5rem; color: var(--accent-2); }
.sound-catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-top: 1rem; }
.sound-card { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.sound-card h3 { margin: .2rem 0 .45rem; }
.sound-card p { margin: .35rem 0; }
.sound-card .button { margin-top: auto; }

.farm-grid, .diplomacy-grid, .event-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.farm-card, .diplomacy-card, .event-card { padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.farm-card > header, .diplomacy-card > header { display: flex; align-items: center; gap: .8rem; }
.farm-card h2, .farm-card h3, .diplomacy-card h2, .diplomacy-card h3 { margin: 0; font-size: 1.15rem; }
.farm-card h2 span, .farm-card h3 span { display: block; color: var(--accent); font-size: .72rem; }
.farm-card > p, .diplomacy-card header p { margin: .2rem 0 1rem; color: var(--muted); }
.crop-symbol { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border: 1px solid var(--accent-2); border-radius: 50% 15% 50% 15%; color: var(--accent-2); font-family: ui-monospace, monospace; transform: rotate(-8deg); }
.farm-stats { display: grid; grid-template-columns: repeat(2, 1fr); margin: 1rem 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.farm-stats div { padding: .7rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.farm-stats div:nth-child(2n) { border-right: 0; }
.farm-stats div:nth-last-child(-n+2) { border-bottom: 0; }
.farm-stats dt { color: var(--muted); font-size: .68rem; text-transform: uppercase; }
.farm-stats dd { margin: .15rem 0 0; font-weight: 800; }
details { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
summary { color: var(--accent); cursor: pointer; font-weight: 750; }
.detail-form { margin-top: 1rem; align-items: center; }
.detail-form .check-label { display: flex; align-items: flex-start; gap: .6rem; width: min(100%, 340px); }
.detail-form .check-label small { display: block; }
.create-farm { display: grid; grid-template-columns: .7fr 1.3fr; gap: 1.5rem; margin-top: 1rem; }
.create-farm .form-grid { grid-template-columns: repeat(2, 1fr); }
.create-farm .button { align-self: end; }
.policy-list { display: grid; gap: .6rem; }
.policy-list label { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: .7rem; padding: .75rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.policy-list label:has(input:checked) { border-color: var(--accent); background: rgb(68 184 194 / .1); }
.policy-list strong, .policy-list small { display: block; }
.relation-status { margin-left: auto; padding: .3rem .55rem; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: .7rem; }
.status-war { border-color: var(--danger); color: var(--danger); }
.status-trade, .status-non_aggression { border-color: var(--accent-2); color: var(--accent-2); }
.faction-dot.large { width: 1rem; height: 1rem; }
.choice-list { display: grid; gap: .65rem; }
.choice-button { width: 100%; padding: .9rem; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-2); color: var(--text); text-align: left; }
.choice-button:hover { border-color: var(--accent); background: var(--surface-3); }
.choice-button strong, .choice-button span { display: block; }
.choice-button span { margin-top: .2rem; color: var(--muted); font-size: .8rem; }
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.achievement { display: flex; gap: .75rem; padding: 1rem; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); background: rgb(11 26 34 / .5); }
.achievement.unlocked { border-style: solid; border-color: #4f9e87; color: var(--text); background: rgb(65 144 118 / .09); }
.achievement > span { color: var(--accent-2); font-size: 1.5rem; }
.achievement h3, .achievement p { margin: 0 0 .25rem; }
.achievement p, .achievement small { color: var(--muted); font-size: .78rem; }
.event-history { margin-top: 1rem; }
.artifact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.artifact-card { position: relative; padding: 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, var(--surface), rgb(20 42 51 / .75)); overflow: hidden; }
.artifact-card::after { content: ""; position: absolute; width: 90px; height: 90px; right: -45px; top: -45px; border: 1px solid var(--artifact-color, var(--accent)); border-radius: 50%; box-shadow: 0 0 28px var(--artifact-color, var(--accent)); opacity: .35; }
.artifact-card h3 { margin: .35rem 0; }
.artifact-card p { color: var(--muted); font-size: .84rem; }
.artifact-card > strong { color: var(--artifact-color, var(--accent)); font-size: .82rem; }
.artifact-rarity { color: var(--artifact-color, var(--accent)); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.rarity-common { --artifact-color: #9db2bb; }
.rarity-rare { --artifact-color: #73dcff; }
.rarity-legendary { --artifact-color: #ffd36e; }
.governor-log { margin-top: 1rem; padding: .85rem; border-left: 4px solid var(--accent-2); background: var(--surface-2); }
.governor-log p { margin: .25rem 0 0; color: var(--muted); }
.check-label { display: flex; align-items: flex-start; gap: .65rem; }
.check-row {
  display: flex; min-height: 44px; align-items: center; gap: .65rem; padding-block: .35rem;
}
.check-row input[type="checkbox"], .check-row input[type="radio"],
.check-label input[type="checkbox"], .check-label input[type="radio"] {
  width: 1.25rem; height: 1.25rem; flex: 0 0 auto;
}
progress { width: 100%; min-height: 1.25rem; accent-color: var(--accent-2); }
.anomaly-note { display: block; color: var(--accent-2); font-size: .72rem; }
.galaxy-secondary { display: block; margin-top: .2rem; color: var(--muted); font-size: .75rem; }



.page-section-index { margin: -1rem 0 1.5rem; padding: 1rem 1.25rem; box-shadow: none; }
.page-section-index h2 { margin-bottom: .2rem; font-size: 1.1rem; }
.page-section-index p { margin: 0 0 .6rem; color: var(--muted); font-size: .84rem; }
.page-section-index ul { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: 0; padding-left: 1.25rem; }
.page-section-index a { display: inline-block; padding: .2rem 0; }
[tabindex="-1"]:focus { outline: 3px solid #fff36b; outline-offset: 5px; }

dialog {
  width: min(720px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 1.4rem;
  border: 2px solid var(--accent); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 24px 80px #000;
}
dialog::backdrop { background: rgb(0 0 0 / .78); }
dialog h2 { margin-top: 0; }
.shortcut-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.shortcut-list { margin: 0; }
.shortcut-list > div { display: grid; grid-template-columns: 9rem 1fr; gap: .7rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.shortcut-list dt { color: var(--accent); font-family: ui-monospace, monospace; font-weight: 900; }
.shortcut-list dd { margin: 0; }

.setup-page { min-height: 100vh; }
.setup-header { max-width: 1100px; margin: 0 auto; padding: 5rem 2rem 2.5rem; }
.setup-header h1 { margin: .2rem 0; font-size: clamp(3rem, 8vw, 6.4rem); line-height: .9; letter-spacing: -.075em; }
.setup-header h1 span { color: var(--accent); font-weight: 350; }
.setup-header > p:last-child { max-width: 620px; color: var(--muted); font-size: 1.08rem; }
.setup-main { width: min(1100px, calc(100% - 2rem)); margin: 0 auto 3rem; }
.about-page { padding-top: clamp(2rem, 7vw, 5rem); }
.about-back { margin-bottom: 1.5rem; }
.saved-games { display: grid; grid-template-columns: .65fr 1.35fr; gap: 2rem; margin-bottom: 1rem; padding: 1.3rem; border: 1px solid var(--accent); border-radius: var(--radius); background: rgb(42 122 135 / .1); }
.saved-games h2 { margin: .2rem 0; }
.saved-games p { margin-bottom: 0; color: var(--muted); }
.save-list { display: grid; gap: .55rem; }
.save-list article { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.save-list strong, .save-list span { display: block; }
.save-list span { color: var(--muted); font-size: .78rem; }
.setup-card { display: grid; grid-template-columns: .65fr 1.35fr; gap: 2rem; padding: clamp(1.3rem, 4vw, 2.5rem); border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(140deg, var(--surface), #102731); box-shadow: var(--shadow); }
.setup-card h2 { margin: .25rem 0 .6rem; font-size: 2rem; }
.setup-card > div > p:last-child { color: var(--muted); }
.step-label { color: var(--accent-2); font-size: .7rem; letter-spacing: .16em; }
.setup-form { display: grid; gap: 1rem; }
.setup-form .form-grid { grid-template-columns: repeat(2, 1fr); }
.setup-form fieldset:first-child label:last-child { grid-column: 1 / -1; }
.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.feature-strip article { padding: 1.2rem; border-right: 1px solid var(--line); }
.feature-strip article:last-child { border: 0; }
.feature-strip strong, .feature-strip span { display: block; }
.feature-strip strong { color: var(--accent); }
.feature-strip span { color: var(--muted); font-size: .83rem; }
footer { padding: 1rem 2rem 3rem; color: var(--muted); text-align: center; font-size: .75rem; }

@media (max-width: 1100px) {
  .topbar { position: static; grid-template-columns: 1fr; }
  .resource-bar { border: 1px solid var(--line); border-inline: 0; }
  .resource-bar dl { grid-template-columns: repeat(7, minmax(95px, 1fr)); }
  .access-tools { justify-content: flex-end; }
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .card-grid { grid-template-columns: 1fr; }
  .metric-grid-six { grid-template-columns: repeat(3, 1fr); }
  .metric-grid-six article:nth-child(3n) { border-right: 0; }
  .metric-grid-eight { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .resource-bar dl { grid-template-columns: repeat(2, 1fr); }
  .resource-bar dl > div { border-bottom: 1px solid var(--line); }
  .resource-bar dl > div:nth-child(2n) { border-right: 0; }
  .resource-bar dl > div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .app-shell { display: block; }
  .sidebar { border: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav ul { grid-template-columns: repeat(2, 1fr); }
  .commander-card { display: none; }
  .main-content { padding: 1rem; }
  .world-orbit { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .dashboard-grid, .settings-grid, .farm-grid, .diplomacy-grid, .event-grid, .create-farm, .sound-catalog-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-grid > * { min-width: 0; }
  .settings-grid .button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .panel-wide { grid-column: auto; }
  .form-grid, .coords { grid-template-columns: 1fr; }
  .tech-card { grid-template-columns: 48px minmax(0, 1fr); padding: 1rem; }
  .card-number { width: 44px; height: 44px; }
  .active-queue { align-items: flex-start; flex-direction: column; }
  .message-list header { grid-template-columns: 1fr; gap: .25rem; }
  .setup-header { padding-top: 3rem; }
  .setup-card, .saved-games { grid-template-columns: 1fr; }
  .setup-form .form-grid { grid-template-columns: 1fr; }
  .setup-form fieldset:first-child label:last-child { grid-column: auto; }
  .achievement-grid { grid-template-columns: 1fr; }
  .artifact-grid { grid-template-columns: 1fr; }
  .wiki-filter-grid, .wiki-entry-grid, .wiki-toc ul { grid-template-columns: 1fr; }
  .wiki-category-heading { display: block; }
  .wiki-category-heading .badge { display: inline-block; margin: .5rem 0 0; }
  .wiki-specs { grid-template-columns: 1fr; }
  .section-heading-with-tools, .advice-list li { display: block; }
  .section-heading-with-tools label { min-width: 0; margin-top: .7rem; }
  .advice-list a { display: inline-block; margin-top: .5rem; }
  .report-filter-form { grid-template-columns: 1fr; }
  .feature-strip { grid-template-columns: 1fr; }
  .feature-strip article { border-right: 0; border-bottom: 1px solid var(--line); }
  .shortcut-columns { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .sidebar nav ul, .metric-grid, .resource-bar dl { grid-template-columns: 1fr; }
  .settings-list div { display: grid; grid-template-columns: minmax(0, 1fr); gap: .2rem; }
  .settings-list dd { overflow-wrap: anywhere; }
  .sidebar nav a { min-height: 44px; }
  .resource-bar dl > div, .metric-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .resource-bar dl > div:last-child { grid-column: auto; }
  .access-tools { justify-content: flex-start; }
  .icon-button { min-height: 44px; }
}

@media (forced-colors: active) {
  * { box-shadow: none !important; }
  :focus-visible, [tabindex="-1"]:focus { outline: 3px solid Highlight !important; }
  .panel, .tech-card, .metric-grid, .sidebar nav a, input, select, textarea, .button { border: 1px solid CanvasText; }
  .sidebar nav a[aria-current="page"], .button-primary { border: 3px solid Highlight; }
  .tab-interface, .tab-button, .sidebar [data-navigation-group] { border: 1px solid CanvasText; }
  .tab-button[aria-selected="true"] { border-bottom: 4px solid Highlight; }
  .faction-dot { forced-color-adjust: none; }
}

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

@media print {
  .sidebar, .topbar .access-tools, .button, .skip-link { display: none !important; }
  .app-shell { display: block; }
  body { background: #fff; color: #000; }
  .panel, .tech-card, table { background: #fff; color: #000; box-shadow: none; }
}
