* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --game-cursor: url("assets/cursor.png") 10 4, crosshair;
    --game-cursor-pointer: url("assets/cursor.png") 10 4, pointer;
    --game-cursor-default: url("assets/cursor.png") 10 4, default;
}
body { overflow: hidden; background: #000; cursor: var(--game-cursor); }
canvas { display: block; cursor: var(--game-cursor); touch-action: none; }
button:focus,
button:focus-visible {
    outline: 0;
}

/* --- Main Menu --- */
#main-menu {
    position: fixed;
    inset: 0;
    z-index: 240;
    overflow: hidden;
    color: #ece8e0;
    font-family: 'VT323', 'Courier New', monospace;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.96) 0%, rgba(4, 3, 6, 0.90) 42%, rgba(0, 0, 0, 0.56) 100%),
        #000;
    cursor: var(--game-cursor-default);
}

#main-menu::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 20;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.7s linear;
}

#main-menu.hidden {
    display: none;
}

#main-menu.loading {
    pointer-events: none;
}

#main-menu.loading::before {
    opacity: 1;
    transition: none;
}

.menu-starfield {
    position: absolute;
    inset: 0;
    opacity: 0.74;
    transition: opacity 0.7s linear;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.9) 0 1px, transparent 1px),
        radial-gradient(circle at 29% 73%, rgba(255, 255, 255, 0.65) 0 1px, transparent 1px),
        radial-gradient(circle at 47% 33%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1px),
        radial-gradient(circle at 69% 64%, rgba(255, 255, 255, 0.72) 0 1px, transparent 1px),
        radial-gradient(circle at 82% 22%, rgba(255, 255, 255, 0.75) 0 1px, transparent 1px);
    background-size: 181px 137px, 233px 191px, 307px 223px, 419px 281px, 509px 331px;
    image-rendering: pixelated;
    pointer-events: none;
}

.menu-copy {
    position: absolute;
    left: clamp(28px, 7vw, 118px);
    top: 50%;
    z-index: 3;
    width: min(380px, calc(100vw - 48px));
    transform: translateY(-50%);
    transition:
        transform 0.82s cubic-bezier(0.72, 0.02, 0.26, 1),
        opacity 0.45s linear;
}

.menu-title {
    margin-bottom: clamp(26px, 5vh, 54px);
    color: #f0ece4;
    font-size: clamp(44px, 7vw, 96px);
    line-height: 0.82;
    letter-spacing: 0;
    text-shadow:
        3px 0 0 rgba(215, 87, 111, 0.28),
        -3px 0 0 rgba(84, 151, 171, 0.22),
        0 0 24px rgba(255, 255, 255, 0.10);
}

.menu-actions {
    display: grid;
    gap: 10px;
}

.menu-option {
    display: block;
    width: max-content;
    max-width: 100%;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: #d8d2ca;
    font: inherit;
    font-size: clamp(34px, 5.2vw, 58px);
    line-height: 0.95;
    letter-spacing: 0;
    text-align: left;
    cursor: var(--game-cursor-pointer);
    text-shadow: 0 0 12px rgba(215, 87, 111, 0.18);
}

.menu-option:hover,
.menu-option:focus-visible {
    color: #ffffff;
    outline: 0;
    transform: translateX(10px);
    text-shadow: 0 0 18px rgba(255, 110, 135, 0.34);
}

.menu-settings-panel {
    display: none;
    width: min(330px, 100%);
    margin-top: 18px;
    padding: 12px 0 0;
    border-top: 2px solid rgba(168, 70, 88, 0.72);
    color: #c9c0bd;
    font-size: 27px;
}

.menu-settings-panel.open {
    display: grid;
    gap: 12px;
}

.menu-sound-toggle,
.menu-volume-control {
    display: grid;
    grid-template-columns: 92px 1fr 42px;
    align-items: center;
    gap: 12px;
}

.menu-sound-toggle input {
    width: 22px;
    height: 22px;
    accent-color: #d7576f;
}

.menu-sound-toggle span {
    grid-column: 1;
}

.menu-sound-toggle input {
    grid-column: 2;
    justify-self: start;
}

.menu-sound-toggle strong,
.menu-volume-control strong {
    justify-self: end;
    color: #f2ece7;
    font-weight: normal;
}

.menu-volume-control input {
    width: 100%;
    accent-color: #d7576f;
}

#menu-moon-stage {
    position: absolute;
    right: clamp(160px, 18vw, 280px);
    top: 50%;
    z-index: 2;
    width: min(62vw, 820px);
    height: min(82vh, 760px);
    min-width: 360px;
    min-height: 360px;
    transform: translateY(-50%);
    transform-origin: center center;
    overflow: visible;
    transition:
        right 2.05s cubic-bezier(0.72, 0.02, 0.26, 1),
        transform 2.05s cubic-bezier(0.72, 0.02, 0.26, 1),
        opacity 0.35s linear,
        filter 2s linear;
    pointer-events: none;
}

#menu-moon-canvas {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    filter: brightness(1.04) contrast(0.98);
    image-rendering: pixelated;
    cursor: var(--game-cursor-default);
}

#menu-blackout {
    position: absolute;
    inset: 0;
    z-index: 8;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.45s linear;
}

#main-menu.starting .menu-copy {
    transform: translate(-130%, -50%);
    opacity: 0;
}

#main-menu.starting #menu-moon-stage {
    right: 50%;
    transform: translate(50%, -50%);
}

#main-menu.zooming #menu-moon-stage {
    transform: translate(50%, -50%);
    filter: brightness(0.84) contrast(1.04);
}

#main-menu.blackout #menu-blackout {
    opacity: 1;
}

#main-menu.handoff .menu-copy,
#main-menu.handoff #menu-moon-stage,
#main-menu.handoff .menu-starfield {
    opacity: 0;
}

/* --- HUD --- */
:root {
    --hud-flesh: #d7576f;
    --hud-flesh-bright: #ff6e87;
    --hud-blood: #4a0d17;
    --hud-blood-dark: #170409;
    --hud-border: #6b2836;
    --hud-border-hot: #a84658;
    --hud-text: #e8e0dc;
    --hud-muted: #8f7980;
    --hud-ash: #9b9ba2;
    --hud-panel: rgba(7, 3, 5, 0.92);
    --hud-panel-soft: rgba(24, 7, 12, 0.86);
    --top-hud-top: 0px;
    --top-hud-left: 10px;
    --top-hud-base-height: 112px;
    --top-hud-height: 112px;
    --top-hud-scale: 1;
}

#hud {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    width: 100%;
    height: 100%;
    pointer-events: none;
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
}

#top-hud {
    position: absolute;
    top: var(--top-hud-top);
    left: var(--top-hud-left);
    display: grid;
    grid-template-columns: 47.4% 22.6% 30.0%;
    align-items: stretch;
    width: calc(var(--top-hud-base-height) * 1989 / 278);
    height: var(--top-hud-base-height);
    padding: 0;
    background-image: url("assets/newest_ui_combine.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    image-rendering: pixelated;
    transform-origin: top left;
    transform: scale(var(--top-hud-scale));
    filter: drop-shadow(0 0 16px rgba(215, 87, 111, 0.16));
}

#top-hud::before,
#top-hud::after {
    content: none;
}

