:root {
    --ink: #241c1b;
    --muted: #726563;
    --paper: #f7f1e5;
    --paper-deep: #ecdfc8;
    --surface: rgba(255, 252, 244, 0.92);
    --surface-solid: #fffaf0;
    --line: rgba(103, 63, 45, 0.18);
    --accent: #8d1f2d;
    --accent-strong: #63131f;
    --accent-soft: #ead0ca;
    --gold: #b88a38;
    --good: #28755a;
    --bad: #a03d38;
    --shadow: 0 18px 50px rgba(74, 40, 27, 0.12);
    --radius: 18px;
    --display-font: "STKaiti", "KaiTi", "FangSong", "Noto Serif SC", serif;
    --body-font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

body[data-theme="industrial"] {
    --ink: #252526;
    --muted: #6d6863;
    --paper: #ede9e1;
    --paper-deep: #d8d0c2;
    --surface: rgba(248, 246, 240, 0.94);
    --surface-solid: #f8f6f0;
    --line: rgba(58, 55, 52, 0.2);
    --accent: #985c35;
    --accent-strong: #683b22;
    --accent-soft: #ddc5b2;
    --gold: #ad773e;
    --shadow: 0 18px 50px rgba(45, 42, 39, 0.14);
}

body[data-theme="space"] {
    --ink: #e8eef7;
    --muted: #aab9cb;
    --paper: #071225;
    --paper-deep: #0b1e38;
    --surface: rgba(12, 29, 52, 0.88);
    --surface-solid: #0e2441;
    --line: rgba(157, 187, 223, 0.2);
    --accent: #c69843;
    --accent-strong: #e0b65b;
    --accent-soft: rgba(198, 152, 67, 0.18);
    --gold: #d2aa59;
    --good: #5ec49e;
    --bad: #f18a85;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

body[data-theme="coronation"] {
    --ink: #fff7df;
    --muted: #d9c9a4;
    --paper: #100817;
    --paper-deep: #25102a;
    --surface: rgba(38, 17, 43, 0.88);
    --surface-solid: #29122e;
    --line: rgba(239, 200, 114, 0.22);
    --accent: #d8ad52;
    --accent-strong: #f0cd76;
    --accent-soft: rgba(216, 173, 82, 0.16);
    --gold: #eccb78;
    --good: #79d4ab;
    --bad: #ef8b8b;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
    min-height: 100%;
    overflow-x: hidden;
    background: var(--paper);
}

body {
    min-width: 0;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 40%),
        radial-gradient(circle at 90% 5%, color-mix(in srgb, var(--gold) 15%, transparent), transparent 35%),
        linear-gradient(145deg, var(--paper), var(--paper-deep));
    font-family: var(--body-font);
    line-height: 1.6;
    transition: color .4s ease, background .4s ease;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    opacity: .26;
    pointer-events: none;
    background-image:
        linear-gradient(30deg, transparent 48%, var(--line) 49%, var(--line) 51%, transparent 52%),
        linear-gradient(-30deg, transparent 48%, var(--line) 49%, var(--line) 51%, transparent 52%);
    background-size: 90px 156px;
    mask-image: linear-gradient(to bottom, black, transparent 70%);
}

body[data-theme="space"]::before,
body[data-theme="coronation"]::before {
    opacity: .45;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, .8) 0 1px, transparent 1.5px),
        radial-gradient(circle, rgba(219, 183, 103, .75) 0 1px, transparent 1.5px);
    background-position: 0 0, 42px 31px;
    background-size: 89px 89px, 131px 131px;
    animation: starDrift 45s linear infinite;
}

button,
textarea,
input,
select {
    font: inherit;
}

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

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 2px;
}

a {
    color: var(--accent);
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

h1,
h2,
h3,
h4 {
    font-family: var(--display-font);
    line-height: 1.25;
}

[hidden] {
    display: none !important;
}

.app-loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    color: #f8e8c0;
    background:
        linear-gradient(90deg, rgba(23, 8, 13, .62), rgba(23, 8, 13, .18) 48%, rgba(5, 9, 20, .56)),
        url("../assets/palace-to-galaxy.png") center / cover no-repeat;
    transition: opacity .35s ease;
}

.app-loading.is-hidden {
    display: none;
}

.loading-inner {
    width: min(460px, calc(100% - 48px));
    padding: 34px 30px 30px;
    border: 1px solid rgba(235, 203, 128, .36);
    border-radius: 24px;
    text-align: center;
    background: rgba(34, 12, 22, .55);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .3);
    backdrop-filter: blur(14px);
}

.loading-seal,
.brand-seal {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(232, 196, 112, .6);
    border-radius: 50%;
    color: #f1ce7d;
    background:
        radial-gradient(circle, rgba(218, 167, 73, .15), transparent 60%),
        #651927;
    box-shadow: inset 0 0 0 5px rgba(99, 19, 31, .8), inset 0 0 0 7px rgba(232, 196, 112, .45), 0 12px 35px rgba(0, 0, 0, .25);
    font-family: var(--display-font);
}

.loading-seal {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    font-size: 48px;
}

