/* Boots Tower: the game's UI. Palette from Boots' Item Shop: dark wood panels, brass edges, paper and ink. */
:root {
  --bg: #120c07; --wood: #2a1d12; --wood2: #3a2818; --edge: #8a6a3a; --brass: #c9973f; --gold: #ffcf4a;
  --text: #f6ead2; --dim: #b8a684; --paper: #f1dfb6; --paper-ink: #3b2a17; --good: #7ad06a; --bad: #ff7a5a; --ember: #ff7a2a;
  --serif: Georgia, 'Times New Roman', serif; --sans: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#gl, #ov { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ov { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- panels and buttons ---------- */
.panel { background: linear-gradient(#3a2818, #2a1d12); border: 2px solid var(--edge); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,220,160,.12); }
.btn { background: linear-gradient(#5b3a1f, #3e2814); border: 2px solid var(--brass); border-radius: 10px; padding: 10px 18px; font-weight: 700; letter-spacing: .02em; color: var(--text); box-shadow: 0 3px 0 #1a0f06, 0 4px 10px rgba(0,0,0,.4); transition: transform .08s, filter .12s; min-height: 44px; }
.btn:hover, .btn.focus { filter: brightness(1.18); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1a0f06; }
.btn.primary { background: linear-gradient(#e0a83a, #b8781e); color: #2b1606; border-color: #ffe08a; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
.focus, [data-nav]:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.stats { position: absolute; left: calc(10px + var(--safe-l)); top: calc(10px + var(--safe-t)); display: flex; gap: 8px; }
.stat { display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; font-weight: 800; font-size: 18px; text-shadow: 0 2px 0 #000; }
.stat .ico { width: 22px; height: 22px; display: inline-block; }
.stat.flash { animation: flash .4s; }
@keyframes flash { 0%,100% { filter: none } 40% { filter: brightness(1.8) drop-shadow(0 0 6px #ff4a3a) } }
.topright { position: absolute; right: calc(10px + var(--safe-r)); top: calc(10px + var(--safe-t)); display: flex; gap: 8px; }
.iconbtn { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; font-size: 20px; font-weight: 900; }
.iconbtn svg { width: 24px; height: 24px; }
.bossbar { position: absolute; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%); width: min(420px, calc(60vw / var(--ui-zoom, 1))); padding: 6px 10px; text-align: center; }
.bossbar .name { font-family: var(--serif); font-weight: 700; color: #bfefff; font-size: 15px; }
.bossbar .track { height: 10px; background: #1a100a; border-radius: 6px; overflow: hidden; margin-top: 4px; border: 1px solid #000; }
.bossbar .fill { height: 100%; background: linear-gradient(#ff7a9a, #c02848); width: 100%; transition: width .2s; }
.bottomleft { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); display: flex; gap: 10px; align-items: flex-end; }
.hero-card { display: flex; align-items: center; gap: 8px; padding: 6px; }
.portrait { width: 64px; height: 64px; border-radius: 10px; border: 2px solid var(--brass); background: radial-gradient(#6a5030, #2a1d12); position: relative; overflow: visible; padding: 0; }
.portrait img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.portrait .dead { border-radius: 8px; }
.portrait.sel { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.portrait .dead { position: absolute; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; font-weight: 900; font-size: 20px; }
.hpbar { width: 64px; height: 6px; background: #1a100a; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.hpbar > div { height: 100%; background: linear-gradient(#ffe070, #d89a20); }
.skill { width: 58px; height: 58px; border-radius: 50%; border: 2px solid var(--brass); background: radial-gradient(#5b3a1f, #2a1d12); position: relative; padding: 0; overflow: visible; }
.skill img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.skill .cd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(0,0,0,.7) var(--cd, 0%), transparent 0); display: grid; place-items: center; font-weight: 900; text-shadow: 0 1px 2px #000; }
.skill.ready { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(255,207,74,.6); }
.skill.armed { box-shadow: 0 0 0 3px #fff, 0 0 20px #fff; }
.skill .key, .glyph { position: absolute; right: -10px; bottom: -8px; z-index: 3; background: #1a100a; color: var(--gold); border: 1px solid var(--gold); border-radius: 6px; font-size: 11px; line-height: 1.2; padding: 1px 5px; font-weight: 800; box-shadow: 0 2px 4px rgba(0,0,0,.6); pointer-events: none; white-space: nowrap; }
.waveflag .glyph { right: -12px; bottom: -6px; }
.waveflag { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; padding: 0; background: radial-gradient(#7a2a1a, #3a120a); border: 3px solid var(--gold); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.6); }
.waveflag svg { width: 34px; height: 34px; }
.waveflag .ring { position: absolute; inset: -6px; border-radius: 50%; background: conic-gradient(var(--gold) var(--p, 0%), rgba(0,0,0,.35) 0); -webkit-mask: radial-gradient(circle, transparent 33px, #000 34px); mask: radial-gradient(circle, transparent 33px, #000 34px); }
.waveflag.pulse { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 0 24px var(--gold); } }
.waveinfo { position: absolute; padding: 8px 10px; font-size: 14px; min-width: 150px; pointer-events: none; }
.waveinfo .row { display: flex; align-items: center; gap: 6px; }
.waveinfo img { width: 30px; height: 30px; }
.toast { position: absolute; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); padding: 10px 18px; font-size: 17px; max-width: min(560px, calc(92vw / var(--ui-zoom, 1))); text-align: center; pointer-events: none; animation: toastIn .3s; }
.toast.big { font-family: var(--serif); font-size: 26px; color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } }
.tip { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); padding: 12px 16px; max-width: min(520px, calc(94vw / var(--ui-zoom, 1))); font-size: 16px; line-height: 1.35; pointer-events: auto; animation: toastIn .3s; }
.tip b { color: var(--gold); }
.pointer { position: absolute; width: 0; height: 0; pointer-events: none; }
.pointer::after { content: ''; position: absolute; left: -14px; top: -64px; border: 14px solid transparent; border-top: 22px solid var(--gold); filter: drop-shadow(0 2px 2px #000); animation: bob .8s infinite alternate; }
@keyframes bob { to { transform: translateY(-10px); } }
.cursor { position: absolute; width: 36px; height: 36px; margin: -18px 0 0 -18px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.5), inset 0 0 0 2px rgba(0,0,0,.4); pointer-events: none; }
.cursor::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; background: #fff; border-radius: 50%; }

/* ---------- the build / upgrade ring ---------- */
.ring { position: absolute; width: 0; height: 0; }
.ring .opt { position: absolute; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%; padding: 0; border: 3px solid var(--brass); background: radial-gradient(#6a4a2a, #2a1d12); box-shadow: 0 4px 10px rgba(0,0,0,.6); animation: pop .18s backwards; }
.ring.still .opt { animation: none; }
.ring .opt img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ring .opt .price { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); background: #1a100a; border: 1px solid var(--brass); border-radius: 8px; font-size: 12px; font-weight: 800; padding: 1px 6px; color: var(--gold); white-space: nowrap; }
.ring .opt.cant { filter: grayscale(.85) brightness(.75); }
.ring .opt.cant .price { color: var(--bad); }
.ring .opt.sel { border-color: #fff; box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold); }
.ring .opt.sel::after { content: '✓'; position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #10200a; font-weight: 900; display: grid; place-items: center; font-size: 14px; }
.ring .opt .pips { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
.ring .opt .pips i { width: 8px; height: 8px; border-radius: 50%; background: #1a100a; border: 1px solid var(--gold); }
.ring .opt .pips i.on { background: var(--gold); }
.ring .opt .lbl { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 22px; text-shadow: 0 2px 2px #000; }
.ring .opt .key { position: absolute; left: -4px; top: -4px; background: #1a100a; border: 1px solid var(--brass); border-radius: 5px; font-size: 10px; padding: 0 4px; font-weight: 800; }
.ring .hub { position: absolute; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; border: 2px dashed rgba(255,230,160,.35); pointer-events: none; animation: pop .18s; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.info { position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); width: min(calc(480px * var(--ui-zoom, 1)), 94vw); z-index: 5; padding: 10px 14px; pointer-events: none; }
.info h3 { font-size: calc(20px * var(--ui-zoom, 1)); color: var(--gold); }
.info p { margin: 4px 0 6px; font-size: calc(16px * var(--ui-zoom, 1)); color: var(--dim); line-height: 1.3; }
.info .row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: calc(15px * var(--ui-zoom, 1)); font-weight: 700; }
.info .row span b { color: var(--text); } .info .row span { color: var(--dim); }
.info .up { color: var(--good) !important; }
.info .hint { font-size: calc(14px * var(--ui-zoom, 1)); color: var(--brass); margin-top: 4px; }

/* ---------- full screens ---------- */
#screen { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; }
#screen > * { pointer-events: auto; }
.veil { position: fixed; inset: 0; background: rgba(10,6,3,.55); backdrop-filter: blur(2px); }
.title { position: relative; text-align: center; padding: 20px; }
.logo { font-family: var(--serif); font-weight: 900; font-size: clamp(54px, 11vw, 118px); line-height: .9; color: #ffe7a6; letter-spacing: .01em;
  text-shadow: 0 3px 0 #b8781e, 0 6px 0 #6a3a10, 0 10px 20px rgba(0,0,0,.7); }
.logo small { display: block; font-size: .28em; letter-spacing: .3em; color: var(--text); text-shadow: 0 2px 4px #000; margin-top: 10px; }
.title .menu { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 34px; }
.title .menu .btn { min-width: 220px; font-size: 20px; }
.byline { position: fixed; left: 0; right: 0; bottom: calc(10px + var(--safe-b)); text-align: center; color: var(--dim); font-size: 12px; text-shadow: 0 1px 2px #000; }
.dialog { position: relative; width: min(560px, calc(94vw / var(--ui-zoom, 1))); max-height: calc(92vh / var(--ui-zoom, 1)); overflow: auto; padding: 20px; }
.dialog h2 { color: var(--gold); font-size: 26px; margin-bottom: 10px; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(201,151,63,.25); }
.setting input[type=range] { width: 50%; accent-color: var(--brass); }
.toggle { min-width: 78px; }
.seg { display: flex; gap: 4px; } .seg .btn { padding: 6px 10px; min-height: 36px; font-size: 14px; }
.seg .btn.on { background: linear-gradient(#e0a83a, #b8781e); color: #2b1606; border-color: #ffe08a; }

/* the map: Oscar's hand-drawn chart of the Glade */
.map { position: relative; width: min(980px, calc(96vw / var(--ui-zoom, 1))); aspect-ratio: 16 / 10; max-height: calc(90vh / var(--ui-zoom, 1)); border-radius: 14px; overflow: hidden; border: 3px solid var(--edge);
  background: radial-gradient(ellipse at 50% 45%, #f6e7c4, #e6cf9e 70%, #c9a86a); box-shadow: 0 10px 40px rgba(0,0,0,.7), inset 0 0 60px rgba(120,80,30,.45); color: var(--paper-ink); }
.map svg.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.map .head { position: absolute; left: 3%; top: 3%; font-family: var(--serif); font-size: clamp(20px, 3.4vw, 34px); font-weight: 900; }
.map .head small { display: block; font-size: .45em; font-weight: 400; font-style: italic; }
.map .crowns { position: absolute; right: 3%; top: 3.5%; font-weight: 800; font-size: 18px; display: flex; gap: 14px; }
.node { position: absolute; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%; border: 4px solid #6a3a10; background: radial-gradient(#ffe7a6, #e0a83a); padding: 0; color: #3b2a17; font-family: var(--serif); font-weight: 900; font-size: 28px; box-shadow: 0 4px 0 #6a3a10, 0 8px 16px rgba(0,0,0,.35); }
.node.locked { background: radial-gradient(#cbb894, #9a8766); color: #6a5a40; border-color: #7a6a50; cursor: default; }
.node.next { animation: pulse 1.4s infinite; }
.node .stars { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 16px; letter-spacing: 1px; }
.node .nm { position: absolute; top: 94px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 14px; font-weight: 700; text-shadow: 0 1px 0 #f6e7c4; }
.map .back { position: absolute; left: 3%; bottom: 4%; }
.star { color: #c9973f; } .star.on { color: #ffcf2a; text-shadow: 0 1px 0 #6a3a10; }

.card { width: min(520px, calc(94vw / var(--ui-zoom, 1))); padding: 18px 20px; position: relative; max-height: calc((100dvh - 16px) / var(--ui-zoom, 1)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.card .lvl { color: var(--dim); font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }
.card h2 { font-size: 30px; color: var(--gold); }
.card p { color: var(--text); line-height: 1.4; }
.foes { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.foe { width: 70px; text-align: center; font-size: 11px; color: var(--dim); }
.foe img { width: 60px; height: 60px; display: block; margin: 0 auto; background: radial-gradient(#4a3420, transparent 70%); border-radius: 50%; }

/* the Bramblecross Crier: results as a newspaper front page */
.crier { width: min(560px, calc(94vw / var(--ui-zoom, 1))); max-height: calc((100dvh - 16px) / var(--ui-zoom, 1)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: #efe1c1; color: var(--paper-ink); padding: 18px 22px 16px; border-radius: 4px; box-shadow: 0 12px 40px rgba(0,0,0,.7); transform: rotate(-1.2deg); position: relative; animation: drop .5s cubic-bezier(.2,1.4,.4,1); font-family: var(--serif); }
@keyframes drop { from { transform: rotate(-8deg) scale(.6) translateY(-80px); opacity: 0; } }
.crier .mast { text-align: center; border-bottom: 3px double var(--paper-ink); padding-bottom: 6px; }
.crier .mast b { font-size: 34px; letter-spacing: .04em; display: block; font-family: 'Old English Text MT', var(--serif); }
.crier .mast small { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; display: flex; justify-content: space-between; }
.crier .headline { font-size: clamp(24px, 5vw, 34px); font-weight: 900; line-height: 1.05; margin: 12px 0 6px; text-align: center; }
.crier .sub { font-style: italic; text-align: center; font-size: 15px; }
.crier .stars { text-align: center; font-size: 46px; margin: 8px 0; }
.crier .stars span { display: inline-block; animation: starIn .4s backwards; }
@keyframes starIn { from { transform: scale(3) rotate(-30deg); opacity: 0; } }
.crier .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-family: var(--sans); font-size: 13px; border-top: 1px solid var(--paper-ink); padding-top: 8px; }
.crier .news { font-family: var(--sans); font-size: 13px; margin-top: 8px; padding: 8px; background: rgba(59,42,23,.08); border-left: 3px solid #b8781e; }
.crier .actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; font-family: var(--sans); }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 10; font-family: var(--serif); font-size: 22px; color: var(--brass); transition: opacity .5s; }
@media (max-width: 640px) {
  .stat { font-size: 15px; padding: 4px 8px 4px 6px; }
  .iconbtn { width: 42px; height: 42px; }
  .ring .opt { width: 54px; height: 54px; margin: -27px 0 0 -27px; }
  .portrait { width: 52px; height: 52px; } .hpbar { width: 52px; }
  .skill { width: 50px; height: 50px; }
}
/* short landscape screens (phones on their side): the Crier and level cards tighten up and scroll (#73) */
@media (max-height: 520px) {
  .crier { padding: 10px 16px 10px; transform: none; }
  .crier .mast b { font-size: 24px; }
  .crier .headline { font-size: 22px; margin: 6px 0 4px; }
  .crier .sub { font-size: 13px; }
  .crier .stars { font-size: 32px; margin: 2px 0; }
  .crier .cols { grid-template-columns: repeat(4, auto); font-size: 12px; }
  .crier .news { margin-top: 4px; padding: 5px 8px; font-size: 12px; }
  .crier .actions { margin-top: 8px; position: sticky; bottom: -10px; background: #efe1c1; padding: 6px 0; }
  .card { padding: 10px 16px; } .card h2 { font-size: 22px; }
  .info { padding: 7px 10px; } .info h3 { font-size: calc(17px * var(--ui-zoom, 1)); } .info p { font-size: calc(14px * var(--ui-zoom, 1)); margin: 2px 0 4px; } .info .row { font-size: calc(14px * var(--ui-zoom, 1)); }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }

/* Act I map: eight nodes, smaller; bosses get a red rim */
.node { width: 58px; height: 58px; margin: -29px 0 0 -29px; font-size: 24px; }
.node .stars { top: 60px; font-size: 14px; }
.node .nm { top: 78px; font-size: 13px; }
.node.boss { border-color: #8a2a1a; box-shadow: 0 4px 0 #8a2a1a, 0 8px 16px rgba(0,0,0,.35); }
@media (max-height: 520px) {
  .node { width: 44px; height: 44px; margin: -22px 0 0 -22px; font-size: 19px; border-width: 3px; }
  .node .stars { top: 44px; font-size: 11px; }
  .node .nm { top: 58px; font-size: 11px; }
}
/* hero picker on the level card */
.foe.hero { background: rgba(255,255,255,.35); border: 2px solid transparent; border-radius: 8px; padding: 4px 2px; cursor: pointer; font: inherit; font-size: 12px; color: var(--ink, #3b2a17); width: 84px; }
.foe.hero small { display: block; font-size: 10px; color: var(--dim); }
.foe.hero.on { border-color: var(--brass, #c8a050); background: rgba(255,230,160,.6); }
.foe.hero.focus { outline: 3px solid var(--brass, #c8a050); }
input.code { width: 100%; font: 700 22px/1.2 var(--serif, Georgia); letter-spacing: 3px; text-transform: uppercase; padding: 8px 10px; border: 2px solid #6a3a10; border-radius: 6px; background: #fff8e6; color: #3b2a17; box-sizing: border-box; }
.card .actions { display: flex; gap: 10px; justify-content: flex-end; position: sticky; z-index: 2; bottom: -18px; margin: 8px -20px -18px; padding: 10px 20px 14px; background: linear-gradient(transparent, #2a1d12 30%); }
.card .foe img { width: 48px; height: 48px; }
.foe.hero.on { color: #3b2a17; }
.foe.hero.on small { color: #6a4a20; }

/* M2: item satchel, Guild Hall, slots */
.satchel { display: flex; gap: 6px; align-items: flex-end; margin-left: 4px; }
.skill.item { width: 46px; height: 46px; border-color: #c8a0d8; }
.skill.item .cnt { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: #2a1d12; border: 1px solid var(--brass); font: 800 12px/16px system-ui; text-align: center; }
.skill.item .glyph { bottom: auto; top: -8px; }
.hall { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 14px max(14px, 3vw); gap: 10px; overflow: auto; }
.hall .tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hall .tabs .purse { margin-left: auto; font-weight: 800; }
.hall .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 10px; }
.hall .tree { padding: 10px 12px; }
.hall .tree h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.hall .tree h3 img { width: 36px; height: 36px; }
.hall .perk { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 3px 0; color: var(--dim); }
.hall .perk.on { color: inherit; }
.hall .perk .pip { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--brass); flex: none; }
.hall .perk.on .pip { background: var(--gold); }
.hall .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 6px; }
.hall .skillrow { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.hall .skillrow b { display: block; font-size: 14px; }
.hall .xpbar { height: 8px; border-radius: 4px; background: rgba(0,0,0,.4); overflow: hidden; margin: 4px 0 8px; }
.hall .xpbar div { height: 100%; background: linear-gradient(90deg, #c98a1e, #ffcf4a); }
.slots { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.slots .slot { display: flex; gap: 8px; align-items: center; }
.slots .slot .btn:first-child { flex: 1; text-align: left; }
textarea.savecode { width: 100%; height: 90px; font: 12px monospace; background: rgba(0,0,0,.35); color: inherit; border: 1px solid var(--brass); border-radius: 6px; }
.chal { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chal .btn.on { box-shadow: 0 0 0 2px var(--gold); }
.acttabs { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 3; }
body.cb .enemy-mark { display: block; }
.mapwrap { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; max-height: calc(100dvh / var(--ui-zoom, 1)); }
.mapwrap .acttabs { position: static; transform: none; }
.mapwrap .map { max-height: calc((100dvh - 120px) / var(--ui-zoom, 1)); }
.mapbar { display: flex; gap: 8px; width: min(980px, calc(96vw / var(--ui-zoom, 1))); align-items: center; }
@media (max-width: 520px) { .node { width: 40px; height: 40px; margin: -20px 0 0 -20px; font-size: 18px; border-width: 3px; } .node .stars { top: 40px; font-size: 10px; } .node .nm { display: none; } .map .head small { display: none; } }

/* the Codex (#59) */
.codex .dim, .codex p.dim { color: var(--dim); margin: 0 0 6px; }
.codex .cx-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); gap: 12px; align-items: start; }
@media (max-width: 760px) { .codex .cx-body { grid-template-columns: 1fr; } .codex .cx-detail { order: -1; } }
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cx-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font: inherit; font-size: 14px; line-height: 1.2; text-align: center;
  color: inherit; background: rgba(255, 248, 230, .08); border: 1px solid rgba(200, 160, 80, .35); border-radius: 8px; cursor: pointer; min-height: 44px; }
.cx-card img { width: 72px; height: 72px; }
.cx-card small { color: var(--dim); font-size: 12px; }
.cx-card.on, .cx-card.focus { border-color: var(--gold); background: rgba(255, 220, 120, .16); }
.cx-card.unknown img { filter: brightness(0) opacity(.55); }
.cx-card.unknown { color: var(--dim); }
.cx-detail { padding: 12px 14px; position: sticky; top: 0; }
.cx-detail .cx-spin { display: block; width: 180px; height: 180px; margin: 0 auto; }
.cx-detail h3 { margin: 4px 0; } .cx-detail ul { margin: 4px 0 8px; padding-left: 18px; font-size: 15px; } .cx-detail p { font-size: 15px; line-height: 1.35; }
.cx-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 15px; margin-bottom: 6px; }
.cx-row { display: flex; gap: 8px; flex-wrap: wrap; font-size: 14px; } .cx-row > div { display: flex; flex-direction: column; align-items: center; width: 92px; text-align: center; }
.cx-row img { width: 56px; height: 56px; } .cx-row small, .cx-branch small { color: var(--dim); }
.cx-branch { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; margin-top: 8px; } .cx-branch img { width: 52px; height: 52px; flex: none; }
.cx-ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 6px; }
.cx-a { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; background: rgba(255, 248, 230, .05); color: var(--dim); font-size: 15px; }
.cx-a.on { color: inherit; background: rgba(255, 220, 120, .12); }
.cx-a .pip { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--brass); flex: none; display: grid; place-items: center; color: var(--gold); font-size: 12px; }

/* accessibility (#61): text size, sound captions, a clear focus ring */
#screen, #hud > :not(.ring):not(.info) { zoom: var(--ui-zoom, 1); }
.captions { position: absolute; left: 12px; bottom: calc(120px + var(--safe-b, 0px)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; max-width: min(60vw, 420px); }
.captions .cap { background: rgba(10, 6, 3, .78); color: #fff; font-size: 14px; padding: 3px 8px; border-radius: 6px; animation: toastIn .2s; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* credits (#62) */
.credits h3 { color: var(--gold); font-size: 16px; margin: 14px 0 4px; }
.credits p { margin: 0 0 4px; } .credits .dim { color: var(--dim); }
.credits .cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; text-align: center; font-size: 12px; }
.credits .cast img { width: 64px; height: 64px; display: block; margin: 0 auto; }
.credits .cast small { display: block; color: var(--dim); font-size: 10px; }
.credits.roll .inner { animation: creditsRoll 70s linear 1s both; }
.credits.roll { overflow: hidden; height: min(560px, calc(86vh / var(--ui-zoom, 1))); padding-bottom: 64px; }
.credits.roll .actions { position: absolute; right: 20px; bottom: 14px; margin: 0; }
@keyframes creditsRoll { from { transform: translateY(60vh); } to { transform: translateY(-100%); } }

/* Graphics page */
.gfxdlg { width: min(700px, calc(96vw / var(--ui-zoom, 1))); }
.setting.gfx > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.setting.gfx small { font-size: 12px; opacity: .7; line-height: 1.25; margin-top: 2px; }
.setting.gfx .seg { flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; max-width: 62%; }
.setting.gfx.off { opacity: .5; }
.setting.gfx .rs { display: flex; align-items: center; gap: 8px; width: 50%; }
.setting.gfx .rs input { flex: 1; width: auto; }
.setting.gfx .rs b { min-width: 3.2em; text-align: right; }
.seg .btn[disabled] { opacity: .45; }
.seg .btn[disabled].on { opacity: 1; }
.gfxnote { font-size: 13px; min-height: 1em; margin-top: 6px; }
@media (max-height: 520px) {
  .gfxdlg { padding: 12px 16px; }
  .gfxdlg h2 { font-size: 20px; margin-bottom: 4px; }
  .setting.gfx { padding: 4px 0; }
  .setting.gfx small { display: none; }
  .gfxdlg .seg .btn { min-height: 32px; padding: 4px 8px; }
}
#fps { position: fixed; top: 4px; left: 50%; transform: translateX(-50%); z-index: 50; pointer-events: none; font: 12px/1.4 ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.45); padding: 1px 6px; border-radius: 4px; }
#fps[hidden] { display: none; }

.setting .seg { flex-wrap: wrap; justify-content: flex-end; }
