:root {
  --brass: #f2a950; --copper: #b87333; --iron: #9aa3ad; --ink: #0b0a10; --panel: #15121aee;
  --text: #efe6d8; --muted: #a99e8c; --danger: #ff5a4a; --steam: #7fd0ff; --scrap: #9be36d;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font-family: var(--font); overflow: hidden; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#overlay { position: fixed; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* screens scroll when the panel is taller than the viewport (phones in landscape);
   auto margins centre the panel when it fits and pin it to the top when it doesn't */
.screen { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; padding: 16px; background: radial-gradient(ellipse at center, #1a1208cc, #0b0a10f2); overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.screen.active { display: flex; }
.screen .panel { margin: auto; }
.screen, .screen * { touch-action: pan-y; }
.screen input[type=range] { touch-action: pan-y pinch-zoom; }
.panel { background: var(--panel); border: 1px solid #3a2f22; border-radius: 14px; padding: 24px 28px; width: min(520px, 100%); box-shadow: 0 20px 60px #000a; }
.panel.wide { width: min(760px, 100%); }
h1.logo { margin: 0 0 4px; font-size: 30px; letter-spacing: 3px; color: var(--brass); text-shadow: 0 0 18px #f2a95055; }
h1.logo .gear { display: inline-block; animation: spin 12s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
h2, h3 { margin: 0 0 8px; color: var(--brass); font-weight: 600; letter-spacing: 1px; }
.tag { margin: 0 0 16px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.field { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
input { width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 8px; border: 1px solid #4a3b2b; background: #0f0d14; color: var(--text); font-size: 16px; }
input#join-code { width: 110px; text-transform: uppercase; letter-spacing: 2px; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.join { display: flex; gap: 8px; align-items: center; }
.btn { padding: 10px 16px; border-radius: 8px; border: 1px solid #5a4530; background: #2a2030; color: var(--text); font-size: 15px; cursor: pointer; }
.btn:hover { background: #3a2c40; }
.btn.primary { background: linear-gradient(#f2a950, #c77d2b); color: #1a1208; border-color: #f2a950; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.chip { margin-top: 14px; background: transparent; border: 1px dashed #5a4530; color: var(--muted); padding: 6px 10px; border-radius: 999px; font-size: 12px; cursor: pointer; }
.hero-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.hero-card { border: 1px solid #4a3b2b; border-radius: 10px; padding: 10px 8px; background: #0f0d14; cursor: pointer; text-align: center; }
.hero-card .sw { width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 6px; border: 2px solid #0006; }
.hero-card b { display: block; font-size: 13px; }
.hero-card small { color: var(--muted); font-size: 11px; }
.hero-card.sel { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass) inset, 0 0 14px #f2a95044; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#lobby-code { font-family: ui-monospace, monospace; letter-spacing: 4px; color: var(--text); }
.lobby-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
ul.roster { list-style: none; margin: 0; padding: 0; }
ul.roster li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #2a2230; font-size: 14px; }
ul.roster li .sw { width: 14px; height: 14px; border-radius: 50%; }
ul.roster li .host { color: var(--brass); font-size: 11px; }
ul.roster li .off { color: var(--muted); font-size: 11px; }
ul.roster li .rdy { margin-left: auto; color: var(--scrap); font-size: 12px; }

#hud { position: absolute; inset: 0; pointer-events: none; font-size: 14px; }
#hud > * { pointer-events: none; }
.hud-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; background: #0b0a10cc; border: 1px solid #3a2f22; border-radius: 10px; padding: 6px 14px; }
.hud-phase { color: var(--brass); font-weight: 700; letter-spacing: 2px; }
.hud-timer { font-family: ui-monospace, monospace; min-width: 48px; text-align: center; }
.hud-core { display: flex; align-items: center; gap: 6px; }
.hud-core .lbl { color: var(--muted); font-size: 12px; }
.bar { position: relative; width: 120px; height: 10px; background: #000a; border-radius: 6px; overflow: hidden; border: 1px solid #3a2f22; }
.bar i { display: block; height: 100%; width: 100%; background: var(--brass); transition: width .15s; }
.bar.hp { width: 180px; height: 14px; }
.bar.hp i { background: linear-gradient(#ff7a5a, #c8352a); }
.bar.hp span { position: absolute; inset: 0; font-size: 10px; line-height: 12px; text-align: center; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.steam { width: 180px; margin-top: 4px; }
.bar.steam i { background: var(--steam); }
.hud-bottom { position: absolute; left: 14px; right: 14px; bottom: 14px; display: flex; justify-content: space-between; align-items: flex-end; }
.hud-stats { background: #0b0a10cc; border: 1px solid #3a2f22; border-radius: 10px; padding: 8px 12px; }
.res { color: var(--muted); font-size: 12px; margin-top: 6px; }
.res #scrap { color: var(--scrap); font-weight: 700; }
.hotbar { display: flex; gap: 6px; }
.hotbar .slot { width: 52px; height: 52px; border: 1px solid #3a2f22; border-radius: 8px; background: #0b0a10cc; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.hotbar .slot b { font-size: 16px; color: var(--text); }
.hud-center { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 56px; font-weight: 800; color: var(--brass); text-shadow: 0 0 30px #f2a95088; letter-spacing: 4px; }
.hud-hint { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 12px; background: #0b0a1099; padding: 4px 10px; border-radius: 6px; }
.btn.ready { position: absolute; right: 14px; top: 64px; pointer-events: auto !important; background: #1d3a1d; border-color: var(--scrap); }
.btn.ready.on { background: var(--scrap); color: #0b0a10; }

#touch-ui { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; left: 40px; bottom: 60px; width: 110px; height: 110px; border-radius: 50%; background: #ffffff12; border: 1px solid #ffffff33; }
.stick .nub { position: absolute; left: 35px; top: 35px; width: 40px; height: 40px; border-radius: 50%; background: #ffffff55; }
.tbtn { position: absolute; width: 64px; height: 64px; border-radius: 50%; background: #ffffff18; border: 1px solid #ffffff44; display: flex; align-items: center; justify-content: center; font-size: 24px; pointer-events: auto; }

#toasts { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #0b0a10dd; border: 1px solid #3a2f22; border-radius: 8px; padding: 6px 12px; font-size: 13px; animation: fade 3s forwards; }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#debug { position: absolute; left: 10px; top: 10px; font: 11px ui-monospace, monospace; color: #9be36d; background: #000a; padding: 4px 6px; border-radius: 4px; white-space: pre; pointer-events: none; }

@media (max-width: 700px) {
  .hero-pick { grid-template-columns: repeat(2, 1fr); }
  .lobby-body { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .hud-hint { display: none; }
}

.lanes { position: absolute; left: 14px; top: 64px; display: flex; flex-direction: column; gap: 6px; max-width: 240px; }
.lane { background: #0b0a10cc; border: 1px solid #3a2f22; border-left: 4px solid var(--lc, #fff); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
.lane.closed { opacity: .45; }
.lane b { color: var(--text); letter-spacing: 1px; }
.lane .kinds { color: var(--muted); margin-top: 2px; }
.lane .kinds span { margin-right: 8px; white-space: nowrap; }
.lane .threat { height: 4px; background: #000a; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.lane .threat i { display: block; height: 100%; background: var(--lc, #fff); }
.lane .boss { color: var(--danger); font-weight: 700; }
#result-title { font-size: 34px; letter-spacing: 4px; }
#screen-results .panel { text-align: center; }
#screen-results .row { justify-content: center; }

.hotbar .slot { width: 74px; height: 58px; position: relative; }
.hotbar .slot .nm { font-size: 10px; color: var(--text); line-height: 1.1; text-align: center; }
.hotbar .slot small { font-size: 9px; color: var(--muted); }
.hotbar .slot.sel { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass) inset, 0 0 12px #f2a95066; }
.prompt { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); background: #0b0a10dd; border: 1px solid #3a2f22; border-radius: 8px; padding: 6px 10px; font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: center; pointer-events: auto !important; }
.prompt .pname { margin-right: 4px; }
.prompt .btn b { color: var(--brass); margin-right: 4px; }
.prompt .muted { color: var(--muted); font-size: 11px; }
.ghost-hint { position: absolute; top: 56%; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--scrap); background: #0b0a1099; padding: 3px 8px; border-radius: 6px; }
.ghost-hint.bad { color: var(--danger); }
.channel { position: absolute; top: 60%; left: 50%; transform: translateX(-50%); text-align: center; font-size: 12px; color: var(--muted); }
.channel .bar { width: 160px; margin: 4px auto 0; }

#dmg-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 15px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px #000; will-change: transform, opacity; }
.dmg.crit { color: #ffe45b; font-size: 20px; }
.dmg.heal { color: #9be36d; }
.dmg.mine { color: #ffb3a0; }

.field.check { display: flex; align-items: center; gap: 8px; }
.field.check input { width: auto; margin: 0; }
input[type=range] { padding: 0; }
select { width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px; border: 1px solid #4a3b2b; background: #0f0d14; color: var(--text); }
.tbtn.sm { width: 48px; height: 48px; font-size: 16px; }
.hotbar .slot { pointer-events: auto; cursor: pointer; }

.map-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.map-card { border: 1px solid #4a3b2b; border-radius: 8px; padding: 8px 6px; background: #0f0d14; text-align: center; font-size: 12px; cursor: pointer; }
.map-card small { display: block; color: var(--muted); font-size: 10px; }
.map-card.sel { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass) inset; }
.map-card.ro { cursor: default; opacity: .85; }
.diff-pick { display: flex; gap: 6px; margin-top: 4px; }
.diff-pick .btn { padding: 6px 10px; font-size: 12px; }
.diff-pick .btn.sel { border-color: var(--brass); color: var(--brass); }

.bossbar { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); text-align: center; }
.bossbar b { color: var(--danger); letter-spacing: 2px; font-size: 12px; text-shadow: 0 0 8px #ff5a4a88; }
.bossbar .bar { width: 320px; height: 10px; margin-top: 3px; }
.bossbar .bar i { background: linear-gradient(#ff7a5a, #8a1a1a); }

.eq-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.eq-slot { border: 1px solid var(--rc); border-radius: 8px; padding: 6px 8px; background: #0f0d14; font-size: 12px; min-height: 54px; }
.eq-slot small { color: var(--muted); display: block; font-size: 10px; }
.eq-slot b { color: var(--rc); display: block; }
.eq-slot span { color: var(--muted); font-size: 11px; display: block; }
.eq-slot.empty { opacity: .6; }
.bag-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; margin-top: 10px; }
.item { border: 1px solid var(--rc); border-left-width: 4px; border-radius: 8px; padding: 8px; background: #0f0d14; font-size: 12px; }
.item b { color: var(--rc); }
.item small { color: var(--muted); display: block; font-size: 10px; }
.item > span { display: block; margin: 4px 0; color: var(--text); font-size: 11px; }
.item .pas { color: var(--brass); font-size: 11px; }
.item .row { margin-top: 6px; gap: 6px; }
.btn.tiny { padding: 4px 8px; font-size: 11px; }
.btn.ghost { background: transparent; }
.warn { color: var(--danger); }
.result-roster { list-style: none; padding: 0; margin: 8px 0; font-size: 13px; }
.result-roster li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid #2a2230; }
.result-roster li .xp { color: var(--scrap); }

.hint-box { position: absolute; top: 70%; left: 50%; transform: translateX(-50%); max-width: 520px; background: #0b0a10ee; border: 1px solid var(--brass); border-radius: 10px; padding: 10px 14px; font-size: 14px; color: var(--text); animation: fade 9s forwards; }
.kick { margin-left: 6px; }
#overlay { font-size: calc(14px * var(--ui, 1)); }
#hud { font-size: calc(14px * var(--ui, 1)); }

.boards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.board { background: #0f0d14; border: 1px solid #2a2230; border-radius: 8px; padding: 6px 8px; font-size: 11px; }
.board b { display: block; color: var(--brass); font-size: 12px; margin-bottom: 3px; }
.board ol { margin: 0; padding-left: 16px; color: var(--muted); }
.board li span { color: var(--text); }
@media (max-width: 700px) { .boards { grid-template-columns: 1fr; } }

/* ---------- touch layout (phones / tablets in landscape) ---------- */
html, body { touch-action: none; }
input, select, button { touch-action: manipulation; }
#touch-ui .tbtn { pointer-events: auto; user-select: none; -webkit-user-select: none; }
.tbtn.big { width: 76px; height: 76px; font-size: 30px; }
.touch .hud-top { left: 50%; top: 6px; padding: 4px 10px; gap: 10px; font-size: 12px; }
.touch .hud-top .bar { width: 80px; }
.touch .hud-bottom { left: 0; right: 0; bottom: 8px; justify-content: center; pointer-events: none; }
.touch .bar.hp, .touch .bar.steam { width: 130px; }
.touch .hotbar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); gap: 4px; }
.touch .hotbar .slot { width: 56px; height: 52px; }
.touch .hotbar .slot .nm { font-size: 9px; }
.touch .lane { padding: 4px 8px; font-size: 11px; }
.touch .btn.ready { display: none; }
.touch .prompt { bottom: 72px; font-size: 12px; flex-wrap: wrap; white-space: normal; max-width: 70vw; justify-content: center; }
.touch .hud-hint { display: none; }
.touch .bossbar { top: 40px; }
.touch .bossbar .bar { width: 220px; }
.touch .hint-box { top: 60%; max-width: 70vw; font-size: 13px; }
.touch .stick { left: 30px; bottom: 30px; }
@media (max-height: 450px) {
  .touch .hotbar .slot { width: 50px; height: 46px; }
}

#rotate-note { display: none; position: absolute; inset: 0; background: #0b0a10f2; z-index: 50; align-items: center; justify-content: center; text-align: center; font-size: 18px; color: var(--brass); padding: 24px; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) { #rotate-note { display: flex; } }

.ui-open #touch-ui { display: none !important; }
.touch .bag-list { max-height: 40vh; }
.touch .bag-list .btn.tiny { padding: 8px 12px; font-size: 13px; }
.touch .eq-slot .btn.tiny { padding: 6px 10px; }

/* compact bag on touch: one strip of equipment, bigger tap targets, list scrolls inside the screen */
.touch .panel { padding: 12px 14px; }
.touch .panel.wide { width: 100%; }
.touch .eq-row { grid-template-columns: repeat(6, 1fr); gap: 4px; }
.touch .eq-slot { min-height: 0; padding: 4px 6px; font-size: 10px; }
.touch .eq-slot span { display: none; }
.touch .eq-slot b { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.touch .bag-list { max-height: none; overflow: visible; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.touch .lobby-body { grid-template-columns: 1fr 1fr; }
.touch .hero-pick { grid-template-columns: repeat(4, 1fr); }
.touch #screen-settings .field { margin: 6px 0; }
@media (max-width: 700px) { .touch .lobby-body { grid-template-columns: 1fr; } .touch .hero-pick { grid-template-columns: repeat(2, 1fr); } }

/* ---------- classes v2: 8-slot hotbar, locks, cooldowns, belt, role tabs ---------- */
.hotbar .slot { width: 64px; }
.hotbar .slot.sep { margin-left: 8px; }
.hotbar .slot.locked { opacity: .45; cursor: default; }
.hotbar .slot.locked::after { content: "🔒"; position: absolute; right: 3px; top: 2px; font-size: 11px; }
.hotbar .slot .cd { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--steam); pointer-events: none; }
.belt { display: flex; gap: 4px; margin-left: 10px; }
.belt .slot { width: 46px; height: 58px; border: 1px solid #3a2f22; border-radius: 8px; background: #0b0a10cc; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); pointer-events: auto; cursor: pointer; position: relative; }
.belt .slot b { font-size: 13px; color: var(--steam); height: 15px; }
.belt .slot .nm { font-size: 9px; color: var(--text); text-align: center; line-height: 1.1; }
.belt .slot .n { position: absolute; right: 3px; bottom: 2px; color: var(--brass); font-size: 10px; }
.belt .slot.sel { border-color: var(--steam); box-shadow: 0 0 0 1px var(--steam) inset; }
.belt .slot.empty { opacity: .5; }
.role-tabs { display: flex; gap: 6px; margin: 6px 0 0; flex-wrap: wrap; }
.role-tabs .btn.sel { border-color: var(--brass); color: var(--brass); }
.hero-pick { grid-template-columns: repeat(5, 1fr); }
.hero-card { padding: 8px 4px; }
.hero-card b { font-size: 12px; }
.hero-card small { font-size: 10px; }
.hero-card.hide { display: none; }
@media (max-width: 700px) { .hero-pick { grid-template-columns: repeat(3, 1fr); } }
.touch .hotbar .slot { width: 46px; height: 48px; }
.touch .hotbar .slot.sep { margin-left: 4px; }
.touch .belt .slot { width: 40px; height: 48px; }
.touch .hero-pick { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 700px) { .touch .hero-pick { grid-template-columns: repeat(3, 1fr); } }
@media (max-height: 450px) { .touch .hotbar .slot { width: 42px; height: 44px; } }

/* ---------- cards (draft, shops, build screen) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; margin-top: 8px; }
.card { border: 1px solid var(--rc, #4a3b2b); border-left-width: 4px; border-radius: 10px; padding: 8px 10px; background: #0f0d14; cursor: pointer; font-size: 12px; position: relative; }
.card .fam { display: block; font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.card .nm { display: block; color: var(--rc, var(--text)); font-weight: 700; font-size: 13px; margin-top: 2px; }
.card .ds { display: block; color: var(--text); margin-top: 3px; line-height: 1.25; }
.card .price { display: block; margin-top: 6px; color: var(--scrap); font-weight: 700; }
.card .stacks { color: var(--brass); font-size: 11px; margin-left: 6px; font-weight: 400; }
.card .key { position: absolute; right: 8px; top: 6px; color: var(--brass); font-weight: 700; font-size: 13px; }
.card.owned, .card.poor, .card.locked, .card.inactive { opacity: .5; cursor: default; }
.card.cursed { border-color: var(--danger); }
.card.cursed .fam { color: var(--danger); }
.card.sel, .card.picked { box-shadow: 0 0 0 1px var(--brass) inset, 0 0 14px #f2a95066; border-color: var(--brass); opacity: 1; }
.card:hover:not(.owned):not(.poor):not(.locked) { background: #17131e; }
.eq-row.kit { grid-template-columns: repeat(4, 1fr); }
.eq-row.kit .eq-slot span { font-size: 10px; }
/* draft overlay + chip (HUD children are pointer-events:none by default) */
.draft { position: absolute; right: 14px; top: 110px; width: 260px; background: #0b0a10ee; border: 1px solid var(--brass); border-radius: 10px; padding: 8px 10px; pointer-events: auto !important; font-size: 12px; }
.draft .lobby-head b { color: var(--brass); letter-spacing: 1px; }
.draft .hint { margin: 2px 0 4px; font-size: 11px; }
.draft .cards { grid-template-columns: 1fr; max-height: none; overflow: visible; margin-top: 4px; }
.timerbar { height: 3px; background: #000a; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.timerbar i { display: block; height: 100%; width: 100%; background: var(--brass); transition: width .5s linear; }
.draft-chip { position: absolute; right: 14px; top: 110px; margin: 0; pointer-events: auto !important; border: 1px solid var(--brass); color: var(--brass); background: #0b0a10cc; font-size: 13px; padding: 8px 12px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 14px #f2a95088; } }
.hud-feats { position: absolute; left: 14px; top: 14px; pointer-events: auto !important; background: #0b0a10cc; border: 1px dashed #5a4530; color: var(--brass); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.ui-open #draft, .ui-open #draft-chip, .ui-open #hud-feats { display: none !important; }
.touch .draft { left: 50%; right: auto; top: auto; bottom: 70px; transform: translateX(-50%); width: min(94vw, 660px); }
.touch .draft .cards { grid-template-columns: repeat(3, 1fr); }
.touch .draft-chip { top: auto; bottom: 70px; right: auto; left: 50%; transform: translateX(-50%); }
.touch .cards { max-height: none; overflow: visible; }
.touch .hud-feats { top: 8px; left: 190px; }
.touch .eq-row.kit { grid-template-columns: repeat(4, 1fr); }

.tabs { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.tabs .btn.sel { border-color: var(--brass); color: var(--brass); }
#anvil-class-pick { max-height: 46vh; overflow-y: auto; }
.card.maxed .price { color: var(--muted); }
.boards { grid-template-columns: repeat(3, 1fr); }
#screen-stageclear .cards { max-height: 34vh; }
#screen-stageclear .map-pick { grid-template-columns: repeat(3, 1fr); }
#screen-stageclear .result-roster { max-height: 18vh; overflow-y: auto; }
.map-card.ro { cursor: default; opacity: .85; }
.card .scope { display: inline-block; margin-top: 6px; font-size: 9px; letter-spacing: 1px; padding: 1px 6px; border-radius: 999px; border: 1px solid #3a2f22; color: var(--muted); }
.card .scope-structures { border-color: var(--scrap); color: var(--scrap); }
.card .scope-team { border-color: var(--brass); color: var(--brass); }
.card .scope-stage, .card .scope-belt { border-color: var(--steam); color: var(--steam); }
.card .scope-unlock { border-color: #c26bfa; color: #c26bfa; }
/* one hotbar, two faces */
.hotbar { flex-direction: column; align-items: flex-end; gap: 4px; }
.hb-tabs { display: flex; gap: 4px; pointer-events: auto; }
.hb-tab { background: #0b0a10cc; border: 1px solid #3a2f22; color: var(--muted); border-radius: 8px 8px 0 0; padding: 3px 10px; font-size: 11px; cursor: pointer; }
.hb-tab small { color: var(--muted); font-size: 9px; margin-left: 4px; }
.hb-tab.sel { color: var(--brass); border-color: var(--brass); }
.hb-slots { display: flex; gap: 6px; }
.hotbar .slot { width: 74px; }
.touch .hotbar { align-items: center; }
.touch .hotbar .slot { width: 54px; height: 50px; }
.bossbar .cast { margin-top: 4px; }
.bossbar .cast span { display: block; color: var(--danger); font-size: 11px; letter-spacing: 1px; animation: pulse 0.6s ease-in-out infinite; }
.bossbar .cast .bar { width: 320px; height: 6px; margin-top: 2px; }
.bossbar .cast .bar i { background: var(--danger); transition: none; }
.hud-doom { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); color: var(--danger); font-weight: 800; font-size: 22px; letter-spacing: 3px; text-shadow: 0 0 16px #ff5a4a88; animation: pulse 0.8s ease-in-out infinite; }
.hotbar .slot.bp { border-color: var(--rc); box-shadow: 0 0 0 1px var(--rc) inset; }
.hotbar .slot.bp .nm { color: var(--rc); }
.card.bp .ds { font-size: 11px; }

/* ==================================================================
   Mobile parity + radial menus + cooldown timers (dd-v23)
   ================================================================== */

/* ---------- glyphs on hotbar slots ---------- */
.hotbar .slot .gl { position: absolute; right: 4px; top: 2px; font-size: 13px; color: var(--brass); opacity: .75; pointer-events: none; }
.hotbar .slot.locked .gl { opacity: .3; }

/* ---------- cooldown as a timer graphic, not a 3px bar ----------
   A conic sweep that unwinds clockwise from 12 o'clock plus the seconds left,
   on BOTH the hotbar slot and the floating touch button (same paintCd()).   */
.cdring {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  border-radius: inherit;
  background: conic-gradient(from 0deg, #05040ad9 0deg, #05040ad9 calc(var(--f, 0) * 360deg), transparent 0);
  transition: opacity .12s linear;
}
.cdnum {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; font-style: normal; color: var(--text);
  text-shadow: 0 1px 3px #000, 0 0 8px #000; pointer-events: none;
}
.cooling .cdring { opacity: 1; }
.cooling .cdnum { display: flex; }
.cooling .nm, .cooling .gl { opacity: .35; }
/* enough cooldown, not enough Steam — a different problem, so a different look */
.poor { border-color: var(--steam) !important; }
.poor .gl, .poor .nm { opacity: .45; }
.poor::before {
  content: "♨"; position: absolute; left: 4px; top: 2px;
  font-size: 12px; color: var(--steam); pointer-events: none;
}
.tbtn .cdring { border-radius: 50%; }
.tbtn .gl { font-size: 26px; line-height: 1; }
.tbtn .k { position: absolute; right: 6px; bottom: 3px; font-size: 10px; color: var(--muted); }
.tbtn.locked { opacity: .4; }

/* ---------- radial menus ---------- */
#radial { position: fixed; inset: 0; z-index: 40; pointer-events: auto; touch-action: none; }
#radial::before { content: ""; position: absolute; inset: 0; background: #05040a5c; }
.rad-hub {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 120px; padding: 6px 10px; border-radius: 10px;
  background: var(--panel); border: 1px solid #3a2f22; pointer-events: none;
  font-size: calc(11px * var(--ui, 1)); text-align: center;
}
.rad-title { color: var(--muted); letter-spacing: 1px; text-transform: uppercase; font-size: .85em; }
.rad-sel { color: var(--brass); font-weight: 700; min-height: 1em; }
.rad-item {
  position: absolute; transform: translate(-50%, -50%);
  width: calc(74px * var(--ui, 1)); height: calc(74px * var(--ui, 1)); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: #15121af2; border: 1px solid #5a4530; color: var(--text);
  font-family: var(--font); font-size: calc(10px * var(--ui, 1)); line-height: 1.1;
  padding: 2px; cursor: pointer; text-align: center;
  box-shadow: 0 6px 18px #000a;
  transition: transform .1s ease-out, border-color .1s linear, background .1s linear;
}
.rad-item .rad-glyph { font-size: calc(22px * var(--ui, 1)); color: var(--brass); }
.rad-item .rad-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rad-item .rad-sub { color: var(--muted); font-size: .85em; }
.rad-item.sel { border-color: var(--brass); background: #2a2030; transform: translate(-50%, -50%) scale(1.14); box-shadow: 0 0 18px #f2a95066, 0 6px 18px #000a; }
.rad-item.sel .rad-sub { color: var(--text); }
.rad-item.disabled { opacity: .42; }
.rad-item.disabled .rad-glyph { color: var(--iron); }
.rad-item.disabled.sel { border-color: var(--danger); box-shadow: none; }
/* a wheel owns the screen: nothing behind it should invite a press */
.radial-open #touch-ui, .radial-open .prompt, .radial-open .draft-chip { pointer-events: none; opacity: .35; }

/* ---------- touch control layout ----------
   Every button used to carry a hand-picked pixel offset (and #tbtn-f carried
   two, one of them dead). They are now placed off four safe-area tokens, so
   nothing lands under a notch or a home indicator, and the whole cluster
   scales with the UI-scale slider.                                          */
.touch {
  --tb: 62px; --tb-big: 78px; --tb-sm: 46px;
  --sr: max(14px, env(safe-area-inset-right));
  --sb: max(14px, env(safe-area-inset-bottom));
  --sl: max(14px, env(safe-area-inset-left));
  --st: max(10px, env(safe-area-inset-top));
}
.touch .tbtn { width: calc(var(--tb) * var(--ui, 1)); height: calc(var(--tb) * var(--ui, 1)); font-size: calc(23px * var(--ui, 1)); }
.touch .tbtn.big { width: calc(var(--tb-big) * var(--ui, 1)); height: calc(var(--tb-big) * var(--ui, 1)); font-size: calc(30px * var(--ui, 1)); }
.touch .tbtn.sm { width: calc(var(--tb-sm) * var(--ui, 1)); height: calc(var(--tb-sm) * var(--ui, 1)); font-size: calc(17px * var(--ui, 1)); }

/* right thumb, combat: attack at the corner, the spell arc sweeping up-left */
#tbtn-attack { right: var(--sr); bottom: var(--sb); }
#tbtn-alt    { right: calc(var(--sr) + 90px); bottom: calc(var(--sb) + 6px); background: #7fd0ff22; border-color: var(--steam); }
#tbtn-dodge  { right: calc(var(--sr) + 8px);  bottom: calc(var(--sb) + 90px); }
#tbtn-q      { right: calc(var(--sr) + 98px); bottom: calc(var(--sb) + 94px); }
#tbtn-e      { right: calc(var(--sr) + 180px); bottom: calc(var(--sb) + 46px); }
#tbtn-r      { right: calc(var(--sr) + 182px); bottom: calc(var(--sb) + 130px); }
#tbtn-f      { right: calc(var(--sr) + 66px);  bottom: calc(var(--sb) + 174px); }
#tbtn-5      { right: calc(var(--sr) + 152px); bottom: calc(var(--sb) + 194px); }
#tbtn-u      { right: calc(var(--sr) + 252px); bottom: calc(var(--sb) + 84px); }
#tbtn-z      { right: calc(var(--sr) + 250px); bottom: calc(var(--sb) + 16px); }

/* right thumb, placing a structure: the same three positions, swapped in */
#tbtn-place  { right: var(--sr); bottom: var(--sb); background: #f2a95066; border-color: var(--brass); }
#tbtn-rot    { right: calc(var(--sr) + 90px); bottom: calc(var(--sb) + 6px); }
#tbtn-cancel { right: calc(var(--sr) + 8px);  bottom: calc(var(--sb) + 90px); }

/* left side: build-phase actions, clear of the movement stick */
#tbtn-ready  { left: var(--sl); bottom: calc(var(--sb) + 152px); background: #1d3a1d66; border-color: var(--scrap); }
#tbtn-build  { left: var(--sl); bottom: calc(var(--sb) + 226px); background: #f2a95033; border-color: var(--brass); }
.touch .stick { left: var(--sl); bottom: var(--sb); }

/* top-right utility row */
#tbtn-menu { right: var(--sr); top: var(--st); }
#tbtn-map  { right: calc(var(--sr) + 54px); top: var(--st); }
#tbtn-bag  { right: calc(var(--sr) + 108px); top: var(--st); }
#tbtn-book { right: calc(var(--sr) + 162px); top: var(--st); }
#tbtn-ping { right: calc(var(--sr) + 216px); top: var(--st); }

/* short landscape phones: pull the arc in so nothing runs off the top */
@media (max-height: 430px) {
  .touch { --tb: 54px; --tb-big: 68px; --tb-sm: 42px; }
  #tbtn-f { bottom: calc(var(--sb) + 158px); }
  #tbtn-5 { bottom: calc(var(--sb) + 176px); }
  #tbtn-ready { bottom: calc(var(--sb) + 132px); }
  #tbtn-build { bottom: calc(var(--sb) + 196px); }
}

/* The bottom bar and the thumb arc both show the spells: the bar carries the
   names and costs, the arc is what you actually press. They no longer disagree
   about cooldown, because both paint through paintCd(). */
.touch .hotbar { left: 50%; bottom: var(--sb); transform: translateX(-50%); }
.touch .hud-bottom { left: 0; right: 0; bottom: var(--sb); }
.touch .prompt { bottom: calc(var(--sb) + 78px); }

/* ---------- HUD visual pass ----------
   One panel treatment for everything that floats over the world, and bars that
   read at a glance: a brass rim, an inner shadow so the fill reads as depth,
   and a damage "chip" trail that shows what you just lost.                  */
.hud-top, .hud-stats, .prompt, .hint-box, .lane, .rad-hub {
  background: linear-gradient(#15121af2, #0b0a10f2);
  border: 1px solid #3a2f22;
  box-shadow: 0 6px 20px #0009, inset 0 1px 0 #ffffff0d;
}
.bar {
  box-shadow: inset 0 2px 5px #000c, 0 0 0 1px #00000060;
  background: #07060bcc;
}
.bar i { box-shadow: inset 0 1px 0 #ffffff33; border-radius: 6px 0 0 6px; }
/* the trail sits behind the fill and catches up late, so a hit is legible */
.bar.hp::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, #ffb08a55, #ffb08a55) no-repeat;
  background-size: var(--chip, 0%) 100%;
  transition: background-size .55s ease-out .12s; pointer-events: none; z-index: 0;
}
/* z-index 0, not -1: the bar paints its own background, and a negative pseudo
   would sit behind that and never be seen. Order is bg → chip → fill → text. */
.bar.hp i { position: relative; z-index: 1; }
.bar.hp span { z-index: 2; }
.bar.steam i { background: linear-gradient(var(--steam), #3f9fd6); }
#core-bar { background: linear-gradient(var(--brass), var(--copper)); }
.hud-top { letter-spacing: 1px; }
.hud-phase { color: var(--brass); font-weight: 700; }
.hud-timer { font-variant-numeric: tabular-nums; }
.res { font-variant-numeric: tabular-nums; }
.prompt .btn b { display: inline-block; min-width: 1.1em; text-align: center; }

/* Reduced motion: kill the animated flourishes, keep the information. Honours
   both the OS preference and the in-game setting (which until now only scaled
   camera shake — main.js:58 — and never reached the UI). */
@media (prefers-reduced-motion: reduce) {
  .bar i, .bar.hp::after, .cdring, .rad-item { transition: none; }
  h1.logo .gear { animation: none; }
}
.reduced-motion .bar i, .reduced-motion .bar.hp::after,
.reduced-motion .cdring, .reduced-motion .rad-item { transition: none; }
.reduced-motion h1.logo .gear { animation: none; }

/* ==================================================================
   Controller / Steam Deck
   ================================================================== */

/* The focus ring. Nothing in this client was ever focusable, so this is the
   only thing telling a pad player where they are — it has to be unmissable
   at arm's length on a 7" screen, and it must not depend on :focus, since
   most of the targets are divs. */
.pad-nav .pad-focus,
.pad-nav .pad-focus.btn,
.pad-nav .pad-focus.card,
.pad-nav .pad-focus.hero-card,
.pad-nav .pad-focus.map-card {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px #0b0a10, 0 0 20px #f2a95077;
  border-radius: 8px;
  position: relative;
  z-index: 2;
}
.pad-nav .pad-focus.disabled, .pad-nav .pad-focus.poor, .pad-nav .pad-focus.maxed {
  outline-color: var(--iron); box-shadow: 0 0 0 1px #0b0a10, 0 0 14px #9aa3ad55;
}
/* the browser's own ring would fight ours on inputs */
.pad-nav :focus-visible { outline: none; }
.pad-nav input.pad-focus, .pad-nav select.pad-focus { outline-offset: 0; }
/* a pad player is not hovering anything; hover styling reads as a second cursor */
.pad-nav .btn:hover { background: #2a2030; }

/* Steam Deck: 1280×800 at 7", held close. Everything is legible but small —
   nudge the base up and give the panels room, without touching desktop. */
@media (min-width: 1000px) and (max-width: 1400px) and (max-height: 860px) and (pointer: fine) {
  #overlay, #hud { font-size: calc(15px * var(--ui, 1)); }
  .panel { width: min(680px, 100%); }
  .panel.wide { width: min(900px, 100%); }
  .btn { padding: 11px 18px; }
}
/* on a pad, tap targets want to be forgiving even on a desktop monitor */
.pad-nav .btn.tiny { padding: 7px 12px; font-size: 13px; }
.pad-nav .hb-tab { padding: 5px 14px; font-size: 12px; }

/* ---------- phone HUD layout, corrected ----------
   BUG: .hud-bottom is absolute, and on touch all three of its children
   (.hud-stats, .hotbar, .belt) are absolute too — so it collapses to ZERO
   height at the bottom of the screen. `.hud-stats { top: 54px }` therefore
   resolved to 54px BELOW the viewport, taking HP, Steam and Scrap off-screen
   entirely. position:fixed takes the stats off that collapsed box and anchors
   them to the viewport, where they were always meant to be.               */
.touch .hud-stats {
  position: fixed;
  left: var(--sl);
  top: calc(var(--st) + 44px);
  bottom: auto; right: auto;
  padding: 6px 9px;
  z-index: 3;
}
.touch .bar.hp, .touch .bar.steam { width: 128px; }
.touch .hud-stats .res { margin-top: 4px; font-size: 11px; }

/* the lanes sit under the stats, not on top of them */
.touch .lanes { left: var(--sl); top: calc(var(--st) + 126px); max-width: 170px; gap: 4px; max-height: 34vh; overflow: hidden; }

/* The potion strip was pinned bottom-left — underneath the movement stick,
   which is drawn over it and moves to wherever the thumb lands. On a phone it
   is also redundant: 🧪 drinks, and holding it opens the belt wheel with the
   names and counts. Hide the strip and put the count on the button. */
.touch .belt { display: none; }
#tbtn-z .n {
  position: absolute; right: -2px; top: -2px; min-width: 17px; height: 17px;
  border-radius: 9px; background: var(--brass); color: #1a1208;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}
#tbtn-z.empty { opacity: .45; }

/* build + ready move to the right, under the utility row: the left edge has to
   carry the stats, the lanes and the movement stick, and could not hold them */
#tbtn-build { left: auto; right: var(--sr); top: calc(var(--st) + 52px); bottom: auto; }
#tbtn-ready { left: auto; right: calc(var(--sr) + 54px); top: calc(var(--st) + 52px); bottom: auto; }
@media (max-height: 430px) {
  #tbtn-build, #tbtn-ready { top: calc(var(--st) + 48px); }
  .touch .lanes { top: calc(var(--st) + 116px); max-height: 30vh; }
}