.loading-title {
    margin-bottom: 8px;
    font-family: var(--display-font);
    font-size: clamp(32px, 8vw, 52px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .16em;
}

.loading-inner p {
    color: rgba(248, 232, 192, .75);
}

.loading-bar {
    height: 2px;
    margin-top: 28px;
    overflow: hidden;
    background: rgba(255, 255, 255, .12);
}

.loading-bar span {
    display: block;
    width: 35%;
    height: 100%;
    background: #e4b95d;
    animation: loadingSweep 1.4s ease-in-out infinite;
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 84%, transparent);
    box-shadow: 0 10px 34px color-mix(in srgb, var(--paper) 70%, transparent);
    backdrop-filter: blur(18px) saturate(120%);
}

.header-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1500px, calc(100% - 40px));
    min-height: 82px;
    margin: 0 auto;
    gap: 28px;
}

.brand-block {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 14px;
}

.brand-seal {
    width: 52px;
    height: 52px;
    font-size: 24px;
}

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

.brand-copy h1 {
    margin: 0;
    overflow: hidden;
    font-size: 24px;
    letter-spacing: .12em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-copy p {
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    gap: 8px;
}

.status-chip {
    display: flex;
    flex-direction: column;
    min-width: 112px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.status-chip small {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .1em;
}

.status-chip strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-navigation {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.main-navigation::-webkit-scrollbar {
    display: none;
}

.main-navigation ul {
    display: flex;
    align-items: stretch;
    width: min(1500px, calc(100% - 40px));
    min-width: max-content;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.main-navigation button {
    position: relative;
    min-width: 86px;
    padding: 13px 18px 15px;
    border: 0;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    transition: color .2s ease;
}

.main-navigation button::after {
    position: absolute;
    right: 18px;
    bottom: 0;
    left: 18px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    content: "";
    background: var(--accent);
    transform: scaleX(0);
    transition: transform .2s ease;
}

.main-navigation button:hover,
.main-navigation button.is-active {
    color: var(--ink);
}

.main-navigation button.is-active::after {
    transform: scaleX(1);
}

.context-strip {
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 60%, transparent);
}

.context-strip-inner {
    display: flex;
    align-items: center;
    width: min(1500px, calc(100% - 40px));
    min-height: 36px;
    margin: 0 auto;
    overflow-x: auto;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    gap: 0;
    scrollbar-width: none;
}

.context-strip-inner::-webkit-scrollbar {
    display: none;
}

.context-strip-inner span + span::before {
    margin: 0 11px;
    color: var(--gold);
    content: "◆";
    font-size: 7px;
}

.main-content {
    width: min(1500px, calc(100% - 40px));
    min-height: 70vh;
    margin: 0 auto;
    padding: 42px 0 80px;
}

[data-tab-panel] {
    animation: panelIn .28s ease both;
}

.section-heading,
.subsection-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 24px;
}

.section-heading {
    align-items: center;
    margin-bottom: 15px;
    gap: 14px;
}

.section-heading .section-intro {
    max-width: none;
    margin: 0;
    color: var(--ink);
    font-family: var(--display-font);
    font-size: clamp(17px, 1.55vw, 22px);
    font-weight: 700;
    line-height: 1.4;
}

.subsection-heading p {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
}

.subsection-heading h3 {
    margin: 4px 0 6px;
    font-size: 28px;
}

.eyebrow,
.card-kicker {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
}

.stat-pill,
.count-badge,
.completion-mark {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent);
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.resource-group {
    margin-bottom: 30px;
}

.resource-group h3,
.technology-era-heading h3 {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 16px;
    letter-spacing: .08em;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    gap: 12px;
}

.resource-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: 0 7px 22px color-mix(in srgb, var(--paper) 50%, transparent);
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.resource-card:hover,
.resource-card.is-selected {
    border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.resource-card-main {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    padding: 15px;
    border: 0;
    color: inherit;
    text-align: left;
    background: transparent;
    cursor: pointer;
    gap: 11px;
}

.resource-glyph {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent);
    border-radius: 50%;
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 11%, transparent);
    font-family: var(--display-font);
    font-size: 16px;
}

.resource-copy,
.resource-figures {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.resource-copy strong,
.resource-figures strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-copy small,
.resource-figures small {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-figures {
    align-items: flex-end;
}

.resource-figures small {
    color: var(--good);
}

.negative {
    color: var(--bad) !important;
}

.resource-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    padding: 0 12px 12px;
    gap: 7px;
}

.resource-workbench {
    display: grid;
    grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
}

.resource-sidebar,
.resource-detail {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.resource-sidebar {
    position: sticky;
    top: 148px;
}

.resource-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    gap: 12px;
}

.resource-sidebar-header h3 {
    margin: 2px 0 0;
    font-size: 19px;
}

.resource-sidebar-header > span {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    min-height: 30px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

.resource-sidebar-scroll {
    max-height: calc(100vh - 285px);
    min-height: 104px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: color-mix(in srgb, var(--accent) 32%, transparent) transparent;
    scrollbar-width: thin;
}

.resource-nav-group + .resource-nav-group {
    border-top: 1px solid var(--line);
}

.resource-nav-group > h4 {
    margin: 0;
    padding: 9px 15px 7px;
    color: var(--muted);
    background: color-mix(in srgb, var(--paper-deep) 35%, transparent);
    font-family: var(--body-font);
    font-size: 10px;
    letter-spacing: .14em;
}

.resource-nav-item {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px;
    min-width: 0;
    border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    background: transparent;
    transition: background .18s ease, box-shadow .18s ease;
}

.resource-nav-group > h4 + .resource-nav-item {
    border-top: 0;
}

.resource-nav-item:hover {
    background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.resource-nav-item.is-selected {
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    box-shadow: inset 4px 0 0 var(--accent);
}

.resource-nav-main {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) minmax(58px, auto);
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 62px;
    padding: 9px 8px 9px 13px;
    border: 0;
    color: inherit;
    text-align: left;
    background: transparent;
    cursor: pointer;
    gap: 9px;
}

.resource-nav-copy {
    display: flex;
    min-width: 0;
    align-items: baseline;
    overflow: hidden;
    gap: 6px;
}

.resource-nav-copy strong,
.resource-nav-copy small,
.resource-nav-amount {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-nav-copy strong {
    min-width: 0;
    flex: 0 1 auto;
    font-size: 13px;
}

.resource-nav-copy small {
    flex: 0 0 auto;
    color: var(--good);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.resource-nav-amount {
    display: flex;
    max-width: 86px;
    min-width: 0;
    flex-direction: column;
    align-items: flex-end;
    color: var(--ink);
    text-align: right;
}

.resource-nav-amount strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
}

.resource-nav-amount small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
}

.resource-quick-gather {
    align-self: stretch;
    min-width: 44px;
    min-height: 44px;
    margin: 8px 7px 8px 0;
    padding: 0 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 9px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 7%, var(--surface-solid));
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.resource-quick-gather:hover {
    color: #fff9ea;
    background: var(--accent);
}

.resource-sidebar-hint {
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
    font-size: 10px;
}

.resource-detail {
    padding: clamp(16px, 1.7vw, 24px);
}

.resource-detail-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    gap: 18px;
}

.resource-detail-identity {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 15px;
}

.resource-detail-identity .resource-glyph {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    font-size: 21px;
}

.resource-detail-identity h3 {
    flex: 0 0 auto;
    margin: 0;
    font-size: clamp(25px, 2.5vw, 34px);
}

.resource-detail-identity p {
    max-width: 700px;
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.resource-detail-copy {
    min-width: 0;
    flex: 1;
}

.resource-name-row,
.resource-title-stats,
.resource-title-stats > span {
    display: flex;
    align-items: baseline;
}

.resource-name-row {
    min-width: 0;
    flex-wrap: wrap;
    gap: 5px 18px;
}

.resource-title-stats {
    min-width: 0;
    flex-wrap: wrap;
    color: var(--muted);
    gap: 6px 14px;
}

.resource-title-stats > span {
    gap: 5px;
    white-space: nowrap;
}

.resource-title-stats > span + span {
    padding-left: 14px;
    border-left: 1px solid var(--line);
}

.resource-title-stats small {
    font-size: 10px;
}

.resource-title-stats strong {
    color: var(--ink);
    font-size: 13px;
}

.resource-detail-balance {
    display: flex;
    min-width: 150px;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.resource-detail-balance small,
.resource-detail-balance span {
    color: var(--muted);
    font-size: 11px;
}

.resource-detail-balance strong {
    max-width: 240px;
    overflow: hidden;
    color: var(--accent);
    font-family: var(--display-font);
    font-size: clamp(26px, 3.4vw, 40px);
    line-height: 1.15;
    text-overflow: ellipsis;
}

.resource-control-row {
    display: flex;
    align-items: center;
    min-width: 0;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 7%, transparent);
    gap: 12px;
}

.manual-gather-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.manual-gather-button {
    min-width: 128px;
    min-height: 40px;
    font-size: 14px;
}

.storage-upgrade-panel {
    display: grid;
    grid-template-columns: auto minmax(74px, 1fr) auto;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    padding-left: 12px;
    border-left: 1px solid var(--line);
    gap: 11px;
}

.storage-inline-copy {
    display: flex;
    min-width: 0;
    align-items: center;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
    gap: 7px;
}

.storage-inline-copy > strong,
.storage-inline-copy > span:last-of-type {
    color: var(--ink);
}

.storage-inline-copy > span:last-of-type {
    color: var(--accent);
}

.storage-inline-copy b {
    font-weight: 700;
}

.storage-progress {
    height: 7px;
    margin: 0;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--line) 62%, transparent);
}

.storage-progress > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-deep), var(--accent));
    transition: width .2s ease;
}

