/* Deepwing. The mine fills the screen; the readouts sit at the top edge and the
   thumbs' controls at the bottom corners, so the middle — where the tunnel is —
   stays clear. */
:root {
  /* R-C40: colours that were written out in rules, as tokens (theme-derive.py) */
  --kBg1: #0f1c30;
  --kBg10: rgba(140, 255, 170, .9);
  --kBg11: rgba(255, 214, 110, .85);
  --kBg12: #24344a;
  --kBg13: #3aa0ff;
  --kBg14: #7fe0ff;
  --kBg15: #ff5b4b;
  --kBg16: #ffa04b;
  --kBg17: #ffc93c;
  --kBg18: #fff1a8;
  --kBg19: rgba(60, 10, 10, .55);
  --kBg2: #1a2f4d;
  --kBg20: #2e5a2e;
  --kBg21: rgba(8, 16, 30, .85);
  --kBg22: rgba(255, 255, 255, .08);
  --kBg23: rgba(255, 255, 255, .35);
  --kBg24: rgba(20, 34, 56, .6);
  --kBg25: rgba(120, 30, 20, .55);
  --kBg26: rgba(255, 255, 255, .3);
  --kBg27: rgba(3, 8, 16, .55);
  --kBg28: rgba(13, 25, 44, .88);
  --kBg29: rgba(8, 14, 24, .7);
  --kBg3: #25406a;
  --kBg30: rgba(0, 0, 0, .6);
  --kBg31: #1f3a5e;
  --kBg32: #5a2a2a;
  --kBg33: #3a1f24;
  --kBg34: #0b1626;
  --kBg35: #ffd04a;
  --kBg4: #112038;
  --kBg5: #0e1b2f;
  --kBg6: #152942;
  --kBg7: #1b3456;
  --kBg8: #000000;
  --kBg9: rgba(140, 255, 170, .85);
  --kInk1: #ffdd57;
  --kInk2: #e8f0ff;
  --kInk3: #c8f7d0;
  --kInk4: #dfe8df;
  --kInk5: #6fb0ff;
  --kInk6: #ffd04a;
  --kLine1: #22385a;
  --kLine2: #ffd27a;
  --kLine3: #e7b94a;
  --kLine4: #4a7a5a;

  --hotInk: #3a2204;
  --bg: #0b1422;
  --ink: #eef4fb;
  --dim: #9fb3c8;
  --card: #13233a;
  --line: #2a4466;
  --hot: #ffb338;
  --good: #57d68d;
  --bad: #ff6b5b;
  --glass: rgba(8, 16, 30, .72);
  /* §40: a piece's rarity, as a stash tile's edge: common, rare, shiny */
  --tier1: #dfe8df;
  --tier2: #6fb0ff;
  --tier3: #ffd04a;
  /* §42: a trophy's rung */
  --bronze: #d0915a;
  --silver: #c9d1dc;
  --gold: #ffd04a;
}

/* R-C40: the light look. This product's own is dark; the other is chosen with the switch beside Home. */
:root[data-theme="light"] {
  --kBg1: #b7c1d2;
  --kBg10: rgba(0, 129, 51, .9);
  --kBg11: rgba(140, 105, 0, .85);
  --kBg12: #a0abbc;
  --kBg13: #0071cc;
  --kBg14: #05404f;
  --kBg15: #c73a2e;
  --kBg16: #a65b00;
  --kBg17: #8d6900;
  --kBg18: #2f2801;
  --kBg19: rgba(218, 179, 175, .55);
  --kBg2: #a0b0c6;
  --kBg20: #819c7f;
  --kBg21: rgba(198, 205, 218, .85);
  --kBg22: rgba(31, 31, 31, .08);
  --kBg23: rgba(31, 31, 31, .35);
  --kBg24: rgba(176, 187, 205, .6);
  --kBg25: rgba(199, 139, 129, .55);
  --kBg26: rgba(31, 31, 31, .3);
  --kBg27: rgba(209, 216, 223, .55);
  --kBg28: rgba(186, 196, 212, .88);
  --kBg29: rgba(202, 208, 217, .7);
  --kBg3: #8da0bd;
  --kBg30: rgba(247, 247, 247, .6);
  --kBg31: #94a6c0;
  --kBg32: #bd9a98;
  --kBg33: #c4aeb1;
  --kBg34: #bec8d5;
  --kBg35: #8d6b00;
  --kBg4: #b1bdd0;
  --kBg5: #b8c2d3;
  --kBg6: #a7b6c9;
  --kBg7: #9aacc4;
  --kBg8: #f7f7f7;
  --kBg9: rgba(0, 129, 51, .85);
  --kInk1: #110000;
  --kInk2: #000002;
  --kInk3: #000300;
  --kInk4: #010201;
  --kInk5: #001b5f;
  --kInk6: #1b0000;
  --kLine1: #97a7c0;
  --kLine2: #453000;
  --kLine3: #8f6a00;
  --kLine4: #67836f;

  --hotInk: #ffffff;
  --bg: #eff7ff;
  --ink: #1d2022;
  --dim: #48535e;
  --card: #d7e4f7;
  --line: #abbdd5;
  --hot: #a26a00;
  --good: #02a25d;
  --bad: #ef6051;
  --glass: rgba(238, 246, 255, .72);
  --tier1: #5d6570;
  --tier2: #1d5fc4;
  --tier3: #8a5a00;
  --bronze: #8a4f1c;
  --silver: #5d6570;
  --gold: #8a5a00;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none;
}
#app { display: flex; flex-direction: column; height: 100%; }