.hud-cell {
    --hud-cell-height: var(--top-hud-base-height);
    position: relative;
    z-index: 1;
    display: block;
    min-width: 0;
    height: 100%;
    padding: 0;
    background-color: transparent;
    background-image: none;
    border: 0;
    color: var(--hud-text);
    font: inherit;
    font-size: 24px;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: 0 0 6px rgba(215, 87, 111, 0.42);
    white-space: nowrap;
    image-rendering: pixelated;
    pointer-events: none;
}

.hud-cell::before {
    content: none;
}

#top-hud > .hud-cell + .hud-cell {
    margin-left: 0;
}

#top-hud > .hud-cell:nth-child(1) { z-index: 1; }
#top-hud > .hud-cell:nth-child(2) { z-index: 2; }
#top-hud > .hud-cell:nth-child(3) { z-index: 3; }

.hud-copy {
    position: relative;
    display: block;
    min-height: 0;
    height: 100%;
}

.hud-copy-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-cell-biomass .hud-copy-row {
    position: absolute;
    left: 0;
    right: 0;
}

.hud-cell-biomass .hud-copy-row.split {
    top: calc(var(--hud-cell-height) * 0.34);
}

.hud-cell-biomass .hud-copy-row:not(.split) {
    top: calc(var(--hud-cell-height) * 0.59);
}

.hud-copy-row.split {
    justify-content: space-between;
    gap: 12px;
}

.hud-cell-node {
    padding-left: calc(var(--hud-cell-height) * 0.72);
}

.hud-cell-biomass {
    padding-left: calc(var(--hud-cell-height) * 1.22);
    padding-right: calc(var(--hud-cell-height) * 0.32);
}

.hud-cell-dna {
    padding-left: calc(var(--hud-cell-height) * 0.92);
    padding-right: calc(var(--hud-cell-height) * 0.16);
}

.hud-cell-sight {
    padding-left: calc(var(--hud-cell-height) * 1.08);
    padding-right: calc(var(--hud-cell-height) * 0.20);
}

#dna-toggle.hud-cell {
    pointer-events: auto;
    cursor: var(--game-cursor-pointer);
    appearance: none;
    transition: transform 0.12s steps(2, end), filter 0.12s linear;
}

#dna-toggle.hud-cell:hover,
#dna-toggle.hud-cell.open {
    transform: translateY(-1px);
    filter: brightness(1.08) drop-shadow(0 0 18px rgba(255, 110, 135, 0.26));
}

#dna-toggle.attention {
    animation: evolutionPulse 1.05s steps(2, end) infinite;
}

@keyframes evolutionPulse {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(255, 110, 135, 0.16)); }
    50% { filter: brightness(1.16) drop-shadow(0 0 24px rgba(255, 110, 135, 0.34)); }
}

.hud-label,
.hud-value {
    position: relative;
    z-index: 1;
}

.hud-label {
    color: var(--hud-text);
    font-size: clamp(18px, calc(var(--hud-cell-height) * 0.29), 22px);
    letter-spacing: 0.04em;
}

.hud-value {
    color: var(--hud-text);
    font-size: clamp(27px, calc(var(--hud-cell-height) * 0.44), 34px);
    line-height: 0.95;
}

.hud-value-row {
    position: absolute;
    top: calc(var(--hud-cell-height) * 0.52);
    left: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.hud-cell-dna .hud-label,
.hud-cell-sight .hud-label {
    position: absolute;
    top: calc(var(--hud-cell-height) * 0.34);
    left: 0;
}

.hud-cell-sight #sight {
    position: absolute;
    top: calc(var(--hud-cell-height) * 0.52);
    left: 0;
}

.hud-cell-node .hud-label {
    padding-top: calc(var(--hud-cell-height) * 0.06);
    font-size: clamp(22px, calc(var(--hud-cell-height) * 0.36), 28px);
}

.hud-cell-dna .hud-value,
.hud-cell-sight .hud-value {
    color: var(--hud-flesh-bright);
}

.hud-cell-biomass .hud-copy {
    position: relative;
}

.hud-cell-biomass .hud-label {
    font-size: clamp(18px, calc(var(--hud-cell-height) * 0.29), 22px);
}

.hud-cell-biomass .hud-value {
    font-size: clamp(27px, calc(var(--hud-cell-height) * 0.44), 34px);
}

.hud-rate {
    position: relative;
    z-index: 1;
    display: inline-block;
    min-width: 52px;
    color: var(--hud-muted);
    font-size: clamp(18px, calc(var(--hud-cell-height) * 0.29), 22px);
    line-height: 0.95;
    text-align: left;
}

.hud-meter {
    --biomass-fill: 83%;
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    height: clamp(12px, calc(var(--hud-cell-height) * 0.18), 16px);
    overflow: hidden;
    background:
        repeating-linear-gradient(90deg, rgba(92, 36, 48, 0.88) 0 4px, rgba(13, 5, 8, 0.9) 4px 8px);
    border-left: 1px solid rgba(215, 87, 111, 0.7);
    border-right: 1px solid rgba(82, 36, 45, 0.8);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.85);
}

#biomass-meter-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--biomass-fill);
    background:
        repeating-linear-gradient(90deg, var(--hud-flesh-bright) 0 4px, rgba(92, 21, 35, 0.95) 4px 8px);
    box-shadow: 0 0 8px rgba(215, 87, 111, 0.5);
}

#biomass.flash,
#dna.flash {
    color: var(--hud-flesh-bright);
    text-shadow: 0 0 11px rgba(255, 110, 135, 0.85);
}

#biomass-rate.positive { color: #d0c3b8; }
#biomass-rate.neutral { color: var(--hud-muted); }
#biomass-rate.negative {
    color: var(--hud-flesh-bright);
    text-shadow: 0 0 10px rgba(255, 110, 135, 0.58);
}

.human-alert {
    --human-alert-fill: 0%;
    --human-alert-color: #b7a7a0;
    position: absolute;
    top: 14px;
    right: 18px;
    width: 246px;
    padding: 9px 11px 10px;
    background: rgba(8, 3, 5, 0.82);
    border: 1px solid rgba(112, 52, 60, 0.88);
    border-left: 3px solid var(--human-alert-color);
    box-shadow:
        inset 0 0 0 1px rgba(255, 110, 135, 0.08),
        0 0 15px rgba(0, 0, 0, 0.45);
    color: var(--hud-text);
    font-size: 20px;
    line-height: 1;
    text-shadow: 0 0 7px rgba(215, 87, 111, 0.30);
    image-rendering: pixelated;
    pointer-events: auto;
    cursor: var(--game-cursor-default);
}

.human-alert-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.human-alert-label {
    color: var(--hud-muted);
    letter-spacing: 0.04em;
}

.human-alert-level {
    color: var(--human-alert-color);
    font-size: 26px;
}

.human-alert-state {
    margin-top: 3px;
    color: var(--hud-text);
    font-size: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.human-alert-meter {
    position: relative;
    height: 8px;
    margin-top: 7px;
    overflow: hidden;
    background:
        repeating-linear-gradient(90deg, rgba(58, 31, 37, 0.92) 0 5px, rgba(9, 4, 6, 0.92) 5px 10px);
    border-left: 1px solid rgba(160, 74, 84, 0.82);
    border-right: 1px solid rgba(73, 35, 42, 0.82);
    box-shadow: inset 0 0 7px rgba(0, 0, 0, 0.8);
}

#human-alert-meter-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--human-alert-fill);
    background:
        repeating-linear-gradient(90deg, var(--human-alert-color) 0 5px, rgba(74, 16, 26, 0.92) 5px 10px);
    box-shadow: 0 0 10px rgba(255, 110, 135, 0.32);
}