.storage-upgrade-panel .button {
    min-width: 166px;
    flex: 0 0 auto;
}

.resource-facilities {
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.resource-facilities-heading {
    align-items: center;
    margin-bottom: 11px;
}

.resource-facilities-heading h3 {
    margin: 0;
    font-size: 21px;
}

.resource-facility-grid {
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.resource-facility-grid .facility-card {
    padding: 14px;
}

.resource-facility-grid .facility-card h4 {
    margin: 2px 0 5px;
    font-size: 19px;
}

.resource-facility-grid .facility-card > p {
    min-height: 0;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
}

.resource-facility-grid .production-line {
    min-height: 0;
    margin-bottom: 8px;
    padding: 7px 9px;
    line-height: 1.45;
}

.resource-facility-grid .cost-list {
    margin: 8px 0;
}

.button {
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform .15s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .4;
}

.button-primary {
    color: #fff9ea;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

.button-quiet {
    border-color: var(--line);
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-solid) 75%, transparent);
}

.button-danger {
    border-color: color-mix(in srgb, var(--bad) 40%, transparent);
    color: var(--bad);
    background: color-mix(in srgb, var(--bad) 9%, transparent);
}

.button-coronation {
    min-width: 170px;
    color: #25140e;
    background: linear-gradient(135deg, #f0d589, #be8a32);
    box-shadow: 0 12px 32px rgba(190, 138, 50, .28);
}

.button-block {
    width: 100%;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    margin-top: 12px;
    gap: 9px;
}

.facilities-section,
.mega-project,
.archive-section,
.technology-era {
    margin-top: 46px;
}

.technology-era-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 14px;
}

.technology-era-heading h3 {
    margin: 0;
}

.technology-era-heading > span {
    color: var(--muted);
    font-size: 12px;
}

.technology-era-clear {
    margin: 0;
    padding: 17px 20px;
    border: 1px dashed color-mix(in srgb, var(--good) 42%, var(--line));
    border-radius: 12px;
    color: var(--good);
    background: color-mix(in srgb, var(--good) 6%, transparent);
    font-size: 13px;
}

.completed-techs {
    overflow: hidden;
    margin-top: 16px;
    border: 1px solid color-mix(in srgb, var(--good) 38%, var(--line));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--good) 5%, var(--surface));
}