#hdr {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: var(--kBg1); border-bottom: 1px solid var(--kLine1);
}
#hdrTitle { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
            font-weight: 700; font-size: 15px; }
@media (max-width: 380px) { #hdrTitle { visibility: hidden; } }
/* R-C26: [hidden] loses to any display of our own */
[hidden] { display: none !important; }
.pill {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px;
  background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer;
}
.pill:active { background: var(--kBg3); }

.scr { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.scr.on { display: block; }
#scr-play.on { display: flex; padding: 0; overflow: hidden; }
#scr-menu, #scr-how { max-width: 720px; margin: 0 auto; width: 100%; }

h1 { font-size: 30px; margin: 8px 0 4px; }
.sub { color: var(--dim); font-size: 14px; line-height: 1.45; margin-bottom: 12px; }
.stat { color: var(--dim); font-size: 13px; }
.goal { color: var(--ink); font-size: 14px; line-height: 1.45; margin: 4px 2px 8px; min-height: 20px; }

.big {
  display: block; width: 100%; min-height: 52px; margin: 8px 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--kBg2);
  color: var(--ink); font-size: 17px; font-weight: 600; cursor: pointer;
}
.big.primary { background: var(--hot); border-color: var(--kLine2); color: var(--hotInk); }

#custom { margin: 10px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--kBg4); }
#custom > summary { list-style: none; }
#custom > summary::-webkit-details-marker { display: none; }
#custom > summary::after { content: "▾"; margin-left: auto; color: var(--dim); }
#custom[open] > summary::after { content: "▴"; }
summary { min-height: 48px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; font-weight: 600; }
.setBody { padding: 10px 12px 14px; }
.setRow { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.setLbl { flex: 1 1 120px; font-size: 14px; }
.setNote { color: var(--dim); font-size: 12px; line-height: 1.4; }
.knob { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.knobBtn {
  min-height: 44px; min-width: 56px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--kBg5); color: var(--dim);
  font-size: 13px; cursor: pointer;
}
.knobBtn.on { background: var(--hot); color: var(--hotInk); border-color: var(--kLine2); font-weight: 700; }

/* Pebblemoon beside the title; the words wrap round it */
#moonBox { float: right; width: min(36vw, 220px); height: min(36vw, 220px); margin: 0 0 4px 8px; }
#moon { display: block; width: 100%; height: 100%; }
#tierRow { clear: both; }

/* R-C12b: the rungs */
.pickRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 6px 0 4px; }
/* R17.8: Fly and On foot, two tabs under the moon */
/* (four tabs since v1.33.0, Delve: four across, and two by two on a narrow phone) */
#modeRow { grid-template-columns: repeat(3, 1fr); clear: both; }
.pick {
  min-width: 0; min-height: 72px;
  background: var(--kBg2); color: var(--ink); border: 2px solid transparent;
  border-radius: 14px; padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.pick .te { font-size: 24px; }
.pick b { font-size: 14px; }
.pick small { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.pick.sel { border-color: var(--hot); background: var(--card); }

/* the mines: a grid that wraps, never a row that scrolls sideways */
/* R1.3: a page a set of ten moons, five across, then the surprise */
#setNav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 0; }
#setName { font-size: 14px; font-weight: 700; color: var(--dim); text-align: center; flex: 1; }
.setBtn { min-width: 44px; min-height: 44px; border-radius: 12px; border: 0; background: var(--kBg6); color: var(--ink); font-size: 18px; cursor: pointer; }
.setBtn:disabled { opacity: .3; cursor: default; }
#mineRow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 6px 0 4px; }
#mineRow > .mine:last-child { grid-column: 1 / -1; min-height: 48px; flex-direction: row; gap: 8px; }
/* R21: bonus moons found through secret ways out */
#bonusRow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0 0 4px; }
#bonusRow > .mine.bonus { min-height: 48px; flex-direction: row; gap: 8px; border-color: var(--kLine3); }
.mine .pic { width: 44px; height: 44px; image-rendering: pixelated; }
.mine.newest { border-color: var(--kLine4); }
.mine {
  min-height: 84px; min-width: 0; border-radius: 12px; border: 2px solid transparent;
  background: var(--kBg6); color: var(--ink); cursor: pointer; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; line-height: 1.2; text-align: center;
}
.mine .n { font-size: 11px; color: var(--dim); }
.mine .st { font-size: 12px; letter-spacing: 1px; min-height: 14px; }
.mine.sel { border-color: var(--hot); background: var(--kBg7); }
.mine.locked { opacity: .45; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 8px 0; font-size: 14px; line-height: 1.5; }
.card h2 { font-size: 17px; margin: 0 0 4px; }

/* ---- the mine -------------------------------------------------------------- */
#stage { position: relative; flex: 1; width: 100%; overflow: hidden; touch-action: none; background: var(--kBg8); }
#cvs { display: block; width: 100%; height: 100%; touch-action: none; }
#glFail {
  position: absolute; inset: 20% 12% auto; padding: 14px; border-radius: 12px; z-index: 30;
  background: var(--kBg1); color: var(--ink); font-size: 14px; line-height: 1.5;
}
#cockpit {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 10px rgba(30, 44, 64, .9), inset 0 0 60px 24px rgba(0, 0, 0, .7);
  border-radius: 18px;
}
#sight {
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  pointer-events: none; border-radius: 50%; border: 2px solid rgba(140, 255, 170, .75);
  box-shadow: 0 0 6px rgba(80, 255, 140, .6);
}
#sight::before, #sight::after { content: ""; position: absolute; background: var(--kBg9); }
#sight::before { left: 15px; top: -8px; width: 2px; height: 46px; clip-path: polygon(0 0, 100% 0, 100% 30%, 0 30%, 0 70%, 100% 70%, 100% 100%, 0 100%); }
#sight::after { top: 15px; left: -8px; height: 2px; width: 46px; clip-path: polygon(0 0, 30% 0, 30% 100%, 0 100%, 0 0, 70% 0, 100% 0, 100% 100%, 70% 100%); }
#sight.lock { border-color: var(--bad); box-shadow: 0 0 10px rgba(255, 90, 70, .9); }
/* R17.4: on foot the sight is a dot in the middle of the screen, red when the aim help has a robot */
body.onFoot #sight { width: 8px; height: 8px; margin: -4px 0 0 -4px; border: 0; background: var(--kBg10); }
body.onFoot #sight::before, body.onFoot #sight::after { display: none; }
body.onFoot #sight.lock { background: var(--bad); }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
         box-shadow: inset 0 0 90px 30px rgba(255, 40, 30, .8); }