.human-alert[data-level="1"] { --human-alert-color: #b7a7a0; }
.human-alert[data-level="2"] { --human-alert-color: #d6bf98; }
.human-alert[data-level="3"] { --human-alert-color: #f0a96d; }
.human-alert[data-level="4"] { --human-alert-color: #ff846d; }
.human-alert[data-level="5"] { --human-alert-color: #ff6e87; }
.human-alert[data-level="6"] { --human-alert-color: #ff445f; }

.human-alert.locked {
    opacity: 0.72;
}

.human-alert.changed {
    animation: humanAlertChanged 0.72s steps(2, end);
}

@keyframes humanAlertChanged {
    0%, 100% { filter: none; }
    50% {
        filter: brightness(1.28) drop-shadow(0 0 14px rgba(255, 110, 135, 0.36));
    }
}

#objective-line {
    position: absolute;
    top: calc(var(--top-hud-top) + var(--top-hud-height) + 8px);
    left: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 50px);
    color: var(--hud-text);
    font-size: 24px;
    line-height: 1;
    letter-spacing: 0;
    text-shadow: 0 0 6px rgba(215, 87, 111, 0.36);
    white-space: normal;
}

#objective-line.hidden { display: none; }

.objective-mark {
    color: var(--hud-flesh-bright);
    font-size: 28px;
    line-height: 0.8;
}

.objective-label {
    color: var(--hud-text);
}

#objective {
    min-width: 0;
    color: var(--hud-text);
    overflow-wrap: anywhere;
}

#objective-line.changed {
    animation: objectiveLineChanged 0.72s steps(2, end);
}

@keyframes objectiveLineChanged {
    0%, 100% {
        filter: none;
    }
    50% {
        filter: brightness(1.24) drop-shadow(0 0 12px rgba(255, 110, 135, 0.34));
    }
}

#objective-announcement {
    --objective-fly-x: 0px;
    --objective-fly-y: 0px;
    position: fixed;
    top: 46%;
    left: 50%;
    z-index: 130;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: min(760px, calc(100vw - 32px));
    padding: 9px 15px 8px;
    background:
        linear-gradient(90deg, rgba(7, 3, 5, 0.20), rgba(22, 5, 10, 0.95) 16%, rgba(22, 5, 10, 0.95) 84%, rgba(7, 3, 5, 0.20)),
        repeating-linear-gradient(180deg, rgba(255, 110, 135, 0.08) 0 1px, transparent 1px 7px);
    border-top: 2px solid rgba(215, 87, 111, 0.62);
    border-bottom: 2px solid rgba(107, 40, 54, 0.88);
    color: var(--hud-text);
    font-size: 38px;
    line-height: 0.95;
    letter-spacing: 0;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 110, 135, 0.54), 0 2px 0 rgba(0, 0, 0, 0.82);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%) scale(0.92);
    overflow-wrap: anywhere;
    will-change: transform, opacity, filter;
}

#objective-announcement.active {
    visibility: visible;
    animation: objectiveAnnouncementMove 2.35s cubic-bezier(0.19, 0.74, 0.22, 1) forwards;
}

.objective-announcement-mark {
    color: var(--hud-flesh-bright);
    font-size: 46px;
    line-height: 0.75;
}

.objective-announcement-label {
    color: var(--hud-muted);
    font-size: 26px;
}

#objective-announcement-text {
    min-width: 0;
    color: var(--hud-text);
}

@keyframes objectiveAnnouncementMove {
    0% {
        opacity: 0;
        filter: brightness(1.2);
        transform: translate(-50%, -42%) scale(0.92);
    }
    10% {
        opacity: 1;
        filter: brightness(1.18) drop-shadow(0 0 22px rgba(255, 110, 135, 0.24));
        transform: translate(-50%, -50%) scale(1);
    }
    58% {
        opacity: 1;
        filter: brightness(1.0);
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        filter: brightness(0.92);
        transform: translate(calc(-50% + var(--objective-fly-x)), calc(-50% + var(--objective-fly-y))) scale(0.68);
    }
}

@media (prefers-reduced-motion: reduce) {
    #objective-announcement.active {
        animation: objectiveAnnouncementReduced 1.8s linear forwards;
    }
}

@keyframes objectiveAnnouncementReduced {
    0%, 12% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.98);
    }
    18%, 76% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

#signal {
    position: absolute;
    top: calc(var(--top-hud-top) + var(--top-hud-height) + 74px);
    left: 26px;
    max-width: min(440px, calc(100vw - 52px));
    padding: 5px 9px;
    background: rgba(8, 3, 5, 0.76);
    border-left: 2px solid rgba(215, 87, 111, 0.72);
    color: var(--hud-muted);
    font-size: 22px;
    line-height: 1;
    text-shadow: 0 0 8px rgba(215, 87, 111, 0.35);
}

#signal:empty {
    display: none;
}

#signal.flash {
    color: var(--hud-flesh-bright);
    text-shadow: 0 0 10px rgba(255, 110, 135, 0.8);
}

#collapse-warning {
    --collapse-fill: 0%;
    position: absolute;
    top: calc(var(--top-hud-top) + var(--top-hud-height) + 38px);
    left: 26px;
    display: none;
    align-items: center;
    gap: 9px;
    max-width: min(520px, calc(100vw - 52px));
    padding: 5px 9px;
    background: rgba(18, 3, 6, 0.88);
    border-left: 2px solid var(--hud-flesh-bright);
    color: var(--hud-text);
    font-size: 22px;
    line-height: 1;
    text-shadow: 0 0 8px rgba(215, 87, 111, 0.42);
}

#collapse-warning.visible {
    display: flex;
}

.collapse-label,
#collapse-timer {
    color: var(--hud-flesh-bright);
}

.collapse-meter {
    position: relative;
    display: inline-block;
    width: 128px;
    height: 14px;
    overflow: hidden;
    background: rgba(12, 4, 7, 0.92);
    border-left: 2px solid rgba(215, 87, 111, 0.76);
    border-right: 2px solid rgba(82, 36, 45, 0.8);
    box-shadow: inset 0 0 7px rgba(0, 0, 0, 0.86);
}

#collapse-meter-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--collapse-fill);
    background:
        repeating-linear-gradient(90deg, var(--hud-flesh-bright) 0 4px, rgba(92, 21, 35, 0.95) 4px 8px);
    box-shadow: 0 0 10px rgba(255, 110, 135, 0.62);
}

#radial {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    z-index: 100;
    pointer-events: none;
}

#construction-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 92;
    width: min(338px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - 126px));
    pointer-events: auto;
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    text-shadow: 0 0 7px rgba(215, 87, 111, 0.28);
}

.construction-panel-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(30, 8, 13, 0.97), rgba(8, 2, 4, 0.96) 22%, rgba(15, 4, 8, 0.98)),
        repeating-linear-gradient(180deg, transparent 0 11px, rgba(255, 110, 135, 0.03) 11px 12px);
    border: 2px solid var(--hud-border);
    box-shadow:
        0 0 26px rgba(0, 0, 0, 0.76),
        0 0 22px rgba(215, 87, 111, 0.14),
        inset 0 0 22px rgba(255, 110, 135, 0.06);
}