.completed-techs-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 64px;
    padding: 13px 18px;
    border: 0;
    color: var(--ink);
    text-align: left;
    background: transparent;
    cursor: pointer;
    gap: 18px;
}

.completed-techs-toggle:hover {
    background: color-mix(in srgb, var(--good) 8%, transparent);
}

.completed-techs-toggle > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.completed-techs-toggle strong {
    color: var(--good);
    font-family: var(--display-font);
    font-size: 17px;
}

.completed-techs-toggle small {
    color: var(--muted);
    font-size: 11px;
}

.completed-techs-toggle i,
.region-toggle i {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .2s ease;
}

.completed-techs-toggle[aria-expanded="true"] i,
.region-toggle[aria-expanded="true"] i {
    transform: translateY(2px) rotate(225deg);
}

.completed-tech-list {
    padding: 16px;
    border-top: 1px solid color-mix(in srgb, var(--good) 28%, var(--line));
}

.completed-tech-list .data-card {
    box-shadow: none;
}

.research-production {
    margin: 4px 0 42px;
    padding: clamp(18px, 2.5vw, 28px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 88%, var(--accent-soft));
    box-shadow: var(--shadow);
}

.research-balance {
    display: flex;
    min-width: 130px;
    flex-direction: column;
    align-items: flex-end;
}

.research-balance small,
.research-balance span {
    color: var(--muted);
    font-size: 11px;
}

.research-balance strong {
    color: var(--accent);
    font-family: var(--display-font);
    font-size: 28px;
    line-height: 1.15;
}

.research-facility-grid {
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.facility-grid,
.card-grid,
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.facility-card,
.data-card,
.settings-card,
.achievement-card {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--paper) 55%, transparent);
}

.facility-card h4,
.data-card h4 {
    margin: 3px 0 8px;
    font-size: 21px;
}

.facility-card > p,
.data-card > p {
    min-height: 48px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}

.facility-heading,
.project-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.production-line {
    display: flex;
    min-height: 48px;
    flex-direction: column;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--good);
    background: color-mix(in srgb, var(--good) 8%, transparent);
    font-size: 12px;
}

.cost-list {
    display: flex;
    flex-wrap: wrap;
    margin: 13px 0;
    gap: 6px;
}

.cost-chip {
    display: inline-flex;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
    font-size: 11px;
}

.cost-chip.is-ready {
    border-color: color-mix(in srgb, var(--good) 35%, var(--line));
    color: var(--good);
}

.cost-chip.is-missing {
    border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
    color: var(--bad);
}