#flash.on { opacity: 1; transition: none; }
#flash.heal { box-shadow: inset 0 0 90px 30px rgba(80, 160, 255, .7); }
/* R22.4: the alarm once the core is down: red light pulsing at the edges of the view */
#liftFade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #000; }
#alarm { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(255, 40, 30, .55); }
#alarm.on { animation: alarmPulse 1.6s ease-in-out infinite; }
#alarm.on.still { animation: none; opacity: .35; }
@keyframes alarmPulse { 0%, 100% { opacity: .15; } 50% { opacity: .6; } }
/* R21: through the secret ring */
#flash.gold { background: var(--kBg11); }

#hud {
  position: absolute; top: 6px; left: 6px; right: 6px; pointer-events: none; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 6px;
}
#hudL, #hudR { display: flex; flex-direction: column; gap: 4px; }
#hudL { align-items: flex-start; }
#hudR { align-items: flex-end; }
#hudC { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.meter { display: flex; align-items: center; gap: 5px; background: var(--glass); border-radius: 10px; padding: 4px 8px; font-size: 14px; }
.meter .bar { width: 84px; height: 10px; border-radius: 5px; background: var(--kBg12); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--kBg13), var(--kBg14)); transition: width .15s; }
.meter i.low { background: linear-gradient(90deg, var(--kBg15), var(--kBg16)); }
/* R18.4: a shield over 100, from the Mega cell */
.meter i.mega { background: linear-gradient(90deg, var(--kBg17), var(--kBg18)); }
.meter b { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
/* §37: the full shield, small, after the shield (its fixed width keeps the HUD row still as it changes) */
.meter small { min-width: 4ch; margin-left: -4px; font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
@media (max-width: 400px) { .meter .bar { width: 60px; } }
#hudWeap { display: flex; gap: 4px; align-items: center; }
/* R5.6: the weapon in hand; tap for the bar (pointer events on, over the touch layer) */
.wpnNow { min-width: 44px; min-height: 44px; border-radius: 12px; border: 2px solid var(--hot); background: var(--glass); color: var(--ink); font-size: 18px; font-weight: 700; cursor: pointer; pointer-events: auto; padding: 0 6px; }
#wpnBar { position: absolute; left: 8px; top: 96px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 180px); z-index: 6; pointer-events: auto; }
#wpnBar[hidden] { display: none; }
.wpn { min-width: 52px; min-height: 48px; border-radius: 12px; border: 2px solid transparent; background: var(--kBg6); color: var(--ink); font-size: 16px; cursor: pointer; }
.wpn.on { border-color: var(--hot); }
.chip { background: var(--glass); border-radius: 10px; padding: 4px 8px; font-size: 14px; white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
#keysRow { display: flex; gap: 3px; background: var(--glass); border-radius: 10px; padding: 3px 6px; min-height: 26px; }
#keysRow:empty { display: none; }
.gem { width: 20px; height: 20px; border-radius: 50%; border: 2px solid; opacity: .35; }
.gem.have { opacity: 1; box-shadow: 0 0 8px currentColor; }
#goalChip {
  background: var(--glass); border-radius: 12px; padding: 5px 10px; font-size: 14px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#goalDist { color: var(--dim); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
#countdown {
  font-size: 34px; font-weight: 900; color: var(--kInk1); text-shadow: 0 0 12px rgba(255, 80, 40, .9), 0 2px 4px #000;
  font-variant-numeric: tabular-nums; background: var(--kBg19); border-radius: 12px; padding: 0 14px;
}
#countdown.hurry { color: var(--bad); animation: throb .5s infinite alternate; }
/* §45 a rift counts up: its depth and the time so far, calmer than a countdown */
#countdown.rift { font-size: 22px; white-space: nowrap; padding: 2px 10px; text-shadow: 0 0 10px rgba(150, 100, 255, .9), 0 2px 4px #000; }
/* (on a narrow phone, two lines, as the countdown is there, clear of the Tinkers' chip beside it: measured at 320 px) */
@media (max-width: 360px) { #countdown.rift { font-size: 18px; white-space: normal; min-width: 92px; max-width: 104px; text-align: center; line-height: 1.2; padding: 2px 6px; } }
@keyframes throb { from { transform: scale(1); } to { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { #countdown.hurry { animation: none; } }
#viewBtns { display: flex; gap: 4px; pointer-events: auto; margin-top: 2px; }
.vb {
  min-width: 44px; min-height: 44px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--glass); color: var(--ink); font-size: 20px;
}
.vb.on { background: var(--kBg20); }

#toast {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 6;
  background: var(--kBg21); border-radius: 14px; padding: 10px 16px; font-size: 17px; font-weight: 700;
  text-align: center; max-width: 86%; pointer-events: none; opacity: 0; transition: opacity .3s;
}
#toast.on { opacity: 1; }

/* ---- the thumbs (R11) ---- */
#touch { position: absolute; inset: 0; z-index: 4; touch-action: none; }
.stickBase {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  background: var(--kBg22); border: 2px solid rgba(255, 255, 255, .25); pointer-events: none;
}
.stickBase.look { border-color: rgba(140, 255, 170, .35); }
.stickKnob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: var(--kBg23); border: 2px solid rgba(255, 255, 255, .6);
}
/* The buttons sit on the side edges at mid height, ABOVE where a thumb rests
   on its stick, so a thumb working a stick does not land on one. */
#leftBtns { position: absolute; left: 8px; top: 34%; display: flex; flex-direction: column; gap: 10px; }
#rightBtns { position: absolute; right: 8px; top: 34%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
body.noSlide #leftBtns { display: none; }
body.autoFire #btnFire { display: none; }
.tb {
  width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .3);
  background: var(--kBg24); color: var(--ink); font-size: 24px; cursor: pointer; touch-action: none;
}
.tb.fire { width: 64px; height: 64px; font-size: 28px; background: var(--kBg25); border-color: rgba(255, 140, 100, .6); }
.tb.down { background: var(--kBg26); }
#touchHint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); transform: translateX(-50%);
  background: var(--glass); border-radius: 12px; padding: 6px 12px; font-size: 13px; color: var(--dim); text-align: center;
  max-width: calc(100% - 200px); pointer-events: none; transition: opacity .6s;
}
#touchHint.gone { opacity: 0; }
#keysHint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 4;
  background: var(--glass); border-radius: 12px; padding: 6px 12px; font-size: 12px; color: var(--dim);
  max-width: 92%; text-align: center; pointer-events: none; transition: opacity .6s;
}
#keysHint.gone { opacity: 0; }
/* a mouse needs none of the thumb controls */
body.mouse #leftBtns, body.mouse #rightBtns, body.mouse #touchHint { display: none; }
/* §31 Delve: taps, not sticks; the attack button alone on the right */
#btnAttack { display: none; }
body.delve #btnAttack { display: block; width: 76px; height: 76px; font-size: 34px; }
/* (§36: Delve has no seekers and no sight: the hero aims by itself) */
body.delve #btnFire, body.delve #btnSeek, body.delve #leftBtns, body.delve #wpnNow, body.delve #chipSeek, body.delve #sight { display: none; }
body.delve #rightBtns { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); }