.construction-panel-frame::before,
.construction-panel-frame::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    height: 8px;
    pointer-events: none;
    opacity: 0.85;
}

.construction-panel-frame::before {
    top: 6px;
    background:
        linear-gradient(90deg, transparent 0 12px, rgba(215, 87, 111, 0.3) 12px 26px, transparent 26px 41px, rgba(116, 41, 54, 0.36) 41px 54px, transparent 54px 70px);
}

.construction-panel-frame::after {
    bottom: 6px;
    background:
        linear-gradient(90deg, transparent 0 16px, rgba(137, 48, 64, 0.34) 16px 28px, transparent 28px 49px, rgba(215, 87, 111, 0.28) 49px 63px, transparent 63px 82px);
}

.construction-panel-tabs {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    padding: 8px 8px 0;
    background: linear-gradient(180deg, rgba(12, 4, 6, 0.98), rgba(7, 3, 5, 0.94));
}

.construction-tab {
    min-height: 42px;
    padding: 6px 10px 4px;
    appearance: none;
    background:
        linear-gradient(180deg, rgba(55, 14, 22, 0.96), rgba(24, 6, 10, 0.96)),
        repeating-linear-gradient(90deg, transparent 0 8px, rgba(255, 110, 135, 0.06) 8px 9px);
    border: 2px solid rgba(122, 41, 55, 0.82);
    border-radius: 0;
    border-bottom: 0;
    color: rgba(232, 224, 220, 0.72);
    font: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: var(--game-cursor-pointer);
}

.construction-tab:hover,
.construction-tab.active {
    color: #ffffff;
    background:
        linear-gradient(180deg, rgba(145, 33, 47, 0.92), rgba(82, 19, 31, 0.94)),
        repeating-linear-gradient(90deg, transparent 0 8px, rgba(255, 202, 209, 0.08) 8px 9px);
    border-color: rgba(199, 89, 108, 0.92);
}

.construction-tab.active {
    box-shadow: inset 0 0 18px rgba(255, 110, 135, 0.14);
}

.construction-panel-head {
    position: relative;
    z-index: 1;
    padding: 12px 12px 10px;
    border-top: 2px solid rgba(107, 40, 54, 0.92);
    border-bottom: 2px solid rgba(107, 40, 54, 0.84);
    background:
        linear-gradient(180deg, rgba(13, 4, 7, 0.96), rgba(23, 7, 11, 0.98)),
        repeating-linear-gradient(90deg, transparent 0 12px, rgba(215, 87, 111, 0.04) 12px 13px);
}

.construction-kicker,
.construction-subtitle,
.construction-card-status,
.construction-card-stat-label,
.construction-footer,
.construction-digest-note {
    color: var(--hud-muted);
}

.construction-kicker {
    font-size: 18px;
}

.construction-title {
    margin-top: 2px;
    color: var(--hud-flesh-bright);
    font-size: 34px;
    line-height: 1;
}

.construction-subtitle {
    margin-top: 4px;
    font-size: 20px;
    line-height: 1.05;
}

#construction-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    z-index: 1;
    padding: 10px;
    overflow-y: auto;
}

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

.construction-card,
.construction-digest-panel,
.construction-digest-stat {
    background:
        linear-gradient(180deg, rgba(46, 11, 18, 0.9), rgba(15, 4, 7, 0.96)),
        repeating-linear-gradient(90deg, transparent 0 9px, rgba(255, 110, 135, 0.04) 9px 10px);
    border: 2px solid rgba(113, 41, 55, 0.82);
    box-shadow: inset 0 0 14px rgba(255, 110, 135, 0.04);
}

.construction-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 210px;
    padding: 8px;
    appearance: none;
    border-radius: 0;
    color: var(--hud-text);
    font: inherit;
    text-align: left;
    cursor: var(--game-cursor-pointer);
}

.construction-card::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: repeating-linear-gradient(90deg, rgba(255, 110, 135, 0.24) 0 6px, transparent 6px 14px);
    pointer-events: none;
}

.construction-card:hover,
.construction-card.selected,
.construction-card.mode-active {
    border-color: rgba(199, 89, 108, 0.92);
    background:
        linear-gradient(180deg, rgba(84, 19, 31, 0.94), rgba(24, 6, 10, 0.97)),
        repeating-linear-gradient(90deg, transparent 0 9px, rgba(255, 110, 135, 0.06) 9px 10px);
}

.construction-card.locked,
.construction-card.disabled {
    color: rgba(232, 224, 220, 0.68);
    border-color: rgba(78, 33, 41, 0.76);
}

.construction-card.locked .construction-card-preview,
.construction-card.disabled .construction-card-preview {
    filter: saturate(0.5) brightness(0.8);
}

.construction-card.disabled {
    cursor: var(--game-cursor-default);
}

.construction-card.shortage {
    border-color: rgba(139, 57, 69, 0.88);
}

.construction-card-top,
.construction-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.construction-card-label {
    color: var(--hud-flesh-bright);
    font-size: 28px;
    line-height: 1;
}

.construction-card-key {
    flex: 0 0 auto;
    min-width: 26px;
    padding: 2px 5px 1px;
    border: 2px solid rgba(199, 89, 108, 0.9);
    background: rgba(10, 3, 5, 0.88);
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    text-align: center;
}

.construction-card-preview {
    position: relative;
    min-height: 86px;
    border: 1px solid rgba(122, 41, 55, 0.8);
    background:
        linear-gradient(180deg, rgba(111, 27, 41, 0.22), rgba(23, 7, 11, 0.14)),
        linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(255, 110, 135, 0.08) calc(50% - 0.5px), rgba(255, 110, 135, 0.08) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
        linear-gradient(transparent calc(50% - 0.5px), rgba(255, 110, 135, 0.08) calc(50% - 0.5px), rgba(255, 110, 135, 0.08) calc(50% + 0.5px), transparent calc(50% + 0.5px));
    overflow: hidden;
}

.construction-card-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 110, 135, 0.06) 18px 19px),
        repeating-linear-gradient(180deg, transparent 0 18px, rgba(255, 110, 135, 0.06) 18px 19px);
    pointer-events: none;
}

.construction-preview-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center 50%;
    transform: scale(1.12);
    image-rendering: pixelated;
    filter:
        drop-shadow(0 0 12px rgba(255, 110, 135, 0.18))
        drop-shadow(0 6px 10px rgba(7, 1, 3, 0.78));
    pointer-events: none;
    user-select: none;
}

.construction-preview-glyph {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 84px;
    height: 84px;
    transform: translate(-50%, -46%);
    filter: drop-shadow(0 0 12px rgba(255, 110, 135, 0.18));
}

.construction-preview-glyph::before,
.construction-preview-glyph::after {
    content: '';
    position: absolute;
}

.construction-preview-node::before {
    left: 18px;
    top: 18px;
    width: 46px;
    height: 46px;
    border: 4px solid rgba(255, 146, 162, 0.9);
    border-radius: 26px;
    background: radial-gradient(circle at 50% 45%, rgba(255, 214, 220, 0.95) 0 8px, rgba(155, 29, 43, 0.95) 9px 16px, rgba(39, 7, 11, 0.92) 17px 100%);
    box-shadow:
        -23px 12px 0 -16px rgba(255, 146, 162, 0.82),
        23px 12px 0 -16px rgba(255, 146, 162, 0.82),
        0 -20px 0 -16px rgba(255, 146, 162, 0.82);
}