.segmented {
    display: inline-flex;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.segmented button {
    min-width: 52px;
    min-height: 34px;
    padding: 5px 10px;
    border: 0;
    border-right: 1px solid var(--line);
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.segmented button:last-child {
    border-right: 0;
}

.segmented button.is-active {
    color: #fff9ea;
    background: var(--accent);
}

.data-card.is-locked {
    opacity: .6;
}

.data-card.is-complete {
    border-color: color-mix(in srgb, var(--good) 45%, var(--line));
    background: color-mix(in srgb, var(--good) 8%, var(--surface));
}

.empty-state {
    grid-column: 1 / -1;
    padding: 34px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
    background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.empty-state.large {
    margin-top: 26px;
    padding: 70px 30px;
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-family: var(--display-font);
    font-size: 24px;
}

.empty-state p {
    margin-bottom: 0;
}

.era-divider {
    display: flex;
    align-items: center;
    margin: 42px 0 16px;
    color: var(--accent);
    font-family: var(--display-font);
    font-size: 20px;
    font-weight: 700;
    gap: 14px;
}

.era-divider i {
    height: 1px;
    flex: 1;
    background: linear-gradient(to right, var(--line), transparent);
}

.region-list {
    display: grid;
    gap: 18px;
}

.region-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.region-card.is-locked {
    filter: grayscale(.3);
    opacity: .58;
}

.region-card.is-current {
    border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
}

.region-card.is-complete {
    border-color: color-mix(in srgb, var(--good) 55%, var(--line));
}

.region-card.is-collapsed {
    box-shadow: 0 7px 22px color-mix(in srgb, var(--paper) 50%, transparent);
}

.region-card.is-collapsed > header {
    padding-bottom: 21px;
}

.region-card > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 21px 24px 14px;
    gap: 20px;
}

.region-card > header h3 {
    margin: 3px 0 0;
    font-size: 28px;
}

.region-title small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.region-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
}

.region-status {
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.region-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--good) 40%, var(--line));
    border-radius: 999px;
    color: var(--good);
    background: color-mix(in srgb, var(--good) 6%, var(--surface));
    cursor: pointer;
    gap: 8px;
}

.region-toggle:hover {
    background: color-mix(in srgb, var(--good) 12%, var(--surface));
}

.region-toggle span {
    font-size: 12px;
    white-space: nowrap;
}

.region-toggle i {
    width: 7px;
    height: 7px;
    border-width: 1px;
}

.region-intro {
    margin: 0;
    padding: 0 24px 17px;
    color: var(--muted);
}

.progress-track {
    height: 3px;
    background: var(--line);
}

.progress-track span {
    display: block;
    height: 100%;
    background: linear-gradient(to right, var(--accent), var(--gold));
    transition: width .3s ease;
}

.project-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.project-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    padding: 18px 24px;
    border-top: 1px solid var(--line);
    gap: 14px;
}

.project-row.is-complete {
    background: color-mix(in srgb, var(--good) 6%, transparent);
}

.project-index,
.stage-number {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--accent);
    background: var(--surface-solid);
    font-size: 12px;
    font-weight: 700;
}

.project-heading h4 {
    margin: 0 0 3px;
    font-size: 17px;
}

.project-heading span {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.project-copy > p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.project-copy .cost-list {
    margin-bottom: 0;
}

.reward-line {
    margin-top: 6px !important;
    color: var(--good) !important;
    font-size: 12px !important;
}

.project-action {
    min-width: 100px;
}

.engineering-overview {
    display: grid;
    grid-template-columns: minmax(220px, .7fr) minmax(280px, 1.3fr);
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    gap: 30px;
}

.stargate-orb {
    display: flex;
    align-items: center;
    color: var(--muted);
    gap: 16px;
}

.stargate-orb > span {
    position: relative;
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    border: 8px double var(--line);
    border-radius: 50%;
    box-shadow: inset 0 0 22px color-mix(in srgb, var(--accent) 25%, transparent);
}

.stargate-orb.is-active > span {
    border-color: var(--gold);
    box-shadow: inset 0 0 25px var(--accent-soft), 0 0 30px color-mix(in srgb, var(--gold) 30%, transparent);
    animation: gatePulse 2.4s ease-in-out infinite;
}

.stargate-orb strong {
    color: var(--ink);
    font-family: var(--display-font);
    font-size: 20px;
}

.requirement-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
    gap: 9px;
}

.requirement-list li {
    display: flex;
    align-items: center;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font-size: 12px;
    gap: 9px;
}

.requirement-list li.is-met {
    border-color: color-mix(in srgb, var(--good) 40%, var(--line));
    color: var(--good);
    background: color-mix(in srgb, var(--good) 7%, transparent);
}

.stage-list {
    display: grid;
    gap: 10px;
}

.mega-stage {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    gap: 15px;
}

.mega-stage.is-complete {
    border-color: color-mix(in srgb, var(--good) 45%, var(--line));
}

.mega-stage h4 {
    margin: 0 0 4px;
    font-size: 19px;
}

.mega-stage p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.mega-stage .cost-list {
    margin-bottom: 0;
}

.throne-project {
    position: relative;
}

.solar-track {
    display: flex;
    margin-bottom: 34px;
    padding: 18px 12px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    scrollbar-width: thin;
}

.solar-stop {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 112px;
    flex-direction: column;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.solar-stop::after {
    position: absolute;
    top: 9px;
    left: 50%;
    z-index: 0;
    width: 100%;
    height: 1px;
    content: "";
    background: var(--line);
}

.solar-stop:last-child::after {
    display: none;
}

.solar-stop span {
    z-index: 1;
    width: 19px;
    height: 19px;
    margin-bottom: 8px;
    border: 4px solid var(--surface-solid);
    border-radius: 50%;
    background: var(--line);
    box-shadow: 0 0 0 1px var(--line);
}

.solar-stop.is-open span {
    background: var(--accent);
}

.solar-stop.is-complete span {
    background: var(--good);
}

.faction-summary {
    display: grid;
    grid-template-columns: repeat(6, minmax(145px, 1fr));
    margin-bottom: 22px;
    gap: 9px;
}

.faction-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    text-align: left;
    background: var(--surface);
    cursor: pointer;
}

