/* Hearthwick HUD and game-specific screens. Menus and dialogs come from css/shell.css (Game Shell), skinned by
   data/theme.json; the variables below follow the same palette, so change both together when you re-skin. */
:root {
  --ink: #2e2010;          /* outlines, text on gold */
  --panel: rgba(29, 36, 22, .92);
  --paper: #ece6d6;        /* text on dark */
  --muted: #aaa68f;
  --btn: #e9dcbc;          /* light buttons (toolbar) */
  --accent: #f2c14e;       /* selected / primary */
  --good: #9fd36b;
  --bad: #ff8466;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d2416; color: var(--paper);
  font: 15px/1.35 'Alegreya Sans', system-ui, -apple-system, "Segoe UI", Roboto, 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; }
#hud { zoom: var(--gs-text, 1); }
#hud button:not(.gs-icon) { font: inherit; color: var(--ink); background: var(--btn); border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
#hud button:disabled { opacity: .45; cursor: default; }
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; }
#hud .icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }
#hud .icon.small { width: 28px; height: 28px; font-size: 18px; }
#hud .icon.on, #hud .tool.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }
#btn-menu { width: 46px; height: 46px; flex: 0 0 auto; }

/* HUD */
#top { position: fixed; left: 8px; right: 8px; top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#lvl-name, #clock, .chip-big { background: var(--panel); padding: 8px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
#stock { display: flex; gap: 4px; background: var(--panel); border-radius: var(--radius); padding: 4px 8px; }
.res { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 2px 4px; border-radius: 8px; }
.res img { width: 24px; height: 24px; }
.res small { color: var(--muted); font-weight: 400; font-size: 11px; }
.res.full { background: rgba(242,199,107,.18); }
.res.full small { color: var(--accent); }
.res.empty { background: rgba(255,122,102,.3); }
.chip-big { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.chip-big small { color: var(--muted); font-weight: 400; font-size: 11px; }
#happy.good { color: var(--good); } #happy.bad { color: var(--bad); }
#happy .face { display: inline-flex; }
#clock { font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; }
.grow { flex: 1; pointer-events: none !important; }
#goals { position: fixed; left: 8px; top: 64px; display: grid; gap: 5px; z-index: 4; pointer-events: none; }
.goal { background: var(--panel); border-radius: var(--radius); padding: 5px 10px 6px 6px; display: grid; grid-template-columns: 26px auto auto; align-items: center; column-gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 170px; }
.goal img, .goal .gi { width: 26px; height: 26px; grid-row: span 2; display: grid; place-items: center; }
.goal .gi svg { width: 22px; height: 22px; }
.goal .gl { font-size: 13px; }
.goal .gn { text-align: right; color: var(--accent); }
.goal i { display: block; grid-column: 2 / 4; height: 4px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.goal i b { display: block; height: 100%; width: 0; background: var(--accent); }
.goal.done i b { background: var(--good); }
.goal.done .gn { color: var(--good); }
.goal.sandbox { grid-template-columns: auto; min-width: 0; color: var(--muted); }
#speed { display: flex; background: var(--panel); border-radius: var(--radius); padding: 4px; gap: 4px; }
#speed .sp { padding: 4px 8px; background: transparent; color: var(--paper); display: inline-flex; align-items: center; gap: 2px; }
#speed .sp svg { width: 16px; height: 16px; }
#speed .sp.on { background: var(--accent); color: var(--ink); }

/* toolbar */
#toolbar { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px; border-radius: 16px; max-width: calc(100vw - 16px); z-index: 5; }
#tools { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.tool { position: relative; min-width: 66px; height: 70px; padding: 2px 4px; display: grid; grid-template-rows: 1fr auto; place-items: center; flex: 0 0 auto; background: #f3e6c8; }
.tool img { max-width: 58px; max-height: 46px; object-fit: contain; pointer-events: none; }
.tool .ic svg { width: 26px; height: 26px; }
.tool small { font-weight: 700; font-size: 11px; }
.cost { display: inline-flex; gap: 3px; font-weight: 700; font-size: 10.5px; line-height: 1; white-space: nowrap; }
.cost span { display: inline-flex; align-items: center; }
.cost img { width: 13px !important; height: 13px !important; max-width: none !important; }
.cost.inline { font-size: 13px; gap: 6px; vertical-align: middle; }
.cost.inline img { width: 18px !important; height: 18px !important; }
.tool.poor .cost { color: #b5402c; }
.tool .lk { display: none; position: absolute; inset: 0; place-items: center; background: rgba(43,30,22,.55); border-radius: 9px; color: var(--paper); }
.tool.locked .lk { display: grid; }
.gsep { width: 2px; align-self: stretch; background: rgba(255,255,255,.12); flex: 0 0 auto; margin: 0 2px; }
.sep { width: 2px; align-self: stretch; background: rgba(255,255,255,.15); }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); background: var(--panel); padding: 6px 12px; border-radius: 10px; max-width: calc(100vw - 32px); color: var(--muted); font-size: 13px; text-align: center; z-index: 4; pointer-events: none; }
#hint .cost { margin: 0 4px; color: var(--paper); }
#hint .cost img { width: 16px !important; height: 16px !important; }
#hint b { color: var(--paper); }

/* info panel */
#panel { position: fixed; right: 8px; top: 64px; width: 280px; max-width: calc(100vw - 16px); background: var(--panel); border-radius: 14px; padding: 10px 12px; z-index: 6; }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
#panel-status { color: var(--muted); margin: 4px 0 6px; }
.bad { color: var(--bad); }
#panel-body p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.row label { width: 62px; color: var(--muted); font-size: 12px; }
.row .bar { flex: 1; }
.why { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.why span { background: rgba(123,214,111,.16); border-radius: 8px; padding: 2px 7px; font-size: 12px; }
.why span.neg { background: rgba(255,122,102,.22); }
p.bad { color: var(--bad) !important; }
.row em { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.1); border-radius: 8px; padding: 1px 6px 1px 2px; font-weight: 700; }
.chip img { width: 22px; height: 22px; }
.recipe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.recipe small { color: var(--muted); }
.bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.bar b { display: block; height: 100%; background: var(--accent); }
.recipes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.recipes button { font-size: 12px; padding: 4px 8px; display: inline-flex; align-items: center; gap: 4px; }
.recipes button img { width: 18px; height: 18px; }
.recipes button.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }
#panel-acts { display: flex; gap: 6px; margin-top: 8px; }
#panel-acts .act { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
#panel-acts svg { width: 16px; height: 16px; }