.construction-preview-node::after {
    left: 39px;
    top: 2px;
    width: 6px;
    height: 24px;
    background: rgba(255, 182, 193, 0.92);
    box-shadow: -24px 48px 0 -2px rgba(215, 87, 111, 0.72), 24px 48px 0 -2px rgba(215, 87, 111, 0.72);
}

.construction-preview-eye::before {
    left: 36px;
    top: 8px;
    width: 12px;
    height: 56px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(222, 130, 146, 0.96), rgba(108, 29, 42, 0.92));
    transform: rotate(6deg);
}

.construction-preview-eye::after {
    left: 18px;
    top: 6px;
    width: 48px;
    height: 42px;
    border: 4px solid rgba(255, 172, 186, 0.92);
    border-radius: 26px;
    background: radial-gradient(circle at 55% 52%, rgba(12, 4, 6, 0.96) 0 7px, rgba(233, 228, 220, 0.92) 8px 15px, rgba(140, 24, 36, 0.9) 16px 24px, rgba(43, 7, 11, 0.94) 25px 100%);
}

.construction-preview-maw::before {
    left: 18px;
    top: 14px;
    width: 50px;
    height: 54px;
    border-radius: 50% 50% 46% 46%;
    background:
        radial-gradient(circle at 45% 42%, rgba(97, 246, 232, 0.92) 0 15px, rgba(41, 121, 125, 0.88) 16px 25px, rgba(109, 30, 45, 0.95) 26px 100%);
    box-shadow:
        inset 0 0 0 5px rgba(96, 16, 27, 0.64),
        0 0 14px rgba(95, 246, 232, 0.22);
}

.construction-preview-maw::after {
    left: 14px;
    top: 40px;
    width: 58px;
    height: 34px;
    background:
        linear-gradient(90deg, transparent 0 9px, rgba(210, 88, 105, 0.92) 10px 15px, transparent 16px 25px, rgba(210, 88, 105, 0.92) 26px 31px, transparent 32px 42px, rgba(210, 88, 105, 0.92) 43px 48px, transparent 49px 100%),
        radial-gradient(ellipse at 50% 90%, rgba(91, 232, 222, 0.32) 0 18px, transparent 19px);
    border-radius: 8px;
    opacity: 0.95;
}

.construction-preview-cyst::before {
    left: 18px;
    top: 18px;
    width: 46px;
    height: 40px;
    border-radius: 24px;
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 194, 202, 0.9) 0 6px, rgba(157, 44, 64, 0.94) 7px 16px, rgba(95, 17, 31, 0.94) 17px 100%);
    box-shadow:
        -20px 12px 0 -8px rgba(179, 70, 91, 0.86),
        22px 10px 0 -9px rgba(179, 70, 91, 0.84),
        2px 24px 0 -12px rgba(134, 45, 60, 0.82);
}

.construction-preview-cyst::after {
    left: 33px;
    top: 10px;
    width: 16px;
    height: 54px;
    border-left: 3px solid rgba(226, 214, 198, 0.78);
    border-right: 3px solid rgba(226, 214, 198, 0.52);
    opacity: 0.88;
}

.construction-preview-bridge::before {
    left: 10px;
    top: 36px;
    width: 64px;
    height: 14px;
    border-radius: 10px;
    background:
        linear-gradient(90deg, rgba(229, 211, 183, 0.9) 0 8px, rgba(150, 56, 68, 0.92) 9px 17px, rgba(229, 211, 183, 0.9) 18px 27px, rgba(150, 56, 68, 0.92) 28px 37px, rgba(229, 211, 183, 0.9) 38px 48px, rgba(150, 56, 68, 0.92) 49px 56px, rgba(229, 211, 183, 0.9) 57px 100%);
    box-shadow:
        0 -13px 0 -5px rgba(224, 209, 188, 0.72),
        0 13px 0 -5px rgba(224, 209, 188, 0.66),
        0 0 14px rgba(215, 87, 111, 0.22);
    transform: rotate(-14deg);
}

.construction-preview-bridge::after {
    left: 13px;
    top: 16px;
    width: 56px;
    height: 52px;
    border-top: 4px solid rgba(226, 214, 198, 0.74);
    border-bottom: 4px solid rgba(226, 214, 198, 0.58);
    border-radius: 50%;
    transform: rotate(-14deg);
    opacity: 0.82;
}

.construction-preview-wall::before {
    left: 12px;
    top: 38px;
    width: 62px;
    height: 15px;
    border-radius: 6px;
    background:
        linear-gradient(90deg, rgba(229, 211, 183, 0.92) 0 10px, rgba(119, 43, 52, 0.92) 11px 15px, rgba(229, 211, 183, 0.92) 16px 29px, rgba(119, 43, 52, 0.92) 30px 34px, rgba(229, 211, 183, 0.92) 35px 48px, rgba(119, 43, 52, 0.92) 49px 53px, rgba(229, 211, 183, 0.92) 54px 100%);
    box-shadow:
        0 -16px 0 -8px rgba(224, 209, 188, 0.74),
        0 16px 0 -8px rgba(224, 209, 188, 0.62),
        0 0 14px rgba(255, 135, 86, 0.18);
    transform: rotate(-5deg);
}

.construction-preview-wall::after {
    left: 18px;
    top: 14px;
    width: 48px;
    height: 58px;
    background:
        linear-gradient(90deg, transparent 0 6px, rgba(224, 209, 188, 0.82) 7px 11px, transparent 12px 23px, rgba(224, 209, 188, 0.82) 24px 28px, transparent 29px 40px, rgba(224, 209, 188, 0.82) 41px 45px, transparent 46px 100%);
    opacity: 0.88;
    transform: rotate(-5deg);
}

.construction-preview-spike::before {
    left: 18px;
    top: 38px;
    width: 48px;
    height: 24px;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at center, rgba(19, 3, 8, 0.96) 0 38%, rgba(96, 28, 38, 0.92) 40% 66%, rgba(198, 177, 148, 0.82) 68% 100%);
    box-shadow:
        0 0 14px rgba(255, 135, 86, 0.20),
        inset 0 0 10px rgba(0, 0, 0, 0.54);
}

.construction-preview-spike::after {
    left: 39px;
    top: 11px;
    width: 10px;
    height: 54px;
    border-radius: 9px 9px 3px 3px;
    background:
        linear-gradient(180deg, rgba(244, 226, 190, 0.96) 0 12px, rgba(225, 205, 169, 0.92) 13px 72%, rgba(116, 47, 55, 0.92) 73% 100%);
    box-shadow:
        -5px 9px 0 -3px rgba(226, 214, 198, 0.62),
        5px 18px 0 -4px rgba(226, 214, 198, 0.48);
    clip-path: polygon(50% 0, 100% 20%, 72% 100%, 28% 100%, 0 20%);
    transform: rotate(18deg);
    transform-origin: 50% 85%;
}

.construction-card-meta {
    color: var(--hud-text);
    align-items: flex-start;
    font-size: 20px;
    line-height: 1;
}

.construction-card-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.construction-card-stat-label {
    font-size: 18px;
}

.construction-card-stat-value {
    color: var(--hud-text);
    font-size: 24px;
}

.construction-card-status {
    margin-top: auto;
    font-size: 18px;
    line-height: 1.05;
}

.construction-digest-view {
    display: grid;
    gap: 8px;
}

.construction-digest-panel {
    padding: 10px;
}