.faction-card > span {
    width: 32px;
    height: 3px;
    margin-bottom: 10px;
    border-radius: 3px;
    background: var(--faction);
}

.faction-card strong,
.faction-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.faction-card small {
    color: var(--muted);
    font-size: 10px;
}

.faction-card.is-selected {
    border-color: var(--faction);
    box-shadow: inset 0 0 0 1px var(--faction);
}

.star-toolbar,
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0;
    gap: 16px;
}

.star-toolbar p,
.pagination span {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

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

.star-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    padding: 17px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--faction);
    border-radius: 14px;
    background: var(--surface);
    gap: 14px;
}

.star-card.is-controlled {
    background: color-mix(in srgb, var(--good) 7%, var(--surface));
}

.star-visual {
    position: relative;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
}

.star-visual span {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--faction);
    box-shadow: 0 0 20px var(--faction);
}

.star-visual i {
    position: absolute;
    inset: 5px;
    border: 1px solid color-mix(in srgb, var(--faction) 55%, transparent);
    border-radius: 50%;
    transform: rotateX(62deg) rotateZ(-18deg);
}

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

.star-copy h4 {
    margin: 2px 0 4px;
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.star-copy p {
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.star-copy .cost-list {
    margin: 8px 0 0;
}

.timeline-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px;
    border: 1px solid color-mix(in srgb, var(--gold) 42%, var(--line));
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 82% 0, color-mix(in srgb, var(--gold) 18%, transparent), transparent 38%),
        var(--surface);
    box-shadow: var(--shadow);
    gap: 30px;
}

.timeline-hero h3 {
    margin: 3px 0 8px;
    font-size: 30px;
}

.timeline-hero p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
}

.archive-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.archive-list li {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    gap: 18px;
}

.archive-list span {
    color: var(--muted);
    font-size: 12px;
}

.archive-list p {
    margin: 0;
}

.achievement-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: center;
    opacity: .58;
    gap: 15px;
}

.achievement-card.is-complete {
    border-color: color-mix(in srgb, var(--gold) 50%, var(--line));
    opacity: 1;
}

.achievement-seal {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border: 3px double var(--line);
    border-radius: 50%;
    color: var(--muted);
    font-family: var(--display-font);
    font-size: 19px;
}

.achievement-card.is-complete .achievement-seal {
    border-color: var(--gold);
    color: var(--gold);
}

.achievement-card h3 {
    margin: 2px 0 4px;
    font-size: 21px;
}

.achievement-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

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

.settings-card h3 {
    margin-bottom: 14px;
    font-size: 23px;
}

.settings-card > p {
    color: var(--muted);
    font-size: 13px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    gap: 18px;
}

.toggle-row > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.toggle-row small {
    color: var(--muted);
}

.toggle-row input {
    position: absolute;
    opacity: 0;
}

.toggle-row i {
    position: relative;
    width: 44px;
    height: 24px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper-deep);
    transition: background .2s ease;
}

.toggle-row i::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    content: "";
    background: var(--muted);
    transition: transform .2s ease, background .2s ease;
}

.toggle-row input:checked + i {
    background: var(--accent-soft);
}

.toggle-row input:checked + i::after {
    background: var(--accent);
    transform: translateX(20px);
}

.settings-card > .button-block {
    margin-top: 18px;
}

textarea {
    width: 100%;
    min-width: 0;
    padding: 12px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    background: var(--paper);
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.link-list a {
    font-size: 13px;
    font-weight: 700;
}

.danger-card {
    border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
}

code {
    overflow-wrap: anywhere;
    color: var(--accent);
    background: var(--accent-soft);
}

.app-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: color-mix(in srgb, var(--paper) 72%, transparent);
}

.save-dock {
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 76%, transparent);
}

.save-dock-inner {
    display: grid;
    grid-template-columns: 190px minmax(220px, 1fr) auto;
    align-items: center;
    width: min(1500px, calc(100% - 40px));
    margin: 0 auto;
    padding: 15px 0;
    gap: 14px;
}

.save-dock-inner > div:first-child {
    display: flex;
    flex-direction: column;
}

.save-dock-inner small {
    color: var(--muted);
    font-size: 11px;
}

.save-dock-inner textarea {
    min-height: 48px;
    max-height: 110px;
}

.save-dock-inner .button-row {
    flex-wrap: nowrap;
    margin: 0;
}

.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1500px, calc(100% - 40px));
    min-height: 74px;
    margin: 0 auto;
    gap: 20px;
}

.app-footer p {
    margin: 0;
    font-size: 12px;
}

.app-footer a {
    font-size: 12px;
}

.toast-region {
    position: fixed;
    top: 150px;
    right: 18px;
    z-index: 200;
    display: grid;
    width: min(360px, calc(100% - 36px));
    pointer-events: none;
    gap: 8px;
}

.toast {
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 11px;
    color: var(--ink);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(25px);
    transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-left-color: var(--good);
}

