/* Crater Colony Outpost in-mission HUD. Menus and dialogs are styled by css/shell.css from data/theme.json; the HUD
   uses the same --gs-* colours where it can, plus a few of its own below. */
:root {
  --bg: var(--gs-bg, #1c1416);
  --bg2: var(--gs-bg2, #2a1f22);
  --panel: color-mix(in srgb, var(--bg2) 92%, transparent);
  --text: var(--gs-fg, #efe6e0);
  --muted: var(--gs-muted, #b9a69c);
  --btn: #3a2b2e;
  --btn-hi: #4a383b;
  --accent: var(--gs-accent, #ffb454);
  --teal: #5fd6c8;
  --good: #8fdc7a;
  --bad: #ff6a50;
  --warn: #ffb454;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.35 var(--gs-font-body, system-ui, sans-serif); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; touch-action: none; }
#game canvas { display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--text); background: var(--btn); border: 1px solid rgba(255,255,255,.06); border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { background: var(--btn-hi); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--bg); font-weight: 800; border-color: transparent; }
button.primary:hover:not(:disabled) { background: #ffc370; }
button.danger { background: var(--bad); color: #fff; font-weight: 700; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg .f { fill: currentColor; stroke: none; }
.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }
.icon.small { width: 28px; height: 28px; font-size: 18px; }
.icon.on, .tool.on { background: var(--accent); color: var(--bg); }
kbd { font: 10px/1 monospace; opacity: .55; }

/* top bar */
#top { position: fixed; left: 8px; right: 8px; top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#lvl-name, #clock { background: var(--panel); padding: 8px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
#clock { display: flex; gap: 6px; align-items: center; }
#clock svg { color: var(--accent); }
#clock.night svg { color: #9fb4ff; }
.grow { flex: 1; }
#res { display: flex; gap: 4px; flex-wrap: wrap; }
.rc { background: var(--panel); border-radius: 10px; padding: 4px 8px 4px 4px; display: grid; grid-template-columns: 26px auto; grid-template-rows: auto auto; column-gap: 4px; align-items: center; min-width: 74px; }
.rc img, .rc svg { grid-row: span 2; width: 26px; height: 26px; }
.rc svg { color: var(--teal); }
.rc b { font-size: 14px; line-height: 1; }
.rc i { font-style: normal; font-size: 10px; color: var(--muted); line-height: 1.1; }
.rc i.up { color: var(--good); } .rc i.dn { color: var(--bad); }
.rc.low { box-shadow: inset 0 0 0 2px var(--bad); animation: blink 1s infinite; }
.rc.full b { color: var(--accent); }
@keyframes blink { 50% { box-shadow: inset 0 0 0 2px transparent; } }
#speed { display: flex; gap: 2px; background: var(--panel); padding: 3px; border-radius: var(--radius); }
#speed .sp { padding: 6px 9px; background: transparent; border: 0; }
#speed .sp.on { background: var(--accent); color: var(--bg); }

/* goals + alerts */
#side { position: fixed; left: 8px; top: 62px; width: 230px; display: grid; gap: 6px; z-index: 4; pointer-events: none; }
#goals { background: var(--panel); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 6px; }
#goals:empty { display: none; }
.g { position: relative; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding-bottom: 5px; }
.g i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); border-radius: 2px; }
.g.done { color: var(--good); } .g.done i { background: var(--good); }
.g.dl { color: var(--muted); }
#alerts { display: grid; gap: 4px; }
.al { background: var(--panel); border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; border-left: 4px solid var(--muted); }
.al svg { width: 16px; height: 16px; }
.al.storm { border-color: #e0884a; } .al.meteor { border-color: var(--bad); } .al.ship { border-color: var(--teal); }

/* toolbar */
#toolbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(8px + var(--safe-b)); display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px; border-radius: 16px; z-index: 5; max-width: calc(100vw - 16px); }
#tools { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tool { position: relative; width: 74px; min-width: 74px; height: 78px; padding: 2px; display: grid; justify-items: center; align-content: start; gap: 0; }
.tool img { width: 56px; height: 40px; object-fit: contain; }
.tool > svg { width: 40px; height: 40px; margin: 0 8px; color: var(--teal); }
.tool .nm { font-size: 10px; line-height: 1.1; text-align: center; height: 22px; overflow: hidden; }
.tool .cs { font-size: 10px; display: flex; gap: 4px; }
.tool kbd { position: absolute; top: 3px; right: 5px; }
.cost { display: inline-flex; align-items: center; gap: 1px; }
.cost img { width: 13px; height: 13px; }
.sep { width: 1px; align-self: stretch; background: rgba(255,255,255,.12); }

#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); background: var(--panel); padding: 6px 12px; border-radius: 10px; font-size: 12px; max-width: min(520px, 92vw); text-align: center; z-index: 5; pointer-events: none; }
#hint b { color: var(--accent); }
/* building panel */
#panel { position: fixed; right: 8px; top: 62px; width: 270px; background: var(--panel); border-radius: var(--radius); padding: 10px; z-index: 6; display: grid; gap: 6px; font-size: 13px; }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.st { font-weight: 700; } .st.good { color: var(--good); } .st.bad { color: var(--bad); } .st.mid { color: var(--warn); }
#panel-body { display: grid; gap: 4px; color: var(--muted); }
.wear { display: flex; align-items: center; gap: 6px; }
.wear i { flex: 1; height: 6px; background: linear-gradient(90deg, var(--good), var(--accent), var(--bad)); border-radius: 3px; max-width: 100%; }
#panel-acts { display: flex; gap: 6px; flex-wrap: wrap; }
#panel-acts .cost img { width: 15px; height: 15px; }

/* phones */
@media (max-width: 720px) {
  #lvl-name { display: none; }
  .rc { min-width: 0; padding-right: 6px; grid-template-columns: 20px auto; }
  .rc img, .rc svg { width: 20px; height: 20px; }
  .rc b { font-size: 12px; }
  #side { top: auto; bottom: calc(104px + var(--safe-b)); width: 190px; }
  #panel { top: auto; bottom: calc(100px + var(--safe-b)); right: 8px; left: auto; width: min(270px, 60vw); }
  .tool { width: 60px; min-width: 60px; height: 70px; }
  .tool img { width: 46px; height: 34px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

/* HUD scales with Settings > Text size */
#hud { zoom: var(--gs-text, 1); }
#btn-pause { width: 42px; height: 42px; }
#panel-close.small { width: 30px; height: 30px; }
#panel-acts .gs-btn { min-width: 0; min-height: 40px; padding: 0 14px; font-size: 14px; border-width: 12px 16px; }
#panel-acts .gs-btn .cost img { width: 15px; height: 15px; }
.tool > svg { width: 40px; height: 40px; }

/* shell screens: game-specific bits */
.gs-banner span { color: var(--gs-ink); text-shadow: 0 1px 0 rgba(255, 240, 210, .6); }
.prog-big { font: 700 40px/1 var(--gs-font-display); color: #fff; margin: 8px 0 0; }
.prog-big .star { color: var(--gs-accent); }
.prog-big small { font: 600 15px var(--gs-font-body); color: var(--gs-muted); margin-left: 6px; }
.prog-bar { height: 12px; border-radius: 6px; background: #160f11; margin: 8px 0 10px; overflow: hidden; }
.prog-bar i { display: block; height: 100%; background: linear-gradient(90deg, #e08a2c, var(--gs-accent)); }
.prog-row { display: flex; justify-content: space-between; gap: 10px; font-size: calc(15px * var(--gs-text)); color: var(--gs-muted); padding: 3px 0; }
.prog-row b { color: var(--gs-fg); font-weight: 700; text-align: right; }
.lv-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lv-note { color: var(--gs-muted); font-size: 14px; }
.brief-d ul, .help-d ul { padding-left: 20px; margin: 6px 0 10px; }
.brief-d .goals li b { color: var(--gs-accent); }
.tips { color: var(--gs-muted); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }
.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 4px 6px; border-bottom: 1px solid #3a2b2e; }
.keys td:first-child { color: var(--gs-accent); font-weight: 700; white-space: nowrap; width: 38%; }
@media (max-width: 720px), (max-height: 500px) {
  .brief-d .tips { display: none; }
  #side { top: auto; bottom: calc(104px + var(--safe-b)); width: 190px; }
}
@media (max-height: 500px) {
  #side { top: 44px; bottom: auto; width: 170px; zoom: .85; }
}
.gs-results.gs-lost .gs-banner span { color: #7a1e10; text-shadow: none; }
/* short screens (phone landscape): one compact HUD row, icon-only toolbar, short briefing */
@media (max-height: 500px) {
  #lvl-name, .rc i, .tool .nm, .tool .cs, .tool kbd { display: none; }
  #top { top: 4px; gap: 4px; }
  .rc { min-width: 0; padding: 2px 6px 2px 2px; grid-template-columns: 18px auto; }
  .rc img, .rc svg { width: 18px; height: 18px; grid-row: auto; }
  .rc b { font-size: 12px; }
  #clock, #speed { padding: 4px 8px; font-size: 12px; }
  #speed .sp { padding: 3px 6px; }
  #btn-pause { width: 34px; height: 34px; }
  #toolbar { padding: 4px; bottom: calc(4px + var(--safe-b)); }
  .tool { width: 46px; min-width: 46px; height: 46px; }
  .tool img { width: 40px; height: 34px; }
  .tool > svg { width: 30px; height: 30px; }
  #hint { display: none; }
  #panel { top: 44px; bottom: auto; max-height: calc(100vh - 110px); overflow-y: auto; }
  .brief-d .small, .brief-d .goals + .tips { display: none; }
  .brief-d .gs-p { margin: 4px 0; }
}