/* ---- overlays ---- */
.ovl {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto;
  background: var(--kBg27);
}
.ovl.on { display: flex; }
.ovlCard {
  margin: auto; width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.ovlCard h2 { margin: 0 0 6px; font-size: 22px; }
.ovlCard p { color: var(--dim); font-size: 14px; line-height: 1.5; margin: 6px 0 10px; }
#brief { background: none; padding: 0; }
#briefBar {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); transform: translateX(-50%);
  width: calc(100% - 16px); max-width: 720px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  background: var(--kBg28); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px;
}
#briefWords { flex: 1 1 260px; min-width: 0; }
#briefWords h2 { margin: 0; font-size: 19px; }
#briefWords p { margin: 2px 0 0; color: var(--dim); font-size: 13px; line-height: 1.35; }
#briefBtns { flex: 0 0 auto; display: flex; gap: 8px; margin-left: auto; }
#briefBtns .big { width: auto; margin: 0; padding: 0 16px; min-height: 48px; }
#mapOv { background: none; padding: 0; pointer-events: none; }
#mapBar {
  position: absolute; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--glass); border-radius: 12px; padding: 4px 4px 4px 12px; pointer-events: auto;
}
#mapTitle { font-weight: 700; }
#mapKey { flex: 1 1 200px; color: var(--dim); font-size: 12px; }
.pb { min-width: 44px; min-height: 44px; border-radius: 12px; border: 0; background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer; }
#doneStars { font-size: 40px; letter-spacing: 6px; margin: 4px 0; }
#doneStars .off { filter: grayscale(1) brightness(.4); }
/* the shared runtime's notices (a newer version is ready) */
.toast-host { position: fixed; left: 0; right: 0; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
/* a phone on its side: the result and pause cards put their buttons in a row,
   so all three fit without scrolling */
@media (max-height: 480px) {
  .ovlCard { padding: 10px 12px; }
  .ovlCard h2 { font-size: 19px; margin-bottom: 2px; }
  .ovlCard p { margin: 4px 0 6px; font-size: 13px; }
  #doneStars { font-size: 30px; margin: 0; }
  #done .big, #paused .big { display: inline-block; width: calc(33% - 8px); min-width: 120px; min-height: 46px; margin: 4px 2px; padding: 0 8px; font-size: 15px; }
  #paused .big { width: calc(50% - 8px); }
}

/* R8.4a: the one way to skip the way out. In the corner, out of the way of a
   thumb that is still where a stick was. */
#btnSkip {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  z-index: 6; min-width: 76px; min-height: 46px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 23px;
  background: var(--kBg29); color: var(--kInk2); font: 700 16px/1 inherit; font-family: inherit; cursor: pointer;
}
#btnSkip[hidden] { display: none; }