.toast-warning {
    border-left-color: var(--bad);
}

.toast-achievement {
    border-color: var(--gold);
    border-left-color: var(--gold);
}

.story-is-open {
    overflow: hidden;
}

.story-modal {
    position: fixed;
    inset: 0;
    z-index: 510;
    display: grid;
    place-items: center;
    padding: 24px;
    background: color-mix(in srgb, var(--paper) 42%, rgba(4, 3, 8, .82));
    opacity: 0;
    backdrop-filter: blur(10px);
    transition: opacity .25s ease;
}

.story-modal[hidden] {
    display: none;
}

.story-modal.is-visible {
    opacity: 1;
}

.story-dialog {
    position: relative;
    width: min(620px, 100%);
    padding: clamp(30px, 5vw, 48px);
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--gold) 70%, var(--line));
    border-radius: 24px;
    color: var(--ink);
    text-align: center;
    background:
        radial-gradient(circle at 50% 0, color-mix(in srgb, var(--gold) 16%, transparent), transparent 44%),
        var(--surface-solid);
    box-shadow: 0 38px 100px rgba(0, 0, 0, .48), inset 0 0 70px color-mix(in srgb, var(--accent) 5%, transparent);
    transform: translateY(16px) scale(.98);
    transition: transform .25s ease;
}

.story-dialog::after {
    position: absolute;
    inset: 10px;
    border: 1px solid color-mix(in srgb, var(--gold) 34%, transparent);
    border-radius: 17px;
    pointer-events: none;
    content: '';
}

.story-modal.is-visible .story-dialog {
    transform: translateY(0) scale(1);
}

.story-seal {
    display: grid;
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    place-items: center;
    border: 3px double color-mix(in srgb, var(--accent) 80%, var(--gold));
    border-radius: 50%;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent-soft) 74%, transparent);
    font-family: var(--display-font);
    font-size: 28px;
    font-weight: 700;
}

.story-dialog .eyebrow {
    color: color-mix(in srgb, var(--accent) 72%, var(--muted));
    letter-spacing: .14em;
}

.story-dialog h2 {
    margin: 8px 0 14px;
    font-size: clamp(29px, 5vw, 42px);
}

.story-dialog p {
    max-width: 48em;
    margin: 0 auto 26px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.9;
}

.story-dialog .button {
    position: relative;
    z-index: 1;
    min-width: 150px;
}

.coronation-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(6, 3, 8, .78);
    opacity: 0;
    backdrop-filter: blur(12px);
    transition: opacity .25s ease;
}

.coronation-modal.is-visible {
    opacity: 1;
}

