/* Wild Camp Survival: HUD and menus. Colours are CSS variables (same palette as the itch page). */
:root {
  --bg: #1f2a17; --bg2: #2b3821; --bg3: #364629; --text: #ebe5d3; --dim: #b9b29c; --accent: #f4a340; --ink: #2a1d10;
  --good: #9be27a; --bad: #ff6b5a; --warn: #ffd166; --line: rgba(235, 229, 211, .14);
  --food: #e8a04c; --warmth: #ff7b3a; --health: #e8505b; --def: #8fd16a; --thr: #ff6b5a;
  --r: 12px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.35 var(--font); -webkit-user-select: none; user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; }
#sky { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > *, #hud .card, #hud button { pointer-events: auto; }
#hud #top, #hud #side, #hud #bottom, #hud #toasts { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.svg { width: 18px; height: 18px; flex: none; }
.ico { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; pointer-events: none; }
.ico.big { width: 40px; height: 40px; }
.card { background: rgba(31, 42, 23, .9); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); backdrop-filter: blur(4px); }
.card-h { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 8px 10px 6px; font-size: 13px; letter-spacing: .02em; color: var(--accent); cursor: pointer; }
.card-h span { margin-left: auto; color: var(--dim); font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg3); font-weight: 600; }
.btn:hover:not(:disabled) { background: #435834; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--ink); border-color: transparent; }
.btn.primary:hover { background: #ffb85c; }
.btn.ghost { background: transparent; }
.btn.icon { width: 40px; height: 40px; padding: 0; background: rgba(31, 42, 23, .9); }
.btn.icon.on { background: var(--accent); color: var(--ink); }
.x { margin-left: auto; background: none; border: 0; color: var(--dim); font-size: 20px; line-height: 1; padding: 0 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.small { font-size: 12px; color: var(--dim); }
.pb { display: block; height: 4px; border-radius: 3px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.pb > i { display: block; height: 100%; background: var(--accent); }
.pb.big { height: 8px; margin: 6px 0; }
.pb.fuel > i { background: linear-gradient(90deg, #ff7b3a, #ffd166); }
.chk { display: flex; gap: 8px; align-items: center; margin: 8px 0; cursor: pointer; }

/* ---------- top bar ---------- */
#top { position: absolute; left: 10px; right: 10px; top: max(10px, env(safe-area-inset-top)); display: flex; gap: 10px; align-items: stretch; }
.clock { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px; }
.dial { width: 38px; height: 38px; border-radius: 50%; position: relative; border: 2px solid var(--line);
  background: conic-gradient(from 0deg, #f7c86b 0 223deg, #e98a4b 223deg 259deg, #2c3a66 259deg 353deg, #e98a4b 353deg 360deg); }
.dial i { position: absolute; left: 50%; top: 50%; width: 2px; height: 16px; margin-left: -1px; margin-top: -16px; background: var(--text); transform-origin: 50% 100%; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.dial::after { content: ''; position: absolute; inset: 13px; border-radius: 50%; background: var(--bg); }
.clock-txt { display: flex; flex-direction: column; min-width: 92px; }
.clock-txt b { font-size: 16px; }
.clock-txt small { color: var(--dim); font-size: 12px; }
.wx { display: flex; align-items: center; gap: 5px; color: #f7c86b; font-size: 12px; }
.wx.rain { color: #9cc3ff; } .wx.soon { color: var(--warn); }
.meters { display: flex; gap: 14px; padding: 8px 14px; align-items: center; flex: 1; max-width: 520px; }
.meter { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.meter .bar { flex: 1; height: 10px; border-radius: 6px; background: rgba(0, 0, 0, .4); overflow: hidden; min-width: 40px; }
.meter .bar i { display: block; height: 100%; border-radius: 6px; transition: width .2s; }
.meter span { width: 24px; text-align: right; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.m-food { color: var(--food); } .m-food i { background: var(--food); }
.m-warmth { color: var(--warmth); } .m-warmth i { background: var(--warmth); }
.m-health { color: var(--health); } .m-health i { background: var(--health); }
.meter.low .svg { animation: pulse .8s infinite; }
@keyframes pulse { 50% { transform: scale(1.3); } }
.threat { padding: 6px 12px; min-width: 200px; margin-left: auto; }
.threat-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.threat-head .svg { color: var(--dim); }
.threat-head span { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--good); }
.threat.bad .threat-head span { color: var(--bad); }
.threat.bad.live { animation: glowbad 1.2s infinite; }
@keyframes glowbad { 50% { box-shadow: 0 0 0 2px var(--bad), 0 6px 18px rgba(0,0,0,.35); } }
.tbar { position: relative; height: 10px; margin: 5px 0 3px; border-radius: 6px; background: rgba(0, 0, 0, .4); }
.t-def { position: absolute; left: 0; top: 0; bottom: 0; background: var(--def); border-radius: 6px; transition: width .3s; }
.t-thr { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: var(--thr); border-radius: 2px; box-shadow: 0 0 6px var(--thr); transition: left .3s; }
.threat-nums { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); }
.threat-nums b { color: var(--text); }
.ctl { display: flex; gap: 6px; align-items: flex-start; }

/* ---------- side: goals + jobs ---------- */
#side { position: absolute; left: 10px; top: 84px; width: 250px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - 250px); }
#side ul { list-style: none; margin: 0; padding: 0 8px 8px; }
#side .closed ul { display: none; }
.goals li { display: flex; gap: 6px; align-items: center; padding: 3px 2px; font-size: 13px; }
.goals li .svg { width: 15px; height: 15px; color: var(--dim); }
.goals li b { margin-left: auto; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.goals li.done { color: var(--good); } .goals li.done .svg { color: var(--good); }
.jobs { overflow: auto; }
.jobs li { display: grid; grid-template-columns: 24px 1fr 20px; grid-template-rows: auto 4px; gap: 1px 6px; align-items: center; padding: 4px 2px; font-size: 13px; opacity: .7; }
.jobs li.on { opacity: 1; }
.jobs li .ico, .jobs li .svg { grid-row: 1 / 3; width: 22px; height: 22px; }
.jobs li .pb { grid-column: 2; }
.jobs li .x { grid-row: 1 / 3; grid-column: 3; font-size: 18px; }
.jobs li.idle { display: block; font-size: 12px; color: var(--dim); opacity: 1; }

/* ---------- bottom: stock + build bar ---------- */
#bottom { position: absolute; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#stock { display: flex; gap: 2px; padding: 4px 8px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
#stock .slot { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; }
#stock .slot .ico { width: 30px; height: 30px; }
#stock .slot b { position: absolute; right: 1px; bottom: -1px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; font-variant-numeric: tabular-nums; }
#stock .slot.zero { opacity: .35; }
#stock .slot.full b { color: var(--warn); }
#stock .slot.tool { opacity: .22; filter: grayscale(1); }
#stock .slot.tool.have { opacity: 1; filter: none; background: rgba(244, 163, 64, .14); }
#stock .slot.bump { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.25); } }
#stock .sep { width: 1px; background: var(--line); margin: 6px 4px; }
#tools { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding: 2px; scrollbar-width: thin; pointer-events: auto; }
#tools .tool { position: relative; flex: none; width: 78px; height: 86px; display: flex; flex-direction: column; align-items: center; padding: 4px 3px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(31, 42, 23, .92); box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
#tools .tool img:not(.ico) { width: 54px; height: 42px; object-fit: contain; }
#tools .tool > .svg, #tools .tool > .ico { width: 30px; height: 30px; margin: 6px 0 6px; }
#tools .tool .nm { font-size: 11px; font-weight: 700; white-space: nowrap; }
#tools .tool .costs { display: flex; gap: 2px; font-size: 10px; }
#tools .tool .cost .ico { width: 13px; height: 13px; }
#tools .tool.sel { border-color: var(--accent); background: #3b3317; box-shadow: 0 0 0 2px var(--accent); }
#tools .tool.poor { opacity: .55; }
#tools .tool:hover { background: #2f3d24; }
.cost { display: inline-flex; align-items: center; gap: 1px; }
.cost.short { color: var(--bad); }

/* ---------- panel ---------- */
#panel { position: absolute; right: 10px; top: 84px; width: 300px; max-height: calc(100% - 260px); overflow: auto; padding-bottom: 8px; }
#panel > *:not(.card-h) { margin-left: 12px; margin-right: 12px; }
#panel .help { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
#panel p { margin: 6px 0; }
#panel .st.lit { color: var(--warmth); font-weight: 700; }
#panel .foot { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.recipes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.recipe { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); }
.recipe:hover { background: var(--bg3); }
.recipe .nm { font-size: 12px; font-weight: 700; }
.recipe .costs { display: flex; gap: 4px; font-size: 11px; }
.recipe .cost .ico { width: 15px; height: 15px; }
.recipe .tm { position: absolute; top: 4px; right: 6px; font-size: 10px; color: var(--dim); }
.recipe em { position: absolute; top: 4px; left: 6px; font-style: normal; font-size: 11px; font-weight: 800; background: var(--accent); color: var(--ink); border-radius: 8px; padding: 0 5px; }
.recipe.poor { opacity: .55; }
.recipe.owned { opacity: .4; }

/* ---------- toasts, flying icons, saved chip ---------- */
#toasts { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(520px, 92vw); }
.toast { padding: 7px 14px; border-radius: 20px; background: rgba(31, 42, 23, .94); border: 1px solid var(--line); font-weight: 600; font-size: 13px; text-align: center; animation: tin .25s; }
.toast.good { border-color: var(--good); color: #d8f5c8; } .toast.bad { border-color: var(--bad); color: #ffd6cf; } .toast.warn { border-color: var(--warn); color: #fff0c2; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
.flyer { position: fixed; width: 30px; height: 30px; z-index: 20; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
#savedChip { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--good); opacity: 0; pointer-events: none; }
#savedChip.show { animation: saved 1.6s; }
@keyframes saved { 15%, 75% { opacity: 1; } }
body.paused #game { filter: saturate(.75); }

/* ---------- game parts inside shell dialogs (menu card, briefing, help) ---------- */
.ms-title { margin: 6px 0 2px; font: 400 calc(22px * var(--gs-text)) var(--gs-font-display); color: var(--gs-fg); }
.gs-p.small { font-size: calc(13px * var(--gs-text)); color: var(--gs-muted); }
.gs-p.center, .center { text-align: center; }
.mm { display: grid; grid-template-columns: 64px 1fr 26px; gap: 8px; align-items: center; font: 800 12px var(--gs-font-body); color: var(--gs-muted); margin: 3px 0; }
.mm i { height: 8px; border-radius: 6px; background: rgba(0,0,0,.45); overflow: hidden; } .mm i b { display: block; height: 100%; border-radius: 6px; }
.mm em { font-style: normal; text-align: right; color: var(--gs-fg); }
.mm.m-food b { background: var(--food); } .mm.m-warmth b { background: var(--warmth); } .mm.m-health b { background: var(--health); }
.ms-prog { display: flex; justify-content: space-between; font: 800 12px var(--gs-font-body); color: var(--gs-muted); margin-top: 10px; }
.ms-bar { height: 8px; border-radius: 6px; background: rgba(0,0,0,.45); overflow: hidden; margin-top: 4px; } .ms-bar b { display: block; height: 100%; background: var(--gs-accent); }
.brief-goals, .brief-tips, .help-list { list-style: none; padding: 0; margin: 10px 0; }
.brief-goals li { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-weight: 800; }
.brief-goals .svg { color: var(--gs-accent); }
.brief-tips li, .help-list li { padding: 3px 0 3px 16px; position: relative; font-size: calc(14px * var(--gs-text)); line-height: 1.4; }
.brief-tips li::before, .help-list li::before { content: '›'; position: absolute; left: 2px; color: var(--gs-accent); font-weight: 900; }
#hud { zoom: var(--gs-text, 1); }
#bMenu { width: 40px; height: 40px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  #top { flex-wrap: wrap; gap: 6px; left: 6px; right: 6px; top: max(6px, env(safe-area-inset-top)); }
  .clock { flex: 1; padding: 4px 8px 4px 6px; } .dial { width: 30px; height: 30px; } .dial::after { inset: 10px; } .dial i { height: 12px; margin-top: -12px; }
  .clock-txt { min-width: 70px; } .clock-txt b { font-size: 14px; } .wx { margin-left: auto; } .wx span { font-size: 11px; }
  .ctl { order: 2; } .btn.icon { width: 38px; height: 38px; }
  .meters { order: 3; flex-basis: 100%; max-width: none; gap: 8px; padding: 6px 10px; }
  .threat { order: 4; flex-basis: 100%; min-width: 0; margin-left: 0; display: grid; grid-template-columns: auto 1fr auto; gap: 0 8px; align-items: center; padding: 4px 10px; }
  .threat-head { gap: 4px; } .threat-head span { margin-left: 4px; }
  .tbar { margin: 0; } .threat-nums { gap: 8px; }
  .threat-nums span { white-space: nowrap; }
  #side { top: 128px; width: 200px; left: 6px; }
  .toast { font-size: 12px; padding: 5px 10px; } .toast:nth-last-child(n+3) { display: none; }
  #panel { left: 6px; right: 6px; width: auto; top: auto; bottom: 150px; max-height: 50%; }
  #toasts { top: auto; bottom: 156px; }
  #bottom { left: 0; right: 0; gap: 4px; bottom: max(6px, env(safe-area-inset-bottom)); }
  #stock { border-radius: 10px; padding: 2px 6px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; max-width: calc(100% - 12px); }
  #stock .slot { width: 32px; height: 34px; flex: none; } #stock .slot .ico { width: 24px; height: 24px; } #stock .sep { display: none; }
  #stock .slot.zero, #stock .slot.tool:not(.have) { display: none; }
  #tools { justify-content: flex-start; padding: 2px 6px; } #tools .tool { width: 64px; height: 72px; } #tools .tool img:not(.ico) { width: 44px; height: 32px; }
  #tools .tool .costs { font-size: 9px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .logo-txt { font-size: 34px; }
}