/* game dialogs built with the shell (briefing, help, pause goals, results lines) */
.brief-d .goals-big, .goals-big { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.goals-big div { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.22); border: 1px solid #3c4630; border-radius: 10px; padding: 4px 12px 4px 4px; }
.goals-big img, .goals-big .gi { width: 38px; height: 38px; display: grid; place-items: center; color: var(--accent); }
.goals-big .gi svg { width: 28px; height: 28px; }
.tips { margin: 10px 0 0; padding-left: 20px; color: var(--paper); font-size: calc(15px * var(--gs-text, 1)); }
.tips li { margin: 4px 0; }
.gs-p.small { font-size: calc(13px * var(--gs-text, 1)); color: var(--muted); }
.center { text-align: center; }
b.acc { color: var(--accent); }
.cost.inline { display: inline-flex; vertical-align: middle; }
table.keys { border-collapse: collapse; width: 100%; font-size: calc(14px * var(--gs-text, 1)); }
table.keys td { padding: 4px 6px; border-bottom: 1px solid #3c4630; } table.keys td:first-child { color: var(--accent); white-space: nowrap; font-weight: 700; }
.pause-goals { display: grid; gap: 7px; margin: 12px 4px 2px; text-align: left; }
.pg { display: grid; grid-template-columns: 22px 1fr auto; column-gap: 8px; align-items: center; font-weight: 700; color: var(--paper); }
.pg img, .pg .gi { width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent); } .pg .gi svg { width: 20px; height: 20px; }
.pg em { font-style: normal; color: var(--muted); font-weight: 400; }
.pg i { grid-column: 2 / 4; height: 6px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; }
.pg i b { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.pg.done i b { background: var(--good); } .pg.done .gi { color: var(--good); }

/* shell stars + locks in the Hearthwick art (assets/ui/star_*.png, lock.png) */
.gs-stars i, .gs-res-stars i { clip-path: none; background: transparent url(../assets/ui/star_off.png) center/contain no-repeat; width: 18px; height: 18px; }
.gs-stars i.on, .gs-res-stars i.on { background: transparent url(../assets/ui/star_on.png) center/contain no-repeat; }
.gs-res-stars i { width: 58px; height: 58px; }
.gs-res-stars i:nth-child(2) { transform: translateY(-10px) scale(1.12); }
.gs-lock { width: 46px; height: 52px; margin-left: -23px; top: 36px; background: url(../assets/ui/lock.png) center/contain no-repeat; border-radius: 0; }
.gs-levels-foot .gs-stars i { width: 20px; height: 20px; vertical-align: -3px; }

@media (max-width: 1100px) { #lvl-name { display: none; } }
/* phones */
@media (max-width: 700px) {
  #top { gap: 5px; }
  #stock { padding: 3px 5px; gap: 1px; }
  .res img { width: 18px; height: 18px; } .res { font-size: 12px; padding: 1px 2px; } .res small { display: none; }
  #goals { top: auto; bottom: calc(84px + var(--safe-b)); }
  .goal { padding: 3px 8px 4px 4px; grid-template-columns: 20px auto auto; font-size: 12px; min-width: 140px; }
  .goal img, .goal .gi { width: 20px; height: 20px; } .goal .gl { font-size: 11px; }
  .chip-big, #clock { padding: 6px 8px; font-size: 13px; } .chip-big svg { width: 16px; height: 16px; } .chip-big small { display: none; }
  #clock { display: none; }
  #speed .sp svg { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #speed .sp { padding: 4px 7px; font-size: 13px; }
  .tool { min-width: 54px; height: 60px; }
  .tool img { max-width: 48px; max-height: 38px; }
  .cost { font-size: 9.5px; gap: 1px; } .cost img { width: 11px !important; height: 11px !important; }
  #toolbar { left: 8px; right: 8px; transform: none; max-width: none; }
  #tools { flex: 1; }
  #toolbar .icon { width: 36px; height: 36px; flex: 0 0 auto; }
  #hint { bottom: calc(80px + var(--safe-b)); font-size: 12px; }
  #hud:has(#hint:not([hidden])) #goals { display: none; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(80px + var(--safe-b)); }
}
@media (max-height: 480px) and (orientation: landscape) {
  .tool { width: 46px; height: 48px; } .tool img { max-height: 28px; }
  #panel { top: 56px; bottom: auto; max-height: calc(100vh - 130px); overflow-y: auto; }
}
.gs-toast.gs-good { background: #34481f; border-color: var(--good); color: var(--paper); }