.coronation-dialog {
    position: relative;
    width: min(650px, 100%);
    padding: 52px 44px 40px;
    overflow: hidden;
    border: 1px solid #d7af59;
    border-radius: 26px;
    color: #fff1cc;
    text-align: center;
    background:
        radial-gradient(circle at 50% 0, rgba(230, 187, 91, .26), transparent 42%),
        linear-gradient(145deg, #39152d, #130a19);
    box-shadow: 0 40px 100px rgba(0, 0, 0, .55), inset 0 0 80px rgba(219, 168, 68, .08);
    transform: translateY(18px) scale(.97);
    transition: transform .25s ease;
}

.coronation-modal.is-visible .coronation-dialog {
    transform: translateY(0) scale(1);
}

.coronation-crown {
    display: grid;
    place-items: center;
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    border: 4px double #d7af59;
    border-radius: 50%;
    color: #efcf7e;
    font-family: var(--display-font);
    font-size: 38px;
}

.coronation-dialog h2 {
    margin-bottom: 10px;
    font-size: clamp(34px, 7vw, 54px);
}

.coronation-dialog p {
    color: #d9c69e;
}

.coronation-dialog strong {
    color: #f3d684;
}

@keyframes loadingSweep {
    from { transform: translateX(-110%); }
    to { transform: translateX(330%); }
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes gatePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes starDrift {
    from { background-position: 0 0, 42px 31px; }
    to { background-position: 89px 89px, -89px 162px; }
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
}

@media (max-width: 1120px) {
    .resource-workbench {
        grid-template-columns: minmax(250px, 290px) minmax(0, 1fr);
    }

    .resource-detail-hero {
        grid-template-columns: 1fr;
    }

    .resource-detail-balance {
        align-items: flex-start;
        text-align: left;
    }

    .header-status .status-chip:nth-child(n+3) {
        display: none;
    }

    .faction-summary {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }

    .star-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .header-primary,
    .main-navigation ul,
    .context-strip-inner,
    .main-content,
    .save-dock-inner,
    .app-footer-inner {
        width: min(100% - 24px, 1500px);
    }

    .header-primary {
        min-height: 68px;
        gap: 10px;
    }

    .brand-seal {
        width: 42px;
        height: 42px;
        font-size: 19px;
    }

    .brand-copy h1 {
        font-size: 20px;
    }

    .brand-copy p {
        max-width: 185px;
    }

    .header-status .status-chip {
        display: none;
    }

    .header-status .status-chip:first-child {
        display: flex;
        min-width: 88px;
    }

    .main-navigation button {
        min-width: 76px;
        padding-right: 13px;
        padding-left: 13px;
    }

    .main-content {
        padding-top: 28px;
    }

    .subsection-heading,
    .timeline-hero,
    .app-footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-heading {
        align-items: center;
        flex-flow: row wrap;
        gap: 8px 12px;
    }

    .save-dock-inner {
        grid-template-columns: 1fr;
    }

    .save-dock-inner .button-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .section-heading .section-intro {
        min-width: min(100%, 230px);
        flex: 1;
        font-size: 17px;
    }

    .resource-workbench {
        grid-template-columns: minmax(0, 1fr);
    }

    .resource-sidebar {
        position: static;
        width: 100%;
    }

    .resource-sidebar-scroll {
        max-height: 320px;
    }

    .resource-detail {
        width: 100%;
        padding: 20px;
    }

    .resource-control-row {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .manual-gather-actions {
        flex: 1 1 auto;
    }

    .manual-gather-actions .button {
        min-height: 40px;
    }

    .storage-upgrade-panel {
        min-width: min(100%, 390px);
        flex: 1 1 480px;
    }

    .resource-grid,
    .facility-grid,
    .card-grid,
    .achievement-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .completed-tech-list {
        padding: 12px;
    }

    .facility-card > p,
    .data-card > p {
        min-height: 0;
    }

    .project-row,
    .mega-stage,
    .star-card {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .project-action,
    .mega-stage > .button,
    .star-card > .button {
        grid-column: 2;
        width: 100%;
    }

    .engineering-overview {
        grid-template-columns: 1fr;
    }

    .requirement-list {
        grid-template-columns: 1fr;
    }

    .faction-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .timeline-hero .button {
        width: 100%;
    }

    .archive-list li {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .toast-region {
        top: 128px;
    }
}

@media (max-width: 440px) {
    .header-primary,
    .main-navigation ul,
    .context-strip-inner,
    .main-content,
    .save-dock-inner,
    .app-footer-inner {
        width: calc(100% - 20px);
    }

    .brand-copy p {
        max-width: 145px;
    }

    .header-status .status-chip:first-child {
        display: none;
    }

    .resource-sidebar-header {
        min-height: 62px;
    }

    .resource-nav-main {
        grid-template-columns: 34px minmax(0, 1fr) minmax(48px, auto);
        min-height: 58px;
        padding-left: 10px;
        gap: 7px;
    }

    .resource-glyph {
        width: 34px;
        height: 34px;
    }

    .resource-nav-amount {
        max-width: 68px;
        font-size: 12px;
    }

    .resource-nav-copy {
        gap: 5px;
    }

    .resource-nav-copy small {
        font-size: 13px;
    }

    .resource-detail {
        padding: 16px;
    }

    .resource-detail-identity {
        gap: 10px;
    }

    .resource-detail-identity .resource-glyph {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .resource-name-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .resource-title-stats {
        width: 100%;
        gap: 4px 10px;
    }

    .resource-title-stats > span + span {
        padding-left: 10px;
    }

    .resource-control-row {
        flex-direction: column;
    }

    .manual-gather-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        width: 100%;
    }

    .manual-gather-actions .button {
        width: 100%;
    }

    .storage-upgrade-panel {
        grid-template-columns: 1fr;
        width: 100%;
        min-width: 0;
        flex: 0 0 auto;
        padding: 11px 0 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .storage-inline-copy {
        justify-content: space-between;
        white-space: normal;
    }

    .storage-upgrade-panel .button {
        width: 100%;
        min-width: 0;
    }

    .resource-facilities .subsection-heading {
        gap: 14px;
    }

    .resource-facilities .segmented {
        width: 100%;
    }

    .resource-facilities .segmented button {
        min-width: 0;
        flex: 1;
    }

    .region-card > header,
    .region-intro,
    .project-row {
        padding-right: 16px;
        padding-left: 16px;
    }

    .region-card > header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .region-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .completed-techs-toggle {
        padding-right: 14px;
        padding-left: 14px;
    }

    .project-row,
    .mega-stage,
    .star-card {
        grid-template-columns: 1fr;
    }

    .project-index,
    .stage-number,
    .star-visual {
        display: none;
    }

    .project-action,
    .mega-stage > .button,
    .star-card > .button {
        grid-column: 1;
    }

    .faction-summary {
        grid-template-columns: 1fr 1fr;
    }

    .star-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .pagination {
        justify-content: center;
    }

    .pagination .button {
        min-width: 0;
        padding-right: 10px;
        padding-left: 10px;
    }

    .story-modal {
        padding: 12px;
    }

    .story-dialog {
        padding: 28px 21px 24px;
        border-radius: 20px;
    }

    .story-dialog::after {
        inset: 7px;
        border-radius: 14px;
    }

    .story-seal {
        width: 54px;
        height: 54px;
        margin-bottom: 14px;
        font-size: 24px;
    }

    .story-dialog p {
        margin-bottom: 21px;
        font-size: 14px;
        line-height: 1.75;
    }

    .story-dialog .button {
        width: 100%;
    }

    .coronation-dialog {
        padding: 38px 22px 28px;
    }
}