/* R14.8: the frame readout, for the owner. Out of the way, and it takes no taps. */
#fpsNow {
  position: absolute; left: calc(8px + env(safe-area-inset-left)); bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 5; padding: 3px 7px; border-radius: 6px; background: var(--kBg30); color: var(--kInk3);
  font: 600 11px/1.3 ui-monospace, Menlo, monospace; pointer-events: none;
}
#fpsNow[hidden] { display: none; }

/* §39: which levels, as tabs: the moons or the player's own bases */
#pickTabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
#pickTabs button { min-height: 44px; border-radius: 12px; border: 2px solid transparent; background: var(--kBg6); color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; }
#pickTabs button.on { border-color: var(--hot); background: var(--card); }
.baseCard.sel { border-color: var(--hot); }
.baseCard.newBase { grid-template-columns: 1fr; text-align: center; min-height: 48px; cursor: pointer; font-weight: 700; color: var(--ink); }
/* R28: the player's own bases, in the menu's Custom tab */
#baseRow { display: grid; gap: 8px; margin: 8px 0 4px; }
.baseCard { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--kBg6); border: 2px solid transparent; }
.baseCard .bn { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.baseCard .bs { color: var(--dim); font-size: 12px; }
.baseCard .bAct { display: flex; gap: 6px; }
.baseCard .bAct button { min-width: 48px; min-height: 48px; border-radius: 12px; border: 0; background: var(--kBg31); color: var(--ink); font-size: 20px; cursor: pointer; }
.baseCard .bAct button:disabled { opacity: .3; cursor: default; }
/* R28.2: the editor */
.bHead { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
#bName { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg5); color: var(--ink); font-size: 16px; padding: 0 10px; }
#bDone { min-width: 88px; font-size: 15px; }
.bTools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.bTool { min-height: 48px; min-width: 0; border-radius: 12px; border: 2px solid transparent; background: var(--kBg6); color: var(--ink); font-size: 13px; cursor: pointer; padding: 2px; }
.bTool .te { display: block; font-size: 20px; }
.bTool.sel { border-color: var(--hot); background: var(--card); }
.bSub { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 44px; }
.bSub .knobBtn { min-width: 48px; }
/* R41.13: the board: a window onto squares without end, dragged and pinched; a square is 44 px or more while it
   can be tapped to edit (.edit), and the rooms alone are drawn when zoomed out (.far) */
#bBoard { position: relative; overflow: hidden; width: 100%; max-width: 480px; height: min(52vh, 420px); height: min(52dvh, 420px); min-height: 220px; margin: 6px auto; touch-action: none;
          border: 1px solid var(--line); border-radius: 12px; background: var(--kBg5); user-select: none; -webkit-user-select: none; }
#bBoard.edit { cursor: pointer; }
#bBoard.far { cursor: zoom-in; }
.bLayer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.bCell { position: absolute; border-radius: 10px; border: 2px dashed var(--line); background: transparent; color: var(--ink); cursor: pointer; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.1; box-sizing: border-box; }
#bBoard.far .bCell { border-radius: 2px; border-width: 1px; }
/* (zoomed out a room is a dot: in the ink, so it reads in both looks) */
#bBoard.far .bCell.room { background: var(--ink); border-color: var(--ink); box-shadow: none; }
.bCell.under { border-style: dotted; background: var(--kBg6); }
.bCell .sh { font-size: 10px; }
.bCell .dot { font-size: 10px; line-height: 1; }
.bFloors { display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr)); gap: 6px; margin: 6px 0; }
.bFloor { min-height: 44px; min-width: 44px; border-radius: 10px; border: 2px solid transparent; background: var(--kBg6); color: var(--ink); cursor: pointer; padding: 0; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.bFloor .fn { font-weight: 700; }
.bFloor .fc { font-size: 10px; color: var(--dim); min-height: 1em; }
.bFloor.sel { border-color: var(--hot); background: var(--card); }
.bCtl { display: grid; grid-template-columns: repeat(5, minmax(44px, 1fr)); gap: 6px; margin: 4px 0; }
.bCtl .bBtn { font-size: 18px; min-width: 44px; }
.bUse { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; color: var(--dim); flex-wrap: wrap; }
.bMeter { flex: 1 1 80px; min-width: 80px; height: 10px; border-radius: 5px; background: var(--kBg6); overflow: hidden; }
#bMeterFill, #keepFill { display: block; height: 100%; width: 0; background: var(--tier2); }
.baseCard .bs.wait { opacity: .6; }
.bCell.room { border-style: solid; background: var(--line); }
.bCell.room.s { box-shadow: inset 0 0 0 8px var(--bg); }
.bCell.room.m { box-shadow: inset 0 0 0 4px var(--bg); }
.bCell.picked { border-color: var(--hot); }
.bCell.stuck { border-color: var(--bad); background: var(--kBg32); }
.bCell .bIcon { font-size: 18px; }
.bCell.room.l { box-shadow: none; }
.bCell .lv { position: absolute; top: 2px; right: 4px; font-size: 10px; color: var(--dim); }
.bTun { position: absolute; background: var(--dim); border-radius: 3px; pointer-events: none; }
.bSay { min-height: 2.6em; font-size: 14px; color: var(--dim); text-align: center; }
.bSay.good { color: var(--good); }
.bSay.bad { color: var(--bad); }
.bRow { display: flex; gap: 8px; margin: 8px 0; }
.bRow > * { flex: 1; }
.bBtn { min-height: 48px; border-radius: 12px; border: 0; background: var(--kBg31); color: var(--ink); font-size: 15px; cursor: pointer; }
.bBtn:disabled { opacity: .35; cursor: default; }
.bBin { background: var(--kBg33); }
.bThemes .knobBtn { min-width: 44px; }
/* (the ten looks wrap within the screen: at 320 px they ran 226 px past its edge before v1.44.0) */
.knob.bThemes { flex: 1 1 100%; min-width: 0; }


/* R9.3: the guide's arrow at the edge of the screen when the way is off it; it chases the way it points */
#edgeArrow { position: absolute; z-index: 3; pointer-events: none; font-size: 64px; line-height: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); text-shadow: 0 0 8px currentColor, 0 0 18px currentColor; animation: edgeChase 0.8s ease-in-out infinite; }
@keyframes edgeChase { 0% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateX(-6px); opacity: .75; } 60% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateX(8px); opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateX(-6px); opacity: .75; } }
@media (prefers-reduced-motion: reduce) { #edgeArrow { animation: none; } }
/* §32 Delve's hangar */
/* §42 the town: its picture fills the screen between the top line and the two buttons; a building opens over it */
#scr-hangar.on { display: flex; flex-direction: column; padding: 0; overflow: hidden; position: relative; }
#townTop { padding: 4px 12px 0; }
#townTop .hgHead { margin: 2px 0 0; font-size: 20px; }
#townTop .stat { margin: 2px 0 2px; }
#townBox { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#townCvs { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#townSigns { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.townSign { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; min-width: 44px; min-height: 44px; padding: 2px 4px;
            border-radius: 12px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: inherit; cursor: pointer;
            display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.townSign .ic { font-size: 18px; white-space: nowrap; }
.townSign small { font-size: 10px; white-space: nowrap; }
/* (with no picture, no WebGL: the signs stand in a grid, each still opening its building) */
#townBox.flat { overflow-y: auto; }
#townBox.flat #townCvs { visibility: hidden; }
#townBox.flat #townSigns { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px; pointer-events: auto; }
#townBox.flat .townSign { position: static; transform: none; }
#townBar { display: flex; gap: 8px; padding: 6px 12px calc(env(safe-area-inset-bottom, 0px) + 8px); }
#townBar .big { margin: 0; flex: 1 1 0; min-width: 0; }
/* a phone on its side: the top line and the two buttons go in a column at the right, so the town keeps the height */
@media (orientation: landscape) and (max-height: 600px) {
  #scr-hangar.on { display: grid; grid-template-columns: minmax(0, 1fr) 168px; grid-template-rows: auto minmax(0, 1fr); }
  #townTop { grid-column: 2; grid-row: 1; padding: 4px 8px 0; }
  #townBox { grid-column: 1; grid-row: 1 / span 2; }
  #townBar { grid-column: 2; grid-row: 2; flex-direction: column; justify-content: flex-end; padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 8px); }
  #townBar .big { flex: 0 0 auto; }
}
/* (on a phone on its side version.js floats the version chip at the bottom right and pads every screen above it,
   under its own query; the town keeps that height for its picture and clears the chip under its column of
   buttons instead) */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 600px) {
  #app.verFloat #scr-hangar.on { padding-bottom: 0; }
  #app.verFloat #townBar { padding-bottom: calc(var(--chiph, 44px) + 12px); }
}
#hgPanel { position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow-y: auto; background: var(--bg); padding: 8px 12px 16px; z-index: 5; }
#hgPanel > * { max-width: 560px; margin-left: auto; margin-right: auto; }
#hgPanelTop { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#hgPanelTop h2 { margin: 0; font-size: 20px; }
.qWho { font-weight: 700; }
.qPic { font-size: 34px; margin: 6px 0; letter-spacing: 2px; }
.qLine { margin: 4px 0; }
.qPay { font-size: 18px; margin: 4px 0 6px; }
.qNow { font-size: 24px; font-weight: 800; margin: 6px 0; font-variant-numeric: tabular-nums; }
/* a trophy's edge is the hardest rung it was beaten on: bronze, silver, gold */
/* lint:runtime tro-cadet tro-pilot tro-ace */
.troChip { border-width: 2px; }
.tro-cadet { border-color: var(--bronze); }
.tro-pilot { border-color: var(--silver); }
.tro-ace { border-color: var(--gold); }
.hgBuy.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.hgHead { margin: 6px 0 2px; font-size: 22px; }
.hgRow { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.hgRow:last-child { border-bottom: 0; }
.hgRow .ic { font-size: 22px; width: 30px; text-align: center; }
.hgRow .nm { flex: 1 1 auto; min-width: 0; }
.hgRow .nm small { display: block; color: var(--dim); font-size: 12px; }
/* lint:runtime t0 t1 t2 t3 */
.hgTier { font-weight: 700; }
.hgTier.t0 { color: var(--dim); font-weight: 400; }
.hgTier.t1 { color: var(--tier1); }
.hgTier.t2 { color: var(--tier2); }
.hgTier.t3 { color: var(--tier3); }
.hgShop h3 { margin: 0 0 4px; font-size: 16px; }
.hgShop p { margin: 0 0 6px; color: var(--dim); font-size: 13px; }
.hgBuy { min-height: 44px; min-width: 44px; margin: 3px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg2); color: var(--ink); font-size: 15px; cursor: pointer; }
.hgBuy:disabled { opacity: .45; cursor: default; }
/* §34 Delve's skills: three buttons in a row above the attack button; a skill waiting is dimmed and shows
   its seconds */