.construction-digest-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.construction-digest-title {
    color: var(--hud-flesh-bright);
    font-size: 30px;
    line-height: 1;
}

.construction-digest-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.construction-digest-stat {
    padding: 8px 9px;
}

.construction-digest-value {
    color: var(--hud-flesh-bright);
    font-size: 24px;
    line-height: 1;
}

.construction-digest-label {
    color: var(--hud-muted);
    font-size: 18px;
    line-height: 1;
}

.construction-digest-action {
    width: 100%;
    margin-top: 10px;
    padding: 8px 10px 7px;
    appearance: none;
    background: rgba(47, 12, 20, 0.78);
    border: 2px solid rgba(199, 89, 108, 0.9);
    border-radius: 0;
    color: var(--hud-text);
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: var(--game-cursor-pointer);
}

.construction-digest-action:hover {
    color: #ffffff;
    background: rgba(90, 20, 33, 0.9);
}

.construction-digest-action.disabled {
    border-color: rgba(82, 36, 45, 0.82);
    color: rgba(232, 224, 220, 0.64);
    cursor: var(--game-cursor-default);
}

.construction-digest-note {
    margin-top: 9px;
    font-size: 19px;
    line-height: 1.08;
}

.construction-footer {
    position: relative;
    z-index: 1;
    padding: 9px 12px 11px;
    border-top: 2px solid rgba(107, 40, 54, 0.84);
    background:
        linear-gradient(180deg, rgba(8, 3, 5, 0.98), rgba(18, 6, 10, 0.98)),
        repeating-linear-gradient(90deg, transparent 0 10px, rgba(255, 110, 135, 0.04) 10px 11px);
    font-size: 19px;
    line-height: 1.05;
}

.radial-wedge {
    fill: rgba(22, 5, 10, 0.82);
    fill-rule: evenodd;
    stroke: var(--hud-border-hot);
    stroke-width: 2;
    cursor: var(--game-cursor-pointer);
    transition: fill 0.08s;
}

.radial-wedge:hover { fill: rgba(60, 16, 26, 0.93); }
.radial-wedge.disabled { fill: rgba(9, 5, 7, 0.66); cursor: var(--game-cursor-default); }
.radial-wedge.disabled:hover { fill: rgba(9, 5, 7, 0.66); }

.radial-label {
    text-anchor: middle;
    dominant-baseline: central;
    fill: var(--hud-flesh-bright);
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 20px;
    pointer-events: none;
    text-shadow: 0 0 6px rgba(215, 87, 111, 0.54);
}

.radial-label.disabled { fill: #6b565c; }

.radial-center {
    fill: rgba(19, 5, 9, 0.94);
    stroke: var(--hud-border-hot);
    stroke-width: 2;
    cursor: var(--game-cursor-pointer);
}

.radial-center:hover { fill: rgba(60, 16, 26, 0.96); }

.radial-center-label {
    text-anchor: middle;
    dominant-baseline: central;
    fill: var(--hud-flesh-bright);
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 22px;
    pointer-events: none;
}

#ending-panel,
#collapse-panel,
#placement-preview,
#tooltip {
    background:
        linear-gradient(180deg, rgba(18, 6, 10, 0.96), rgba(4, 2, 3, 0.94));
    border: 2px solid var(--hud-border);
    border-radius: 0;
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    text-shadow: 0 0 7px rgba(215, 87, 111, 0.28);
    box-shadow: 0 0 26px rgba(0, 0, 0, 0.72), inset 0 0 18px rgba(215, 87, 111, 0.07);
}

#evolution-panel {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: none;
    padding: clamp(10px, 2.2vw, 28px);
    background:
        radial-gradient(circle at 46% 48%, rgba(104, 24, 42, 0.22), transparent 42%),
        linear-gradient(180deg, rgba(9, 3, 5, 0.90), rgba(0, 0, 0, 0.96));
    pointer-events: auto;
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 20px;
    line-height: 1.2;
    text-shadow: 0 0 7px rgba(215, 87, 111, 0.28);
}

#evolution-panel.open { display: grid; }

.evolution-panel-frame {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(18, 6, 10, 0.94), rgba(4, 2, 3, 0.90));
    border: 2px solid var(--hud-border);
    box-shadow: 0 0 36px rgba(0, 0, 0, 0.78), inset 0 0 26px rgba(215, 87, 111, 0.07);
}

.evolution-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 8px;
    border-bottom: 2px solid var(--hud-border);
}

.evolution-kicker,
.ending-kicker,
.evolution-dna,
.evolution-state,
.evolution-meta,
#tooltip .tooltip-meta {
    color: var(--hud-muted);
}

.evolution-kicker,
.ending-kicker {
    font-size: 18px;
}

.evolution-title,
.ending-title,
.evolution-name,
#tooltip .tooltip-title {
    color: var(--hud-flesh-bright);
}

.evolution-title { font-size: 26px; }

#evolution-close,
.evolution-action,
#ending-close,
#collapse-restart {
    background: rgba(47, 12, 20, 0.76);
    border: 2px solid var(--hud-border-hot);
    border-radius: 0;
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    cursor: var(--game-cursor-pointer);
}

#evolution-close {
    min-width: 28px;
    height: 28px;
    font-size: 22px;
}

#evolution-close:hover,
.evolution-action:hover:not(:disabled),
#ending-close:hover,
#collapse-restart:hover {
    color: #ffffff;
    border-color: var(--hud-flesh-bright);
    background: rgba(75, 18, 30, 0.86);
}

.evolution-dna {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(107, 40, 54, 0.76);
}

#evolution-progress {
    color: var(--hud-muted);
}

.evolution-panel-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    min-height: 0;
}

.evolution-web-viewport {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    cursor: var(--game-cursor);
    background:
        linear-gradient(rgba(145, 57, 76, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(145, 57, 76, 0.08) 1px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(223, 84, 109, 0.10), transparent 58%),
        rgba(3, 1, 2, 0.72);
    background-size: 54px 54px, 54px 54px, auto, auto;
    touch-action: none;
}

.evolution-web-viewport.dragging {
    cursor: grabbing;
}

.evolution-web-space {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.evolution-links {
    position: absolute;
    inset: 0;
    overflow: visible;
}

.evolution-link {
    stroke: rgba(103, 51, 62, 0.72);
    stroke-width: 5;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.evolution-link.available {
    stroke: rgba(196, 84, 105, 0.86);
}

.evolution-link.active {
    stroke: rgba(255, 110, 135, 0.96);
    filter: drop-shadow(0 0 7px rgba(255, 110, 135, 0.42));
}

.evolution-node-layer {
    position: absolute;
    inset: 0;
}

.evolution-node {
    position: absolute;
    display: grid;
    justify-items: center;
    gap: 5px;
    width: 120px;
    height: 128px;
    border: 0;
    background: transparent;
    color: var(--hud-muted);
    font-family: 'VT323', 'Courier New', monospace;
    cursor: var(--game-cursor-pointer);
    transform: translate(-50%, -29px);
    text-align: center;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.85);
}

.evolution-node.organ,
.evolution-node.major {
    transform: translate(-50%, -35px);
}

.evolution-node-core {
    position: relative;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border: 2px solid rgba(107, 40, 54, 0.94);
    border-radius: 50%;
    background:
        radial-gradient(circle at 42% 38%, rgba(120, 31, 48, 0.92), rgba(26, 6, 11, 0.96) 68%);
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.78), 0 0 12px rgba(0, 0, 0, 0.62);
}

.evolution-node.organ .evolution-node-core,
.evolution-node.major .evolution-node-core {
    width: 70px;
    height: 70px;
    border-width: 3px;
}

.evolution-node-core::before,
.evolution-node-core::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.evolution-node-core::before {
    inset: 12px;
    background: rgba(255, 110, 135, 0.12);
}

.evolution-node-core::after {
    width: 9px;
    height: 9px;
    background: rgba(232, 224, 220, 0.82);
    box-shadow: 0 0 9px rgba(255, 110, 135, 0.54);
}

.evolution-node.available .evolution-node-core {
    border-color: var(--hud-border-hot);
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.78), 0 0 18px rgba(215, 87, 111, 0.30);
}

