/* Bastion Road Defense HUD (the in-level interface). Menus and dialogs are styled by css/shell.css; both read the
   theme colours from data/theme.json (--gs-*), so a reskin changes everything at once. */
:root {
  --ink: var(--gs-ink, #3a2610);          /* text on gold */
  --bg: var(--gs-bg, #1b2414);
  --panel: rgba(27, 36, 20, .9);           /* HUD boxes */
  --edge: #8a8070;                         /* stone edge of HUD boxes */
  --paper: var(--gs-fg, #e9e6d8);          /* text on dark */
  --muted: var(--gs-muted, #a9b096);
  --btn: #e9d8b4;                          /* light buttons */
  --accent: var(--gs-accent, #ffcf4a);     /* selected / primary */
  --good: var(--gs-good, #9be36a);
  --bad: var(--gs-danger, #ff8a70);
  --magic: #b9a2ff;
  --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, 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(--ink); background: var(--btn); border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: linear-gradient(#ffe07a, var(--accent) 55%, #e8a92a); font-weight: 700; box-shadow: inset 0 -2px 0 rgba(90,50,0,.35), 0 0 0 2px #6b4a14; }
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; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.08); border-radius: 8px; padding: 1px 7px 1px 2px; font-weight: 700; white-space: nowrap; }
.chip img { width: 26px; 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); }
#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, .stat { background: var(--panel); padding: 6px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: 16px; padding: 4px 12px 4px 6px; }
.stat img { width: 28px; height: 28px; }
#gold b { color: var(--accent); }
#lives.low { animation: blink 1s infinite; }
@keyframes blink { 50% { background: rgba(160, 40, 30, .9); } }
.grow { flex: 1; pointer-events: none !important; }
#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); }

/* wave bar */
#wavebar { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel); padding: 6px 6px 6px 12px; border-radius: 16px; max-width: calc(100vw - 16px); z-index: 5; }
#wave-next { display: grid; gap: 2px; min-width: 0; }
#wave-next small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
#wave-chips { display: flex; gap: 4px; flex-wrap: wrap; }
#btn-wave { padding: 10px 16px; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#btn-wave em { font-style: normal; color: #7a4a00; }
#btn-wave small { opacity: .7; font-weight: 600; }
#btn-wave.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(242, 199, 107, .35); } }
.gtag { position: fixed; display: flex; gap: 3px; background: var(--panel); border: 2px solid var(--accent); border-radius: 10px; padding: 3px 4px; z-index: 4; pointer-events: none; }
.gtag .chip { background: none; padding: 0 3px 0 0; font-size: 12px; }
.gtag .chip img { width: 22px; height: 22px; }

#banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); font-size: 30px; font-weight: 900; color: var(--paper); text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(0,0,0,.5); z-index: 7; pointer-events: none; white-space: nowrap; }
#banner em { font-style: normal; color: var(--accent); font-size: 20px; }
#banner.show { animation: drop 1.9s ease-out forwards; }
@keyframes drop { 0% { opacity: 0; transform: translate(-50%, -20px); } 15% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* build menu (follows its pad) */
#build { position: fixed; display: grid; grid-template-columns: repeat(4, auto); gap: 6px; background: var(--panel); padding: 8px; border-radius: 14px; z-index: 6; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: calc(100vw - 16px); }
#build .bt { width: 80px; padding: 4px 2px 5px; display: grid; justify-items: center; gap: 1px; background: #f3e6c8; }
#build .bt > img { height: 54px; width: 70px; object-fit: contain; object-position: bottom; }
#build .bt b { font-size: 11px; line-height: 1.1; }
#build .bt small { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; }
#build .bt small img { width: 16px; height: 16px; }
#build .bt.poor { opacity: .55; }
#build .bt.poor small { color: #b5402c; }
#build .binfo { grid-column: 1 / -1; color: var(--muted); font-size: 12px; max-width: 340px; text-align: center; }

/* tower 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; }
.ph b { display: inline-flex; align-items: center; gap: 6px; }
.ph b img { width: 28px; height: 28px; }
.ph .lv { color: var(--accent); font-size: 14px; letter-spacing: 1px; }
#panel-body p { margin: 4px 0 6px; color: var(--muted); font-size: 13px; }
.kv { display: flex; gap: 6px; align-items: baseline; font-size: 13px; padding: 2px 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); }
#panel-modes { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
#panel-modes label { color: var(--muted); font-size: 12px; margin-right: 2px; }
#panel-modes button { font-size: 12px; padding: 3px 8px; }
#panel-modes button.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }
#panel-acts { display: flex; gap: 6px; margin-top: 10px; }
#panel-acts .act { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; padding: 8px 6px; }
#panel-acts .act img { width: 20px; height: 20px; }
#panel-acts .act small { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; }
#panel-acts .act small img { width: 15px; height: 15px; }
#panel-acts .act.poor { opacity: .6; }


/* theme touches: stone edge on HUD boxes, display font for titles, shell icon buttons */
#lvl-name, .stat, #speed, #wavebar, #build, #panel { border: 2px solid var(--edge); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
#lvl-name, #banner, .ph b, #wave-next small { font-family: var(--gs-font-display, inherit); font-weight: 400; letter-spacing: .4px; }
#lvl-name { font-size: 16px; }
#banner { -webkit-text-stroke: 1px #10213f; text-shadow: 0 3px 0 #10213f, 0 0 18px rgba(0,0,0,.5); font-size: 34px; }
#btn-pause { width: 46px; height: 46px; }
.gs-icon.gs-small { width: 32px; height: 32px; }
#build .bt { background: linear-gradient(#f6ead0, #e3cfa6); box-shadow: inset 0 -2px 0 rgba(90,60,20,.25); }
#panel-modes button.on { background: var(--accent); box-shadow: inset 0 0 0 2px #6b4a14; }

/* inside shell dialogs (briefing, help, pause, results, menu side panel) */
.foes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; margin: 4px 0 6px; }
.foes div { display: grid; grid-template-columns: 40px auto; column-gap: 8px; align-items: center; background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 3px 8px 3px 4px; }
.foes img { width: 40px; height: 40px; 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-dialog .row .chip { font-size: calc(14px * var(--gs-text, 1)); }
.gs-p.small { font-size: calc(13px * var(--gs-text, 1)); color: var(--muted); }
.gs-p.center, p.center { text-align: center; }
b.acc { color: var(--accent); }
.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: 16px; margin-top: 6px; font-weight: 700; }
.pstats span { display: inline-flex; align-items: center; gap: 4px; }
.pstats img { width: 22px; height: 22px; }

/* phones */
@media (max-width: 700px) {
  #lvl-name { display: none; }
  #top { gap: 5px; }
  .stat { font-size: 14px; padding: 3px 9px 3px 4px; gap: 4px; }
  .stat img { width: 22px; height: 22px; }
  #speed .sp svg { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #speed .sp { padding: 4px 6px; font-size: 13px; }
  #speed { padding: 3px; gap: 2px; }
  #btn-pause { width: 38px; height: 38px; }
  #top { flex-wrap: nowrap; }
  #wavebar { left: 8px; right: 8px; transform: none; max-width: none; justify-content: space-between; }
  #btn-wave { padding: 9px 12px; font-size: 14px; }
  .chip img { width: 22px; height: 22px; }
  #build { grid-template-columns: repeat(4, 1fr); }
  #build .bt { width: auto; min-width: 66px; }
  #build .bt > img { height: 44px; width: 58px; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(76px + var(--safe-b)); }
  #panel-body p { display: none; }
  #banner { font-size: 24px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  #panel { top: 56px; bottom: auto; max-height: calc(100vh - 120px); overflow-y: auto; }
  #panel-body p { display: none; }
}
