html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: #171717;
}

canvas {
    display: block;
}

:root {
    color-scheme: dark;
    font-family: "Courier New", monospace;
}

#pause-hint {
    position: fixed;
    bottom: 12px;
    left: 16px;
    margin: 0;
    color: #ffe1b3;
    font-size: 12px;
    text-shadow: 2px 2px #2a1c20;
    pointer-events: none;
}

.game-menu {
    box-sizing: border-box;
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100dvh - 40px);
    padding: 28px;
    overflow-y: auto;
    color: #ffe5bc;
    background: #30252b;
    border: 4px solid #edac73;
    border-radius: 0;
    box-shadow: 0 0 0 4px #161b25, 8px 8px 0 4px #161b25;
}

.game-menu::backdrop {
    background: #101622bb;
}

.mission-label {
    margin: 0 0 10px;
    color: #edac73;
    font-size: 12px;
    letter-spacing: 3px;
}
.game-logo { display: block; width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; margin: 0 0 14px; }
#title-screen { position: fixed; inset: 0; z-index: 10; overflow-y: auto; display: grid; align-items: center; padding: 40px 8vw; box-sizing: border-box; background: #101622 url('../assets/ui/title-background.png') center / cover no-repeat; }
#title-screen::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: linear-gradient(90deg, #101622ef 0%, #101622b0 43%, #10162210 85%); }
.title-content { position: relative; width: min(590px, 100%); padding: 24px 0; text-shadow: 3px 3px #101622; }
.title-logo { width: 128px; height: 128px; image-rendering: pixelated; }
#title-screen h1 { color: #ffe5bc; font-size: clamp(32px, 5vw, 64px); line-height: 1.1; margin: 20px 0; letter-spacing: -2px; }
.title-tagline { color: #edac73; font-size: 16px; line-height: 1.7; max-width: 430px; }
#title-screen .menu-actions { max-width: 350px; margin: 28px 0; }
#title-screen button { box-shadow: 4px 4px #101622; text-align: left; }
#title-screen .language-setting { max-width: 350px; }
#title-save-warning { color: #ffaba5; font-size: 13px; line-height: 1.5; }
#intro-screen { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
#intro-screen p { display: none; }
#intro-screen button { position: absolute; z-index: 1; right: 24px; bottom: 24px; font-size: 13px; background: #30252bdd; pointer-events: auto; }
.landing-active #pause-hint, .landing-active #build-button, .landing-active #night-overlay { display: none; }
#title-language-select { padding: 10px 12px; border: 2px solid #edac73; color: #ffe5bc; background: #17212d; font: inherit; }
#network-power-hud { margin: 0; font-size: 11px; grid-column: 1 / -1; }
#dev-mode-badge { margin: 0; padding: 5px 8px; grid-column: 1 / -1; border: 2px solid #94671d; color: #172635; background: #f4c54f; font-weight: bold; font-size: 11px; }
#equipment-power { line-height: 1.6; font-size: 12px; }
#equipment-water { line-height: 1.6; font-size: 12px; color: #96ceec; }
#excavators-panel { margin-top: 18px; padding-top: 12px; border-top: 2px solid #edac73; }
.excavator-row { padding: 12px 0; border-bottom: 2px solid #8a624c; }
.excavator-row p, .excavator-row label { font-size: 12px; line-height: 1.5; }
.excavator-row select { display: block; width: 100%; margin: 8px 0; padding: 8px; font: inherit; background: #172635; color: #ffe5bc; border: 2px solid #edac73; }
.excavator-row button, #create-excavator { font-size: 12px; padding: 10px; margin: 4px 4px 4px 0; }
[data-power="powerShortage"] { color: #b62f24; }
#equipment-power[data-power="powerShortage"] { color: #ffaba5; }
#network-power-hud[data-power="powerOnBattery"] { color: #865013; }
#equipment-power[data-power="powerOnBattery"] { color: #f4c54f; }
.front-end #pause-hint, .front-end #build-button, .front-end #night-overlay { display: none; }
@media (max-width: 600px) { #title-screen { padding: 24px; background-position: 65% center; } .title-logo { width: 96px; height: 96px; } }

.menu-title {
    margin: 0 0 24px;
    font-size: 30px;
    line-height: 1.1;
    text-transform: uppercase;
    text-shadow: 3px 3px #161b25;
}

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

.menu-actions button {
    min-height: 48px;
    padding: 12px;
    border: 2px solid #edac73;
    border-radius: 0;
    box-shadow: 4px 4px 0 #161b25;
    background: #844530;
    color: #fff0d4;
    font: bold 16px "Courier New", monospace;
    cursor: pointer;
}

.menu-actions button:hover, .menu-actions button:focus-visible {
    background: #ad593b;
    outline: 2px solid #fff0d4;
    outline-offset: 3px;
}

.menu-actions button:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #161b25;
}

.menu-actions button:disabled {
    opacity: 0.45;
    cursor: default;
}

#new-game {
    background: #3b3033;
}

.mission-status {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 2px solid #70504a;
    font-size: 13px;
    line-height: 1.6;
}

#zone-label, #save-status {
    display: block;
}

#save-status {
    color: #d8c7b4;
}

.controls-help {
    margin: 18px 0 0;
    color: #d8c7b4;
    font-size: 12px;
    line-height: 1.8;
}

kbd {
    color: #fff0d4;
    font: bold 12px "Courier New", monospace;
}
[hidden] { display: none !important; }

#build-button {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

#build-button img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#build-button:hover { transform: translateY(-2px); }
#build-button:focus-visible { outline: 3px solid #ffe5bc; outline-offset: 4px; }
#build-button:disabled { opacity: 0.45; cursor: default; }

#building-options button {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
}

#building-options img {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
}