.evolution-node.active .evolution-node-core {
    border-color: var(--hud-flesh-bright);
    background:
        radial-gradient(circle at 42% 38%, rgba(255, 110, 135, 0.92), rgba(72, 14, 26, 0.98) 68%);
    box-shadow: inset 0 0 16px rgba(255, 226, 232, 0.10), 0 0 24px rgba(255, 110, 135, 0.38);
}

.evolution-node.maxed .evolution-node-core {
    border-color: #ffd3dc;
}

.evolution-node.selected .evolution-node-core {
    outline: 2px solid rgba(232, 224, 220, 0.74);
    outline-offset: 5px;
}

.evolution-node.locked {
    opacity: 0.54;
}

.evolution-node-label {
    width: 120px;
    color: var(--hud-text);
    font-size: 18px;
    line-height: 0.95;
}

.evolution-node.minor .evolution-node-label {
    color: #c5a8b0;
}

.evolution-node-ranks,
.evolution-selected-ranks {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.evolution-rank-pip {
    width: 8px;
    height: 8px;
    border: 1px solid rgba(143, 121, 128, 0.88);
    border-radius: 50%;
    background: rgba(18, 6, 10, 0.96);
}

.evolution-rank-pip.filled {
    border-color: var(--hud-flesh-bright);
    background: var(--hud-flesh-bright);
    box-shadow: 0 0 7px rgba(255, 110, 135, 0.52);
}

.evolution-details {
    display: grid;
    align-content: start;
    gap: 10px;
    min-width: 0;
    padding: 14px;
    border-left: 2px solid var(--hud-border);
    background:
        linear-gradient(180deg, rgba(14, 4, 8, 0.92), rgba(4, 2, 3, 0.94));
}

.evolution-selected-title {
    color: var(--hud-flesh-bright);
    font-size: 32px;
    line-height: 0.95;
}

.evolution-selected-branch,
.evolution-selected-meta,
.evolution-selected-state {
    color: var(--hud-muted);
}

.evolution-selected-body {
    color: var(--hud-text);
    font-size: 22px;
}

.evolution-selected-ranks {
    justify-content: flex-start;
    margin-top: 2px;
}

.evolution-entry {
    padding: 10px;
    border-bottom: 1px solid rgba(107, 40, 54, 0.76);
}

.evolution-entry:last-child { border-bottom: 0; }

.evolution-entry.unrevealed {
    color: #68565c;
}

.evolution-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.evolution-name {
    font-size: 24px;
}

.evolution-entry.unrevealed .evolution-name { color: #71676b; }

.evolution-body {
    margin-top: 4px;
}

.evolution-state {
    margin-top: 5px;
}

.evolution-action {
    flex: 0 0 auto;
    padding: 4px 8px;
    font-size: 20px;
}

.evolution-action:disabled {
    cursor: var(--game-cursor-default);
    opacity: 0.48;
}

.evolution-details .evolution-action {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    font-size: 22px;
}

#ending-panel,
#collapse-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 130;
    display: none;
    width: min(460px, calc(100vw - 32px));
    transform: translate(-50%, -50%);
    pointer-events: auto;
    padding: 14px;
    font-size: 22px;
    line-height: 1.15;
}

#ending-panel.open,
#collapse-panel.open {
    display: block;
}

.ending-title {
    margin-top: 3px;
    font-size: 34px;
}

.ending-body {
    margin-top: 8px;
}

#ending-close,
#collapse-restart {
    margin-top: 12px;
    padding: 6px 10px;
    font-size: 22px;
}

#tooltip {
    position: fixed;
    display: none;
    z-index: 200;
    max-width: 280px;
    padding: 8px 10px;
    font-size: 20px;
    line-height: 1.2;
    pointer-events: none;
}

#tooltip .tooltip-title {
    font-size: 22px;
    margin-bottom: 4px;
}

#tooltip .tooltip-meta {
    margin-top: 5px;
}

#placement-preview {
    position: fixed;
    display: none;
    z-index: 190;
    width: 178px;
    padding: 8px 10px;
    font-size: 20px;
    line-height: 1.1;
    pointer-events: none;
}

#placement-preview.visible {
    display: block;
}

#placement-preview.invalid {
    border-color: rgba(255, 110, 135, 0.95);
}

.placement-preview-title {
    margin-bottom: 6px;
    color: var(--hud-flesh-bright);
    font-size: 22px;
}

.placement-preview-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.placement-preview-row + .placement-preview-row,
.placement-preview-status {
    margin-top: 3px;
}

.placement-preview-label {
    color: var(--hud-muted);
}

.placement-preview-value {
    color: var(--hud-text);
}

.placement-preview-status {
    overflow-wrap: anywhere;
    color: var(--hud-muted);
}

#placement-preview.invalid .placement-preview-status {
    color: var(--hud-flesh-bright);
}

#heart-indicator {
    --heart-scale: 1;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 80;
    display: none;
    width: 42px;
    height: 42px;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(var(--heart-scale));
    transform-origin: center;
    filter: drop-shadow(0 0 9px rgba(215, 87, 111, 0.55));
}

#heart-indicator.visible { display: block; }

#heart-indicator .heart-marker {
    position: absolute;
    inset: 4px;
    border: 2px solid var(--hud-flesh);
    background: rgba(8, 3, 5, 0.78);
    transform: rotate(45deg);
    box-shadow: inset 0 0 12px rgba(215, 87, 111, 0.22);
}

#heart-indicator .heart-marker::before,
#heart-indicator .heart-marker::after {
    content: '';
    position: absolute;
    background: var(--hud-muted);
    opacity: 0.72;
}

#heart-indicator .heart-marker::before {
    left: 50%;
    top: -8px;
    width: 2px;
    height: 46px;
    transform: translateX(-50%);
}

#heart-indicator .heart-marker::after {
    left: -8px;
    top: 50%;
    width: 46px;
    height: 2px;
    transform: translateY(-50%);
}

#heart-indicator .heart-core {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 13px;
    height: 13px;
    background: var(--hud-flesh-bright);
    border: 2px solid var(--hud-border-hot);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(255, 110, 135, 0.78);
    animation: heartIconPulse 0.9s infinite;
}

#human-detection-layer {
    position: fixed;
    inset: 0;
    z-index: 82;
    overflow: hidden;
    pointer-events: none;
}

.human-detection-marker {
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -118%) scale(var(--detection-scale, 1));
    transform-origin: center bottom;
    opacity: var(--detection-opacity, 1);
    image-rendering: pixelated;
    filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.82)) drop-shadow(0 0 7px rgba(255, 110, 135, 0.20));
}

.human-detection-marker.visible {
    display: block;
}

