/* Dead Town Holdout HUD (the in-game interface). Menus and dialogs are styled by css/shell.css; both read the theme
   colours and fonts from data/theme.json (--gs-*), so a reskin changes everything at once. */
:root {
  --bg: var(--gs-bg, #1c1a17);
  --bg2: var(--gs-bg2, #2a2723);
  --panel: rgba(30, 28, 25, .92);          /* HUD boxes */
  --edge: #4a443b;                         /* HUD box border */
  --paper: var(--gs-fg, #e6e0d4);          /* text on dark */
  --muted: var(--gs-muted, #a39b8c);
  --accent: var(--gs-accent, #ffd166);     /* selected / primary */
  --ink: var(--gs-ink, #2b1e10);           /* text on the accent */
  --good: var(--gs-good, #8fd16a);
  --bad: var(--gs-danger, #ff6b4a);
  --night: #7f9cff;
  --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(--paper);
  font: 500 14px/1.35 var(--gs-font-body, system-ui, -apple-system, "Segoe 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(--paper); background: #3a362f; border: 1px solid #575046; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { background: #464036; }
button:disabled { opacity: .45; cursor: default; }
button.primary { color: var(--ink); background: linear-gradient(#ffe08e, var(--accent) 55%, #e6a93a); border-color: #8a6420; font-weight: 800; box-shadow: inset 0 -2px 0 rgba(90,50,0,.3); }
button.primary:hover:not(:disabled) { background: linear-gradient(#ffe9a8, #ffd97e 55%, #f0b44a); }
button.danger { background: #8c3326; border-color: #b04a38; color: #fff; font-weight: 700; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 2px; }
button.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; background: var(--panel); border: 2px solid var(--edge); }
button.icon.small { width: 28px; height: 28px; font-size: 18px; line-height: 1; border-width: 1px; }
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; }
code { background: rgba(255,255,255,.08); padding: 0 4px; border-radius: 4px; }
.c { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; white-space: nowrap; margin-right: 5px; font-variant-numeric: tabular-nums; }
.c img { width: 18px; height: 18px; }
.c.short { color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.07); border-radius: 8px; padding: 2px 8px 2px 3px; font-weight: 700; white-space: nowrap; }
.chip img { width: 30px; height: 26px; object-fit: contain; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }

/* HUD */
#hud { zoom: var(--gs-text, 1); }
#btn-pause { width: 44px; height: 44px; }
#lvl-name, #banner, .ph b, .tool b { font-family: var(--gs-font-display, inherit); font-weight: 400; letter-spacing: .4px; }
#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, .stat, #speed, #teams, #res { background: var(--panel); border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
#lvl-name { padding: 7px 12px; font-weight: 800; white-space: nowrap; }
.stat { position: relative; display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 800; padding: 4px 10px 6px 6px; white-space: nowrap; }
.stat img { width: 26px; height: 26px; }
.stat .ic { display: inline-grid; color: var(--accent); }
.stat .bar { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 3px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--accent); }
#clock.dusk .ic, #clock.dusk .bar i { color: #ff9a4a; background: #ff9a4a; }
#clock.night { border-color: #39477a; }
#clock.night .ic { color: var(--night); } #clock.night .bar i { background: var(--night); }
#camp .ic { color: #ff7a6a; } #camp .bar i { background: #ff7a6a; }
#camp.low { animation: blink 1s infinite; }
@keyframes blink { 50% { background: rgba(160, 40, 30, .9); } }
#res { display: flex; padding: 2px 4px; }
#res .stat { background: none; border: 0; box-shadow: none; padding: 2px 6px 2px 2px; }
#res .res-ammo.low b { color: var(--bad); }
#teams { display: flex; gap: 2px; padding: 3px 5px; }
.team { display: grid; justify-items: center; width: 50px; padding: 1px 0; border-radius: 8px; color: var(--good); }
.team svg { width: 18px; height: 18px; }
.team small { font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.team.out { color: var(--accent); } .team.out small { color: var(--accent); }
.team.hiding { color: var(--night); }
.team.hurt { color: var(--bad); }
.grow { flex: 1; pointer-events: none !important; }
#speed { display: flex; padding: 4px; gap: 3px; }
#speed .sp { padding: 4px 8px; background: transparent; border: 0; display: inline-flex; align-items: center; gap: 2px; }
#speed .sp svg { width: 15px; height: 15px; }
#speed .sp.on { background: var(--accent); color: var(--ink); }

/* bottom: build bar + night button */
#bottom { position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); display: flex; align-items: flex-end; justify-content: center; gap: 8px; pointer-events: none; z-index: 5; }
#bottom > * { pointer-events: auto; }
#build { display: flex; gap: 5px; background: var(--panel); border: 2px solid var(--edge); border-radius: 16px; padding: 6px; box-shadow: 0 3px 0 rgba(0,0,0,.35); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
#build.closed { opacity: .45; pointer-events: none; }
.tool { position: relative; width: 84px; flex: none; padding: 3px 2px 4px; display: grid; justify-items: center; gap: 0; background: var(--bg2); }
.tool > img { height: 46px; width: 64px; object-fit: contain; object-position: bottom; }
.tool b { font-size: 10.5px; line-height: 1.15; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tool small { display: flex; justify-content: center; font-size: 12px; }
.tool small .c { margin: 0 2px; } .tool small img { width: 15px; height: 15px; }
.tool kbd { position: absolute; top: 2px; left: 4px; font: 700 10px system-ui; color: var(--muted); }
.tool.on { background: #5a4b26; border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.tool.poor { opacity: .55; }
.tool.repair .ri { height: 46px; display: grid; place-items: center; color: var(--accent); } .tool.repair .ri svg { width: 30px; height: 30px; }
#btn-night { padding: 12px 16px; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: 14px; align-self: stretch; }
#btn-night small { opacity: .7; font-weight: 600; }
#btn-night:disabled { opacity: 1; background: #263052; color: #cfd9ff; border-color: #4a5a99; }
#btn-night.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 209, 102, .35); } }
#hint { position: fixed; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 6px 12px; font-size: 13px; max-width: calc(100vw - 24px); z-index: 5; text-align: center; pointer-events: none; }
#hint em { color: var(--muted); font-style: normal; margin-left: 6px; }

.tag { position: fixed; display: inline-flex; align-items: center; gap: 3px; background: var(--panel); border: 2px solid var(--accent); color: var(--accent); border-radius: 10px; padding: 2px 8px 2px 4px; font-weight: 800; font-size: 12px; z-index: 4; pointer-events: none; white-space: nowrap; }
.tag svg { width: 15px; height: 15px; }
.tag.hiding { border-color: var(--night); color: var(--night); }

#banner { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; font-size: 34px; font-weight: 900; color: var(--paper); text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.6); z-index: 7; pointer-events: none; white-space: nowrap; }
#banner svg { width: 34px; height: 34px; }
#banner em { font-style: normal; color: var(--accent); font-size: 18px; }
#banner.night { color: #dbe3ff; } #banner.night svg { color: var(--night); }
#banner.dawn svg { color: var(--accent); }
#banner.show { animation: drop 2.2s ease-out forwards; }
@keyframes drop { 0% { opacity: 0; transform: translate(-50%, -20px); } 12% { opacity: 1; transform: translate(-50%, 0); } 82% { opacity: 1; } 100% { opacity: 0; } }

/* selection panel */
#panel { position: fixed; right: 8px; top: 64px; width: 290px; max-width: calc(100vw - 16px); background: var(--panel); border: 2px solid var(--edge); border-radius: 14px; padding: 10px 12px; z-index: 6; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.ph .lv { color: var(--accent); font-size: 14px; letter-spacing: 1px; }
#panel-body p { margin: 4px 0 6px; color: var(--muted); font-size: 13px; }
#panel-body p.small { font-size: 12px; }
#panel-body .warn, .kv em.warn { color: #ff9a4a; }
#panel-body .out { color: var(--accent); }
.kv { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.kv > span { flex: 1; color: var(--muted); }
.kv em { color: var(--good); font-style: normal; font-weight: 700; font-size: 12px; }
.kv.muted b { color: var(--muted); }
.kv .loot { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.pips { display: flex; gap: 3px; } .pips i { width: 14px; height: 8px; border-radius: 3px; background: #4a443b; } .pips i.on { background: var(--accent); }
.meter { flex: 1.3; height: 8px; background: #3a352d; border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); }
.risk.mid .meter i { background: var(--accent); } .risk.high .meter i { background: var(--bad); }
.risk.high b { color: var(--bad); }
.hp.s1 .meter i { background: var(--accent); } .hp.s2 .meter i { background: var(--bad); }
.state.s0 { color: var(--good); } .state.s1 { color: var(--accent); } .state.s2 { color: var(--bad); }
#panel-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#panel-acts .act { flex: 1 1 40%; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 13px; padding: 8px 6px; }
#panel-acts .act small { display: inline-flex; align-items: center; }
#panel-acts .why { width: 100%; color: var(--muted); font-size: 12px; text-align: center; }

/* inside shell dialogs (briefing, help, pause, results, menu side panel) */
.foes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin: 4px 0 6px; }
.foes div { display: grid; grid-template-columns: 44px auto; column-gap: 8px; align-items: center; background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.07); border-radius: 10px; padding: 3px 8px 3px 4px; }
.foes img { width: 44px; height: 44px; object-fit: contain; grid-row: span 2; }
.foes b { font-size: calc(15px * var(--gs-text, 1)); }
.foes small { color: var(--muted); font-size: calc(12.5px * var(--gs-text, 1)); line-height: 1.25; }
.tips { margin: 8px 0 4px; padding-left: 20px; color: var(--paper); font-size: calc(15px * var(--gs-text, 1)); }
.tips li { margin: 4px 0; }
.gs-p.goal { color: var(--accent); font-weight: 800; }
.gs-p.small { font-size: calc(13px * var(--gs-text, 1)); color: var(--muted); }
.gs-p.small em { color: var(--paper); }
.gs-p.center, p.center { text-align: center; }
b.acc { color: var(--accent); }
.gs-dialog .row .chip { font-size: calc(14px * var(--gs-text, 1)); }
.help-d .keys { border-collapse: collapse; width: 100%; }
.help-d .keys td { padding: 4px 6px; vertical-align: top; font-size: calc(14px * var(--gs-text, 1)); border-bottom: 1px solid rgba(255,255,255,.06); }
.help-d .keys td:first-child { color: var(--accent); white-space: nowrap; font-weight: 700; }
table.camp { width: 100%; border-collapse: collapse; font-size: calc(16px * var(--gs-text, 1)); }
table.camp td { padding: 5px 2px; border-bottom: 1px solid rgba(255,255,255,.08); }
table.camp tr:last-child td { border: 0; }
table.camp td:last-child { text-align: right; font-weight: 700; color: #fff; }
.st1 svg { width: 18px; height: 18px; color: var(--accent); vertical-align: -3px; }
.pstats { display: flex; justify-content: center; gap: 14px; margin-top: 8px; font-weight: 800; }
.pstats span { display: inline-flex; align-items: center; gap: 4px; }
.pstats img { width: 24px; height: 24px; }
.nights { display: flex; justify-content: center; gap: 5px; margin: 8px 0 0; }
.nights i { width: 26px; height: 10px; border-radius: 3px; background: #3d382f; } .nights i.done { background: var(--night); } .nights i.cur { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.gs-toast .c img { width: 20px; height: 20px; }

/* phones */
@media (max-width: 760px) {
  #lvl-name, #speed .sp svg { display: none; }
  #btn-pause { width: 38px; height: 38px; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #top { gap: 4px; }
  .stat { font-size: 13px; padding: 3px 7px 5px 4px; }
  .stat img { width: 20px; height: 20px; }
  #res .stat { padding: 1px 4px 1px 1px; }
  .team { width: 26px; } .team small { display: none; }
  #clock .bar, #camp .bar { left: 6px; right: 6px; }
  #speed .sp { padding: 3px 6px; font-size: 12px; }
  #bottom { flex-direction: column; align-items: stretch; }
  .tool { width: 66px; } .tool > img { height: 36px; width: 52px; } .tool b { font-size: 10px; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(150px + var(--safe-b)); }
  #panel-body p { display: none; }
  #hint { bottom: calc(150px + var(--safe-b)); }
  #banner { font-size: 24px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  /* phone held sideways: one slim top row, a slim bottom row, the map gets the rest */
  .gs-foot { display: none; }
  #lvl-name, #speed .sp svg, .team small { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #top { flex-wrap: nowrap; gap: 4px; top: 4px; }
  .stat { font-size: 12px; padding: 2px 6px 4px 3px; }
  .stat img { width: 18px; height: 18px; }
  #res .stat { padding: 1px 3px 1px 1px; }
  .team { width: 22px; }
  #speed .sp { padding: 2px 5px; font-size: 11px; }
  #btn-pause { width: 32px; height: 32px; }
  #bottom { bottom: calc(4px + var(--safe-b)); gap: 6px; }
  #build { padding: 3px; gap: 3px; }
  .tool { width: 60px; } .tool > img { height: 26px; width: 40px; } .tool b { font-size: 9px; } .tool small { font-size: 10px; } .tool small img { width: 12px; height: 12px; } .tool kbd { display: none; }
  .tool.repair .ri { height: 26px; } .tool.repair .ri svg { width: 20px; height: 20px; }
  #btn-night { padding: 6px 10px; font-size: 13px; }
  #btn-night small { display: none; }
  #hint { bottom: calc(66px + var(--safe-b)); font-size: 12px; padding: 4px 10px; }
  #panel { top: 44px; bottom: auto; right: 6px; width: 270px; max-height: calc(100vh - 116px); overflow-y: auto; padding: 6px 10px; }
  #panel-body p { display: none; }
  #banner { font-size: 22px; top: 18%; }
}