#close-build-menu { margin-top: 20px; }

#build-placement {
    position: fixed;
    bottom: 46px;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
    width: min(560px, calc(100vw - 32px));
    padding: 14px;
    border: 2px solid #edac73;
    background: #30252bf2;
    color: #ffe5bc;
    font-size: 13px;
    text-align: center;
}

#build-placement p { margin: 0 0 10px; line-height: 1.5; }
#placement-status[data-valid="false"] { color: #ffaba5; }
#placement-status[data-valid="true"] { color: #98deb6; }
#build-placement .menu-actions { grid-template-columns: 1fr 1fr; gap: 12px; }
#build-placement button { font-size: 13px; }
#resource-hud {
    position: fixed;
    z-index: 2;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 32px;
    align-items: center;
    border-bottom: 4px solid #172635;
    box-shadow: inset 0 -3px #8d9da7;
    background: #c3cdd2;
    color: #172635;
    font-size: 12px;
    pointer-events: none;
}
.game-menu:not(#pause-menu) #resource-hud {
    position: static;
    margin-bottom: 24px;
    padding: 10px;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}
.resource-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 32px; }
.game-menu:not(#pause-menu) .resource-row { grid-template-columns: minmax(0, 1fr); }
#pause-menu {
    margin-top: calc(var(--pause-hud-height, 0px) + 20px);
    max-height: calc(100dvh - var(--pause-hud-height, 0px) - 40px);
}
.hud-icon svg { display: block; width: 32px; height: 32px; }
#food-bar { --bar-color: #8ab867; --bar-highlight: #badb97; }
#water-bar { --bar-color: #409cca; --bar-highlight: #a8e8ef; }
.resource-bar--pending { opacity: 0.45; }
.resource-card {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.resource-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.resource-heading > span { font-weight: bold; letter-spacing: 1px; }
.resource-heading strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.resource-card small { display: block; margin-top: 6px; color: #354d5d; }
.hud-icon { width: 32px; height: 32px; position: relative; }
.hud-icon--bag { box-sizing: border-box; margin-top: 5px; height: 26px; border: 4px solid #172635; background: #bd8855; box-shadow: inset 0 4px #edc78d; }
.hud-icon--bag::before { content: ''; position: absolute; left: 5px; top: -9px; width: 10px; height: 5px; border: 3px solid #172635; }
.transfer-row { padding: 8px 0; border-bottom: 2px solid #8a624c; }
.transfer-row p { font-size: 12px; }
.transfer-row button { padding: 7px; margin: 2px; font-size: 12px; }
.hud-icon--energy {
    background: #172635;
    clip-path: polygon(14px 0, 30px 0, 30px 4px, 26px 4px, 26px 8px, 22px 8px, 22px 12px, 30px 12px, 30px 16px, 26px 16px, 26px 20px, 22px 20px, 22px 24px, 18px 24px, 18px 28px, 14px 28px, 14px 32px, 6px 32px, 6px 24px, 10px 24px, 10px 20px, 2px 20px, 2px 12px, 6px 12px, 6px 8px, 10px 8px, 10px 4px, 14px 4px);
}
.hud-icon--energy::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #f4c54f;
    clip-path: polygon(16px 3px, 25px 3px, 25px 5px, 22px 5px, 22px 9px, 18px 9px, 18px 15px, 25px 15px, 25px 17px, 22px 17px, 22px 21px, 18px 21px, 18px 25px, 14px 25px, 14px 28px, 10px 28px, 10px 25px, 14px 25px, 14px 17px, 5px 17px, 5px 14px, 9px 14px, 9px 10px, 13px 10px, 13px 6px, 16px 6px);
}
.hud-icon--oxygen {
    display: grid;
    place-items: center;
    background: #172635;
    clip-path: polygon(8px 0, 24px 0, 24px 4px, 28px 4px, 28px 8px, 32px 8px, 32px 24px, 28px 24px, 28px 28px, 24px 28px, 24px 32px, 8px 32px, 8px 28px, 4px 28px, 4px 24px, 0 24px, 0 8px, 4px 8px, 4px 4px, 8px 4px);
}
.hud-icon--oxygen::before { content: ''; position: absolute; inset: 3px; background: #56bde2; clip-path: polygon(5px 0, 21px 0, 21px 3px, 26px 3px, 26px 23px, 21px 23px, 21px 26px, 5px 26px, 5px 23px, 0 23px, 0 3px, 5px 3px); }
.hud-icon--oxygen span { position: relative; font-size: 15px; font-weight: bold; color: #11212e; }
.resource-bar {
    height: 18px;
    padding: 4px;
    box-sizing: border-box;
    background: #111c26;
    clip-path: polygon(4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 0 calc(100% - 2px), 0 2px, 4px 2px);
}
.resource-fill { display: block; height: 100%; width: 0; background: var(--bar-color); box-shadow: inset 0 2px var(--bar-highlight); }
#energy-bar { --bar-color: #edba4c; --bar-highlight: #ffe19b; }
#oxygen-bar { --bar-color: #379fc6; --bar-highlight: #83d2ed; }
.resource-card[data-critical="true"] .resource-fill { --bar-color: #ce4b43; --bar-highlight: #f69180; }
.resource-card[data-critical="true"] strong { color: #9f2829; }
#mission-clock { margin: 0; padding-left: 20px; border-left: 2px solid #8d9da7; line-height: 1.7; font-weight: bold; font-variant-numeric: tabular-nums; }
#resource-warning { grid-column: 1 / -1; margin: 0; color: #9f2829; font-weight: bold; line-height: 1.5; }
.game-menu:not(#pause-menu) #mission-clock { padding: 6px 0 0; border-left: 0; border-top: 2px solid #8d9da7; }
@media (max-width: 820px) {
    #resource-hud { padding: 10px 12px; gap: 8px 16px; grid-template-columns: minmax(0, 1fr); }
    .resource-row { gap: 10px 16px; }
    #mission-clock { grid-column: 1 / -1; padding: 0; border: 0; text-align: center; }
    .game-menu:not(#pause-menu) #resource-hud { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
    #resource-hud { gap: 8px 12px; font-size: 10px; }
    .resource-card { gap: 6px; }
    .resource-heading { gap: 3px; }
    .resource-heading > span { letter-spacing: 0; }
    .resource-heading strong { font-size: 10px; }
    .resource-bar { height: 16px; }
}
#building-options small { display: block; font-size: 11px; font-weight: normal; line-height: 1.5; margin-top: 6px; }
.simulation-note { font-size: 11px; line-height: 1.6; color: #d8c7b4; }
.simulation-note a { color: #edac73; }
.language-setting { display: grid; gap: 8px; margin-top: 24px; font-size: 14px; }
#language-select { padding: 10px; min-width: 0; border: 2px solid #edac73; border-radius: 0; background: #30252b; color: #ffe5bc; font: inherit; }
#language-select:focus-visible { outline: 2px solid #fff0d4; outline-offset: 3px; }
#inventory-menu { width: min(580px, calc(100vw - 32px)); }
#inventory-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 0; margin: 20px 0; list-style: none; }
.inventory-slot { min-height: 72px; padding: 8px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; border: 2px solid #70504a; background: #211e26; box-shadow: inset 2px 2px #161b25; overflow-wrap: anywhere; font-size: 12px; }
.inventory-slot strong { align-self: flex-end; color: #edac73; font-size: 16px; }
@media (max-width: 420px) { #inventory-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#collection-hint { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 120px); box-sizing: border-box; padding: 12px 16px; border: 2px solid #edac73; background: #30252bf2; color: #ffe5bc; text-align: center; font-size: 13px; pointer-events: none; }
#collection-text { margin: 0; line-height: 1.5; }
#collection-progress { display: block; width: 100%; margin-top: 8px; height: 14px; accent-color: #edac73; }
#build-button, #pause-hint, #build-placement, #collection-hint { z-index: 1; }
#equipment-panel { position: fixed; z-index: 3; top: calc(var(--hud-height, 0px) + 16px); left: 50%; transform: translateX(-50%); max-height: calc(100dvh - var(--hud-height, 0px) - 32px); }
#equipment-status, #equipment-warning { line-height: 1.6; font-size: 13px; }
#equipment-warning { color: #ffaba5; }
#power-priority-select { padding: 10px; min-width: 0; border: 2px solid #edac73; border-radius: 0; background: #30252b; color: #ffe5bc; font: inherit; }
#power-priority-select:focus-visible { outline: 2px solid #fff0d4; outline-offset: 3px; }
#equipment-hint { position: fixed; z-index: 1; bottom: 44px; left: 50%; transform: translateX(-50%); padding: 12px 16px; border: 2px solid #edac73; background: #30252bf2; color: #ffe5bc; font-size: 13px; text-align: center; pointer-events: none; max-width: calc(100vw - 120px); }
#power-priority { grid-column: 1 / -1; margin: 0; font-size: 11px; }
#night-overlay { position: fixed; z-index: 1; left: 0; right: 0; bottom: 0; background: #0a1126; opacity: 0; pointer-events: none; }
.sleep-curtain { position: fixed; inset: 0; margin: 0; padding: 0; border: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; opacity: 0; }
.sleep-curtain::backdrop { background: transparent; }
#tutorial-card { position: fixed; z-index: 4; left: 16px; bottom: 62px; width: min(340px, calc(100vw - 32px)); padding: 16px; max-height: calc(100dvh - var(--hud-height, 0px) - 90px); }
#tutorial-card h2 { font-size: 17px; margin: 8px 0; }
#tutorial-card p, #tutorial-card summary { font-size: 12px; line-height: 1.5; }
#tutorial-clock { color: #98deb6; }
#tutorial-progress { color: #edac73; margin: 0; }
#tutorial-card button { font-size: 12px; padding: 9px; }
#tutorial-card details { margin: 10px 0; }
#tutorial-checklist { padding: 0; margin: 10px 0; list-style: none; font-size: 11px; line-height: 1.5; }
#tutorial-checklist li { margin: 4px 0; }
#tutorial-checklist [data-done="true"] { color: #98deb6; }
#tutorial-welcome { width: min(600px, calc(100vw - 32px)); }
#tutorial-welcome p { line-height: 1.6; }
.tutorial-target { outline: 3px solid #98deb6 !important; outline-offset: 3px; }
body:has(dialog[open]) #tutorial-card { visibility: hidden; }
@media (max-width: 1000px) {
    #tutorial-card { bottom: 6px; max-height: 190px; }
    body:has(#tutorial-card:not([hidden])) #equipment-panel { max-height: max(100px, calc(100dvh - var(--hud-height, 0px) - 230px)); }
}

/* Shared resource vocabulary: crisp pixel silhouettes, labels and gauges. */
.resource-symbol { display: inline-flex; width: 28px; height: 28px; flex: 0 0 28px; vertical-align: middle; filter: drop-shadow(2px 2px #171b24); }
.resource-symbol svg { display: block; width: 100%; height: 100%; }
.resource-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.stock-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stock-card { min-width: 0; padding: 10px; background: #211e26; border: 2px solid #70504a; display: flex; flex-direction: column; gap: 6px; }
.stock-label { font-size: 12px; color: #e9cba3; }
.stock-card strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.stock-card small { color: #c1b7ae; font-size: 11px; line-height: 1.5; }
.stock-card progress { appearance: none; width: 100%; height: 10px; border: 2px solid #101821; background: #101821; }
.stock-card progress::-webkit-progress-bar { background: #101821; }
.stock-card progress::-webkit-progress-value { background: #8bbda8; }
.stock-card progress::-moz-progress-bar { background: #8bbda8; }
.section-label { margin: 16px 0 8px; font-size: 13px; color: #edac73; }
.equipment-state { font-size: 12px; color: #bbd7b1; }
.equipment-help { margin: 12px 0; color: #c8b9ae; font-size: 12px; }
.equipment-help summary { cursor: pointer; padding: 8px 0; }
#equipment-panel { width: min(700px, calc(100vw - 32px)); box-sizing: border-box; }
#equipment-panel .transfer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 0; }
.transfer-heading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.transfer-heading > span:last-child { font-size: 12px; color: #c3b6ad; }
.transfer-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.transfer-direction { width: 100%; font-size: 11px; color: #d6bea1; margin-bottom: 4px; }
#equipment-panel .transfer-actions button { min-width: 44px; min-height: 40px; margin: 0; }
.resource-cost { display: inline-flex; flex-wrap: wrap; gap: 12px; }
.building-cost { display: flex; margin-top: 8px; color: #f0d1a4; font-weight: bold; }
.resource-cost .resource-symbol { width: 24px; height: 24px; flex-basis: 24px; }
#network-power-hud.stock-grid { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; }
#network-power-hud .stock-card { flex-direction: row; align-items: center; gap: 6px; padding: 0; background: transparent; border: 0; color: #263c4d; }
#network-power-hud .stock-label { font-size: 10px; color: inherit; gap: 4px; }
#network-power-hud .resource-symbol { width: 18px; height: 18px; flex-basis: 18px; }
#network-power-hud .stock-card strong { font-size: 11px; }
#network-power-hud .stock-card small { font-size: 10px; color: inherit; }
@media (max-width: 560px) {
    .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .power-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stock-card { padding: 8px; }
    .stock-label { font-size: 11px; gap: 4px; }
    .stock-card strong { font-size: 14px; }
    .transfer-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
}
.equipment-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
#equipment-panel .equipment-actions .menu-actions { margin: 0; }
.equipment-actions .menu-actions:has(> button[hidden]) { display: none; }
.equipment-actions button { width: 100%; height: 100%; padding: 10px; font-size: 12px; min-height: 44px; }
.equipment-actions .resource-label { justify-content: center; }
#create-excavator { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Let the placement ghost show through its controls when they overlap. */
#build-placement { transition: opacity 140ms ease; }
#build-placement.overlaps-preview { opacity: 0.3; }
#build-placement.overlaps-preview:hover,
#build-placement.overlaps-preview:focus-within { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    #build-placement { transition: none; }
}
#hazard-effects { position: fixed; left: 0; z-index: 2; pointer-events: none; image-rendering: pixelated; }
#hazard-banner { position: fixed; z-index: 4; top: calc(var(--hud-height, 0px) + 8px); right: 12px; width: min(360px, calc(100vw - 24px)); box-sizing: border-box; padding: 12px; border: 2px solid #eab06b; background: #30252bf2; color: #ffe5bc; font-size: 12px; }
#hazard-banner p { margin: 8px 0; line-height: 1.5; }
#hazard-banner details { margin-top: 8px; font-size: 10px; }
.hazard-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hazard-actions button { padding: 9px; font-size: 12px; }
#repair-hint { position: fixed; z-index: 3; bottom: 75px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px; background: #30252be6; border: 2px solid #edac73; color: #ffe5bc; font-size: 12px; }
.demolition-menu { margin: 18px 0; padding: 12px; border: 2px solid #b87569; }
.demolition-menu summary { cursor: pointer; color: #ffaba5; }
#demolition-options { margin-top: 12px; }
#placement-status > .resource-cost { margin-left: 8px; }
#placement-status > small { display: block; margin-top: 8px; }
#dev-menu { width: min(760px, calc(100vw - 24px)); }
#dev-controls fieldset { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; border: 2px solid #80624e; padding: 14px; }
#dev-controls legend { color: #f0c176; padding: 0 8px; }
#dev-controls label { display: flex; flex-direction: column; gap: 6px; flex: 1 1 140px; min-width: 0; font-size: 12px; }
#dev-controls input, #dev-controls select { box-sizing: border-box; min-width: 0; width: 100%; min-height: 38px; border: 2px solid #88634e; background: #211e26; color: #ffe5bc; padding: 8px; font: inherit; }
#dev-controls input[type="checkbox"] { width: 24px; height: 24px; min-height: 24px; accent-color: #e5b168; }
#dev-controls button { padding: 10px; font-size: 12px; min-height: 42px; }
#dev-mode-badge { cursor: pointer; text-align: left; }
/* Electricity: charge first, then separate input, load and balance. */
#equipment-power.power-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#equipment-power .stock-card:has(progress:not([hidden])) { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; align-items: center; border-color: #b59051; }
#equipment-power .stock-card:has(progress:not([hidden])) progress { grid-column: 1 / -1; height: 18px; }
#equipment-power .stock-card:has(progress:not([hidden])) small { grid-column: 1 / -1; }
.power-grid .stock-card progress::-webkit-progress-value { background: #d7b45e; }
.power-grid .stock-card progress::-moz-progress-bar { background: #d7b45e; }
.power-grid[data-power="powerShortage"] { border-left: 4px solid #e88475; padding-left: 8px; }
.power-grid[data-power="powerOnBattery"] .stock-card:last-child strong { color: #e5b86a; }
#network-power-hud .stock-card progress { width: 76px; height: 10px; }
#network-power-hud .stock-card:first-child small { color: inherit; }
@media (max-width: 560px) { #network-power-hud .stock-card small { display: none; } }
/* Resource hierarchy throughout the game: gauge, icon/label, secondary numbers. */
.stock-card > progress { order: -1; height: 18px; margin-bottom: 4px; }
.stock-card > strong { font-size: 13px; color: #d1c1ad; }
.stock-label { color: #f1d7b1; }
.resource-card .resource-bar { height: 18px; margin-bottom: 8px; }
.resource-heading { margin-top: 4px; margin-bottom: 0; }
.resource-heading strong { font-size: 11px; color: #354d5d; }
#equipment-power .stock-card:has(progress:not([hidden])) progress { grid-row: 1; }
#equipment-power .stock-card:has(progress:not([hidden])) strong { font-size: 13px; }
#network-power-hud .stock-card:has(progress:not([hidden])) { display: grid; grid-template-columns: auto auto; }
#network-power-hud .stock-card progress { grid-row: 1; grid-column: 1 / -1; width: 100%; min-width: 110px; height: 12px; margin: 0; }
#network-power-hud .stock-card small { grid-column: 1 / -1; }
#inventory-load, #equipment-growth { box-sizing: border-box; width: 100%; height: 22px; accent-color: #9bcf99; margin: 12px 0 4px; }
#inventory-capacity { font-size: 12px; color: #c3b4a3; }
#night-forecast { border: 2px solid #a58055; background: #211e26; padding: 12px; margin: 12px 0; }
#night-forecast h3 { margin: 0 0 8px; font-size: 13px; color: #edac73; }
#night-forecast p, #morning-report p { font-size: 13px; line-height: 1.6; }
#night-forecast small { color: #c6b6a7; line-height: 1.5; }
#oxygen-emergency { position: fixed; z-index: 6; pointer-events: none; left: 8%; right: 8%; top: calc(var(--hud-height, 0px) + (100dvh - var(--hud-height, 0px)) * 0.28); padding: 20px; text-align: center; color: #ff6960; text-shadow: 3px 3px #190c15, -1px -1px #190c15; background: #210d16b8; border: 3px solid #e75d55; box-shadow: 0 0 0 4px #210d1666; animation: oxygen-emergency-pulse 1.5s ease-in-out infinite; }
#oxygen-emergency h2 { font-size: clamp(26px, 5vw, 68px); margin: 0 0 12px; }
#oxygen-emergency p { font-size: clamp(13px, 1.6vw, 22px); line-height: 1.5; margin: 8px 0; }
#oxygen-emergency-countdown { font-weight: bold; }
@keyframes oxygen-emergency-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { #oxygen-emergency { animation: none; } }
#building-options { display: block; }
.construction-categories { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
#building-options .construction-categories button { flex: 1 1 auto; padding: 10px; min-height: 42px; font-size: 12px; justify-content: center; text-align: center; }
#building-options .construction-categories button[aria-pressed="true"] { background: #d39b65; color: #211e26; border-color: #ffe5bc; }
#building-options section h3 { font-size: 14px; color: #edac73; margin: 12px 0; }
#hazard-banner.hazard-banner-left { right: auto; left: 12px; }
#studio-skip { position: absolute; right: 24px; bottom: 24px; background: transparent; color: #aaa; border: 1px solid #555; padding: 10px 14px; font: inherit; font-size: 12px; cursor: pointer; }
#studio-skip:hover, #studio-skip:focus-visible { color: #fff; border-color: #fff; }
/* Chromium visual audit: restore HUD contrast and keep construction controls in view. */
#network-power-hud .stock-card strong { color: #172635; }
#build-menu { width: min(720px, calc(100vw - 24px)); }
#build-menu #resource-hud { margin-bottom: 16px; }
#build-menu #resource-hud .resource-card small { display: none; }
#build-menu.game-menu .resource-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
#build-menu #resource-hud .resource-card { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; }
#build-menu #resource-hud .hud-icon { transform: scale(0.75); transform-origin: left center; }
@media(max-width: 420px){
    #build-menu { padding: 16px; }
    #build-menu .resource-heading > span { font-size: 9px; letter-spacing: 0; }
    #build-menu .resource-heading strong { font-size: 9px; }
}
.title-studio-logo { position: absolute; right: 24px; bottom: 20px; width: 104px; height: auto; opacity: 0.72; image-rendering: pixelated; pointer-events: none; }
@media (max-width: 600px), (max-height: 600px) {
    .title-studio-logo { position: relative; right: auto; bottom: auto; justify-self: end; width: 72px; margin-top: 12px; }
}
#dev-mode-badge { pointer-events: auto; }

/* Multi-touch controls retain the same square, pixel-art language as menus. */
#touch-controls { position:fixed; inset:auto 0 env(safe-area-inset-bottom,0px); z-index:15; display:flex; justify-content:space-between; align-items:end; padding:10px; gap:12px; pointer-events:none; user-select:none; -webkit-user-select:none; }
#touch-controls[hidden] { display:none; }
#touch-controls button { pointer-events:auto; touch-action:none; min-width:44px; min-height:44px; border:2px solid #e8b17b; background:rgba(64,40,39,.82); color:#ffe5bc; font: bold 12px monospace; padding:5px; border-radius:0; }
#touch-controls button.held { background:#b77a49; }
.touch-pad { display:grid; grid-template-columns:repeat(3,44px); grid-template-rows:repeat(2,44px); gap:3px; }
.touch-pad button:first-child { grid-column:2; }
.touch-pad button:nth-child(2) { grid-row:2;grid-column:1; }
.touch-pad button:nth-child(3) { grid-row:2;grid-column:2; }
.touch-pad button:nth-child(4) { grid-row:2;grid-column:3; }
.touch-actions { display:grid;grid-template-columns:repeat(2,minmax(44px,88px));gap:3px; }
.touch-enabled #pause-hint { display:none; }
.touch-enabled #build-button { bottom:calc(160px + env(safe-area-inset-bottom,0px)); }
.touch-enabled #build-placement { bottom:calc(160px + env(safe-area-inset-bottom,0px)); max-height:45dvh; overflow:auto; }
@media (max-height:500px) { .touch-actions { grid-template-columns:repeat(3,minmax(44px,80px)); } .touch-enabled #build-button { bottom:110px; } .touch-enabled #build-placement { bottom:110px; } }
.touch-enabled #equipment-hint, .touch-enabled #repair-hint, .touch-enabled #collection-hint { bottom:170px; }
.touch-enabled #equipment-panel { max-height:calc(100dvh - var(--hud-height,0px) - 180px); overflow-y:auto; }
.touch-enabled #tutorial-card { bottom:170px; max-height:calc(100dvh - var(--hud-height,0px) - 190px); overflow-y:auto; }
@media (max-height:500px) {
    .touch-enabled #equipment-hint, .touch-enabled #repair-hint, .touch-enabled #collection-hint { bottom:110px; }
    .touch-enabled #equipment-panel { max-height:calc(100dvh - var(--hud-height,0px) - 120px); }
    .touch-enabled #tutorial-card { bottom:110px; max-height:calc(100dvh - var(--hud-height,0px) - 130px); }
}

/* Mobile-only density. No global desktop dimensions are overridden here. */
body.mobile-ui { --touch-clearance:110px; }
.mobile-ui #resource-hud,
.mobile-ui .game-menu #resource-hud {
    padding:6px 8px; gap:4px 8px; font-size:10px;
    grid-template-columns:minmax(0,1fr); margin-bottom:0;
}
.mobile-ui #resource-hud .resource-row,
.mobile-ui .game-menu #resource-hud .resource-row { grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px 12px; }
.mobile-ui #resource-hud .resource-card { grid-template-columns:20px minmax(0,1fr); gap:4px; }
.mobile-ui #resource-hud .hud-icon { transform:scale(.625); transform-origin:left center; }
.mobile-ui #resource-hud .resource-card small,
.mobile-ui #resource-hud #power-priority { display:none; }
.mobile-ui #resource-hud .resource-bar { height:10px; padding:2px; margin:0; }
.mobile-ui #resource-hud .resource-heading { flex-wrap:nowrap; gap:4px; margin:2px 0 0; font-size:9px; }
.mobile-ui #resource-hud .resource-heading > span { letter-spacing:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mobile-ui #resource-hud .resource-heading strong { font-size:9px; flex-shrink:0; }
.mobile-ui #resource-hud #mission-clock { font-size:10px; line-height:1.2; padding:0; border:0; text-align:center; }
.mobile-ui #resource-hud #network-power-hud { gap:3px 10px; font-size:9px; }
.mobile-ui #network-power-hud .stock-card { gap:3px; }
.mobile-ui #network-power-hud .stock-label { font-size:9px; }
.mobile-ui #network-power-hud .stock-card strong { font-size:10px; }
.mobile-ui #network-power-hud .stock-card small { display:none; }
.mobile-ui #network-power-hud .stock-card progress { min-width:65px; height:6px; }
.mobile-ui #network-power-hud .resource-symbol { width:14px; height:14px; flex-basis:14px; }
.mobile-ui #resource-warning { font-size:10px; line-height:1.2; }
.mobile-ui #touch-controls { padding:6px; gap:6px; }
.mobile-ui .touch-actions { grid-template-columns:repeat(3,minmax(0,64px)); gap:3px; max-width:calc(100vw - 153px); }
.mobile-ui #touch-controls button { font-size:10px; padding:3px; overflow-wrap:anywhere; }
.mobile-ui #build-button { width:44px; height:44px; right:8px; bottom:calc(var(--touch-clearance) + env(safe-area-inset-bottom,0px)); }
.mobile-ui #build-placement { width:calc(100vw - 16px); padding:8px; bottom:calc(var(--touch-clearance) + env(safe-area-inset-bottom,0px)); max-height:35dvh; font-size:11px; }
.mobile-ui #build-placement p { margin-bottom:5px; }
.mobile-ui #build-placement .menu-actions { gap:8px; }
.mobile-ui #build-placement button { font-size:12px; }
.mobile-ui .game-menu { padding:12px; border-width:2px; width:min(600px,calc(100vw - 16px)); max-height:calc(100dvh - 16px); box-shadow:0 0 0 2px #161b25; }
.mobile-ui .menu-title { font-size:22px; margin-bottom:12px; }
.mobile-ui .mission-label { font-size:10px; letter-spacing:1px; margin-bottom:6px; }
.mobile-ui .game-logo { width:40px; height:40px; margin-bottom:8px; }
.mobile-ui .menu-actions { gap:8px; }
.mobile-ui .menu-actions button { min-height:44px; padding:8px; font-size:13px; box-shadow:2px 2px #161b25; }
.mobile-ui .language-setting { margin-top:12px; gap:6px; font-size:12px; }
.mobile-ui .language-setting:has(input[type="checkbox"]) { display:flex; align-items:center; min-height:44px; }
.mobile-ui input[type="checkbox"] { width:22px; height:22px; flex-shrink:0; }
.mobile-ui .controls-help, .mobile-ui .simulation-note { margin-top:10px; font-size:11px; line-height:1.45; }
.mobile-ui .mission-status { margin-top:12px; padding-top:8px; font-size:11px; }
.mobile-ui #pause-menu { margin-top:calc(var(--pause-hud-height,0px) + 8px); max-height:calc(100dvh - var(--pause-hud-height,0px) - 16px); }
.mobile-ui #build-menu #resource-hud { margin-bottom:10px; }
.mobile-ui #building-options button { gap:8px; }
.mobile-ui #building-options img { width:40px; height:40px; object-fit:contain; flex-shrink:0; }
.mobile-ui #building-options small { font-size:10px; line-height:1.3; margin-top:3px; }
.mobile-ui .building-cost { margin-top:4px; }
.mobile-ui .construction-categories { gap:5px; margin-bottom:8px; }
.mobile-ui #building-options .construction-categories button { padding:6px; font-size:11px; min-height:44px; }
.mobile-ui #building-options section h3 { margin:8px 0; font-size:12px; }
.mobile-ui #close-build-menu { margin-top:12px; }
.mobile-ui #inventory-slots { gap:6px; margin:10px 0; grid-template-columns:repeat(3,minmax(0,1fr)); }
.mobile-ui .inventory-slot { min-height:52px; padding:6px; gap:4px; font-size:11px; }
.mobile-ui .inventory-slot strong { font-size:13px; }
.mobile-ui .resource-symbol { width:22px; height:22px; flex-basis:22px; }
.mobile-ui #equipment-panel { top:calc(var(--hud-height,0px) + 6px); max-height:calc(100dvh - var(--hud-height,0px) - var(--touch-clearance) - 12px); overflow-y:auto; }
.mobile-ui .stock-grid { gap:5px; margin:8px 0; }
.mobile-ui .stock-card { padding:6px; gap:4px; }
.mobile-ui .stock-card > progress { height:10px; margin-bottom:0; }
.mobile-ui #equipment-power .stock-card:has(progress:not([hidden])) progress { height:10px; }
.mobile-ui .stock-label, .mobile-ui .stock-card strong { font-size:11px; }
.mobile-ui #equipment-status, .mobile-ui #equipment-warning { font-size:11px; }
.mobile-ui #equipment-panel .transfer-row { gap:6px; padding:8px 0; }
.mobile-ui #equipment-panel .transfer-actions button { min-height:44px; }
.mobile-ui .section-label { margin:10px 0 6px; font-size:12px; }
.mobile-ui #tutorial-card { left:8px; width:calc(100vw - 16px); bottom:calc(var(--touch-clearance) + env(safe-area-inset-bottom,0px)); max-height:min(180px,calc(100dvh - var(--hud-height,0px) - var(--touch-clearance) - 16px)); }
.mobile-ui #tutorial-card h2 { font-size:15px; margin:5px 0; }
.mobile-ui #tutorial-card p { font-size:11px; margin:6px 0; }
.mobile-ui #equipment-hint, .mobile-ui #repair-hint, .mobile-ui #collection-hint { bottom:calc(var(--touch-clearance) + env(safe-area-inset-bottom,0px)); padding:6px 8px; font-size:11px; max-width:calc(100vw - 24px); }
.mobile-ui #hazard-banner { right:8px; width:min(320px,calc(100vw - 16px)); padding:8px; font-size:11px; }
.mobile-ui #oxygen-emergency { padding:10px; left:4%; right:4%; }
.mobile-ui #title-screen { padding:16px; }
.mobile-ui .title-content { padding:10px 0; }
.mobile-ui .title-logo { width:72px; height:72px; }
.mobile-ui #title-screen h1 { font-size:32px; margin:12px 0; }
.mobile-ui .title-tagline { font-size:13px; line-height:1.4; }
.mobile-ui #title-screen .menu-actions { margin:16px 0; }
@media (orientation:landscape) {
    .mobile-ui #resource-hud .resource-row { grid-template-columns:repeat(4,minmax(0,1fr)); }
    .mobile-ui #resource-hud { grid-template-columns:auto 1fr; }
    .mobile-ui #resource-hud .resource-row { grid-column:1 / -1; }
    .mobile-ui #resource-hud #mission-clock { grid-column:auto; }
    .mobile-ui #resource-hud #network-power-hud { grid-column:auto; justify-content:flex-end; }
    .mobile-ui #inventory-slots { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
.transport-route { min-width:0; margin:10px 0; padding:10px; border:2px solid #70504a; }
.transport-route legend { color:#edac73; font-size:12px; }
.transport-route p { color:#edac73; }
.industry-controls { margin:10px 0; }