.human-detection-marker::before {
    content: '';
    position: absolute;
    inset: 1px;
    background-image: url("assets/ui/human-detection-icons.png");
    background-repeat: no-repeat;
    background-size: 200% 200%;
}

.human-detection-marker::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -5px;
    width: 22px;
    height: 3px;
    background: rgba(255, 110, 135, 0.72);
    transform: translateX(-50%);
    box-shadow: 0 0 7px rgba(255, 110, 135, 0.54);
}

.human-detection-marker[data-source="rover-scan"]::before {
    background-position: 0% 0%;
}

.human-detection-marker[data-source="relay-sight"]::before {
    background-position: 100% 0%;
}

.human-detection-marker[data-source="human-sight"]::before {
    background-position: 0% 100%;
}

.human-detection-marker[data-source="burn-target"] {
    animation: detectionBurnPulse 0.52s steps(2, end) infinite;
}

.human-detection-marker[data-source="burn-target"]::before {
    background-position: 100% 100%;
}

.human-detection-marker[data-source="burn-target"]::after {
    background: rgba(255, 79, 55, 0.88);
    box-shadow: 0 0 9px rgba(255, 79, 55, 0.72);
}

@keyframes detectionBurnPulse {
    0%, 100% { filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.82)) drop-shadow(0 0 8px rgba(255, 79, 55, 0.40)); }
    50% { filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.82)) drop-shadow(0 0 13px rgba(255, 79, 55, 0.74)); }
}

@keyframes heartIconPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(0.92); }
    50% { transform: translate(-50%, -50%) scale(1.16); }
}

@media (max-width: 1220px) {
    #objective-line,
    #signal,
    #collapse-warning {
        left: 16px;
        max-width: calc(100vw - 32px);
    }
    #human-alert {
        top: calc(var(--top-hud-top) + var(--top-hud-height) + 8px);
        right: 16px;
        width: 220px;
    }
    #objective-line {
        max-width: calc(100vw - 288px);
    }
    #construction-panel {
        right: 8px;
        bottom: 8px;
        width: min(320px, calc(100vw - 16px));
        max-height: min(500px, calc(100vh - 132px));
    }
    .evolution-panel-body {
        grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
    }
}

@media (max-width: 620px) {
    #top-hud {
        left: 6px;
    }
    #objective-announcement {
        top: 48%;
        max-width: calc(100vw - 24px);
        padding: 8px 11px 7px;
        gap: 7px;
        font-size: 29px;
    }
    .objective-announcement-mark {
        font-size: 36px;
    }
    .objective-announcement-label {
        font-size: 21px;
    }
    #human-alert {
        left: 12px;
        right: auto;
        width: min(246px, calc(100vw - 24px));
    }
    #objective-line,
    #signal,
    #collapse-warning {
        left: 12px;
        max-width: calc(100vw - 24px);
    }
    #objective-line {
        top: calc(var(--top-hud-top) + var(--top-hud-height) + 88px);
    }
    #collapse-warning {
        top: calc(var(--top-hud-top) + var(--top-hud-height) + 118px);
    }
    #signal {
        top: calc(var(--top-hud-top) + var(--top-hud-height) + 154px);
    }
    #evolution-panel {
        padding: 8px;
    }
    .evolution-panel-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }
    .evolution-details {
        max-height: 230px;
        overflow-y: auto;
        border-left: 0;
        border-top: 2px solid var(--hud-border);
    }
    .evolution-selected-title {
        font-size: 28px;
    }
    .evolution-selected-body {
        font-size: 20px;
    }
    #construction-panel {
        width: calc(100vw - 16px);
        max-height: min(420px, calc(100vh - 228px));
    }
    .construction-tab {
        min-height: 38px;
        font-size: 24px;
    }
    .construction-title {
        font-size: 30px;
    }
    .construction-subtitle,
    .construction-footer {
        font-size: 18px;
    }
    .construction-grid {
        gap: 6px;
    }
    .construction-card {
        min-height: 186px;
        padding: 7px;
    }
    .construction-card-label {
        font-size: 24px;
    }
    .construction-card-key,
    .construction-digest-value {
        font-size: 18px;
    }
    .construction-card-meta,
    .construction-digest-action {
        font-size: 18px;
    }
    .construction-card-status,
    .construction-card-stat-label,
    .construction-digest-label,
    .construction-digest-note {
        font-size: 16px;
    }
    .construction-card-stat-value {
        font-size: 20px;
    }
}

@media (max-width: 460px) {
    .construction-grid,
    .construction-digest-grid {
        grid-template-columns: 1fr;
    }
    .construction-card {
        min-height: 170px;
    }
}

#dev-panel {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 220;
    display: none;
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    pointer-events: auto;
    background: rgba(7, 3, 5, 0.96);
    border: 2px solid var(--hud-border);
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 20px;
    line-height: 1.15;
    text-shadow: 0 0 7px rgba(215, 87, 111, 0.28);
}
#dev-panel.open { display: block; }
.dev-panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    background: rgba(7, 3, 5, 0.98);
    border-bottom: 2px solid var(--hud-border);
}
.dev-kicker {
    color: var(--hud-muted);
    font-size: 18px;
}
.dev-title {
    color: var(--hud-flesh-bright);
    font-size: 28px;
}
.dev-close,
.dev-button {
    background: rgba(47, 12, 20, 0.76);
    border: 2px solid var(--hud-border-hot);
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    cursor: var(--game-cursor-pointer);
}
.dev-close {
    min-width: 28px;
    height: 28px;
    font-size: 22px;
}
.dev-button {
    padding: 5px 8px;
    font-size: 20px;
    text-align: left;
}
.dev-close:hover,
.dev-button:hover {
    color: #ffffff;
    border-color: var(--hud-flesh-bright);
}
.dev-section {
    border-bottom: 1px solid rgba(107, 40, 54, 0.8);
}
.dev-section summary {
    padding: 8px 10px;
    color: var(--hud-flesh-bright);
    font-size: 23px;
    cursor: var(--game-cursor-pointer);
    user-select: none;
}
.dev-section-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 0 10px 10px;
}
.dev-control {
    display: grid;
    align-items: center;
    gap: 6px;
}
.dev-range {
    grid-template-columns: minmax(118px, 1fr) minmax(92px, 1.1fr) 64px 48px;
}
.dev-checkbox {
    grid-template-columns: 20px 1fr;
    color: var(--hud-text);
}
.dev-control-label {
    color: var(--hud-text);
}
.dev-control-value {
    color: var(--hud-muted);
    text-align: right;
}
.dev-control input[type="range"] {
    width: 100%;
    accent-color: var(--hud-flesh);
    cursor: var(--game-cursor-pointer);
}
.dev-control input[type="number"],
.dev-export {
    width: 100%;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid var(--hud-border);
    color: var(--hud-text);
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 19px;
}
.dev-control input[type="number"] {
    height: 28px;
    padding: 2px 4px;
}
.dev-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--hud-flesh);
    cursor: var(--game-cursor-pointer);
}
.dev-export {
    min-height: 110px;
    resize: vertical;
    padding: 6px;
    line-height: 1.15;
}

@media (max-width: 560px) {
    #dev-panel {
        left: 8px;
        bottom: 8px;
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }
    .dev-range {
        grid-template-columns: 1fr 1fr 64px;
    }
    .dev-range .dev-control-label {
        grid-column: 1 / -1;
    }
}
