/* Dark anodized metal, beveled edges and status lights. */
#app > header {
 display:grid;grid-template-columns:minmax(135px,1fr) auto minmax(54px,1fr);
 align-items:start;gap:8px;height:auto;padding:7px max(12px,var(--hud-right)) 7px max(12px,var(--hud-left));
 pointer-events:none;
}
#app > header button {pointer-events:auto}
.hud-resource-bank {position:relative;display:grid;justify-items:center;gap:8px}
#app > header .resources {margin:0;gap:clamp(6px,2cqw,24px);padding:0}
#app :is(header,aside,footer,.hud-waves) button:not(.resource-open),.clean-skin #panelBody button {
 border:1px solid #526878;border-top-color:#82939b;border-bottom-color:#263744;
 box-shadow:inset 0 1px #e2eff123,inset 0 -2px #02081077,0 2px 5px #0007;
}
#app :is(header,aside,footer,.hud-waves) button:not(.resource-open) {
 background:linear-gradient(150deg,#2f3c46,#14232e 46%,#0a141d 52%,#192a35);
 color:#cfe1e8;border-radius:4px;
}
#app :is(header,aside,footer,.hud-waves) button:not(.resource-open):hover,.clean-skin #panelBody button:not(:disabled):hover {
 border-color:#80b8bc;filter:brightness(1.15);
}
#app :is(header,aside,footer,.hud-waves) button:not(.resource-open):active,.clean-skin #panelBody button:not(:disabled):active {
 translate:0 1px;box-shadow:inset 0 2px 6px #000c;
}
#app button[hidden],#hudWaves[hidden] {display:none!important}

#app > header .commander {
 width:min(100%,225px);min-width:0;display:grid;grid-template-columns:auto minmax(0,1fr);
 gap:8px;align-items:center;min-height:62px;padding:5px 9px;text-align:left;
}
.hud-portrait {position:relative;display:block;width:44px;height:44px}
#hudAvatar {display:block;width:100%;height:100%;object-fit:cover;border:1px solid #788f99;border-radius:4px}
#hudLeagueEmblem {
 position:absolute;right:-4px;bottom:-4px;width:23px;height:23px;pointer-events:none;
}
.hud-commander-row {display:grid;grid-template-columns:minmax(0,1fr) 83px;gap:6px}
.hud-commander-meta {display:grid;min-width:0;gap:4px}
#app > header .commander .hud-commander-meta > strong {
 font:700 clamp(12px,2.3cqw,17px)/1.1 system-ui,sans-serif;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
#hudCommanderPower {
 display:grid;place-content:center;justify-items:center;gap:4px;min-width:0;padding:5px;
 text-align:center;white-space:nowrap;
}
#hudCommanderPower small {color:#b8c9d2;font:600 12px/1.1 system-ui,sans-serif}
#hudCommanderPower #power {font:700 17px/1.1 system-ui,sans-serif;font-variant-numeric:tabular-nums}
#hudCommander #hudCommanderRank {
 color:#b8c9d2;font:600 12px/1.2 system-ui,sans-serif;letter-spacing:0;
 white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
