/* VASMEZŐ: DOM layers over the canvas. Dark, worn industrial; amber for actions, teal for ours, red for aliens. */
:root {
  --u: 1;
  --bg: #0b0e13; --panel: rgba(14, 18, 24, 0.92); --panel2: rgba(24, 30, 38, 0.95); --line: rgba(255, 255, 255, 0.12);
  --text: #e6e2d8; --dim: #9aa0a6; --amber: #f0a828; --amber2: #ffcc66; --teal: #5cc8e8; --good: #7fdc6a; --bad: #ff6a4a; --alien: #c060ff;
  --r: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05060a; color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
body { user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; touch-action: none; cursor: default; }
body[data-scene="battle"]:not(.touch) #game { cursor: none; }
#ui { position: fixed; inset: 0; pointer-events: none; font-size: calc(15px * var(--u)); }
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer > * { pointer-events: auto; }
.layer-screen { z-index: 1; } .layer-hud { z-index: 3; } .layer-panel { z-index: 4; } .layer-tools { z-index: 4; }
.layer-tip { z-index: 6; } .layer-modal { z-index: 8; } .layer-toast { z-index: 9; pointer-events: none; }
.layer-toast > * { pointer-events: none; }
.layer-panel, .layer-tools, .layer-tip { pointer-events: none; }

img.ico { width: 1.35em; height: 1.35em; object-fit: contain; vertical-align: -0.3em; image-rendering: auto; }
img.ico.portrait { width: 3.2em; height: 3.2em; border-radius: 50%; background: #1b2a22; border: 2px solid rgba(120, 255, 150, 0.4); flex: none; object-fit: cover; }

/* ---------------------------------------------------------------- buttons */
.btn { font: inherit; font-weight: 600; color: var(--text); background: linear-gradient(#2a323c, #1c222a); border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-color: rgba(0, 0, 0, 0.6); border-radius: 8px; padding: 0.55em 1em; cursor: pointer; min-height: 2.6em; display: inline-flex; align-items: center;
  justify-content: center; gap: 0.45em; touch-action: manipulation; transition: transform 0.06s, filter 0.1s; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.btn:hover { filter: brightness(1.18); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--amber2); outline-offset: 2px; }
.btn.primary { background: linear-gradient(#ffbe40, #d88a10); color: #1a1206; border-color: #ffd890; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn.danger { background: linear-gradient(#d84a30, #a02a18); color: #fff; border-color: #ff8a70; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.22); box-shadow: none; }
.btn.big { font-size: 1.12em; min-width: 15em; padding: 0.7em 1.3em; flex-direction: column; gap: 0.1em; }
.btn.big small { font-weight: 400; font-size: 0.72em; opacity: 0.8; }
.btn.small { min-height: 2.1em; padding: 0.3em 0.8em; font-size: 0.9em; }
.btn.dis, .btn.small.dis { filter: grayscale(0.8) brightness(0.7); }
.btn.x { min-height: 2em; width: 2em; padding: 0; background: transparent; border: 0; box-shadow: none; font-size: 1.1em; color: var(--dim); }
.btn[hidden] { display: none; }

/* ---------------------------------------------------------------- screens (title, intro, end, loading) */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 70% 30%, #2a1838 0%, #10121c 45%, #05060a 100%) center / cover no-repeat; }
.screen.title, .screen.intro, .screen.end { background-size: cover; background-position: center; }
.screen.title::before, .screen.intro::before, .screen.end::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5, 6, 10, 0.85) 0%, rgba(5, 6, 10, 0.45) 55%, rgba(5, 6, 10, 0.1) 100%); }
.screen > * { position: relative; }
.screen.title { justify-content: flex-start; padding-left: 7vw; }
.title-box { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6em; max-width: 34em; }
.logo { width: min(34em, 60vw); max-height: 34vh; object-fit: contain; object-position: left; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.8)); }
.logo-text { margin: 0; font-size: calc(76px * var(--u)); font-weight: 900; letter-spacing: 0.06em; line-height: 1; color: #f2e6cc;
  text-shadow: 0 3px 0 #7a4a10, 0 6px 22px rgba(240, 160, 40, 0.35); }
.subtitle { font-size: 1.35em; font-weight: 700; color: var(--amber2); letter-spacing: 0.03em; }
.tagline { color: var(--dim); max-width: 28em; margin-bottom: 0.8em; }
.menu-col { display: flex; flex-direction: column; gap: 0.6em; align-items: stretch; }
.menu-label { color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8em; }
.btn.sound { position: absolute; top: 1em; right: 1em; width: 2.8em; min-height: 2.8em; padding: 0; font-size: 1.1em; }
.foot { position: absolute; bottom: 1em; left: 0; right: 0; text-align: center; color: var(--dim); font-size: 0.8em; padding: 0 1em; }

.screen.loading { flex-direction: column; gap: 0.8em; }
.screen.loading .logo-text { font-size: calc(54px * var(--u)); }
.loadbar { width: 16em; height: 6px; background: #1a1e26; border-radius: 3px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.15s; }

.intro-box { width: min(40em, 88vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.3em 1.5em; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.intro-head { display: flex; align-items: center; gap: 0.8em; margin-bottom: 0.8em; color: #b8ffc0; font-size: 1.05em; }
.intro-text { font-size: 1.22em; line-height: 1.5; min-height: 4.6em; }
.intro-text.in { animation: fadein 0.45s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dots { display: flex; gap: 6px; margin: 1em 0; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: #3a4048; }
.dots span.on { background: var(--amber); }
.row { display: flex; gap: 0.6em; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

.screen.end { flex-direction: column; }
.end-box { width: min(36em, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.2em 1.5em; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); max-height: 96vh; overflow: auto; }
.end-title { font-size: calc(54px * var(--u)); font-weight: 900; letter-spacing: 0.08em; color: var(--amber2); text-shadow: 0 4px 20px rgba(240, 160, 40, 0.4); }
.screen.end.lose .end-title { color: var(--bad); text-shadow: 0 4px 20px rgba(255, 60, 40, 0.4); }
.end-text { font-size: 1.08em; line-height: 1.45; color: var(--text); margin: 0.5em 0 0.9em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5em; margin-bottom: 0.9em; }
.stat { background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 0.5em 0.3em; display: flex; flex-direction: column; gap: 0.2em; }
.stat span { font-size: 0.75em; color: var(--dim); }
.stat b { font-size: 1.15em; }
.share-text { width: 100%; resize: none; font: inherit; font-size: 0.92em; background: #0a0d12; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0.6em; margin-bottom: 0.8em; user-select: text; -webkit-user-select: text; }
.end-box .row { justify-content: center; }

/* ---------------------------------------------------------------- strategic HUD */
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 0.6em; padding: 0.35em 0.6em; padding-top: max(0.35em, env(safe-area-inset-top));
  background: linear-gradient(rgba(8, 10, 14, 0.95), rgba(8, 10, 14, 0.78)); border-bottom: 1px solid var(--line); font-size: 0.95em; }
.topbar .btn { min-height: 2.3em; padding: 0.3em 0.7em; }
.tb-back { margin-right: 0.2em; }
.tb-res { display: flex; gap: 0.9em; }
.res { display: inline-flex; align-items: center; gap: 0.3em; white-space: nowrap; }
.res b { font-variant-numeric: tabular-nums; }
.res.full b { color: var(--amber2); }
.tb-clock { display: flex; align-items: center; gap: 0.4em; margin-left: auto; background: rgba(255, 255, 255, 0.06); border-radius: 8px; padding: 0.25em 0.6em; white-space: nowrap; }
.tb-clock .time { font-size: 1.15em; font-variant-numeric: tabular-nums; color: var(--amber2); }
.tb-clock.paused .time { animation: blink 1s steps(2) infinite; color: var(--dim); }
@keyframes blink { 50% { opacity: 0.35; } }
.tb-speed { display: flex; gap: 2px; }
.btn.sp { min-width: 2.5em; padding: 0.3em 0.4em; font-size: 0.85em; letter-spacing: -0.1em; }
.btn.sp.on { background: linear-gradient(#ffbe40, #d88a10); color: #1a1206; }
.tb-lvl { color: var(--alien); font-weight: 700; white-space: nowrap; font-size: 0.9em; }
.tb-tools { display: flex; gap: 0.35em; margin-left: auto; }
.tb-tools .btn.busy img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.logbox { position: absolute; right: 0.6em; top: 3.6em; width: min(24em, 50vw); max-height: calc(100% - 5em); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.logbox[hidden] { display: none; }
.logtitle { display: flex; justify-content: space-between; align-items: center; padding: 0.3em 0.4em 0.3em 0.8em; font-weight: 700; border-bottom: 1px solid var(--line); }
.loglist { overflow: auto; padding: 0.4em 0.8em; font-size: 0.88em; }
.logline { padding: 0.25em 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.logline.bad { color: #ffb0a0; }
.lt { color: var(--dim); margin-right: 0.5em; font-variant-numeric: tabular-nums; }

/* hex panel */
.hexpanel { position: absolute; right: 0.6em; top: 3.7em; width: min(21em, 42vw); max-height: calc(100% - 4.4em); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 0.6em 0.8em 0.8em; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.hexpanel[hidden] { display: none; }
.hp-head { display: flex; align-items: center; gap: 0.6em; margin-bottom: 0.3em; }
.hp-head > div { flex: 1; }
.hp-head img.ico { width: 2.2em; height: 2.2em; }
.hp-name { font-weight: 800; font-size: 1.12em; }
.hp-sub { color: var(--dim); font-size: 0.85em; }
.hp-acts { display: flex; flex-direction: column; gap: 0.4em; margin-top: 0.6em; }
.desc { color: var(--dim); font-size: 0.88em; line-height: 1.35; margin: 0.3em 0 0.5em; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 1em; padding: 0.28em 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.kv span { color: var(--dim); }
.kv.good b { color: var(--good); } .kv.bad b, .kv.bad span { color: var(--bad); }
p { margin: 0.4em 0; }
p.dim { color: var(--dim); font-size: 0.88em; }
p.good { color: var(--good); font-weight: 600; }
p.bad { color: var(--bad); font-weight: 600; }
.squadchip { position: absolute; left: 0.6em; bottom: max(0.6em, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 0.4em; background: var(--panel); border: 1px solid rgba(255, 180, 40, 0.4); border-radius: 999px; padding: 0.35em 0.9em 0.35em 0.4em; cursor: pointer; font-size: 0.9em; max-width: 60vw; }
.squadchip img.ico { width: 1.8em; height: 1.8em; }

/* base view */
.basecard { position: absolute; left: 0.6em; top: 3.7em; width: min(17em, 36vw); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 0.5em 0.7em; font-size: 0.9em; }
.bc-title { display: flex; align-items: center; gap: 0.4em; font-weight: 800; font-size: 1.1em; margin-bottom: 0.3em; }
.bc-row { padding: 0.2em 0; display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.bc-row.bad { color: var(--bad); }
.bc-row.alarm { color: #fff; background: rgba(220, 50, 30, 0.35); border-radius: 6px; padding: 0.35em 0.5em; margin-top: 0.3em; animation: pulse 1.4s ease-in-out infinite; display: block; }
.bc-row.warn { color: #ffc0a0; }
.toolbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(0.5em, env(safe-area-inset-bottom)); display: flex; gap: 0.3em; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.3em; max-width: 98vw; overflow-x: auto; }
.btn.tool { flex-direction: column; gap: 0.05em; min-width: 4.6em; padding: 0.3em 0.4em; min-height: 3.6em; font-size: 0.82em; position: relative; }
.btn.tool img.ico { width: 1.9em; height: 1.9em; }
.tico { font-size: 1.5em; line-height: 1.2em; }
.tico.demo { color: #ff8a6a; }
/* flat SVG glyphs instead of emoji (GR-09) */
.glyph { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.2em; pointer-events: none; }
.glyph svg { display: block; width: 100%; height: 100%; }
.tico .glyph { width: 0.95em; height: 0.95em; vertical-align: -0.12em; }
.tname { white-space: nowrap; }
.tcost { position: absolute; top: 1px; right: 3px; font-size: max(11px, 0.72em); line-height: 1; background: rgba(8, 10, 14, 0.75); border-radius: 4px; padding: 1px 3px; color: var(--amber2); font-weight: 700; }
.btn.tool.on { background: linear-gradient(#ffbe40, #d88a10); color: #1a1206; }

/* ---------------------------------------------------------------- battle HUD (DOM part) */
.btn.bpause { position: absolute; top: 0.5em; right: calc(140px * var(--u) + 1.2em); width: 2.6em; min-height: 2.6em; padding: 0; background: rgba(8, 10, 14, 0.6); font-size: 0.9em; }
body.touch .btn.bpause { right: auto; left: calc(214px * var(--u) + 1em); }

/* ---------------------------------------------------------------- tips */
.tip { position: absolute; left: 50%; transform: translateX(-50%); bottom: 5.4em; width: min(34em, 80vw); display: flex; align-items: center; gap: 0.8em;
  background: rgba(10, 20, 14, 0.95); border: 1px solid rgba(120, 255, 150, 0.35); border-radius: 12px; padding: 0.6em 0.8em; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); animation: tipin 0.3s ease-out; }
@keyframes tipin { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
body[data-scene="battle"] .tip { bottom: auto; top: 3.4em; width: min(30em, 60vw); }
.tip-body { flex: 1; }
.tip-name { color: #8fe8a0; font-weight: 700; font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.08em; }
.tip-text { line-height: 1.35; }
.btn.tip-ok { flex: none; }

/* ---------------------------------------------------------------- modals */
.modal-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2, 3, 6, 0.55); animation: fadein 0.18s ease-out; padding: 0.6em; }
.modal { width: min(30em, 94vw); max-height: 94%; display: flex; flex-direction: column; background: var(--panel2); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7); overflow: hidden; }
.modal.wide { width: min(44em, 96vw); }
.modal.alert { border-color: rgba(255, 100, 70, 0.6); box-shadow: 0 0 0 1px rgba(255, 80, 50, 0.2), 0 24px 70px rgba(0, 0, 0, 0.7); }
.modal.win { border-color: rgba(130, 230, 110, 0.6); }
/* 9-slice metal frame from the gfx sheet (panel.png, slice 24, fill). The flat colours above stay as the
   fallback: the background is clipped to the padding box, so it only shows if the image is missing. */
.modal, .hexpanel, .basecard, .intro-box, .end-box, .logbox {
  border: 10px solid transparent; border-radius: 16px; background-clip: padding-box;
  border-image: url('assets/gfx/panel.png') 24 fill / 10px stretch;
}
.hexpanel { padding: 0.25em 0.45em 0.45em; }
.basecard { padding: 0.15em 0.35em; }
.intro-box { padding: 0.75em 1em; }
.end-box { padding: 0.6em 1em; }
.modal.alert { box-shadow: 0 0 0 2px rgba(255, 90, 60, 0.55), 0 24px 70px rgba(0, 0, 0, 0.7); }
.modal.win { box-shadow: 0 0 0 2px rgba(130, 230, 110, 0.5), 0 24px 70px rgba(0, 0, 0, 0.7); }
.modal-title { display: flex; align-items: center; gap: 0.5em; font-size: 1.2em; font-weight: 800; padding: 0.7em 1em 0.4em; }
.modal-title img.ico { width: 1.6em; height: 1.6em; }
.modal.alert .modal-title { color: #ffb4a0; }
.modal.result.win .modal-title { color: var(--good); }
.modal-body { padding: 0 1em; overflow: auto; flex: 1; min-height: 0; }
.modal-body p.big { font-size: 1.08em; font-weight: 600; line-height: 1.35; }
.modal-body p.big.good { color: var(--good); } .modal-body p.big.bad { color: var(--bad); }
.modal-body p.eta { color: var(--teal); font-weight: 600; }
.modal-body p.eta.bad { color: var(--bad); }
.modal-buttons { display: flex; gap: 0.5em; justify-content: flex-end; flex-wrap: wrap; padding: 0.8em 1em 0.9em; border-top: 1px solid var(--line); margin-top: 0.6em; }
.radio { display: flex; gap: 0.6em; align-items: center; background: rgba(20, 40, 26, 0.7); border: 1px solid rgba(120, 255, 150, 0.25); border-radius: 10px; padding: 0.5em; margin: 0.6em 0; font-size: 0.92em; line-height: 1.35; }
.radio img.ico.portrait { width: 2.6em; height: 2.6em; }
.radio b { color: #8fe8a0; }
.menu p { color: var(--dim); }

/* research */
.rlist { display: flex; flex-direction: column; gap: 0.35em; }
.ractive { background: rgba(92, 200, 232, 0.12); border: 1px solid rgba(92, 200, 232, 0.4); border-radius: 8px; padding: 0.45em 0.7em; color: var(--teal); font-weight: 600; }
.rsamples { font-weight: 700; padding: 0.2em 0; }
.ritem { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 0.8em; align-items: center; background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 0.45em 0.7em; }
.ritem .rname { font-weight: 700; display: flex; gap: 0.6em; align-items: baseline; flex-wrap: wrap; }
.ritem .rdesc { grid-column: 1; color: var(--dim); font-size: 0.85em; }
.ritem > .btn, .ritem > .rstate { grid-column: 2; grid-row: 1 / span 2; }
.rcost { color: var(--teal); font-weight: 400; font-size: 0.85em; }
.rstate { color: var(--dim); font-size: 0.85em; }
.ritem.done { opacity: 0.55; } .ritem.done .rstate { color: var(--good); }
.ritem.locked { opacity: 0.45; }
.ritem.active { border: 1px solid rgba(92, 200, 232, 0.5); }

/* armory */
.armory { display: flex; flex-direction: column; gap: 0.3em; }
.armory > .btn { margin: 0.5em 0; }
.queue { display: flex; gap: 4px; }
.queue .slot { flex: 1; height: 6px; border-radius: 3px; background: #2a3038; }
.queue .slot.on { background: var(--amber); }
.wlist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4em; }
.witem { display: flex; flex-direction: column; align-items: center; gap: 0.1em; background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 0.4em; text-align: center; font-size: 0.88em; }
.witem img.ico { width: 3.4em; height: 2em; }
.witem small { color: var(--dim); }
.witem.locked { opacity: 0.4; filter: grayscale(1); }

/* ---------------------------------------------------------------- toasts */
.layer-toast { display: flex; flex-direction: column; align-items: center; gap: 0.35em; padding-top: 3.9em; }
.toast { background: rgba(14, 18, 24, 0.94); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 8px; padding: 0.45em 0.9em; max-width: 80vw; font-size: 0.92em; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); animation: fadein 0.25s ease-out; transition: opacity 0.5s, transform 0.5s; }
.toast.bad { border-left-color: var(--bad); }
.toast.day { border-left-color: var(--amber); font-weight: 700; }
.toast.out { opacity: 0; transform: translateY(-6px); }
body[data-scene="battle"] .layer-toast { padding-top: 5.5em; }

/* ---------------------------------------------------------------- rotate message */
#rotate { position: fixed; inset: 0; z-index: 50; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; background: #05060a; color: var(--text); font-size: 18px; text-align: center; padding: 2em; }
body.portrait #rotate { display: flex; }
body.portrait #ui { display: none; }
.rot-phone { width: 54px; height: 92px; border: 4px solid var(--amber); border-radius: 10px; animation: rot 2.2s ease-in-out infinite; }
@keyframes rot { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ---------------------------------------------------------------- small landscape screens (phones) */
@media (max-height: 520px) {
  #ui { font-size: calc(13px * var(--u)); }
  .logo-text { font-size: 52px; }
  .tagline { display: none; }
  .btn.big { min-width: 12em; padding: 0.45em 1em; }
  .tb-tools .btn img + span, .tb-back img + span { display: none; }
  .tb-lvl { font-size: 0.8em; }
  .hexpanel { top: 3.3em; max-height: calc(100% - 3.8em); }
  .basecard { top: 3.3em; }
  .tip { bottom: 4.6em; }
  .intro-text { font-size: 1.08em; min-height: 3.2em; }
  .end-title { font-size: 34px; }
  .end-text { margin: 0.2em 0 0.5em; }
}
@media (max-width: 900px) {
  .tb-tools .btn img + span, .tb-back img + span { display: none; }
  .tb-res { gap: 0.55em; }
}

/* ---------------------------------------------------------------- tips never sit on a modal (JM-06) */
body.modal-open .layer-tip, body.modal-open .layer-toast > .toast:not(.live) { visibility: hidden; }   /* a toast shown just before a modal hides too (GR-08); an error from a click in the modal shows */

/* ---------------------------------------------------------------- touch screens (JM-12, GR-10, GR-11)
   Text at least 13 css px, every touch target at least 44x44, whatever the screen size. */
body.touch #ui { font-size: 15px; }
body.touch .btn { min-height: 44px; }
body.touch .btn.small, body.touch .btn.x, body.touch .btn.sound, body.touch .btn.tip-ok { min-width: 44px; min-height: 44px; }
body.touch .btn.big { min-width: 13em; padding: 0.4em 1em; }
body.touch .btn.big small, body.touch .foot, body.touch .menu-label, body.touch .stat span, body.touch .hp-sub, body.touch .desc, body.touch p.dim,
body.touch .tip-name, body.touch .loglist, body.touch .witem small, body.touch .rdesc, body.touch .rcost, body.touch .rstate, body.touch .rwhy, body.touch .witem,
body.touch .squadchip, body.touch .basecard, body.touch .toast, body.touch .tb-lvl, body.touch .btn.small, body.touch .btn.bpause { font-size: 13px; }
body.touch .foot { bottom: 0.3em; }
/* top bar: icon-only tools, 44 px buttons */
body.touch .topbar { gap: 0.4em; padding-top: max(0.15em, env(safe-area-inset-top)); padding-bottom: 0.15em; font-size: 14px; }
body.touch .topbar .btn { min-width: 44px; min-height: 44px; padding: 0 0.45em; }
body.touch .btn.sp { min-width: 44px; font-size: 13px; letter-spacing: 0; }
body.touch .btn .glyph { width: 18px; height: 18px; }
body.touch .tb-tools .btn img + span, body.touch .tb-back img + span { display: none; }
body.touch .tb-res { gap: 0.6em; }
body.touch .tb-clock { padding: 0.1em 0.45em; }
body.touch .tb-clock .time { font-size: 15px; }
body.touch .logbox, body.touch .hexpanel { top: 50px; max-height: calc(100% - 56px); }
body.touch .hexpanel { width: min(22em, 46vw); }
body.touch .basecard { top: 50px; width: min(15em, 32vw); }
body.touch .layer-toast { padding-top: 52px; }
/* base toolbar: 48x44 tools, the cost badge stays readable */
body.touch .btn.tool { min-width: 52px; min-height: 48px; font-size: 13px; padding: 0.15em 0.3em; }
body.touch .btn.tool img.ico { width: 22px; height: 22px; }
body.touch .tico { font-size: 18px; }
body.touch .tcost { font-size: 13px; top: -2px; right: -1px; padding: 0 2px; }
body.touch .toolbar { padding: 0.2em; gap: 0.2em; bottom: max(0.25em, env(safe-area-inset-bottom)); }
/* modals: the buttons wrap instead of shrinking */
body.touch .modal { width: min(32em, 94vw); }
body.touch .modal-title { padding: 0.45em 0.8em 0.2em; }
body.touch .modal-buttons { padding: 0.45em 0.8em 0.55em; margin-top: 0.4em; }
body.touch .tip { bottom: 4.2em; }
/* battle: the pause button is placed by the scene next to the minimap (GR-11) */
body.touch .btn.bpause, .btn.bpause.placed { right: auto; width: 44px; min-height: 44px; }
.rwhy { grid-column: 1; color: var(--bad); font-size: 0.85em; opacity: 0.9; }
@media (max-height: 520px) {
  body.touch .intro-text { font-size: 15px; }
  body.touch .end-box { padding: 0.35em 0.8em; }
  body.touch .stats { margin-bottom: 0.4em; }
  body.touch .end-text { font-size: 14px; }
  /* the controls line would sit on the menu; the battle tip and the pause menu say it too */
  body.touch .foot { display: none; }
}