#skillBtns { display: none; }
body.delve #skillBtns { display: flex; gap: 8px; }
.tb.skill { width: 56px; height: 56px; font-size: 22px; position: relative; }
.tb.skill.cool { opacity: .45; }
.hgSkill .nm small { display: block; color: var(--dim); font-size: 12px; }
.hgXp { height: 8px; border-radius: 4px; background: var(--kBg34); overflow: hidden; margin: 4px 0 8px; }
.hgXp i { display: block; height: 100%; background: var(--kBg35); }
.hgHead2 { font-weight: 700; margin-bottom: 2px; }
/* §40 Delve's loot: the power number is the big thing; an arrow says better (▲ green) or not (▼ red) */
.hgPiece { width: 100%; min-height: 48px; padding: 0 8px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.hgPiece:disabled { cursor: default; }
.hgPiece.sel, .hgTile.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.hgPw { font-weight: 800; font-size: 20px; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.hgNote { margin: 4px 0; color: var(--dim); font-size: 13px; }
.hgGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; margin-top: 6px; }
.hgTile { min-height: 60px; min-width: 0; padding: 2px; border-radius: 12px; border: 2px solid var(--line); background: var(--kBg2); color: var(--ink); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.hgTile .ic { font-size: 20px; }
.hgTile .hgPw { font-size: 15px; min-width: 0; text-align: center; }
.hgTile.rar1 { border-color: var(--tier1); }
.hgTile.rar2 { border-color: var(--tier2); }
.hgTile.rar3 { border-color: var(--tier3); }
.hgArrow { font-weight: 800; }
.hgArrow.up, .lootTag.up { color: var(--good); }
.hgArrow.down, .lootTag.down { color: var(--bad); }
.hgArrow.same, .lootTag.same { color: var(--dim); }
.hgTile .hgArrow { font-size: 13px; }
.hgBig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hgBig .ic { font-size: 34px; }
.hgBig .hgPw { font-size: 34px; min-width: 0; }
.hgBig .hgArrow { font-size: 28px; }
.hgChips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.hgChip { min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 22px; border: 1px solid var(--line); background: var(--kBg2); color: var(--ink); font: inherit; font-size: 15px; }
button.hgChip { cursor: pointer; }
.hgChip.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.hgChip.main { background: none; }
.hgChip.sock { min-width: 44px; justify-content: center; background: none; }
.hgChip.gem { border-color: var(--kInk5); }
.hgActs { display: flex; flex-wrap: wrap; gap: 0; }
.hgOdds { margin: 4px 0 0; font-size: 13px; color: var(--dim); }
#lootTags { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
/* §45 a rift champion's traits, as a badge over it */
#traitTags { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.traitTag { position: absolute; transform: translate(-50%, -100%); font-size: 18px; padding: 1px 5px; border-radius: 10px; background: var(--glass); white-space: nowrap; }
.lootTag { position: absolute; transform: translate(-50%, -100%); font-weight: 800; font-size: 17px; padding: 1px 6px; border-radius: 10px; background: var(--glass); white-space: nowrap; }

/* §43 the builder's tools and sharing: a stroke drawn over the board as the finger moves; a piece's picture */
.bStroke { position: absolute; box-sizing: border-box; border: 3px solid var(--good); border-radius: 6px; background: var(--kBg22); pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--ink); overflow: hidden; }
.bStroke.rub { border-color: var(--bad); }
.bStroke.no { border-style: dashed; border-color: var(--bad); }
.bStrokeLine { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.pcPic { position: relative; flex: 0 0 auto; align-self: center; margin: 0 6px; }
.pcSq { position: absolute; width: 8px; height: 8px; border-radius: 2px; background: var(--ink); }
.pcSq.s { transform: scale(.65); }
.pcSq.m { transform: scale(.85); }
.pcJoin { position: absolute; background: var(--dim); }
#keepWords.bad { color: var(--bad); }
/* §43 a base by link */
#shLink, #shPasteBox { display: block; width: 100%; box-sizing: border-box; margin: 6px 0; padding: 8px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--kBg6); color: var(--ink); font: 13px/1.3 ui-monospace, Menlo, monospace; word-break: break-all; resize: vertical; min-height: 88px; }
#shName { font-weight: 700; font-size: 20px; overflow-wrap: anywhere; margin: 6px 0 2px; }
#shMini { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0; }
.shFloor { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.shFl { font-size: 12px; color: var(--dim); }
.shMap { position: relative; background: var(--kBg6); border-radius: 6px; }
.shRoom { position: absolute; background: var(--ink); border-radius: 2px; }
.shRoom.s { opacity: .55; }
.shRoom.m { opacity: .8; }
.shRoom.shHangar { background: var(--good); opacity: 1; }
.shRoom.shCore { background: var(--bad); opacity: 1; }
/* §44 builds: a skill's three styles as pictures, a point back, the powers and sets */
.hgStyles { display: flex; gap: 8px; padding: 2px 0 8px 38px; border-bottom: 1px solid var(--line); }
.hgStyle { min-width: 52px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg2); color: var(--ink); font-size: 22px; cursor: pointer; }
.hgStyle.sel { outline: 3px solid var(--ink); outline-offset: 1px; }
.hgLess, .hgMore { padding: 0; font-size: 20px; }
/* §45 the rift's gate: the depth picked between ➖ and ➕, and the way in; the suit ranks at ⭐ Skills */
.hgRiftPick { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; }
.hgRiftD { min-width: 96px; text-align: center; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hgRiftGo { width: 100%; margin: 8px 0 10px; }
.hgTraits { margin-top: 4px; }
.hgRanks { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.hgRankHead { font-weight: 700; }
.hgGap { margin-top: 12px; }
.hgOwn { font-size: 13px; color: var(--dim); white-space: nowrap; }
.hgOwn.on { color: var(--good); font-weight: 700; }
.hgPower { margin: 4px 0; font-size: 14px; }
.hgMark { font-size: 12px; line-height: 1; }
.hgTree, .hgBuild { display: block; }
.hgRow .ic.hgPair { flex: none; width: auto; min-width: 30px; white-space: nowrap; font-size: 18px; }