#hudCommander[data-league="bronze"] {--league-color:#cd9870}
#hudCommander[data-league="silver"] {--league-color:#a9c5d8}
#hudCommander[data-league="gold"] {--league-color:#f0ca73}
#hudCommander[data-league="platinum"] {--league-color:#8fdbd4}
#hudCommander[data-league="diamond"] {--league-color:#b19aef}
#hudCommander[data-league="command"] {--league-color:#eeac6f}
#hudCommander[data-league="heroes"] {--league-color:#ffe099}
#app #hudMapToggle {
 justify-self:end;display:grid;place-items:center;overflow:hidden;width:54px;height:54px;min-width:54px;
 padding:3px;border-radius:50%;background:radial-gradient(circle,#0d2033 62%,#82939b 70%,#263744 79%);
}
#hudMapArt {width:46px;height:46px;object-fit:contain;filter:drop-shadow(0 0 3px #88dfff9c)}
#app[data-galaxy=false] #hudMapArt {animation:hud-orbit 35s linear infinite}
@keyframes hud-orbit {to {rotate:1turn}}
@media(prefers-reduced-motion:reduce) {#app[data-galaxy=false] #hudMapArt {animation:none}}
#hudBoosts {display:flex;gap:5px}
#app #hudBoosts .hud-boost {
 display:flex;align-items:center;justify-content:center;gap:4px;min-width:36px;min-height:30px;
 padding:3px 6px;background:rgba(8,18,32,.88);
 box-shadow:inset 0 1px #9fbdc2,inset 0 -2px #020610,inset 0 0 0 2px #374b59,0 2px 4px #0009;
}
.hud-boost img {width:19px;height:19px;object-fit:contain;filter:drop-shadow(0 0 3px #77e8df72)}
#app #hudBoosts .hud-boost.active {border-color:#6ce4da;box-shadow:inset 0 0 9px #73cbb345,0 0 7px #59f7dd60}
.hud-boost time,.hud-wave time {font:700 9px/1 ui-monospace,monospace;white-space:nowrap;color:#9ce5e0;font-variant-numeric:tabular-nums}
#app #hudBoosts .hud-aggression {flex-direction:column;gap:2px;color:#ffd39c;font-size:9px;box-shadow:inset 0 0 0 1px #d98a50}
#app #hudBoosts .hud-aggression time {color:inherit}
.hud-boost-detail {max-width:420px;margin:auto;text-align:center}
.hud-boost-detail > img {width:52px;height:52px;object-fit:contain}
.hud-boost-detail .stat {margin-bottom:8px}

#app .hud-profile-stack > aside {left:max(11px,var(--hud-left));top:138px;display:grid;gap:4px;align-content:start}
#gameSurface #app :is(#hudWaves,#galaxyFlights) {
 position:absolute;z-index:24;right:var(--unity-hud-right,max(8px,var(--hud-right)));
 width:168px;max-height:var(--flight-list-space,0px);zoom:1;
 overflow:hidden auto;overscroll-behavior:contain;touch-action:pan-y;scroll-behavior:smooth;
}
#gameSurface #app #hudWaves {display:grid;gap:2px;pointer-events:auto!important}
#gameSurface.hud-phone #app :is(#hudWaves,#galaxyFlights) {
 max-height:min(254px,var(--flight-list-space,0px));
 max-height:clamp(0px,calc(round(down,var(--flight-list-space,0px) + 2px,32px) - 2px),254px);
}
.force-landscape #gameSurface #app :is(#hudWaves,#galaxyFlights) {touch-action:none}
#app:has(#galaxy:not([hidden]) #galaxyFlights:not([hidden])) #hudWaves {margin-right:172px}
#app:has(#galaxy:not([hidden]) #galaxyFlights:not([hidden])) #hudWaves > :not(.hud-rally-invite) {display:none}
#app:has(#galaxy:not([hidden]) #galaxyFlights:not([hidden])) #hudWaves:not(:has(.hud-rally-invite)) {display:none}
#app.building-view :is(#hudWaves,#hudBoosts) {visibility:hidden}
.hud-flight-row {display:flex;gap:2px;min-width:0}
#galaxyFlightCards {gap:2px}
#gameSurface #app :is(#hudWaves,#galaxyFlightCards) .compact-flight-entry {
 display:flex;align-items:center;gap:4px;flex:1;min-width:0;min-height:30px;height:30px;
 padding:0 4px;font:700 12px/1 system-ui,sans-serif;color:#def2fd;
 text-align:left;white-space:nowrap;
}
#app #hudWaves .compact-flight-entry {background:#0b1824eb;border:1px solid #344a58}
.compact-flight-entry :is(.compact-flight-phase,.compact-flight-target) {display:grid;place-items:center;flex:none}
.compact-flight-phase {width:17px;height:20px;color:#ffb096;border-bottom:2px solid currentColor;font-size:16px}
.compact-flight-phase[data-flight-phase="gathering"] {color:#ffd070}
.compact-flight-phase[data-flight-phase="return"] {color:#82dcf7}
.compact-flight-phase[data-flight-phase="spy"] {color:#c6a5ff}
.compact-flight-phase:is([data-flight-phase="recycle"],[data-flight-phase="mining"]) {color:#e4d58a}
.compact-flight-phase[data-flight-phase="reinforce"] {color:#93ebaf}
.compact-flight-phase[data-flight-phase="transport"] {color:#7de6dc}
.compact-flight-phase img {width:15px;height:15px;object-fit:contain}
.compact-flight-target {position:relative;width:27px;height:26px}
.compact-flight-target img {width:26px;height:26px;object-fit:contain}
.compact-flight-level {
 position:absolute;right:-1px;bottom:0;min-width:13px;padding:1px 2px;text-align:center;
 color:#fff0bc;background:#172337;border:1px solid #d9b570;border-radius:3px;font:800 11px/1 system-ui,sans-serif;
}
.compact-flight-name {min-width:0;overflow:hidden;text-overflow:ellipsis}
.compact-flight-entry :is(time,.compact-flight-count) {
 flex:none;margin-left:auto;white-space:nowrap;font-size:12px;color:#b1eef8;font-variant-numeric:tabular-nums;
}
.flight-card-list>.flight-card.rally-organizer,#app #hudWaves .rally-organizer {
 border-color:#d9a64d;background:linear-gradient(#b77b212e,#b77b212e),var(--bg);
}
.rally-flight-status {flex:none;color:#ffd070;font:700 10px/1 system-ui,sans-serif;white-space:nowrap}
#gameSurface #app :is(#hudWaves,#galaxyFlightCards) .compact-flight-entry:has(.rally-flight-status) {gap:3px;padding-inline:3px}
:is(#hudWaves,#galaxyFlightCards) .rally-waiting {width:min-content;white-space:normal}
.rally-flight-clocks {
 display:grid;gap:1px;flex:none;margin-left:auto;color:#b1eef8;
 font:700 11px/1 system-ui,sans-serif;font-variant-numeric:tabular-nums;white-space:nowrap;
}
.compact-flight-entry .rally-flight-clocks time {font-size:inherit}
:is(#hudWaves,#galaxyFlightCards) .rally-flight-clocks {font-size:10px}
#app :is(#hudWaves,#galaxyFlightCards) :is(.hud-flight-recall,.flight-recall-button) {
 order:-1;display:grid;place-items:center;flex:0 0 27px;width:27px;min-width:0;min-height:0;padding:0;
}
.hud-recall-icon {position:relative;width:18px;height:18px;pointer-events:none}
.hud-recall-icon::before,.hud-recall-icon::after {content:"";position:absolute}
.hud-recall-icon::before {inset:5px 1px 4px 3px;border:2px solid currentColor;border-left:0;border-radius:0 6px 6px 0}
.hud-recall-icon::after {top:3px;left:1px;width:6px;height:6px;border-left:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg)}
#galaxyFlightCards .flight-recall-button img {width:18px;height:18px;object-fit:contain}
#app #hudWaves .hud-rally-invite {border-color:#688f89}
#notification-zone {
 position:fixed;z-index:201;display:grid;justify-items:center;gap:4px;
 pointer-events:none;
 font:700 12px/1.25 system-ui,sans-serif;
}
.notification-pill {
 display:flex;align-items:center;gap:.65em;min-height:26px;max-width:100%;
 padding:3px 8px;border:1px solid #5f98b4;border-radius:7px;background:#102e44;color:#e1f5ff;
}
#notification-zone [hidden] {display:none}
#attackAlert {color:#ffc0cb;background:#320d1b;border-color:#b53357;text-shadow:0 1px 3px #120309}
#attackAlert b {font-variant-numeric:tabular-nums;white-space:nowrap}
#toast {display:block;max-width:min(100%,320px);text-align:center;overflow-wrap:anywhere}
#privateNotification {max-width:min(100%,320px);padding:0;gap:0;min-width:0}
#privateNotification button {
 display:flex;align-items:center;gap:6px;min-width:0;min-height:26px;
 padding:3px 8px;border:0;background:transparent;box-shadow:none;color:inherit;
 font:inherit;letter-spacing:normal;text-transform:none;pointer-events:auto;touch-action:manipulation;
}
#privateNotification button:focus-visible {outline:2px solid var(--cyan);outline-offset:-2px}
#privateNotificationName,#privateNotificationText {overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#privateNotificationName {flex:0 1 auto;max-width:105px}
#privateNotificationText {color:#bbd3e2}
#privateNotificationDismiss {flex:none}

#app > footer {
 display:flex;align-items:flex-end;justify-content:space-between;gap:8px;padding:8px max(12px,var(--hud-right)) 8px max(12px,var(--hud-left));height:62px;
}
#app > footer nav {display:flex;gap:4px;min-width:0;flex:none}
#app > footer nav button {width:clamp(44px,8cqw,86px);height:46px;min-height:44px;min-width:44px;padding:2px;flex:none}
#app > footer nav button span {font:700 clamp(7px,1.3cqw,10px)/1.15 system-ui,sans-serif;letter-spacing:0;margin:0;white-space:nowrap}
#app > footer nav button img {width:21px;height:21px}
.hud-comms {position:relative;display:grid;align-items:end;flex:0 1 322px;min-width:0}
#app #chat-hud {
 position:relative;width:100%;height:46px;display:flex;gap:6px;align-items:center;text-align:left;padding:4px 7px;min-width:0;
}
.hud-chat > img {width:21px;height:21px;object-fit:contain;flex:none}
.hud-chat-copy {min-width:0;display:grid;gap:3px;font:600 10px/1.05 system-ui,sans-serif}
.hud-chat-meta {display:flex;align-items:center;gap:4px;min-width:0}
#hudChatChannel {border:1px solid #446a74;border-radius:2px;padding:1px 3px;color:#b3e8e2}
#hudChatAuthor,#hudChatText {display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-hud-count {position:absolute;right:3px;top:3px;font-size:8px}
#app > footer #quest-hud {
 position:absolute;bottom:calc(100% + 4px);left:0;width:max-content;max-width:100%;height:44px;min-height:44px;padding:4px 7px;
}
#app > footer #quest-hud img {width:22px;height:22px}
#app > footer #quest-hud.quest-reward-ready {border-color:#65f7de;box-shadow:0 0 9px #52eaca99,inset 0 0 8px #57edc345}
#app > footer #quest-hud .quest-hud-copy {display:grid;min-width:0}
#app > footer #quest-hud .quest-hud-copy small {margin:0}
#app > footer #quest-hud .quest-hud-copy b {display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:9px}

/* Solid bevels, brushed grain and machined notches share the button's background. */
#app :is(header .commander,footer #chat-hud,footer nav button) {
 --steel-rim:#8ca3b0;
 --steel-face:#253d4b;
 --steel-notches:repeating-linear-gradient(115deg,#94aebc 0 2px,#08121c 2px 4px);
 clip-path:polygon(7px 0,calc(100% - 7px) 0,100% 7px,100% calc(100% - 7px),calc(100% - 7px) 100%,7px 100%,0 calc(100% - 7px),0 7px);
 border:1px solid var(--steel-rim);
 border-radius:0;
 background:
  var(--steel-notches) center top / 18px 3px no-repeat,
  var(--steel-notches) center bottom / 18px 3px no-repeat,
  repeating-linear-gradient(178deg,#d3e9ff07 0 1px,#0002 1px 2px,#0000 2px 4px),
  linear-gradient(162deg,#4a6070 0%,var(--steel-face) 39%,#14232f 55%,#0a131d 70%,#273d4d 100%);
 box-shadow:inset 0 0 0 1px #040d15,inset 0 0 0 3px #6e889960,inset 0 3px #c1d1da55,inset 0 -4px #07111b;
}
#app :is(header .commander,footer #chat-hud,footer nav button):is(:hover,:active,:focus-visible) {
 --steel-rim:#9cfaf1;
 --steel-face:#276f75;
 border-color:var(--steel-rim);
 color:#edfffe;
 box-shadow:inset 0 0 0 1px #031924,inset 0 0 0 3px #79e6dd8c,inset 0 0 12px #37ffed73;
}
@container game-frame (max-height:430px) {
 .source-skin #app > header .resources > div {padding-block:0}
 #app header .resources .resource-open {min-height:38px}
 #hudBoosts {translate:calc(43px - 50%) 0}
 #app #hudBoosts .hud-boost {min-width:32px;padding-inline:4px}
 #app .hud-profile-stack > aside {top:105px;gap:1px}
}

.chat-overlay #chat-stream {touch-action:pan-y;overscroll-behavior:contain}
.chat-overlay #chat-screen {touch-action:pan-y}

.commander-summary-card {display:flex;align-items:center;gap:12px;padding:8px 12px;background:#111f2c;border:1px solid #576b77;border-radius:4px}
.commander-summary-card > .league-insignia {width:53px;height:53px;flex:none}
.commander-summary-card > div {display:grid;gap:4px}
.commander-summary-card small {color:#a6d6d3}
.commander-combat {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;text-align:center;margin:8px 0}
.commander-combat div {padding:6px;background:#071724;border:1px solid #304451}
.commander-combat dd {margin:4px 0 0;color:#9fe9d9;font-weight:700}
.commander-avatars {display:flex;gap:7px;margin:8px 0}
#panelBody .commander-avatars button {width:52px;height:52px;padding:2px}
.commander-avatars img {display:block;width:100%;height:100%;object-fit:cover}
.clean-skin #panelBody .commander-avatars button[aria-pressed=true] {border-color:#6cf5da;box-shadow:0 0 7px #6cf5da88}

.inventory-toolbar .inventory-tab[aria-pressed=true] {border-color:#71dccd!important;background:#23454d!important}
/* Galaxy controls sit below the commander profile. */
.hud-profile-stack {display:grid;justify-items:start;gap:3px;min-width:0}
#app .galaxy-toolbar {position:static;display:none;width:max-content;max-width:100%;gap:2px}
#app[data-galaxy=true] .galaxy-toolbar {display:flex}
#app .galaxy-toolbar button {
 min-width:0;min-height:29px;height:29px;padding:3px 4px;
 font:700 9px/1 system-ui,sans-serif;white-space:nowrap;
}
#app .galaxy-toolbar #galaxyCenter {font-variant-numeric:tabular-nums}
@container game-frame (max-height:430px) {
 #app[data-galaxy=true] .hud-profile-stack > aside {top:108px}
}

/* Threat overlays stay outside the galaxy layout. */
#app.under-attack::after {
 position:absolute;inset:0;z-index:4;pointer-events:none;content:"";
 box-shadow:inset 0 0 34px 3px #ff3659;
 animation:threat-pulse 1.8s ease-in-out infinite alternate;
}
@keyframes threat-pulse {from{opacity:.3}to{opacity:.85}}
@media (prefers-reduced-motion:reduce) {
 #app.under-attack::after {animation:none;opacity:.6}
}
#app #hudWaves .hostile .hud-wave,.flight-card.hostile {border-color:#fa536e;color:#ffc0c9;background:#39101f}
#app #hudWaves .ally-threat .hud-wave,.flight-card.ally-threat {border-color:#f6aa4d;color:#ffd392;background:#35230e}
.hud-flight-row.hostile time,.flight-card.hostile [data-ends]{color:#ff9caf}
.hud-flight-row.ally-threat time,.flight-card.ally-threat [data-ends]{color:#ffc675}
#reportsCount:not([hidden]) {background:#a8203c;color:#fff;padding:1px 4px;border-radius:5px;font-style:normal}
#reportsCount[hidden] {display:none}
/* HUD controls use reference dimensions before the shared scene scale is applied. */
#app > footer {height:90px}
#app > footer nav button {width:104px;height:70px;min-height:70px}
#app > footer nav button img {width:32px;height:32px}
#app > footer nav button span {font-size:14px}
#app #chat-hud {height:70px}
#app #hudMapToggle {width:76px;height:76px;min-width:76px}
#app > header .commander {width:min(100%,320px);min-height:84px}
#app > header .commander .hud-commander-meta > strong {font-size:23px}
#app > header .hud-portrait {width:60px;height:60px}
#app > header .hud-resource-bank .resource-open {min-height:58px}
#app #hudBoosts .hud-boost {min-width:54px;min-height:48px}
/* Each timed effect is a liquid charge cell; its level follows the server clock. */
#app #hudBoosts .hud-boost {position:relative;isolation:isolate;overflow:hidden}
#app #hudBoosts .hud-boost > img {position:relative;z-index:1;pointer-events:none}
#app #hudBoosts .hud-boost:has(.effect-charge) > img {align-self:center;translate:0 -5px}
.effect-charge {
 --effect-color:#68e3dd;position:absolute;inset:4px;overflow:hidden;
 border:1px solid color-mix(in srgb,var(--effect-color) 45%,transparent);
 border-radius:3px;background:#02101b99;pointer-events:none;
}
.effect-liquid {
 position:absolute;inset:auto 0 0;height:var(--effect-fill);min-height:0;
 background:linear-gradient(0deg,color-mix(in srgb,var(--effect-color) 48%,transparent),color-mix(in srgb,var(--effect-color) 24%,transparent));
 border-top:1px solid var(--effect-color);box-shadow:0 -1px 5px color-mix(in srgb,var(--effect-color) 55%,transparent);
 transition:height 1s linear;
}
.effect-liquid::before {
 content:'';position:absolute;top:-3px;left:-50%;width:200%;height:5px;border-radius:45%;
 background:color-mix(in srgb,var(--effect-color) 38%,transparent);animation:effect-surface 3s ease-in-out infinite alternate;
}
.effect-percent {position:absolute;bottom:1px;left:0;right:0;z-index:2;text-align:center;font:700 10px/1.15 ui-monospace,monospace;color:#f1ffff;text-shadow:0 1px 3px #000,0 0 3px #000;font-variant-numeric:tabular-nums}
.effect-charge[data-effect-level="low"] {--effect-color:#ffac41}
.effect-charge[data-effect-level="critical"] {--effect-color:#ff4e64}
.effect-charge:is([data-effect-level="low"],[data-effect-level="critical"]) {animation:effect-warning 1s ease-in-out infinite alternate}
.effect-charge[data-effect-level="empty"] {opacity:.45}
.effect-charge[data-effect-level="empty"] .effect-liquid {display:none}
@keyframes effect-surface {from{transform:translateX(-6%) rotate(-2deg)}to{transform:translateX(6%) rotate(2deg)}}
@keyframes effect-warning {from{border-color:var(--effect-color);box-shadow:inset 0 0 12px color-mix(in srgb,var(--effect-color) 55%,transparent)}to{border-color:transparent;box-shadow:inset 0 0 3px color-mix(in srgb,var(--effect-color) 12%,transparent)}}
.effect-detail-icon {position:relative;isolation:isolate;display:grid;place-items:center;width:80px;height:80px;margin:0 auto}
.effect-detail-icon > img {position:relative;z-index:1;width:40px;height:40px;object-fit:contain;translate:0 -6px}
.effect-detail-icon .effect-percent {font-size:14px;bottom:4px}
.hud-boost-detail {max-width:600px}
.effect-variants {display:grid;gap:8px}
#app .effect-variant {display:flex;align-items:center;gap:12px;width:100%;min-height:60px;text-align:left;padding:8px 12px}
.effect-variant > img {width:40px;height:40px;object-fit:contain}
.effect-variant > span {flex:1;min-width:0}
.effect-variant small {display:block;color:var(--muted);margin-top:4px}
.effect-variant > b {font-size:11px;color:var(--cyan)}
@media (prefers-reduced-motion:reduce) {
 .effect-liquid {transition:none}
 .effect-liquid::before,.effect-charge {animation:none!important}
}
