/* Fonts are bundled so the game works offline. Licenses are in fonts/. */
@font-face { font-family: 'Pixelify Sans'; src: url(../fonts/pixelify-sans.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Chakra Petch'; src: url(../fonts/chakra-petch-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Chakra Petch'; src: url(../fonts/chakra-petch-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Chakra Petch'; src: url(../fonts/chakra-petch-700.woff2) format('woff2'); font-weight: 700 900; font-display: swap; }
:root {
  --bg: #0a0810; --ink: #f4ecdc; --dim: #a99f92; --dimmer: #6f665e;
  --steel1: #2a2532; --steel2: #1b1821; --steel3: #131017; --edge: #3d3548; --edge2: #574c66;
  --gold: #ffc94a; --gold2: #e89a2a; --gold3: #8a4e10; --red: #ec4a3c; --green: #72dc6a; --cyan: #6ad8e8; --pink: #ff7ad8;
  --hud: 'Pixelify Sans', 'Trebuchet MS', sans-serif;
  --body: 'Chakra Petch', 'Segoe UI', sans-serif;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: var(--body);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; touch-action: none; overscroll-behavior: none; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
img.ic, .ic { image-rendering: pixelated; flex: none; }
.px { image-rendering: pixelated; }
h1, h2, h3, h4 { font-family: var(--hud); font-weight: 600; letter-spacing: 0.5px; }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; font-family: var(--hud); font-size: 17px; font-weight: 600; letter-spacing: 0.4px;
  background: linear-gradient(#3a3346, #2a2433); color: var(--ink);
  box-shadow: inset 0 1px 0 #ffffff22, inset 0 0 0 1px #4d4459, 0 4px 0 #0f0c13, 0 6px 12px #0006;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1px 0 #ffffff22, inset 0 0 0 1px #4d4459, 0 1px 0 #0f0c13, 0 2px 6px #0006; }
.btn.primary { background: linear-gradient(#ffd66a, #f0a234 55%, #d9822a); color: #2b1504; text-shadow: 0 1px 0 #ffe9a866;
  box-shadow: inset 0 1px 0 #fff3c0, inset 0 0 0 1px #ffcf70, 0 4px 0 var(--gold3), 0 6px 14px #0007, 0 0 18px #ffb03a33; }
.btn.primary:active:not(:disabled) { box-shadow: inset 0 1px 0 #fff3c0, inset 0 0 0 1px #ffcf70, 0 1px 0 var(--gold3), 0 2px 6px #0007; }
.btn.danger { background: linear-gradient(#b24a3e, #852c25); box-shadow: inset 0 1px 0 #ffb0a033, inset 0 0 0 1px #c85a4c, 0 4px 0 #3e100c, 0 6px 12px #0006; }
.btn.danger:active:not(:disabled) { box-shadow: inset 0 0 0 1px #c85a4c, 0 1px 0 #3e100c; }
.btn.ghost { background: #ffffff0a; box-shadow: inset 0 0 0 1px #ffffff1c; }
.btn.big { min-height: 56px; font-size: 22px; padding: 0 28px; border-radius: 12px; }
.btn.icon { padding: 0; width: 44px; min-width: 44px; }
.btn:disabled { filter: grayscale(0.7) brightness(0.6); cursor: default; }
.btn .ic { width: 24px; height: 24px; }
.btn .cost { display: inline-flex; align-items: center; gap: 2px; font-size: 0.9em; }
.btn .cost .ic { width: 20px; height: 20px; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff;
  font: 700 12px/20px var(--body); box-shadow: 0 0 0 2px var(--bg); text-align: center; }
.x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 10px; background: #ffffff0d; display: grid; place-items: center; z-index: 2; }
.x svg { width: 18px; height: 18px; }
.x:active { background: #ffffff22; }

/* ---------- panels and chips ---------- */
.panel { background: linear-gradient(180deg, #25202dee, #17141ef2); border-radius: 14px;
  box-shadow: inset 0 1px 0 #ffffff17, inset 0 0 0 1px #3d3548, 0 0 0 1px #000, 0 12px 32px #000a; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 6px; border-radius: 17px; background: #0009;
  box-shadow: inset 0 0 0 1px #ffffff1a; font: 600 16px var(--hud); white-space: nowrap; }
.chip .ic { width: 24px; height: 24px; }
.hazard { height: 5px; background: repeating-linear-gradient(-45deg, #f0b43a 0 8px, #1a1410 8px 16px); opacity: 0.85; }
.eyebrow { font: 700 11px var(--body); letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; animation: screenIn 0.28s ease-out both; background: var(--bg) center / cover no-repeat; image-rendering: pixelated; }
.screen::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--shade, linear-gradient(#0a0810cc, #0a0810ee)); }
.screen > * { position: relative; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l)); flex: none; }
.topbar h2 { margin: 0; font-size: 26px; flex: 1; min-width: 0; text-shadow: 0 2px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroll { flex: 1; min-height: 0; overflow: auto; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }

/* title */
.title { --shade: radial-gradient(ellipse at 50% 40%, #0a081000 0%, #0a081055 55%, #0a0810e8 100%), linear-gradient(#0a081066, #0a081000 30%, #0a081000 55%, #0a0810f0); background-size: cover; animation: screenIn 0.4s ease-out both, pan 40s ease-in-out infinite alternate; }
@keyframes pan { from { background-position: 30% 50%; } to { background-position: 70% 50%; } }
.title .logo { margin-top: calc(18px + var(--safe-t)); text-align: center; }
.title h1 { margin: 0; font-size: clamp(36px, min(10vh, 11vw), 84px); line-height: 0.95; color: var(--gold); letter-spacing: 3px;
  background: linear-gradient(#fff2b0, #ffcc4a 45%, #e8862a 55%, #ffb648); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #5a2a08) drop-shadow(0 0 2px #000) drop-shadow(0 6px 14px #000c); }
.title .tag { margin-top: 6px; font: 600 14px var(--body); letter-spacing: 4px; text-transform: uppercase; color: #e8dcc0; text-shadow: 0 2px 4px #000; }
.title .menu { margin-top: auto; padding: 0 calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title .play { min-width: 280px; flex-direction: column; gap: 0; line-height: 1.05; min-height: 64px; }
.title .play small { font: 600 13px var(--body); opacity: 0.75; letter-spacing: 1px; }
.title .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.tile-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 84px; height: 72px; border-radius: 12px;
  background: linear-gradient(#2c2735e8, #1b1822f0); box-shadow: inset 0 1px 0 #ffffff1c, inset 0 0 0 1px #463e52, 0 4px 0 #0c0a10, 0 6px 14px #0008; font: 600 13px var(--hud); }
.tile-btn .ic { width: 36px; height: 36px; }
.tile-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px #463e52, 0 1px 0 #0c0a10; }
.tile-btn.locked { filter: grayscale(1) brightness(0.55); }
.tile-btn svg { width: 30px; height: 30px; margin: 3px; }

/* campaign map */
.map { --shade: linear-gradient(#0a0810dd, #0a0810f2); }
.depths { display: flex; gap: 14px; padding: 4px calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(14px + var(--safe-l)); scroll-snap-type: x mandatory; height: 100%; }
.depth { position: relative; flex: none; width: min(340px, 78vw); height: 100%; min-height: 250px; scroll-snap-align: center; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  background: #111 center / cover no-repeat; image-rendering: pixelated; box-shadow: inset 0 0 0 1px #ffffff22, 0 0 0 1px #000, 0 10px 30px #000a; }
.depth::before { content: ''; position: absolute; inset: 0; background: linear-gradient(#0a081022, #0a081000 30%, #0a0810cc 62%, #0a0810f4); }
.depth > * { position: relative; }
.depth .head { padding: 14px 16px 0; }
.depth .head .eyebrow { color: var(--glow); text-shadow: 0 1px 2px #000; }
.depth h3 { margin: 2px 0 0; font-size: 26px; text-shadow: 0 2px 0 #000, 0 0 12px #000; }
.depth .sub { font-size: 13px; color: #d8d0c4; text-shadow: 0 1px 2px #000; }
.depth .nodes { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 14px 16px 16px; position: relative; }
.depth .nodes::before { content: ''; position: absolute; left: 36px; right: 40px; top: 42px; height: 4px; background: #ffffff22; border-radius: 2px; }
.node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.node .disc { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font: 700 22px var(--body);
  background: radial-gradient(circle at 50% 35%, #4a4258, #231e2a 70%); box-shadow: inset 0 0 0 2px #6a5e7c, 0 0 0 3px #000a, 0 4px 10px #000a; }
.node.done .disc { background: radial-gradient(circle at 50% 35%, #6a5a30, #2e2614 70%); box-shadow: inset 0 0 0 2px var(--gold2), 0 0 0 3px #000a, 0 4px 10px #000a; }
.node.next .disc { background: radial-gradient(circle at 50% 35%, #ffd66a, #d9822a 70%); color: #2b1504; box-shadow: inset 0 0 0 2px #fff0b0, 0 0 0 3px #000a, 0 0 22px #ffb03a99; animation: glow 1.6s ease-in-out infinite; }
.node.boss .disc { width: 66px; height: 66px; }
.node.boss .disc .ic { width: 40px; height: 40px; }
.node.locked .disc { filter: grayscale(1) brightness(0.45); }
.node.locked .disc .ic { width: 26px; height: 26px; }
.node .stars { display: flex; gap: 1px; height: 16px; }
.node .stars .ic { width: 16px; height: 16px; }
.node .stars .off { filter: grayscale(1) brightness(0.35); }
.node .iron { position: absolute; top: -6px; right: -8px; width: 26px; height: 26px; }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2px #fff0b0, 0 0 0 3px #000a, 0 0 34px #ffb03acc; } }
.depth.locked { filter: saturate(0.2) brightness(0.55); }
.depth.locked h3 { color: var(--dim); }

/* sheets (briefing, results, pause) */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
  background: radial-gradient(ellipse at center, #0a081099, #0a0810e6); animation: fadeIn 0.2s ease-out both; }
.modal.out { animation: fadeOut 0.16s ease-in both; }
.sheet { position: relative; width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; animation: popIn 0.26s cubic-bezier(0.2, 1.3, 0.4, 1) both; text-align: center; }
.sheet .body { padding: 16px 18px 18px; overflow: auto; touch-action: pan-y; min-height: 0; scrollbar-width: none; }
.sheet .art { height: 110px; flex: none; background: #111 center / cover no-repeat; image-rendering: pixelated; position: relative; }
.sheet .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#0a081000 40%, #1f1b26); }
.sheet h2 { margin: 0; font-size: 30px; line-height: 1.05; text-shadow: 0 2px 0 #000; }
.sheet .lede { margin: 6px 0 0; color: var(--dim); font-size: 15px; }
.sheet .actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.sheet .actions .btn.primary { flex: 1; max-width: 300px; }
.sheet.wide { width: min(760px, 100%); }
.sheet.split { flex-direction: row; text-align: left; }
.sheet.split .art { width: 40%; height: auto; }
.sheet.split .art::after { background: linear-gradient(90deg, #0a081000 50%, #1f1b26); }
.sheet.split .body { flex: 1; display: flex; flex-direction: column; }
.sheet.split .actions { margin-top: auto; padding-top: 14px; justify-content: stretch; }
.sheet.split .actions .btn.primary { max-width: none; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } }

.cards { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.info { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 12px; background: #0006; box-shadow: inset 0 0 0 1px #ffffff14; text-align: left; }
.info .pic { width: 52px; height: 52px; flex: none; border-radius: 10px; background: radial-gradient(circle, #3a3346, #1a1620); display: grid; place-items: center; overflow: hidden; }
.info .pic img { max-width: 46px; max-height: 46px; image-rendering: pixelated; }
.info b { font-family: var(--hud); font-weight: 600; font-size: 16px; display: block; }
.info .tagline { font: 700 10px var(--body); letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); }
.info.new .tagline { color: var(--pink); }
.info.tower .tagline { color: var(--cyan); }
.info p { margin: 1px 0 0; color: var(--dim); font-size: 13px; line-height: 1.3; }
.facts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.sheet.split .facts { justify-content: flex-start; }
.fact { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 5px; border-radius: 99px; background: #0007; box-shadow: inset 0 0 0 1px #ffffff14; font: 600 14px var(--hud); }
.fact .ic { width: 22px; height: 22px; }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #0006; box-shadow: inset 0 0 0 1px #ffffff14; text-align: left; cursor: pointer; }
.toggle .ic { width: 34px; height: 34px; }
.toggle b { font: 600 15px var(--hud); display: block; }
.toggle small { color: var(--dim); font-size: 12px; }
.toggle input { display: none; }
.toggle .sw { margin-left: auto; width: 46px; height: 26px; flex: none; border-radius: 13px; background: #3a3346; position: relative; transition: background 0.2s; }
.toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #ddd; transition: transform 0.2s; }
.toggle input:checked + .sw { background: var(--gold2); }
.toggle input:checked + .sw::after { transform: translateX(20px); background: #fff; }
.bigstars { display: flex; justify-content: center; gap: 6px; margin: 8px 0 2px; }
.bigstars .ic { width: 58px; height: 58px; filter: grayscale(1) brightness(0.3); }
.bigstars .ic.on { filter: none; animation: starPop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.bigstars.small .ic { width: 30px; height: 30px; }
@keyframes starPop { 0% { transform: scale(0.1) rotate(-40deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.reward { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 14px 6px 8px; border-radius: 99px; background: #1e3a1c; box-shadow: inset 0 0 0 1px #4a9a44; font: 600 17px var(--hud); color: #b8f0a8; animation: popIn 0.4s 0.6s both; }
.reward .ic { width: 28px; height: 28px; }
.menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.menu-list .btn { width: 100%; }

/* research */
.lab { --shade: linear-gradient(#0a0810d8, #0a0810f0); }
.tree { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 12px; padding: 0 calc(14px + var(--safe-r)) 90px calc(14px + var(--safe-l)); min-width: 720px; }
.tier { display: flex; flex-direction: column; gap: 8px; }
.tier > .eyebrow { padding: 2px 4px; color: var(--dim); }
.rnode { position: relative; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 10px 8px 8px; border-radius: 12px; text-align: left;
  background: linear-gradient(#2a2532ee, #1b1822f2); box-shadow: inset 0 1px 0 #ffffff14, inset 0 0 0 1px #3d3548, 0 3px 0 #0c0a10; }
.rnode .ic { width: 34px; height: 34px; }
.rnode b { font: 600 15px var(--hud); display: block; line-height: 1.1; }
.rnode small { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 3px; }
.rnode small .ic { width: 16px; height: 16px; }
.rnode.owned { background: linear-gradient(#24361f, #172414); box-shadow: inset 0 0 0 1px #4a8a44, 0 3px 0 #0c0a10; }
.rnode.owned small { color: var(--green); }
.rnode.can { box-shadow: inset 0 1px 0 #ffffff14, inset 0 0 0 2px var(--gold2), 0 3px 0 #0c0a10, 0 0 14px #ffb03a33; }
.rnode.blocked { opacity: 0.45; }
.rnode.sel { transform: translateY(-2px); box-shadow: inset 0 0 0 2px #fff, 0 6px 16px #000a; }
.dock { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 12px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(#17141ef4, #0d0b12fa); box-shadow: 0 -1px 0 #3d3548, 0 -10px 30px #0009; animation: dockIn 0.2s ease-out both; }
.dock .txt { flex: 1; min-width: 0; }
.dock b { font: 600 18px var(--hud); }
.dock p { margin: 2px 0 0; font-size: 14px; color: var(--dim); }
@keyframes dockIn { from { transform: translateY(100%); } }

/* codex */
.codex { --shade: linear-gradient(#0a0810d0, #0a0810f0); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #0008; box-shadow: inset 0 0 0 1px #ffffff14; }
.tabs button { height: 36px; padding: 0 14px; border-radius: 9px; font: 600 15px var(--hud); color: var(--dim); }
.tabs button.on { background: linear-gradient(#3a3346, #2a2433); color: var(--ink); box-shadow: inset 0 0 0 1px #5a4f68; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; padding: 0 calc(14px + var(--safe-r)) 20px calc(14px + var(--safe-l)); }
.dex button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 8px; border-radius: 12px;
  background: radial-gradient(circle at 50% 35%, #2f2a38, #17141d 75%); box-shadow: inset 0 0 0 1px #3d3548, 0 3px 0 #0c0a10; }
.dex button img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 2px #000a); }
.dex button span { font: 600 12px var(--hud); line-height: 1.1; min-height: 26px; display: flex; align-items: center; text-align: center; }
.dex button.unseen span { color: var(--dimmer); }
.dex button.boss { box-shadow: inset 0 0 0 1px #8a3a3a, 0 3px 0 #0c0a10; }
.dex button:active { transform: translateY(2px); }
.dex h4 { grid-column: 1 / -1; margin: 8px 2px -2px; font-size: 15px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.dex h4 i { width: 10px; height: 10px; border-radius: 50%; background: var(--glow); box-shadow: 0 0 8px var(--glow); }
.detail .portrait { width: 140px; height: 140px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, #3a3346, #15121a 70%); }
.detail .portrait img { width: 120px; height: 120px; object-fit: contain; image-rendering: pixelated; }
.sheet.split .detail-art { width: 38%; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #3a334a, #120f16 70%); }
.sheet.split .detail-art img { width: 80%; max-width: 180px; image-rendering: pixelated; filter: drop-shadow(0 8px 6px #000a); }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.statgrid div { padding: 6px; border-radius: 10px; background: #0007; box-shadow: inset 0 0 0 1px #ffffff12; text-align: center; }
.statgrid small { display: block; font: 700 10px var(--body); letter-spacing: 1px; text-transform: uppercase; color: var(--dim); }
.statgrid b { font: 600 17px var(--hud); }
.tipbox { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: #2c2412; box-shadow: inset 0 0 0 1px #6a5420; color: #f4dfa8; font-size: 14px; text-align: left; }
.tipbox b { color: var(--gold); }

/* ---------- battle ---------- */
#game { position: absolute; inset: 0; display: grid; grid-template-columns: auto 1fr auto; background: #000; }
#lrail, #bar { position: relative; z-index: 3; background: linear-gradient(90deg, #131017, #1a1720); }
#lrail { width: calc(104px + var(--safe-l)); padding: calc(8px + var(--safe-t)) 8px calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); display: flex; flex-direction: column; gap: 6px; box-shadow: 1px 0 0 #2d2736, 6px 0 18px #0008; }
#bar { width: calc(118px + var(--safe-r)); padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) 8px; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; gap: 6px; align-content: start; overflow-y: auto; touch-action: pan-y; scrollbar-width: none;
  background: linear-gradient(270deg, #131017, #1a1720); box-shadow: -1px 0 0 #2d2736, -6px 0 18px #0008; }
#bar::-webkit-scrollbar { display: none; }
#field { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#field canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.rbtn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 10px; background: linear-gradient(#2c2735, #1e1a25); box-shadow: inset 0 1px 0 #ffffff14, inset 0 0 0 1px #3d3548, 0 3px 0 #0a080d; font: 600 15px var(--hud); }
.rbtn:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px #3d3548, 0 1px 0 #0a080d; }
.rbtn svg { width: 18px; height: 18px; }
.rrow { display: flex; gap: 6px; }
.rrow > * { flex: 1; }
.stat { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 8px 0 2px; border-radius: 9px; background: #0007; box-shadow: inset 0 0 0 1px #ffffff10; font: 600 18px var(--hud); white-space: nowrap; }
.stat .ic { width: 28px; height: 28px; }
.stat.ore b { color: var(--gold); }
.stat.hp b { color: #ff9a8a; }
.stat.hp.low { animation: lowHp 0.8s infinite; }
@keyframes lowHp { 50% { background: #5a1410aa; } }
.stat small { font-size: 13px; color: var(--dim); }
.stat.bump { animation: bump 0.25s; }
@keyframes bump { 40% { transform: scale(1.12); } }
.hpbar { height: 5px; margin: -2px 2px 0; border-radius: 3px; background: #0009; overflow: hidden; }
.hpbar i { display: block; height: 100%; background: linear-gradient(90deg, #5cd65c, #9af06a); transition: width 0.3s; }
.hpbar.mid i { background: linear-gradient(90deg, #e8a830, #f2d050); }
.hpbar.low i { background: linear-gradient(90deg, #c8302a, #ff6a4a); }
#preview { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 3px; overflow: hidden; padding: 4px; border-radius: 10px; background: #0005; box-shadow: inset 0 0 0 1px #ffffff0c; }
#preview .eyebrow { font-size: 9px; color: var(--dim); letter-spacing: 1.5px; padding-left: 2px; }
#preview .grp { display: flex; align-items: center; gap: 2px; font: 600 15px var(--hud); }
#preview .grp img { width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; }
#preview .grp.boss b { color: #ff7a6a; }
#send { position: relative; flex-direction: column; gap: 0; height: 58px; min-height: 58px; padding: 0 6px; font-size: 17px; line-height: 1.05; overflow: hidden; }
#send small { font: 700 12px var(--body); opacity: 0.85; }
#send .fill { position: absolute; left: 0; bottom: 0; height: 4px; background: #2b150488; }
#send:disabled { filter: none; background: linear-gradient(#3a3346, #2a2433); color: var(--dim); box-shadow: inset 0 0 0 1px #4d4459, 0 4px 0 #0f0c13; }

.tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 62px; border-radius: 10px; padding: 2px;
  background: radial-gradient(circle at 50% 30%, #332d3d, #1c1923 80%); box-shadow: inset 0 1px 0 #ffffff14, inset 0 0 0 1px #3d3548, 0 3px 0 #0a080d; transition: transform 0.08s; }
.tool img { width: 38px; height: 38px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 2px 1px #000c); }
.tool .cost { display: flex; align-items: center; gap: 1px; font: 600 13px var(--hud); color: var(--gold); line-height: 1; }
.tool .cost .ic { width: 14px; height: 14px; }
.tool.on { background: radial-gradient(circle at 50% 30%, #6a5228, #2e2414 80%); box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px #ffc94a66, 0 3px 0 #0a080d; transform: translateY(-1px); }
.tool.poor { filter: saturate(0.2) brightness(0.65); }
.tool.poor .cost { color: #c86a5a; }
.tool .cd { position: absolute; inset: 0; border-radius: 10px; background: #000b; display: none; align-items: center; justify-content: center; font: 600 18px var(--hud); color: #fff; }
.tool.lockt { filter: grayscale(1) brightness(0.45); }
.tool.lockt .cost { color: var(--dim); font-size: 11px; }
.tool:active { transform: translateY(2px); }
.bar-sep { grid-column: 1 / -1; height: 1px; background: #ffffff12; margin: 2px 0; }

/* overlays on the field */
#panel { position: absolute; z-index: 4; top: 8px; width: 250px; padding: 12px; display: none; animation: popIn 0.18s ease-out both; }
#panel.show { display: block; }
#panel.left { left: 8px; } #panel.right { right: 8px; }
#panel .hd { display: flex; align-items: center; gap: 10px; padding-right: 36px; }
#panel .hd img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
#panel .hd b { display: block; font: 600 18px var(--hud); line-height: 1.05; }
#panel .hd small { color: var(--dim); font-size: 12px; }
#panel .x { top: 6px; right: 6px; width: 36px; height: 36px; }
#panel .pips { display: flex; gap: 3px; margin-top: 3px; }
#panel .pips i { width: 14px; height: 5px; border-radius: 2px; background: #ffffff1c; }
#panel .pips i.on { background: var(--gold); box-shadow: 0 0 6px #ffc94a88; }
#panel .pips i.br { background: var(--pink); box-shadow: 0 0 6px #ff7ad888; }
#panel .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; }
#panel .stats div { padding: 4px 2px; border-radius: 8px; background: #0007; text-align: center; }
#panel .stats small { display: block; font: 700 9px var(--body); letter-spacing: 1px; text-transform: uppercase; color: var(--dim); }
#panel .stats b { font: 600 16px var(--hud); }
#panel .stats em { font-style: normal; font: 600 12px var(--hud); color: var(--green); margin-left: 2px; }
#panel p { margin: 8px 0 0; font-size: 13px; color: var(--dim); line-height: 1.3; }
#panel .seg { display: flex; gap: 3px; margin-top: 8px; padding: 3px; border-radius: 10px; background: #0008; }
#panel .seg button { flex: 1; height: 32px; border-radius: 7px; font: 600 13px var(--hud); color: var(--dim); }
#panel .seg button.on { background: #4a3a1c; color: var(--gold); box-shadow: inset 0 0 0 1px #8a6a2a; }
#panel .acts { display: flex; gap: 6px; margin-top: 10px; }
#panel .acts .btn { flex: 1; min-height: 46px; padding: 0 8px; font-size: 15px; flex-direction: column; gap: 0; line-height: 1.1; }
#panel .acts .btn.danger { flex: 0 0 76px; }
#panel .acts .btn small { font: 600 13px var(--hud); display: inline-flex; align-items: center; gap: 2px; }
#panel .acts .btn small .ic { width: 16px; height: 16px; }
/* the upgrade button previews the next look */
#panel .acts .btn.up { flex-direction: row; gap: 6px; padding: 0 8px 0 4px; }
#panel .acts .btn.up .next { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 1px 0 #0008); }
#panel .acts .btn.up span { display: flex; flex-direction: column; align-items: center; }
#panel .branches { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
#panel .branches .btn { justify-content: flex-start; text-align: left; min-height: 50px; padding: 4px 10px; flex-direction: row; gap: 8px; }
#panel .branches .btn span { flex: 1; display: flex; flex-direction: column; font-size: 15px; }
#panel .branches .btn span small { font: 500 11px var(--body); opacity: 0.8; }
#panel .branches .btn .cost { font-size: 14px; }
#toast { position: absolute; z-index: 5; top: 10px; left: 50%; transform: translate(-50%, -8px); padding: 8px 16px; border-radius: 12px; background: #0d0b12ee; box-shadow: inset 0 0 0 1px #4d4459, 0 6px 16px #000a;
  font: 600 15px var(--hud); pointer-events: none; opacity: 0; transition: opacity 0.18s, transform 0.18s; max-width: 86%; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { box-shadow: inset 0 0 0 1px #c84a3c, 0 6px 16px #000a; color: #ffc0b0; }
#hint { position: absolute; z-index: 4; bottom: 10px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 14px; max-width: calc(100% - 20px);
  background: #0d0b12ee; box-shadow: inset 0 0 0 1px #6a5a30, 0 6px 16px #000a; animation: popIn 0.18s both; }
#hint.show { display: flex; }
#hint img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
#hint .t { min-width: 0; }
#hint b { font: 600 15px var(--hud); display: block; line-height: 1.1; }
#hint small { font-size: 12px; color: var(--dim); display: block; line-height: 1.25; }
#hint .x { position: static; width: 36px; height: 36px; flex: none; }
#tip { position: absolute; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 20px)); display: none; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
  background: linear-gradient(#3a2c10f2, #2a1f0cf2); box-shadow: inset 0 0 0 2px #c8902a, 0 8px 20px #000a; font-size: 15px; font-weight: 600; line-height: 1.3; pointer-events: none; animation: popIn 0.25s both; }
#tip.show { display: flex; }
#tip { justify-content: space-between; padding: 4px 5px 4px 12px; }
#tip .rbtn { width: 44px; min-height: 44px; flex: none; }
#tip .rbtn svg { width: 16px; height: 16px; }
/* boss entrance card */
#bossintro { position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; pointer-events: none; animation: biShade 3.4s ease-out both;
  background: radial-gradient(ellipse at center, #5a0a0a55 0%, #1a020288 70%, #000a 100%); }
#bossintro .bi-band { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px max(16px, 8%); box-sizing: border-box; animation: biBand 3.4s cubic-bezier(.2,.8,.2,1) both;
  background: linear-gradient(90deg, #0000, #1a0608ee 18%, #2a0a0cf2 50%, #1a0608ee 82%, #0000);
  box-shadow: 0 -2px 0 #c8302a99, 0 2px 0 #c8302a99; border-image: repeating-linear-gradient(135deg, #e8b030 0 10px, #1a1208 10px 20px) 6 0 / 6px 0; border-style: solid; border-width: 6px 0; }
#bossintro .bi-art { flex: none; width: 110px; height: 110px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle, #ff503055 0%, #ff302000 70%); animation: biArt 3.4s ease-out both; }
#bossintro .bi-art img { width: 108px; height: 108px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 0 10px #ff4a3a88) drop-shadow(0 4px 0 #000a); }
#bossintro .bi-txt { min-width: 0; max-width: 420px; }
#bossintro small { display: block; font: 700 12px var(--body); letter-spacing: 4px; text-transform: uppercase; color: #ff7a5a; }
#bossintro b { display: block; font: 700 34px/1.05 var(--hud); color: #ffe0b0; text-shadow: 0 2px 0 #000, 0 0 18px #ff503088; letter-spacing: 1px; }
#bossintro p { margin: 4px 0 0; font-size: 14px; line-height: 1.3; color: #e8d0c0; }
@keyframes biShade { 0% { opacity: 0; } 8%, 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes biBand { 0% { transform: translateX(-60%) skewX(-8deg); opacity: 0; } 12% { transform: none; opacity: 1; } 84% { transform: none; opacity: 1; } 100% { transform: translateX(40%); opacity: 0; } }
@keyframes biArt { 0% { transform: scale(0.4); } 14% { transform: scale(1.12); } 22%, 100% { transform: scale(1); } }
@media (max-width: 560px) { #bossintro .bi-art { width: 80px; height: 80px; } #bossintro .bi-art img { width: 78px; height: 78px; } #bossintro b { font-size: 26px; } #bossintro p { font-size: 13px; } }
#banner { position: absolute; z-index: 5; top: 38%; left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 1.5s ease-out both; }
#banner span { display: inline-block; padding: 6px 40px; font: 700 38px var(--hud); letter-spacing: 3px; color: var(--gold);
  background: linear-gradient(90deg, #0000, #000c 20%, #000c 80%, #0000); text-shadow: 0 3px 0 #5a2a08, 0 0 18px #ffb03a88; }
#banner small { display: block; font: 600 14px var(--body); letter-spacing: 2px; color: #e8dcc0; text-shadow: none; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.4); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#flash { position: absolute; inset: 0; z-index: 3; pointer-events: none; box-shadow: inset 0 0 80px #ff2a1a; opacity: 0; }
#flash.on { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* ---------- portrait ---------- */
@media (orientation: portrait) {
  .depths { flex-direction: column; scroll-snap-type: y proximity; height: auto; }
  .depth { width: 100%; height: 230px; min-height: 230px; scroll-snap-align: start; }
  .tree { grid-template-columns: 1fr 1fr; min-width: 0; }
  .sheet.split { flex-direction: column; text-align: center; }
  .sheet.split .art, .sheet.split .detail-art { width: 100%; height: 120px; }
  .sheet.split .art::after { background: linear-gradient(#0a081000 40%, #1f1b26); }
  .sheet.split .detail-art { height: 150px; }
  .sheet.split .detail-art img { width: auto; height: 90%; }
  .sheet.split .facts { justify-content: center; }
  .title .play { min-width: 0; width: 100%; max-width: 340px; }

  #game { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  #lrail { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: calc(6px + var(--safe-t)) 8px 6px; box-shadow: 0 1px 0 #2d2736, 0 6px 18px #0008; background: #16131b; }
  #lrail .rrow.top { flex: none; order: 0; }
  #lrail .rrow.top .rbtn { width: 44px; }
  #lrail .rrow.top #speed { display: none; }
  #lrail .stat { order: 1; flex: 1; min-width: 0; justify-content: center; }
  #lrail .hpwrap { order: 1; flex: 1; }
  #lrail .hpbar { display: none; }
  #preview { order: 3; flex: 1 1 100%; flex-direction: row; align-items: center; gap: 8px; height: 38px; padding: 2px 8px; }
  #preview .eyebrow { margin-right: 2px; }
  #lrail .sendrow { order: 4; flex: 1 1 100%; display: flex; gap: 6px; }
  #lrail .sendrow #speed2 { display: flex; width: 64px; height: auto; }
  #send { flex: 1; height: 50px; min-height: 50px; flex-direction: row; gap: 8px; }
  #bar { width: auto; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); padding: 8px 8px calc(8px + var(--safe-b)); max-height: 40vh; background: #16131b; box-shadow: 0 -1px 0 #2d2736, 0 -6px 18px #0008; }
  .bar-sep { display: none; }
  #panel { top: auto; bottom: 8px; left: 8px !important; right: 8px !important; width: auto; }
}
@media (orientation: landscape) {
  #speed2 { display: none !important; }
}
@media (orientation: landscape) and (max-height: 360px) {
  .stat { height: 30px; font-size: 16px; }
  .stat .ic { width: 24px; height: 24px; }
  .tool { height: 54px; }
  .tool img { width: 32px; height: 32px; }
  #send { height: 50px; min-height: 50px; }
  #preview .grp img { width: 24px; height: 24px; }
}
@media (orientation: landscape) and (max-height: 430px) {
  .sheet .art { height: 70px; }
  .sheet h2 { font-size: 24px; }
  .sheet .body { padding: 12px 16px 14px; }
  .title .tag { display: none; }
  .depth h3 { font-size: 22px; }
}
@media (min-width: 1100px) and (min-height: 700px) {
  #lrail { width: 130px; } #bar { width: 150px; }
  .tool { height: 74px; } .tool img { width: 48px; height: 48px; }
}
.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px #fff, 0 0 18px #ffc94acc, 0 3px 0 #0a080d; transform: scale(1.05); } }
/* results: art beside the summary in landscape, so the buttons stay on screen */
.sheet.result { width: min(720px, 100%); }
@media (orientation: landscape) { .sheet.result .art { width: 34%; } }
.sheet.result .body { text-align: center; }
.sheet.result .facts, .sheet.result .actions { justify-content: center; }
.sheet.result .actions .btn.primary { max-width: 300px; }
@media (orientation: landscape) and (max-height: 430px) { .sheet.result .bigstars .ic { width: 44px; height: 44px; } .sheet.result .cards { margin-top: 8px; } .sheet.result .lede { font-size: 13px; } }
.sheet.split .actions { position: sticky; bottom: -18px; margin-bottom: -18px; padding-bottom: 18px; background: linear-gradient(#1c182300, #1c1823 35%); z-index: 1; }
@media (orientation: landscape) and (max-height: 430px) {
  .info { padding: 6px 10px 6px 6px; }
  .info .pic { width: 44px; height: 44px; }
  .info p { font-size: 12px; }
  .cards { gap: 6px; margin-top: 8px; }
  .facts { margin-top: 6px; }
  .btn.big { min-height: 50px; font-size: 20px; }
}
.fact .dot { width: 12px; height: 12px; border-radius: 50%; margin: 0 4px 0 5px; }
.sendrow { display: flex; gap: 6px; }
#send { flex: 1; }
.btn > *, .tool > *, .rbtn > *, .tile-btn > *, .node > *, .rnode > *, .dex button > * { pointer-events: none; }
@media (orientation: portrait) {
  .title .row { gap: 7px; flex-wrap: nowrap; }
  .tile-btn { width: min(68px, 18vw); height: 66px; font-size: 11px; }
  .tile-btn .ic { width: 32px; height: 32px; }
  .title .logo { margin-top: calc(60px + var(--safe-t)); }
}
@media (orientation: portrait) and (max-width: 440px) {
  .topbar .btn.icon:not(:first-child) { display: none; }
  .topbar h2 { font-size: 22px; }
  .topbar .chip { padding-right: 9px; font-size: 14px; }
}
#panel .acts .btn.danger.confirm { background: linear-gradient(#ff6a4a, #c83a2a); }
@media (orientation: landscape) and (max-height: 430px) {
  .tool { height: clamp(46px, calc((100vh - 52px) / 7), 62px); }
  .tool img { width: 30px; height: 30px; }
}
#bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool { min-width: 0; }
.tool .cost { white-space: nowrap; overflow: hidden; max-width: 100%; }
@media (orientation: portrait) { #bar { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); } }
#panel { max-height: calc(100% - 16px); overflow-y: auto; touch-action: pan-y; scrollbar-width: none; }
#panel .branches .btn { min-height: 48px; padding: 4px 8px; }
#panel .branches .btn span { min-width: 0; }
#panel .branches .btn span small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.2; }
@media (orientation: landscape) and (max-height: 430px) {
  #panel { padding: 10px; width: 264px; }
  #panel .stats { margin-top: 8px; }
  #panel .seg { margin-top: 6px; }
  #panel .seg button { height: 30px; }
  #panel .acts { margin-top: 8px; }
  #panel .acts .btn { min-height: 42px; }
  #panel .hd img { width: 38px; height: 38px; }
}
#bossbar { position: absolute; z-index: 4; top: 8px; left: 50%; transform: translateX(-50%); width: min(320px, 70%); display: none; text-align: center; pointer-events: none; }
#bossbar.show { display: block; }
#bossbar b { font: 600 14px var(--hud); color: #ffb0a0; text-shadow: 0 2px 0 #000, 0 0 8px #000; letter-spacing: 1px; }
#bossbar .bar { height: 10px; margin-top: 2px; border-radius: 5px; background: #000c; box-shadow: inset 0 0 0 1px #ff6a5a66, 0 0 12px #ff3a2a44; overflow: hidden; }
#bossbar .bar i { display: block; height: 100%; background: linear-gradient(#ff8a6a, #c8302a); transition: width 0.2s; }
.embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.embers i { position: absolute; bottom: -10px; width: 3px; height: 3px; background: #ffb050; box-shadow: 0 0 6px 1px #ff8a2a; opacity: 0; animation: ember 8s linear infinite; }
.embers i:nth-child(3n) { width: 2px; height: 2px; background: #ffe0a0; }
@keyframes ember { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 0.9; } 70% { opacity: 0.6; } 100% { transform: translate(40px, -110vh); opacity: 0; } }
/* numbers read best in the body face */
.stat, .chip, .fact, .tool .cost, #panel .stats b, #panel .stats em, .statgrid b, #preview .grp, .btn .cost, #panel .acts .btn small, .rnode small, .reward { font-family: var(--body); font-weight: 700; }
.stat { font-size: 19px; }
/* centered overlays get the full field width to wrap in, not just half of it */
#toast, #hint { left: 10px; right: 10px; margin: 0 auto; width: fit-content; max-width: min(560px, calc(100% - 20px)); }
#toast { transform: translateY(-8px); }
#toast.show { transform: none; }
#hint { transform: none; }
@media (orientation: portrait) {
  #bar { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 5px; }
  .tool { height: 56px; }
  .tool img { width: 32px; height: 32px; }
  .tool .cost { font-size: 12px; }
}
/* next wave list with the level name under it */
#preview { gap: 0; }
#preview .list { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: hidden; }
#preview .lvl { margin-top: auto; padding: 6px 4px 2px; border-top: 1px solid #ffffff10; }
#preview .lvl .eyebrow { display: block; color: var(--glow); font-size: 9px; letter-spacing: 1.5px; padding: 0; }
#preview .lvl b { display: block; font: 600 13px var(--hud); line-height: 1.1; color: #e8dcc8; }
#preview .grp img { width: 32px; height: 32px; }
@media (orientation: portrait) {
  /* one compact row: speed, next wave, send */
  #lrail .sendrow { display: contents; }
  #lrail .sendrow #speed2 { order: 3; flex: none; width: 52px; height: 46px; }
  #preview { order: 4; flex: 1 1 0; min-width: 0; height: 46px; }
  #preview .list { flex-direction: row; align-items: center; gap: 8px; }
  #preview .lvl { display: none; }
  #preview .eyebrow { font-size: 8px; max-width: 34px; line-height: 1.2; }
  #preview .grp img { width: 28px; height: 28px; }
  #send { order: 5; flex: 0 0 auto; width: 132px; height: 46px; min-height: 46px; flex-direction: column; gap: 0; }
}
@media (orientation: portrait) {
  #lrail::after { content: ''; order: 2; flex-basis: 100%; height: 0; }
}
/* codex: each depth is its own group, two groups side by side when there is room */
.dex.aliens { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 370px), 1fr)); gap: 6px 18px; align-items: start; }
.dex.aliens section { display: flex; flex-direction: column; gap: 8px; }
.dex.aliens h4 { margin: 6px 2px 0; }
.dex.aliens .cards4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dex.aliens .cards4 button img { width: 56px; height: 56px; }
@media (orientation: portrait) and (max-width: 440px) { .topbar h2 .long { display: none; } }
.btn svg { width: 22px; height: 22px; flex: none; }
.menu-list .btn span { pointer-events: none; }
.loadbar { position: absolute; left: 50%; bottom: calc(6px + var(--safe-b)); transform: translateX(-50%); width: min(240px, 60%); height: 4px; border-radius: 2px; background: #ffffff14; overflow: visible; transition: opacity 0.4s 0.3s; z-index: 2; }
.loadbar i { display: block; height: 100%; width: 0; border-radius: 2px; background: linear-gradient(90deg, var(--gold2), var(--gold)); box-shadow: 0 0 8px #ffb03a88; transition: width 0.15s; }
.loadbar span { position: absolute; left: 0; right: 0; top: -16px; text-align: center; font: 700 9px var(--body); letter-spacing: 2px; text-transform: uppercase; color: var(--dim); }
.loadbar.done { opacity: 0; }
@media (orientation: landscape) {
  #bar[data-many] .lockt { display: none; }
  #bar .tool { height: clamp(42px, calc((100dvh - 30px - var(--safe-t) - var(--safe-b) - var(--rows, 6) * 6px) / var(--rows, 6)), 62px); }
  #bar .tool > img { width: auto; height: 58%; max-width: 40px; }
}
/* let the screen art show through a little more */
.map { --shade: radial-gradient(ellipse at 50% 40%, #0a081077, #0a0810d8 75%), linear-gradient(#0a081088, #0a0810cc); }
.lab { --shade: radial-gradient(ellipse at 50% 30%, #0a081088, #0a0810e0 80%), linear-gradient(#0a081066, #0a0810cc); }
.codex { --shade: radial-gradient(ellipse at 50% 30%, #0a081088, #0a0810e0 80%), linear-gradient(#0a081066, #0a0810cc); }
@media (orientation: portrait) {
  .dock { flex-wrap: wrap; row-gap: 10px; }
  .dock .txt { flex: 1 1 calc(100% - 60px); }
  .dock > .btn, .dock > .chip { flex: 1 1 100%; justify-content: center; }
}
@media (orientation: portrait) { .tree { padding-bottom: 190px; } }
.sheet .body > .x ~ h2, .sheet .body > .x ~ .eyebrow { padding-right: 44px; }
.sheet:not(.split) .body > .x ~ h2, .sheet:not(.split) .body > .x ~ .eyebrow { padding-left: 44px; }
#panel .branches .btn span.cost { flex: none; flex-direction: row; align-items: center; gap: 2px; font-size: 15px; }
#panel .branches .btn span.cost .ic { width: 18px; height: 18px; }
#preview .lvl .eyebrow { white-space: nowrap; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; }
.loadbar { bottom: calc(3px + var(--safe-b)); height: 3px; }
.loadbar span { display: none; }
/* the rails never grow past the screen, so the send button always stays in view */
@media (orientation: landscape) {
  #game { grid-template-rows: minmax(0, 1fr); }
  #lrail, #bar { min-height: 0; }
  #lrail { overflow: hidden; }
}

/* Leave cave art visible around the playable board at wide and overview zooms. */
#field {
  background: linear-gradient(0deg, #09070dec, #110e17bd 54%, #09070de6), var(--cave) center / cover no-repeat, #09070d;
}
#view-toggle {
  position: absolute; z-index: 3; right: 10px; bottom: 10px; width: auto;
  min-width: 84px; min-height: 44px; padding: 0 12px; background: #211c2aee;
}
#hint.show ~ #view-toggle { visibility: hidden; }
#panel.show ~ #view-toggle { visibility: hidden; }
