:root {
  --bg: #0b0f1d;
  --panel: rgba(18, 22, 40, 0.94);
  --panel2: rgba(30, 36, 62, 0.95);
  --line: rgba(160, 180, 255, 0.18);
  --text: #e8ecff;
  --dim: #9aa4c8;
  --acc: #c77dff;
  --acc2: #2affc6;
  --gold: #ffd23f;
  --hp: #ff4a5a;
  --mp: #4a8cff;
  --exp: #ffd23f;
  --bad: #ff4f6d;
  --good: #7affb0;
}
* { box-sizing: border-box; }
/* The login card is the logo, the tabs and the form: no tagline or controls line (the in-game H help has those). */
#login .tag, #login .hint { display: none; }
/* A ‹ name › control is two arrows around a fixed name box; the expression picker reuses the same
   widths so every control in a label column lines up. */
:root { --ar-w: 22px; --name-w: 130px; --sw: 15px; }
html.touch { --ar-w: 44px; --name-w: 136px; --sw: 26px; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font, ui-monospace, monospace); overflow: hidden; user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: auto; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: none; }
.hidden { display: none !important; }
button { font: inherit; }

/* ---------- Login ---------- */
.screen { position: absolute; inset: 0; display: flex; overflow-y: auto; padding: 16px 0; box-sizing: border-box; pointer-events: auto !important; background: radial-gradient(ellipse at 50% 45%, rgba(20, 10, 50, 0.18), rgba(5, 8, 20, 0.5)); }
.login-card { margin: auto; width: min(520px, calc(100vw - 32px)); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: var(--s5) var(--s6); }
.login-card.wide { width: min(940px, calc(100vw - 32px)); }
/* The Create character tab is the character creator: the pitch line, the version link and the
   controls hint have nothing to add to it. */
.login-card.creating .tag, .login-card.creating .hint, .login-card.creating .pn-link { display: none; }
.logo { margin: 0; font-size: var(--f-xl); letter-spacing: .09em; font-weight: 800; text-align: center; color: var(--t1); }
.logo span { color: var(--accent); }
.tag { text-align: center; color: var(--t2); margin: var(--s2) 0 var(--s4); }
.tabs { display: flex; width: 100%; margin-bottom: var(--s4); }
#login .tabs .tab {
  position: relative; flex: 1; min-height: 38px; padding: 0 var(--s3); margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background-color: transparent;
  color: var(--t2); font: inherit; font-size: var(--f-xs); font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
#login .tabs .tab:hover { color: var(--t1); border-bottom-color: var(--hair); }
#login .tabs .tab.on { color: var(--t1); border-bottom-color: var(--accent); }
.login-card .tab:focus-visible, .login-card .btn:focus-visible, #authForm input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#authForm { display: flex; flex-direction: column; gap: var(--s3); }
#authForm input { min-height: var(--h-md); padding: 0 var(--s3); border-radius: var(--r-sm); border: 1px solid var(--hair); background: var(--inset); color: var(--t1); font: inherit; font-size: var(--f-sm); outline: none; }
#authForm input:focus { border-color: var(--accent-line); }
/* Creator: the stage takes the left 45%, the name/password/body/weapon rows the right column. */
#authForm.creating { display: grid; grid-template-columns: 45% minmax(0, 1fr); grid-template-areas: "stage rows" "stage btn" "err err" "conn conn"; gap: var(--s3); align-items: start; }
#authForm.creating .cr-stage { grid-area: stage; display: flex; min-height: 400px; height: 420px; }
#authForm.creating .class-pick { grid-area: rows; }
#authForm:not(.creating) #authBtn { align-self: center; width: min(220px, 100%); }
#authForm.creating #authBtn { grid-area: btn; justify-self: stretch; width: 100%; }
#authForm.creating #authErr { grid-area: err; }
#authForm.creating #connStatus { grid-area: conn; }
#authForm.creating .pick { width: 180px; flex: none; }
#authForm.creating #authErr:empty, #authForm.creating #connStatus { display: none; }
#authForm.creating .cr-body, #authForm.creating .cr-weapon { display: block; }
.cr-stage, .cr-body, .cr-weapon { display: none; }
.login-card:not(.creating) .cr-stage { display: none; }

/* ---------- Creator rows: a fixed label column, then the control, and nothing stretched ---------- */
.row-line { display: flex; align-items: center; gap: var(--s3); margin: 0 0 var(--s2); min-width: 0; }
.login-card .row-line { margin-bottom: var(--s2); }
.row-line > label { width: 76px; flex: none; font-size: var(--f-xs); letter-spacing: .09em; text-transform: uppercase; color: var(--t2); }
/* A label sits level with the first line of its control (the stepper, or the first swatch row). */
.row-line:has(> .row-stack) > label, .row-line:has(> .sws) > label { align-self: flex-start; display: flex; align-items: center; }
.row-line:has(> .row-stack) > label { height: var(--h-md); }
.row-line:has(> .sws) > label { height: var(--h-touch); }
.row-stack { display: flex; flex-direction: column; gap: var(--s2); align-items: stretch; min-width: 0; }
.step { display: flex; align-items: center; gap: var(--s1); }
.step .ar { width: var(--ar-w); min-width: var(--ar-w); height: var(--h-md); padding: 0; line-height: 1; }
.step-name { display: grid; place-items: center; width: var(--name-w); min-height: var(--h-md); flex: none; text-align: center; }
/* The expression picker: one select, exactly as wide as a ‹ name › control. */
select.expr { width: calc(var(--ar-w) * 2 + var(--name-w) + 8px); flex: none; }
.pick { flex: 1; min-width: 0; }
.sws { display: flex; flex-wrap: wrap; gap: var(--s2); min-width: 0; max-width: 100%; overflow: visible; }
/* KIT-REQUEST: compact colour swatches with a larger spaced hit area on touch. */
.sw { position: relative; flex: none; width: 20px; height: 20px; padding: 0; border: 1px solid var(--hair); border-radius: var(--r-sm); cursor: pointer; }
.sw::before { content: ''; position: absolute; inset: calc(-1 * var(--s1)); }
.sw.cell.sel, .sw.cell.on { border-color: var(--hair); box-shadow: none; outline: 2px solid var(--accent); outline-offset: 2px; }
.sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cr-picks { display: flex; flex-wrap: wrap; gap: var(--s2); min-width: 0; }
/* Weapon buttons: the icon only, the name in the tooltip, so no label can overflow the card. */
.class-card { position: relative; display: flex; align-items: center; justify-content: center; flex: none; width: 64px; height: 64px; padding: 0; }
.class-card img { width: 44px; height: 44px; image-rendering: pixelated; }
.class-card.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.btn { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; transition: transform .06s, background .15s; }
.btn:hover { background: rgba(80, 90, 150, 0.6); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--acc); border-color: var(--acc); font-weight: 700; color: #170a26; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.good { background: linear-gradient(135deg, #10a37f, #2affc6); color: #04150f; font-weight: 700; border: none; }
.btn.bad { background: linear-gradient(135deg, #b0203a, #ff4f6d); color: #fff; font-weight: 700; border: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.err { color: var(--bad); min-height: 18px; font-size: 14px; font-weight: 600; text-align: center; }
.err:not(:empty) { background: rgba(255, 79, 109, 0.12); border: 1px solid rgba(255, 79, 109, 0.5); border-radius: 8px; padding: 6px 10px; }
.conn { font-size: 12px; text-align: center; margin-top: 6px; color: var(--dim); }
.conn::before { content: '●'; margin-right: 6px; }
.conn.ok::before { color: #4fff9a; } .conn.wait::before { color: #ffd54f; } .conn.bad::before { color: #ff4f6d; }
#authBtn:disabled { opacity: 0.6; cursor: progress; }
.hint { color: var(--dim); font-size: 12px; text-align: center; margin: 14px 0 0; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; }
.hud-bottom { position: absolute; right: var(--s4); bottom: var(--s4); display: flex; gap: var(--s3); align-items: flex-end; pointer-events: auto; }
.vitals { width: 280px; background: linear-gradient(180deg, rgba(24,28,50,.97), rgba(12,16,32,.97)); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: var(--s3); box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.vitals .top { display: flex; justify-content: space-between; align-items: baseline; min-height: 18px; margin-bottom: var(--s1); font-size: var(--f-xs); }
.vitals .top b { font-size: var(--f-sm); letter-spacing: 0; }
.vitals .lvl { font-weight: 900; color: var(--gold); margin-right: 5px; }
.bar { position: relative; height: 14px; border-radius: 5px; background: rgba(0,0,0,.62); overflow: hidden; margin-top: 4px; box-shadow: 0 1px 0 rgba(255,255,255,.08) inset; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; transition: width .12s linear; box-shadow: 0 1px 0 rgba(255,255,255,.24) inset; }
.bar > span { position: absolute; inset: 0; font-size: 10.5px; line-height: 14px; text-align: center; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; letter-spacing: .2px; }
.bar.hp { height: 16px; } .bar.hp > span { line-height: 16px; }
.bar.hp > i { background: linear-gradient(90deg, #a80e2c, #ff5368); }
.bar.mp > i { background: linear-gradient(90deg, #194bab, #5c9dff); }
.bar.exp { height: 7px; margin-top: 5px; border-radius: 4px; } .bar.exp > i { background: linear-gradient(90deg, #b9810c, #ffe36e); border-radius: 4px; } .bar.exp > span { font-size: 8px; line-height: 7px; color: #fff7cf; }
.skills { display: flex; gap: var(--s2); background: rgba(12,16,32,.94); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: var(--s2); box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.slot { position: relative; width: 46px; height: 46px; border-radius: var(--r-md); background: rgba(0,0,0,.5); border: 1px solid var(--hair); overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.slot canvas { width: 100%; height: 100%; display: block; }
.slot .key { position: absolute; z-index: 3; left: 3px; top: 1px; min-width: 14px; text-align: center; font-size: 10px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px #000; }
.slot .cnt { position: absolute; z-index: 3; right: 3px; bottom: 1px; font-size: 10px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.slot .cd { --sweep: 0deg; position: absolute; z-index: 1; inset: 0; background: conic-gradient(from 0deg, rgba(3,5,12,.78) 0deg var(--sweep), transparent var(--sweep) 360deg); }
.slot .cdt { position: absolute; z-index: 2; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.slot.ready { border-color: rgba(126,240,255,.48); box-shadow: 0 0 8px rgba(91,192,255,.13); }
.slot.locked { opacity: .38; filter: saturate(.45); }
.slot.active-buff { border-color: var(--good); box-shadow: 0 0 0 1px var(--good), 0 0 12px rgba(122,255,176,.3); }
.hud-tl { position: absolute; left: var(--s4); top: var(--s4); }
.minimap-shell { position: relative; width: 218px; height: 124px; background: rgba(10,14,28,.92); border: 1px solid var(--hair); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.mapname { position: absolute; z-index: 2; left: 0; right: 0; top: 0; padding: var(--s2) var(--s3); font-weight: 800; font-size: var(--f-xs); background: linear-gradient(180deg, rgba(12,16,32,.96), rgba(12,16,32,.68)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapname small { color: var(--t2); font-weight: 650; margin-left: var(--s2); font-size: var(--f-xs); }
#minimap { position: absolute; left: 1px; bottom: 1px; width: 216px; height: 96px; background: rgba(7,11,24,.82); }
.hud-tr { position: absolute; right: var(--s4); top: var(--s4); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); align-items: start; pointer-events: auto; }
.hud-tr > .menu-btns, .hud-tr > .buffs { grid-column: 1 / -1; }
.hud-status { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2); }
.chip-row { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.chip { min-height: 32px; background: rgba(15,19,36,.94); border: 1px solid var(--hair); border-radius: var(--r-sm); padding: var(--s1) var(--s2); font-size: var(--f-xs); display: flex; gap: var(--s1); align-items: center; white-space: nowrap; }
.chip b { color: #fff; font-variant-numeric: tabular-nums; }
.chip small { color: var(--t2); font-size: var(--f-xs); font-variant-numeric: tabular-nums; }
.chip img { width: 16px; height: 16px; }
.chip .mi { font-size: var(--f-md); line-height: 1; }
.rankbox { background: rgba(15,19,36,.94); border: 1px solid var(--hair); border-radius: var(--r-md); padding: var(--s2) var(--s3); width: 148px; font-size: var(--f-xs); letter-spacing: .02em; }
.rankbox .bar { height: 6px; margin-top: var(--s2); border-radius: 3px; } .rankbox .bar > i { background: var(--accent); }
.rankbox .coupon { color: var(--gold); font-weight: 800; }
.menu-btns { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); background: rgba(10,14,28,.82); border: 1px solid var(--hair); border-radius: var(--r-md); }
.menu-group { display: flex; align-items: center; gap: var(--s1); }
.menu-group + .menu-group { margin-left: var(--s1); padding-left: var(--s2); border-left: 1px solid var(--hair); }
.menu-btns button { position: relative; width: 38px; height: 38px; padding: 0; background: rgba(28,34,58,.9); border: 1px solid var(--hair); color: var(--t1); border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.menu-btns button:hover { background: rgba(64,72,112,.96); border-color: var(--accent-line); }
.menu-btns .mi { font-size: 18px; line-height: 1; transform: translateY(-1px); }
.menu-btns button kbd { position: absolute; right: 2px; bottom: 2px; padding: 0 2px; font-size: 9px; line-height: 10px; border: 0; background: rgba(5,8,18,.66); color: var(--t2); opacity: 0; transition: opacity .12s; }
.menu-btns button:hover kbd, .menu-btns button:focus-visible kbd { opacity: 1; }
.menu-btns .ml { display: none; }
.menu-btns button .dot { position: absolute; left: -2px; top: -2px; width: 7px; height: 7px; background: var(--bad); border: 1px solid #1a132c; border-radius: 50%; }
#dotL { position: absolute; inset: 0; pointer-events: none; }
#dotL.pulse { animation: dotPulse .7s ease-in-out 3; }
@keyframes dotPulse { 50% { filter: brightness(1.8); transform: scale(1.45); } }
.buffs { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.buff { background: rgba(15,19,36,.94); border: 1px solid var(--hair); border-radius: var(--r-sm); padding: var(--s1) var(--s2); font-size: var(--f-xs); color: var(--pos); }
.party { position: absolute; left: var(--s4); top: calc(var(--hud-tl-b, 148px) + var(--s2)); display: flex; flex-direction: column; gap: var(--s2); width: 200px; }
.pm { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r-md); padding: var(--s2) var(--s3); font-size: var(--f-xs); pointer-events: auto; cursor: pointer; }
.pm .bar { height: 5px; margin-top: var(--s1); }
.pm-map { margin-top: var(--s1); font-size: var(--f-xs); }
.chat { position: absolute; left: var(--s4); bottom: var(--s4); width: clamp(240px, calc(100vw - 920px), 420px); pointer-events: auto; }
.chatlog { max-height: 132px; overflow-y: auto; font-size: var(--f-sm); line-height: 1.4; padding: var(--s2) var(--s3); background: rgba(8, 10, 20, 0.55); border-radius: var(--r-md) var(--r-md) 0 0; scrollbar-width: thin; }
.chatlog div { margin: var(--s1) 0; text-shadow: 0 1px 2px #000; word-wrap: break-word; }
.chatlog .sys { color: var(--t2); opacity: .7; } .chatlog .party { color: #7affb0; } .chatlog .whisper { color: #ff9af0; } .chatlog .exp { color: #ffe36e; font-size: var(--f-xs); } .chatlog .loot { color: #9ef0ff; font-size: var(--f-xs); }
#chatInput { width: 100%; padding: 7px 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.6); color: #fff; border-radius: 0 0 10px 10px; outline: none; font-size: 13px; }
/* Below ~890 px the chat no longer fits beside the bottom bar: stack it on the bar's measured top. */
@media (max-width: 900px) { .chat { bottom: calc(var(--hud-b, 100px) + 8px); width: 340px; } .chatlog { max-height: 66px; } }
.boss-hud { position: absolute; top: calc(max(var(--hud-tl-b, 148px), var(--hud-tr-b, 120px)) + 6px); left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 520px)); padding: 0; background: none; border: 0; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.8)); }
.boss-line { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(90px, 1.6fr) auto; gap: var(--s3); align-items: center; }
.boss-hud .name { min-width: 0; display: flex; align-items: center; gap: var(--s2); font-size: var(--f-sm); white-space: nowrap; text-shadow: 0 1px 3px #000; }
.boss-hud .name b { overflow: hidden; text-overflow: ellipsis; }
.boss-hud .name > span:not(.rage) { flex: none; font-size: var(--f-xs); font-weight: 700; }
.boss-hud .bar { height: 14px; margin: 0; border: 1px solid var(--hair); background: rgba(5,7,16,.58); box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset; }
.boss-hud .bar > i { background: linear-gradient(90deg, #8a0f2a, #ff4f6d, #ffb02e); }
.boss-hud .bar > span { font-size: var(--f-xs); line-height: 14px; }
.boss-hud .bar > b.tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: rgba(255,255,255,0.9); box-shadow: 0 0 4px #000; }
.boss-hud .bar > b.tick.passed { background: rgba(255,255,255,0.3); }
.boss-hud .rage { flex: none; padding: 1px 5px; border-radius: 4px; background: #ff2a4a; color: #fff; font-size: 9px; letter-spacing: .7px; animation: ragepulse .5s infinite alternate; }
@keyframes ragepulse { from { box-shadow: 0 0 0 rgba(255,42,74,0); } to { box-shadow: 0 0 12px rgba(255,42,74,0.95); } }
.boss-hud.enraged .bar > i { background: linear-gradient(90deg, #ff2a4a, #ff7a2e); }
.boss-hud .meta { display: flex; align-items: center; gap: var(--s3); font-size: var(--f-xs); white-space: nowrap; color: var(--t1); font-variant-numeric: tabular-nums; }
.boss-hud .meta .clock.urgent { color: #ff6a7a; font-weight: 800; }
.boss-hud .meta .lives { letter-spacing: 1px; color: #ffd23f; font-size: 9px; }
.boss-hud .meta .lives .lost { color: rgba(255,255,255,0.25); }
.runpanel { position: absolute; right: var(--s4); top: 120px; width: 250px; background: rgba(15,19,36,.94); border: 1px solid var(--hair); border-radius: var(--r-md); padding: var(--s3); font-size: var(--f-xs); pointer-events: auto; }
.run-resources { display: flex; justify-content: space-between; gap: 8px; color: #cbd3f2; font-variant-numeric: tabular-nums; }
.run-resources span { white-space: nowrap; }
.run-warn { margin-top: 4px; color: #ff8a9b; font-weight: 700; }
.runpanel .row { display: flex; justify-content: space-between; }
.protos { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; max-height: 160px; overflow-y: auto; }
.proto { font-size: var(--f-xs); padding: var(--s1) var(--s2); border-radius: var(--r-sm); border: 1px solid var(--hair); background: rgba(0,0,0,0.3); cursor: help; }

/* ---------- Toasts / Banner ---------- */
#toasts { position: absolute; top: 132px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s2); align-items: stretch; width: min(400px, 90vw); pointer-events: none; }
.toast { max-width: 100%; background: rgba(12, 14, 30, 0.82); border: 1px solid var(--hair); padding: var(--s2) var(--s3); border-radius: var(--r-md); font-size: var(--f-sm); font-weight: 650; text-align: left; animation: toastIn .25s ease-out; text-shadow: 0 1px 2px #000; }
.toast.out { opacity: 0; transition: opacity .5s; }
.toast.bump { animation: toastBump .18s ease-out; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastBump { 50% { transform: scale(1.04); } }
#banner { position: absolute; top: 13%; left: 0; right: 0; text-align: center; opacity: 0; transition: opacity .4s; }
#banner.show { opacity: 1; }
#banner .t { font-size: 54px; font-weight: 900; letter-spacing: 4px; text-shadow: 0 0 30px rgba(42,255,198,0.7), 0 4px 10px #000; }
#banner .s { font-size: 18px; color: var(--dim); text-shadow: 0 2px 6px #000; }

/* ---------- Windows ---------- */
#windows { position: absolute; inset: 0; }
.win { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(var(--w, 720px), calc(100vw - 32px)); max-height: calc(100vh - 96px); display: flex; flex-direction: column; background: #121628; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,0.58); pointer-events: auto; animation: winIn .15s ease-out; }
.win.modal-bg { top: calc(50% + 40px); max-height: calc(100vh - 200px); }
.win.modal-bg::before { content: ''; position: fixed; inset: -100vh -100vw; background: rgba(0,0,0,0.35); z-index: -1; }
@keyframes winIn { from { transform: translate(-50%, -48%) scale(0.98); opacity: 0; } }
.win-head { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); cursor: move; }
.win-head h3 { margin: 0; font-size: 15px; font-variant: small-caps; letter-spacing: 0.8px; line-height: 1.2; }
/* Header buttons sit on the right, next to ✕ — never stranded in the middle of the title row. */
.win-head .wh-r { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.win-head .x { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border-radius: 5px; background: transparent; border: 1px solid transparent; color: var(--dim); font-size: 20px; cursor: pointer; line-height: 1; }
.win-head .x:hover { background: rgba(255,255,255,0.07); border-color: var(--line); color: #fff; }
.win-head .x:focus-visible, .win-tabs button:focus-visible, .win:not([data-kind=wardrobe]):not([data-kind=boutique]) .btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.win-body { box-sizing: border-box; min-height: 0; padding: 12px 14px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(170,190,255,.32) transparent; }
.win-body::-webkit-scrollbar { width: 8px; height: 8px; }
.win-body::-webkit-scrollbar-thumb { background: rgba(170,190,255,.28); border: 2px solid #121628; border-radius: 4px; }
.win-body::-webkit-scrollbar-thumb:hover { background: rgba(170,190,255,.48); }
.win-tabs { display: flex; align-items: stretch; gap: 3px; flex-wrap: wrap; margin-bottom: 10px; }
.win-tabs button { min-height: 32px; padding: 5px 10px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255,255,255,0.025); color: var(--dim); cursor: pointer; font-size: 13px; }
.win-tabs button:hover { border-color: rgba(199,125,255,0.55); color: var(--text); }
.win-tabs button.on { background: rgba(199,125,255,0.16); color: #fff; border-color: rgba(199,125,255,0.65); }
.win:not([data-kind=wardrobe]):not([data-kind=boutique]) .btn { border-radius: 6px; }
.win:not([data-kind=wardrobe]):not([data-kind=boutique]) .btn.good { background: #16725c; border: 1px solid #26997b; color: #effff9; }
.win:not([data-kind=wardrobe]):not([data-kind=boutique]) .btn.bad { background: #7d3040; border: 1px solid #aa4657; color: #fff2f3; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: var(--s2); min-width: 0; }
.cell img { width: 70%; height: 70%; image-rendering: auto; }
.cell .q { position: absolute; right: 4px; bottom: 2px; font-size: var(--f-xs); font-weight: 800; }
.cell .st { position: absolute; left: 4px; top: 2px; font-size: var(--f-xs); color: var(--gold); font-weight: 800; }
.cell .eq, .cell .lk { position: absolute; right: 3px; top: 2px; }
.cell .lk { top: auto; right: auto; left: 3px; bottom: 2px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 300px); gap: var(--s4); min-width: 0; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
.inventory-gold { margin-left: auto; }
.inventory-actions { margin-top: var(--s3); }
.gear-card { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.gear-card section { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; margin-top: var(--s1); }
.gear-card section > .k-h { margin-top: 0; }
.gear-card .k-title { overflow-wrap: anywhere; }
.gear-long { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); min-width: 0; }
.gear-long > :first-child { font-size: var(--f-xs); }
.gear-long > :last-child { color: var(--t2); text-align: left; }
.gear-card .kv, .eq-stats .kv, .inspect-stats .kv { display: flex; justify-content: space-between; gap: var(--s3); min-width: 0; }
.gear-card .kv > :last-child, .eq-stats .kv > :last-child, .inspect-stats .kv > :last-child { text-align: right; }
.line { font-size: 12.5px; padding: 2px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--dim); font-size: 12.5px; }
.offer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 760px) { .offer { grid-template-columns: 1fr; } }
.ocard { border: 2px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(0,0,0,0.3); cursor: pointer; transition: transform .1s, box-shadow .1s; display: flex; flex-direction: column; gap: 6px; }
.ocard:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.ocard .rar { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.ocard .nm { font-size: 16px; font-weight: 800; }
.ocard .ds { font-size: 12.5px; color: #cfd6f5; }
.list { display: flex; flex-direction: column; gap: 4px; }
.li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 5px; background: rgba(5,8,16,0.42); border: 1px solid rgba(170,190,255,.18); font-size: 13px; }
.li:hover { border-color: rgba(170,190,255,.34); }
.li.done { opacity: 0.55; }
.boss-list { display: flex; flex-direction: column; gap: var(--s3); }
.bosscard { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: var(--s3); align-items: center; }
.bosscard canvas { width: 90px; height: 90px; }
.diffs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.diffs .btn { display: flex; flex-direction: column; align-items: center; min-width: 96px; white-space: normal; }
.diffs .btn small { color: var(--t2); }
.eqslots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.eqslot { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s2); }
.eqslot img { width: 56%; }
.eqslot .k-dot { position: absolute; top: var(--s2); right: var(--s2); }
.eq-skills { margin-top: var(--s4); min-width: 0; }
.eq-skill-total { margin-left: auto; }
.eqskill { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(48px, 1.4fr) 40px; gap: var(--s2); align-items: center; min-height: 30px; }
.eqskill > :last-child { text-align: right; }
.eq-stats .cp-stat { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; }
.eq-subhead { margin-top: var(--s4); }
.eq-record { display: block; margin-top: var(--s3); }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s3); }
.module-row { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.module-milestones { display: flex; flex-direction: column; }
.module-milestones .li { min-height: 32px; }
.recovery-talents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.recovery-talent { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); width: 100%; color: var(--t1); font: inherit; text-align: left; cursor: pointer; }
.recovery-talent.on { border-color: var(--accent); }
.extraction-result { display: flex; flex-direction: column; gap: var(--s2); align-items: center; text-align: center; }
.loot-item { display: inline-flex; align-items: center; gap: var(--s2); }
.loot-item img, .loot-icon { width: 24px; height: 24px; object-fit: contain; }
.pell-row { min-height: 56px; }
.forge-resources { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin: 0; }
.forge-resources .kv { flex-direction: column; align-items: flex-start; gap: var(--s1); padding: 0; min-width: 0; }
.win[data-kind=vela] .forge-resources + .k-h { margin-top: var(--s4); }
.forge-grid { max-height: 420px; overflow-y: auto; align-content: start; }
.forge-action { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3); }
.forge-msg { min-height: 22px; }
.forge-subhead { margin-top: var(--s4); }
.forge-prism { margin-top: var(--s3); }
.socket-row { flex-wrap: wrap; }
.crest-forge { display: flex; flex-direction: column; align-items: center; gap: var(--s3); width: min(100%, 420px); }
.sw-wrap { display: grid; grid-template-columns: minmax(150px, 240px) minmax(0, 1fr); gap: var(--s4); min-width: 0; }
.sw-hero { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.sw-hero > img { width: 72px; height: 72px; object-fit: contain; flex: none; }
.sw-hero-info { display: flex; flex: 1; flex-direction: column; gap: var(--s1); min-width: 0; }
.sw-ore { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); min-height: var(--h-md); }
.sw-ore img { width: 22px; height: 22px; }
.sw-ore-name { flex: 1 1 120px; }
.sw-ore .n { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.sw-mats { margin-bottom: var(--s3); }
.sw-mats img { width: 16px; height: 16px; object-fit: contain; }
.sw-info { margin: var(--s3) 0; }
.sw-fod-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); max-height: 160px; overflow-y: auto; }
.sw-grid .lv { position: absolute; right: 3px; bottom: 1px; font-size: var(--f-xs); font-weight: 800; }
.sw-modes { align-self: flex-start; }
.sw-msg { min-height: 22px; }
.sw-details { border-top: 1px solid var(--hair); padding-top: var(--s3); }
.sw-details summary { cursor: pointer; }
.sw-modes + .k-h { margin-top: var(--s1); }
.sw-info .sw-long { flex-direction: column; align-items: flex-start; gap: var(--s1); }
.sw-info .sw-long > :first-child { font-size: var(--f-xs); }
.sw-info .sw-long > :last-child { color: var(--t2); text-align: left; font-variant-numeric: normal; }
.recovery-action { display: flex; justify-content: center; }
.win[data-kind=recovery] .k-stack > section,
.win[data-kind=recovery] .recovery-action + .card { margin-top: var(--s1); }

@media (min-width: 761px), (orientation: landscape) {
  .equipment-layout { align-items: start; }
  .equipment-left { display: flex; flex-direction: column; min-width: 0; }
}
  .win[data-kind=vela] .crest-forge { margin-inline: auto; }
@media (max-width: 520px) {
  .forge-resources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.k-info-line { display: flex; align-items: center; gap: var(--s2); color: var(--t2); }
.big { font-size: 22px; font-weight: 800; }
.center { text-align: center; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; word-break: break-all; }
.tutorial li { margin: 4px 0; }
kbd { background: rgba(255,255,255,0.12); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; }
.tooltip { position: fixed; z-index: 99; pointer-events: none; background: #0c1020; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; font-size: 12.5px; max-width: 280px; }
@media (max-height: 780px) {
  .login-card { padding: var(--s4) var(--s6); }
  .login-card .logo { margin: 0; }
}
@media (max-width: 980px) {
  .vitals { width: 250px; }
  .skills { gap: 4px; padding: 6px; }
  .slot { width: 40px; height: 40px; }
  .menu-btns button { width: 29px; }
  .rankbox { width: 132px; }
}

/* ---------- Abilities & loadout ---------- */
.win[data-kind=abilities] .ab-section + .ab-section { margin-top: var(--s4); }
.win[data-kind=abilities] .weapon-select { width: min(100%, 320px); }
.win[data-kind=abilities] .lo-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s2); }
.win[data-kind=abilities] .lo-slot { position: relative; min-width: 0; min-height: 96px; padding: var(--s1); display: grid; grid-template-rows: 28px 36px auto; justify-items: center; align-content: start; gap: 0; text-align: center; }
.win[data-kind=abilities] .lo-slot.empty { border-style: dashed; }
.win[data-kind=abilities] .lo-slot .lo-icon { grid-row: 2; display: grid; place-items: center; width: 100%; height: 36px; }
.win[data-kind=abilities] .lo-slot img, .win[data-kind=abilities] .lo-slot .plus { width: 32px; height: 32px; object-fit: contain; }
.win[data-kind=abilities] .lo-slot .plus { display: grid; place-items: center; color: var(--t3); font-size: var(--f-lg); }
.win[data-kind=abilities] .lo-slot .key { position: absolute; top: 2px; left: 2px; }
.win[data-kind=abilities] .lo-slot .lo-name { grid-row: 3; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; min-width: 0; color: var(--t1); font-size: var(--f-xs); line-height: 1.15; }
.win[data-kind=abilities] .lo-slot .lo-name-text { overflow-wrap: anywhere; }
.win[data-kind=abilities] .lo-slot .lo-name .k-badge { font-size: inherit; }
.win[data-kind=abilities] .lo-slot .lo-x { position: absolute; top: 0; right: 0; width: var(--h-sm); height: var(--h-sm); min-width: var(--h-sm); min-height: var(--h-sm); padding: 0; }
.win[data-kind=abilities] .ab-scroll { margin-top: var(--s4); }
.win[data-kind=abilities] .ab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.win[data-kind=abilities] .ab { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; min-width: 0; padding: var(--s3); }
.win[data-kind=abilities] .ab > img { width: 40px; height: 40px; object-fit: contain; }
.win[data-kind=abilities] .ab-info { min-width: 0; }
.win[data-kind=abilities] .ab-info > b { display: block; }
.win[data-kind=abilities] .ab-info small { display: block; color: var(--t2); line-height: 1.35; }
.win[data-kind=abilities] .ab.locked { opacity: .55; }
.win[data-kind=abilities] .ab-keys { display: flex; flex-wrap: nowrap; align-self: center; justify-self: end; gap: var(--s1); }
.win[data-kind=abilities] .ab-equip { min-width: var(--h-sm); padding: 0 var(--s1); }
.win[data-kind=abilities] .ab-equip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--t1); }
.win[data-kind=abilities] .res-panel { margin-top: var(--s3); }
.win[data-kind=abilities] .res-panel .k-h { margin-bottom: var(--s1); }
.win[data-kind=abilities] .res-lines { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.win[data-kind=abilities] .res-on, .win[data-kind=abilities] .res-hint, .win[data-kind=abilities] .ab-disc { display: inline-flex; align-items: center; gap: var(--s1); }
.win[data-kind=abilities] .res-hint { color: var(--t2); }
.win[data-kind=abilities] .ab-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin: var(--s1) 0; }
.win[data-kind=abilities] .ab-cat { color: var(--t2); }
.win[data-kind=abilities] .ab-filters { display: grid; gap: var(--s3); margin: var(--s3) calc(-1 * var(--s4)) 0; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--hair); background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.win[data-kind=abilities] .ab-filter-toggle { width: 100%; padding: 0; border: 0; background: transparent; color: var(--t2); font: inherit; text-align: left; cursor: pointer; }
.win[data-kind=abilities] .ab-filter-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.win[data-kind=abilities] .ab-filter-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.win[data-kind=abilities] .ab-filter-options[hidden] { display: none; }
.win[data-kind=abilities] .ab-filter .k-h { margin-bottom: var(--s1); }
.win[data-kind=abilities] .ab-cats { display: flex; }
.win[data-kind=abilities] .ab-discs { display: flex; max-width: 100%; }
.win[data-kind=abilities] .ab-discs button { display: inline-flex; align-items: center; gap: var(--s1); }
.win[data-kind=abilities] .ab-filters .k-row { align-items: flex-start; }
.win[data-kind=abilities] .ab-scroll h4 { margin-top: var(--s4); }
.win[data-kind=abilities] .sig-note { margin-bottom: var(--s3); }
.win[data-kind=abilities] .ab-cost { color: var(--neg); }
@media (max-width: 760px) { .win[data-kind=abilities] .ab-grid { grid-template-columns: 1fr; } }
/* The creator stage is a shared surface: .av-stage in the Avatar Editor section below. */

/* ---------- Inspect another player ---------- */
.insp-head { display: flex; gap: var(--s3); align-items: center; margin-bottom: var(--s4); }
.insp-head .av-stage { width: 120px; height: 130px; }
.insp-av { display: block; image-rendering: pixelated; }
.insp-gone { color: var(--warn); margin-top: var(--s1); }
.insp-row { cursor: pointer; }
.insp-row img { width: 26px; height: 26px; }
.insp-row.sel { background: var(--accent-soft); }
.inspect-gear { margin-top: var(--s3); }
.inspect-stats { min-width: 0; }

/* ---------- Narrow / short windows ----------
   Below 700 px wide (split screens) or 500 px tall the HUD compacts around the playfield. Stack
   everything anchored to an edge on the measured size of its neighbour (ui.js measureHud sets
   --hud-b, --hud-tl-b and --hud-tr-b on #hud), so nothing overlaps whatever wraps. */
@media (max-width: 700px), (max-height: 500px) {
  .hud-tl { left: 6px; top: 6px; }
  .minimap-shell { width: 132px; height: 80px; }
  #minimap { width: 130px; height: 58px; }
  .mapname { font-size: 10px; }
  .hud-tr { right: 12px; top: 12px; gap: 6px; max-width: calc(100vw - 150px); }
  .menu-btns { flex-wrap: wrap; justify-content: flex-end; }
  .menu-group { flex-wrap: wrap; }
  .menu-btns button { width: 34px; height: 34px; }
  .menu-btns .mi { font-size: 16px; }
  .chip-row { gap: 4px; }
  .chip { min-height: 28px; padding: 4px 6px; font-size: var(--f-xs); gap: 4px; }
  .chip img { width: 14px; height: 14px; }
  .rankbox { width: 128px; font-size: var(--f-xs); padding: 6px 8px; }
  .party { left: 6px; top: calc(var(--hud-tl-b, 86px) + 6px); width: 150px; }
  .runpanel { right: 6px; top: calc(var(--hud-tr-b, 110px) + 6px); width: 200px; }
  .hud-bottom { left: 6px; right: 6px; bottom: 6px; gap: 6px; justify-content: center; }
  .vitals { width: min(230px, 46vw); padding: 5px 6px; }
  .vitals .top { font-size: 10px; min-height: 14px; }
  .bar { height: 11px; margin-top: 3px; }
  .bar.hp { height: 13px; }
  .skills { padding: 4px; gap: 3px; }
  .slot { width: 34px; height: 34px; }
  .slot .key { font-size: 8px; }
  .chat { width: min(200px, 42vw); bottom: calc(var(--hud-b, 78px) + 6px); left: 6px; }
  .chatlog { max-height: 66px; }
  #chatInput { font-size: 11px; padding: 5px 7px; }
  .boss-hud { width: calc(100vw - 16px); top: calc(max(var(--hud-tl-b, 86px), var(--hud-tr-b, 110px)) + 6px); }
  #toasts { width: min(300px, 80vw); top: 96px; }
  .win { width: min(var(--w, 720px), calc(100vw - 16px)); max-height: calc(100vh - 80px); }
  .win.modal-bg { top: 50%; max-height: calc(100vh - 24px); }
  .login-card { padding: var(--s4) var(--s3); }
  .le-row label { width: 64px; }
}
/* Phones: the vitals and skill bar no longer fit side by side, so stack them (skills on top). */
@media (max-width: 480px) {
  .hud-bottom { left: 50%; right: auto; transform: translateX(-50%); flex-direction: column-reverse; align-items: stretch; gap: 4px; }
  .vitals { width: auto; }
}
@media (max-height: 500px) {
  html:not(.touch) .chat { left: auto; right: 6px; width: min(200px, 42vw); }
}

/* Patch notes (client/ui-patchnotes.js) */
.patchnotes { display: grid; gap: var(--s2); }
.pn-summary { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); min-height: var(--h-touch); cursor: pointer; }
.pn-content { display: grid; gap: var(--s4); margin-top: var(--s3); }
.pn-items { margin: 0; padding-left: var(--s5); }
.pn-items li + li { margin-top: var(--s1); }
.pn-link { display: block; margin: 8px auto 0; background: none; border: 0; color: #b9a6e8; font-size: 12px; cursor: pointer; text-decoration: underline; }

/* Information and progression windows compose the UI kit. These rules only place kit components. */
.help-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .9fr); gap: var(--s4); align-items: start; }
.help-keys { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.k-list .help-step { justify-content: flex-start; gap: var(--s3); white-space: nowrap; }
.k-list .help-step > span:last-child { white-space: nowrap; }
.mission-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); gap: var(--s4); align-items: start; }
.mission-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.module-card { display: flex; flex-direction: column; gap: var(--s2); }
.protocol-stats { width: 220px; max-width: 100%; }
.grove-stats { width: 320px; max-width: 100%; }
.rest-stats { width: 300px; max-width: 100%; }
.talent-overview { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s3); align-items: center; }
.talent-rank, .talent-resources { align-items: center; }
.talent-resources { gap: var(--s2); }
.talent-resources .k-kvs { flex: 1 1 144px; min-width: 140px; }
.talent-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
.talent-owned { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); }
.talent-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); min-width: 0; }
.protocol-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.protocol-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); min-width: 0; text-align: left; }
.talent-choices .talent-card, .protocol-choices .protocol-card { width: 100%; padding: var(--s3); align-items: flex-start; white-space: normal; text-align: left; }
.field-row { align-items: center; }
.field-info { flex: 1 1 auto; min-width: 0; }
.bounty-row { align-items: center; }
.bounty-info { flex: 1 1 auto; min-width: 0; }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.grove-actions { align-items: stretch; }

@media (max-width: 760px) {
  .help-layout, .mission-layout { grid-template-columns: minmax(0, 1fr); }
  .mission-groups, .talent-choices, .protocol-choices, .record-grid { grid-template-columns: minmax(0, 1fr); }
  .talent-overview { grid-template-columns: minmax(0, 1fr); }
  .talent-owned { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Player housing (§22) */
.hs-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); }
.hs-home { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); align-items: start; }
.hs-home > :last-child { grid-column: 1 / -1; }
.hs-panel { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.hs-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); }
.hs-item img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; flex: none; }
.hs-item > div { min-width: 0; }
.hs-sws { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.hs-sw { display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); min-height: 96px; padding: var(--s2); color: var(--t1); text-align: left; }
.hs-sw img { width: 100%; height: 48px; object-fit: cover; image-rendering: pixelated; border-radius: var(--r-sm); }
.hs-sw small { font-size: var(--f-xs); line-height: 1.3; }
.hs-colors { width: 100%; }
.hs-book { max-height: 170px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s2); }
.hs-book > .li { display: block; }
.hs-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: var(--s2); max-height: 150px; overflow-y: auto; }
.hs-tray .cell img { image-rendering: pixelated; object-fit: contain; }
@media (max-width: 640px) { .hs-shop, .hs-home { grid-template-columns: 1fr; } .hs-home > :last-child { grid-column: auto; } .hs-item { grid-template-columns: 48px minmax(0, 1fr); } .hs-item > :last-child { grid-column: 2; justify-self: start; } }
html.touch .win[data-kind=housing] .k-seg .k-chip,
html.touch .win[data-kind=decor] .k-seg .k-chip { min-height: var(--h-touch); }
html.touch .win[data-kind=decor] .hs-tray { max-height: 32vh; }

/* ---------- Echo Abyss (§19) & tickets (§18) ---------- */
.runpanel { border-color: color-mix(in srgb, var(--tint, #2affc6) 45%, transparent); }
.abyss-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.abyss-head small { display: block; color: #aab4dc; font-size: 10px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.abyss-depth { font-size: 17px; color: var(--tint, #2affc6); font-variant-numeric: tabular-nums; text-shadow: 0 0 8px color-mix(in srgb, var(--tint, #2affc6) 60%, transparent); }
.abyss-lantern { color: #ffd23f; font-size: 10px; white-space: nowrap; cursor: help; }
.abyss-meter { position: relative; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); margin: 2px 0 5px; cursor: help; }
.abyss-meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, rgba(255,255,255,0.15), var(--tint, #2affc6)); }
.abyss-meter > b { position: absolute; top: -2px; width: 2px; height: 10px; background: #ffd23f; opacity: .8; }
.affixes { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 5px; }
.affix { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 5px; border: 1px solid currentColor; background: rgba(0,0,0,0.35); cursor: help; }
.dive-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.card.dive { display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); min-width: 0; }
.card.dive .k-h { align-items: center; }
.card.dive .k-h img { width: 20px; height: 20px; object-fit: contain; }
.win[data-kind=spireEnter] .spire-record { margin-top: var(--s3); }
.win[data-kind=spireEnter] .spire-camp-label { color: var(--t2); }
.win[data-kind=spireEnter] .k-empty-state { min-height: 44px; padding: var(--s2); }
.win[data-kind=party] .party-actions { margin-top: var(--s3); }
.win[data-kind=party] .party-invite { align-items: stretch; }
.win[data-kind=party] .party-invite input { flex: 1; min-width: 0; }
.card.curse { margin-top: 10px; border-color: rgba(255,154,46,0.55); }
.card.curse > b { color: #ff9a2e; }
.card.curse .kv { gap: 10px; margin-top: 4px; }
.card.curse .kv span:last-child { text-align: right; }
.card.calm { margin-top: 10px; border-color: rgba(122,255,176,0.45); }
.card.calm > b { color: #7affb0; }
.card.pity { margin-top: 10px; }
.pity-row { display: grid; grid-template-columns: 20px 130px 1fr 62px; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.pity-row img { width: 18px; height: 18px; }
@media (max-width: 560px) { .dive-row { grid-template-columns: 1fr; } .pity-row { grid-template-columns: 20px 1fr 1fr 56px; } }

.le-select { flex: 1; min-width: 132px; }
.le-tabs { flex: none; }
.le-row { display: flex; align-items: center; gap: var(--s2); margin: var(--s2) 0; flex-wrap: wrap; }
.le-row label { width: 74px; font-size: var(--f-xs); color: var(--t2); flex: none; }
.av-slots { margin-bottom: var(--s3); }
.av-slots button { min-width: var(--h-sm); }
.av-slots button i { font-style: normal; color: var(--t2); font-size: var(--f-xs); }

/* ---- Avatar Editor + Boutique + Creator Market (GAME_BIBLE.md §23) ---- */
.win[data-kind=wardrobe] { max-height: calc(100vh - var(--s6)); }
.win[data-kind=boutique] { max-height: calc(100vh - var(--s6)); }
.win[data-kind=wardrobe] .win-body, .win[data-kind=boutique] .win-body { padding: var(--s3); }
.av-ed, .bq { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: var(--s4); align-items: stretch; }
.av-ed { height: 480px; }
.bq { grid-template-columns: 220px minmax(0, 1fr); }
.av-left, .bq-left { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.bq-left { align-items: stretch; }
.bq-left .av-stage { width: 100%; height: 230px; flex: none; }
.av-left .av-screen { flex: 1; min-height: 0; }
.av-stage { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
.av-frame { position: relative; flex: none; background: var(--inset); border: 1px solid var(--hair); border-radius: var(--r-md); overflow: hidden; }
html:not(.no-glass) .login-card .av-stage .av-frame,
html:not(.no-glass) .win .av-stage .av-frame { background: var(--inset); }
.av-canvas { display: block; image-rendering: pixelated; touch-action: none; }
.av-flip, .av-dice { position: absolute; width: var(--h-sm); height: var(--h-sm); min-height: var(--h-sm); padding: 0; }
.av-flip { right: var(--s2); bottom: var(--s2); }
.av-dice { right: var(--s2); top: var(--s2); }
.av-acts { display: flex; gap: var(--s2); }
.av-acts .btn { flex: 1; }
.av-acts [hidden] { display: none; }
.av-acts .btn:focus-visible, .av-rail:focus-visible, .av-card:focus-visible, .av-ofcard:focus-visible, .sq:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.av-right, .bq-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; max-height: 480px; overflow: hidden; }
.bq-right { overflow-y: auto; }
.av-tabs { flex: none; }
.av-panel { display: flex; flex: 1; flex-direction: column; gap: var(--s2); min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.av-rows { max-width: 360px; }
.av-ed .expr { width: calc(var(--ar-w) * 2 + var(--name-w) + var(--s2)); }
.av-ward { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--s3); flex: 1; min-height: 0; }
.av-rails { display: flex; flex-direction: column; gap: var(--s1); }
.av-rail { width: 44px; height: 44px; min-height: 44px; padding: var(--s1); }
.av-card.none span { font-size: var(--f-xs); letter-spacing: .09em; text-transform: uppercase; }
.av-rail img { width: 34px; height: 34px; image-rendering: pixelated; }
.av-rail .av-off { display: block; width: 22px; height: 22px; color: var(--t3); }
.av-rail .av-off path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.av-items { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, 76px); grid-auto-rows: 76px; gap: var(--s2); justify-content: start; align-content: start; flex: 1 1 0; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding-right: var(--s1); }
.av-card { position: relative; width: 76px; height: 76px; padding: 0; display: flex; align-items: center; justify-content: center; }
.av-card img { width: 57px; height: 57px; image-rendering: pixelated; }
.av-card.selected { outline: 1px solid var(--t3); outline-offset: 1px; }
.av-card.dim { opacity: .55; }
.av-card em { position: absolute; top: var(--s1); right: var(--s1); font-style: normal; }
.av-card b { font-size: var(--f-sm); line-height: 1.25; }
.av-card small { color: var(--t2); font-size: var(--f-xs); }
.av-card .pr { font-size: var(--f-sm); font-weight: 650; }
.av-card .deal { font-style: normal; color: var(--pos); }
.av-card .lim { color: var(--t2); }
.win[data-kind=boutique] .bq .av-grid { flex: none; grid-template-columns: repeat(auto-fill, minmax(min(100px, 100%), 1fr)); grid-auto-rows: minmax(156px, auto); gap: var(--s3); align-items: stretch; max-height: none; min-height: 0; overflow: visible; }
.win[data-kind=boutique] .bq .bq-card { aspect-ratio: auto; flex-direction: column; align-items: flex-start; gap: var(--s1); width: 100%; height: auto; min-width: 0; min-height: 156px; padding: var(--s2); overflow: visible; text-align: left; }
.bq-card img { width: 40px; height: 40px; flex: none; object-fit: contain; image-rendering: pixelated; }
.bq-card b, .bq-card small, .bq-card .pr { display: block; max-width: 100%; overflow-wrap: anywhere; }
.bq-card .k-badge { white-space: normal; overflow-wrap: anywhere; }
.bq-card em { position: static; }
.av-sel { margin: var(--s2) 0 0; min-height: var(--h-sm); font-size: var(--f-sm); font-weight: 650; }
.av-dyes { margin-top: var(--s2); }
.av-dyes .row-line { align-items: flex-start; gap: var(--s2); margin-bottom: var(--s2); }
.av-dyes .row-line > label { width: 46px; height: auto; padding-top: var(--s1); }
.av-dyes .sws { gap: var(--s1); }
.av-ofs { display: flex; flex-wrap: wrap; gap: var(--s3); align-content: flex-start; }
.av-of { display: flex; flex-direction: column; gap: var(--s2); align-items: center; }
.av-ofcard { width: 92px; height: 112px; padding: 0; display: flex; align-items: center; justify-content: center; }
.av-of.off .av-ofcard { opacity: .4; cursor: default; }
.av-ofcard.av-ofnew { font-size: var(--f-xl); line-height: 1; color: var(--t2); }
.av-ofcv { width: 100%; height: 100%; image-rendering: pixelated; }
.av-ofacts { display: flex; gap: var(--s1); }
.sq { width: var(--h-touch); height: var(--h-touch); padding: 0; line-height: 1; }
.bq-bal, .bq-sel { width: 100%; }
.bq-bal { display: grid; gap: var(--s2); }
.bq .g { color: var(--gold); } .bq .gl { color: var(--accent); }
.bq-name { font-weight: 800; font-size: var(--f-md); }
.bq .ok { color: var(--pos); }
.bq .coin { display: inline-block; width: 10px; height: 10px; margin-left: var(--s1); border-radius: 50%; background: var(--gold); vertical-align: -1px; }
.bq a { color: var(--accent); }
.bq-list { display: flex; flex-direction: column; }
.bq-list-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); }
.bq-list-item img { width: 40px; height: 40px; image-rendering: pixelated; }
.bq-list-item .bq-item-name { min-width: 0; }
.bq-list-item .bq-item-name b { display: block; }
.bq-list-item .bq-item-stats { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: var(--s2); }
.bq-list-item .bq-item-stats > span { color: var(--t2); }
.bq-sel:empty { display: none; }
.bq-lock { max-width: 420px; }
.px-wrap { display: flex; gap: var(--s4); align-items: flex-start; flex-wrap: wrap; }
.px-cv { width: min(256px, 100%); aspect-ratio: 1; height: auto; image-rendering: pixelated; border-radius: var(--r-sm); cursor: crosshair; touch-action: none; }
.px-tools { flex: 1; min-width: 170px; }
.sws.pal { max-width: 100%; } .sw.big { width: var(--h-touch); height: var(--h-touch); } .sw.big i { width: 22px; height: 22px; }
.bq-pub { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--hair); }
@media (max-width: 760px) { .av-ed, .bq { grid-template-columns: minmax(0, 1fr); } .av-right, .bq-right { max-height: none; } .av-ed { height: auto; } }
@media (max-width: 900px) {
  .win[data-kind=boutique] .bq { grid-template-columns: minmax(0, 1fr); }
  .win[data-kind=boutique] .bq-left { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); align-items: start; }
  .win[data-kind=boutique] .bq-left .av-stage { grid-row: span 2; }
  .win[data-kind=boutique] .bq-right { max-height: none; overflow-y: visible; }
}
@media (max-width: 760px) { .win[data-kind=boutique] .bq-left { display: flex; } }
@media (orientation: landscape) and (max-height: 510px) {
  html.touch .win[data-kind=boutique] .bq { grid-template-columns: minmax(144px, 25%) minmax(0, 1fr); }
  html.touch .win[data-kind=boutique] .bq-left { display: flex; flex-direction: column; gap: var(--s2); }
  html.touch .win[data-kind=boutique] .bq-left .av-stage { height: 132px; }
  html.touch .win[data-kind=boutique] .bq .av-grid { grid-template-columns: repeat(auto-fill, minmax(min(80px, 100%), 1fr)); }
}
html:not(.no-glass) .login-card .class-card.sel,
html:not(.no-glass) .win[data-kind=wardrobe] .av-rail.on,
html:not(.no-glass) .win[data-kind=wardrobe] .av-card.sel,
html:not(.no-glass) .win[data-kind=wardrobe] .sw.sel,
html:not(.no-glass) .win[data-kind=boutique] .bq-card.sel,
html:not(.no-glass) .win[data-kind=housing] .hs-sw.sel,
html:not(.no-glass) .win[data-kind=decor] .hs-tray .cell.sel,
html:not(.no-glass) .win[data-kind=boutique] .sw.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#ui .win .sw.cell.sel, #ui .win .sw.cell.on { border-color: var(--hair); box-shadow: none; outline: 2px solid var(--accent); outline-offset: 2px; }

.bq .coin { display: inline-block; width: 10px; height: 10px; margin-left: 3px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, #ffd23f 55%, #b8860b); vertical-align: -1px; }
.bq a { color: var(--acc2); }
/* ---------- Desktop HUD finish ---------- */
html:not(.touch) .vitals,
html:not(.touch) .skills,
html:not(.touch) .minimap-shell {
  background: rgba(10,14,28,.96);
  border-color: rgba(170,190,255,.22);
  border-radius: 6px;
  box-shadow: 0 5px 16px rgba(0,0,0,.3);
}
html:not(.touch) .bar.hp > i { background: #e8495c; }
html:not(.touch) .bar.mp > i { background: #4386df; }
html:not(.touch) .bar.exp > i, html:not(.touch) .rankbox .bar > i { background: #d3ae31; }
html:not(.touch) .slot {
  background: rgba(3,6,14,.82);
  border-radius: 5px;
}
html:not(.touch) .slot .key {
  left: 2px; top: 2px; min-width: 15px; padding: 0 2px;
  border: 1px solid rgba(170,190,255,.2); border-radius: 2px;
  background: rgba(5,8,18,.94); font-size: 9px; line-height: 11px;
}
html:not(.touch) .slot.ready { box-shadow: none; }
html:not(.touch) .slot.active-buff { box-shadow: inset 0 0 0 1px rgba(122,255,176,.38); }
html:not(.touch) .mapname {
  font-size: 11px; letter-spacing: .055em; text-transform: uppercase;
  background: rgba(10,14,28,.96);
}
html:not(.touch) .chip {
  background: rgba(10,14,28,.96);
  border-radius: 4px;
}
html:not(.touch) .rankbox {
  background: rgba(10,14,28,.96);
  border-radius: 5px;
}
html:not(.touch) .menu-btns {
  background: rgba(10,14,28,.96);
  border-color: var(--hair);
  border-radius: var(--r-md);
}
html:not(.touch) .menu-btns button {
  background: rgba(24,30,50,.94);
  border-radius: var(--r-sm);
}
html:not(.touch) .menu-btns button:hover { background: var(--hover); border-color: var(--accent-line); }
html:not(.touch) .menu-btns button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html:not(.touch) .menu-btns button:active { background: var(--accent-soft); }
html:not(.touch) .menu-btns kbd {
  min-width: 10px; text-align: center; border: 0; border-radius: 2px;
  background: rgba(5,8,18,.78); color: var(--t2);
}
html:not(.touch) .chatlog {
  background: rgba(8,10,20,.82);
  border: 1px solid var(--hair);
  border-bottom: 0; border-radius: var(--r-md) var(--r-md) 0 0;
}
html:not(.touch) #chatInput {
  background: rgba(8,10,20,.96);
  border-color: var(--hair);
  border-radius: 0 0 var(--r-md) var(--r-md);
}
html:not(.touch) #chatInput:focus-visible { border-color: var(--accent); }
html:not(.touch) .boss-hud .bar > i { background: #e8495c; }
html:not(.touch) .runpanel {
  background: rgba(10,14,28,.97);
  border-color: var(--hair);
  border-radius: var(--r-md);
}
html:not(.touch) .toast {
  background: rgba(10,14,28,.97);
  border-color: var(--hair);
  border-radius: var(--r-md);
}
html:not(.touch) #banner .t { text-shadow: 0 4px 10px #000; }

/* =====================================================================
   Touch (iPhone fullscreen web app) — HUD & window layout (HUD lane)
   ---------------------------------------------------------------------
   Every rule is scoped under html.touch, so the desktop renders and behaves
   exactly as before. Safe-area insets come from client/mobile.css
   (--safe-t/-r/-b/-l); the control boxes come from client/touch.css
   (--tz-l-w, --tz-r-w, --tz-h). The contract defaults are the var()
   fallbacks, so this block stands on its own.
   Landscape: pads in the bottom corners. Portrait: one bottom band.
   ===================================================================== */

/* ---------- HUD frame ---------- */
/* Windows cover almost the whole screen on a phone, so the HUD must stack under them: #hud gets
   its own stacking context (it has no z-index on desktop, where .mapname's z-index:2 can leak
   above #windows), and the sheet goes nearly opaque so nothing behind it distracts. */
html.touch #hud { z-index: 0; }
/* The touch controls (#tc-layer) sit above the HUD; an open ☰ sheet or a focused chat line lifts
   the HUD over them (the scrim then covers the controls, so a tap outside still closes the sheet). */
html.touch #hud.menu-open, html.touch #hud:has(.chat:focus-within) { z-index: 1; }
html.touch .hud-scrim {
  position: absolute; inset: 0; background: rgba(4, 6, 14, 0.66);
  opacity: 0; visibility: hidden; transition: opacity .14s, visibility .14s;
  pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
html.touch #hud.menu-open .hud-scrim { opacity: 1; visibility: visible; }
html.touch .hud-tl { left: calc(var(--safe-l, 0px) + 6px + var(--c-tl, 0px)); top: calc(var(--safe-t, 0px) + 6px + var(--c-tl, 0px)); }
html.touch .minimap-shell {
  width: clamp(132px, 19vw, 200px); height: clamp(80px, 11.5vw, 118px);
  border-radius: 11px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
html.touch .mapname { padding: 4px 7px; font-size: 12px; line-height: 1.35; }
html.touch .mapname small { font-size: 12px; }
html.touch #minimap { width: calc(100% - 2px); height: calc(100% - 27px); }

html.touch .hud-tr {
  display: flex; flex-direction: column;
  right: calc(var(--safe-r, 0px) + 6px + var(--c-tr, 0px)); top: calc(var(--safe-t, 0px) + 6px + var(--c-tr, 0px));
  gap: 4px; align-items: flex-end;
  max-width: min(250px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 150px));
}
html.touch .hud-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; width: 100%; }
html.touch .chip-row { gap: 4px; }
html.touch .chip { min-height: 30px; padding: 4px 7px; font-size: 12px; gap: 4px; border-radius: var(--r-sm); }
html.touch .chip img { width: 14px; height: 14px; }
html.touch .chip small { font-size: 12px; }
html.touch .chip .mi { font-size: 13px; }
html.touch .rankbox { width: min(148px, 100%); padding: 6px 9px; font-size: 12px; border-radius: var(--r-md); }
html.touch .rankbox .bar { height: 6px; margin-top: 6px; }
html.touch .buffs { flex-wrap: wrap; justify-content: flex-end; }
html.touch .buff { font-size: 12px; padding: 3px 6px; }

/* ☰ — the 12 menu buttons collapse into a sheet (tap outside to close) */
html.touch .menu-toggle {
  width: 46px; height: 46px; margin-left: auto; padding: 0; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 28, .92); border: 1px solid rgba(170, 190, 255, .28);
  border-radius: 12px; color: var(--text); font-size: 22px; line-height: 1;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
html.touch .menu-btns {
  position: fixed; left: 50%; top: 50%; right: auto; z-index: 30;
  transform: translate(-50%, -50%) scale(.96); transform-origin: 50% 50%;
  display: flex; flex-direction: column; gap: var(--s2);
  width: min(320px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 28px));
  padding: 12px; background: rgba(12, 16, 32, .98);
  border: 1px solid rgba(170, 190, 255, .26); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .13s, transform .13s, visibility .13s;
}
html.touch .menu-group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); align-self: stretch; }
html.touch .menu-group + .menu-group { margin: 0; padding: var(--s2) 0 0; border: 0; border-top: 1px solid var(--hair); }
html.touch #hud.menu-open .menu-btns { visibility: visible; opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
html.touch .menu-btns button { width: 100%; min-width: 44px; height: 64px; border-radius: var(--r-md); pointer-events: auto; flex-direction: column; gap: 5px; }
/* Touch has no hover tooltips, so each menu button names itself under its icon. */
html.touch .menu-btns .ml { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--f-xs); line-height: 1; color: var(--t2); }
html.touch .menu-btns .mi { font-size: 22px; }
html.touch .menu-btns kbd { display: none; }
html.touch .menu-btns button .dot { left: 2px; top: 2px; width: 9px; height: 9px; }
/* Chat sits beside ☰ in the top bar (it used to float above the action cluster). */
html.touch .hud-tr-row { display: flex; gap: 6px; justify-content: flex-end; }
html.touch .hud-chat {
  width: 46px; height: 46px; padding: 0; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 28, .92); border: 1px solid rgba(170, 190, 255, .28);
  border-radius: 12px; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
html.touch .hud-chat svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; pointer-events: none; }
html.touch #hud.menu-open .menu-toggle { border-color: rgba(199, 125, 255, .7); background: rgba(56, 38, 86, .95); }

/* Vital bar: compact, in the pad gap (landscape) or above the band (portrait).
   #skills keeps running (its DOM is updated by tickHud) but is taken out of the
   layout and made invisible — the touch buttons mirror it. */
html.touch .hud-bottom {
  transform: none; flex-direction: row; align-items: stretch; gap: 0;
  justify-content: center; pointer-events: none;
}
html.touch .skills { position: absolute; left: -9999px; top: 0; visibility: hidden; }
html.touch .vitals {
  width: 100%; max-width: 340px; padding: 6px 9px; border-radius: 12px;
  pointer-events: auto; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
html.touch .vitals .top { min-height: 16px; margin-bottom: 2px; font-size: 12px; }
html.touch .vitals .top b { font-size: 13.5px; }
html.touch .bar { height: 13px; margin-top: 4px; }
html.touch .bar.hp { height: 17px; }
html.touch .bar > span { font-size: 12px; line-height: 13px; }
html.touch .bar.hp > span { font-size: 12px; line-height: 17px; }
html.touch .bar.exp { height: 13px; margin-top: 4px; }
html.touch .bar.exp > span { font-size: 12px; line-height: 13px; }

html.touch .party {
  left: calc(var(--safe-l, 0px) + 6px + var(--c-tl, 0px)); top: calc(var(--hud-tl-b, 150px) + 6px);
  width: min(170px, 44vw); gap: 4px; max-height: 40vh; overflow: hidden;
}
html.touch .pm { padding: 4px 8px; font-size: 12px; }
html.touch .pm .bar { height: 5px; margin-top: 3px; }
html.touch .pm-map { display: none; }

/* ---------- Chat ---------- */
html.touch .chat {
  left: calc(var(--safe-l, 0px) + 8px);
  width: calc(var(--tz-l-w, 190px) - 16px);
  bottom: calc(var(--safe-b, 0px) + var(--tz-h, 200px) + 8px);
  pointer-events: auto;
}
html.touch .chatlog { display: none; max-height: 120px; font-size: var(--f-sm); line-height: 1.4; padding: var(--s2) var(--s3); background: rgba(8, 10, 20, .88); border-radius: var(--r-md); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
html.touch .chatlog div { margin: 0; }
html.touch .chatlog .sys { opacity: .7; }
html.touch #chatInput {
  height: 0; min-height: 0; margin-top: 0; padding: 0 8px;
  border-width: 0; opacity: 0; font-size: 16px; /* 16px stops iOS from zooming the page */
  border-radius: 9px; transition: opacity .12s;
}
html.touch .chat:focus-within { z-index: 12; left: calc(var(--safe-l, 0px) + 8px); right: calc(var(--safe-r, 0px) + 8px); width: auto; bottom: calc(max(var(--kb, 0px), var(--safe-b, 0px)) + 8px); }
html.touch .chat:focus-within #chatInput { height: 42px; padding: 8px 10px; border-width: 1px; opacity: 1; margin-top: 4px; }
html.touch .chat:focus-within .chatlog { display: block; max-height: 120px; background: rgba(8, 10, 20, .92); }
html.touch .chat:focus-within #chatInput { background: rgba(6, 8, 16, .97); }

/* ---------- Boss HUD, Abyss panel, toasts, banner ---------- */
html.touch .boss-hud {
  transform: none; width: auto; pointer-events: none;
  left: calc(var(--safe-l, 0px) + 8px); right: calc(var(--safe-r, 0px) + 8px);
  top: calc(var(--hud-top-b, 150px) + 6px);
}
html.touch .boss-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
html.touch .boss-hud .name { flex: 1 1 auto; min-width: 0; font-size: 12px; }
html.touch .boss-hud .meta { order: 1; flex: none; margin-left: auto; font-size: 12px; }
html.touch .boss-hud .bar { order: 2; flex: 1 1 100%; height: 14px; margin: 0; }
html.touch .boss-hud .bar > span { font-size: 12px; line-height: 14px; }
html.touch .boss-hud .name > span:not(.rage), html.touch .boss-hud .rage, html.touch .boss-hud .life { font-size: 12px; }

html.touch .runpanel { padding: 0; overflow: hidden; font-size: var(--f-sm); }
html.touch .runpanel .rp-fold {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  width: 100%; min-height: 42px; padding: 5px 9px; text-align: left; cursor: pointer;
  background: rgba(15, 19, 36, .95); border: 0; color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
html.touch .rp-fold .abyss-depth { grid-row: 1 / 3; font-size: 15px; }
html.touch .rp-fold .rp-sum { grid-column: 1; font-size: 12px; color: #cbd3f2; }
html.touch .rp-fold .rp-caret { grid-row: 1 / 3; grid-column: 2; color: var(--dim); font-size: 13px; }
html.touch .runpanel .rp-body { padding: var(--s3); max-height: 44vh; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
html.touch .runpanel .proto { font-size: var(--f-xs); padding: var(--s1) var(--s2); }
html.touch .runpanel small, html.touch .runpanel .abyss-lantern, html.touch .runpanel .affix { font-size: var(--f-sm); }
/* Expanded, the Abyss panel is a centred sheet over the scrim (like ☰): there is no room for it
   beside the controls on a phone. Tap outside or on its bar to fold it again. */
html.touch #hud.run-open { z-index: 1; }
html.touch #hud.run-open .hud-scrim { opacity: 1; visibility: visible; }
html.touch #hud .runpanel.rp-open {
  position: fixed; left: 50%; top: 50%; right: auto; bottom: auto; z-index: 30;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 24px));
  max-height: calc(100vh - var(--safe-t, 0px) - var(--safe-b, 0px) - 24px);
  display: flex; flex-direction: column; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
html.touch #hud .runpanel.rp-open .rp-body { max-height: none; flex: 1 1 auto; min-height: 0; background: rgba(12, 16, 32, .97); }

html.touch #toasts { width: min(300px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 24px)); top: 100px; }
html.touch .toast { font-size: var(--f-sm); padding: var(--s2) var(--s3); }
html.touch #banner { top: 34%; }
html.touch #banner .t { font-size: clamp(26px, 8vw, 44px); letter-spacing: 2px; }
html.touch #banner .s { font-size: 14px; }

/* ---------- Windows: near-fullscreen sheets inside the safe area ---------- */
html.touch .win {
  inset: calc(var(--safe-t, 0px) + 6px) calc(var(--safe-r, 0px) + 6px) calc(var(--safe-b, 0px) + 6px) calc(var(--safe-l, 0px) + 6px);
  width: auto; max-width: none; max-height: none; transform: none; animation: none;
  border-radius: 12px; background: #121628;
}
html.touch .win.modal-bg { top: calc(var(--safe-t, 0px) + 6px); max-height: none; }
@media (orientation: portrait) { html.touch .sw-wrap { grid-template-columns: minmax(0, 1fr); } }
html.touch .win-head { min-height: 50px; padding: 0 6px 0 14px; cursor: default; }
html.touch .win-head h3 { font-size: 16px; }
html.touch .win-head .x {
  width: 50px; height: 50px; flex: none; font-size: 28px; line-height: 1;
  border-radius: 12px; color: #fff; background: rgba(255, 255, 255, .06);
  -webkit-tap-highlight-color: transparent;
}
html.touch .win-head .x:active { background: rgba(255, 255, 255, .16); }
html.touch .win-body {
  padding: 12px; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  overscroll-behavior: contain;
}
html.touch .win-tabs { gap: 6px; }
html.touch .win-tabs button {
  min-height: 44px; padding: 8px 12px; font-size: 13px;
  -webkit-tap-highlight-color: transparent;
}
html.touch .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; -webkit-tap-highlight-color: transparent; }
html.touch .btn.small { min-height: 44px; padding: 10px 12px; font-size: 13.5px; }
html.touch .win[data-kind=vela] .k-seg button, html.touch .win[data-kind=vela] .k-chip { min-height: var(--h-touch); }
html.touch .btn:active { background: rgba(80, 90, 150, .7); }
html.touch .card { padding: 10px; }
html.touch .card h4 { font-size: 14px; }
html.touch .kv { font-size: 13px; padding: 3px 0; }
html.touch .line { font-size: 12.5px; padding: 3px 0; }
html.touch .muted { font-size: 12.5px; }
html.touch .li { padding: 9px 10px; font-size: 13px; flex-wrap: wrap; }
html.touch .grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
html.touch .cell { min-width: 56px; }
html.touch .cell .q, html.touch .cell .st { font-size: 12px; }
html.touch .split { gap: 12px; }
html.touch .eqslots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
html.touch .eqskill { grid-template-columns: minmax(76px, 1fr) minmax(40px, 1fr) 40px; gap: 8px; }
html.touch .diffs .btn { min-width: 0; flex: 1 1 96px; }
html.touch .bosscard { grid-template-columns: 84px 1fr; gap: 10px; }
html.touch .bosscard canvas { width: 84px; height: 84px; }
html.touch .pity-row { grid-template-columns: 22px 1fr 1fr 58px; }
html.touch .hs-shop { grid-template-columns: 1fr; }
html.touch .offer { gap: 8px; }
html.touch .recovery-talents { grid-template-columns: 1fr; }
html.touch .ocard { padding: 10px; }
html.touch .win[data-kind=abilities] .ab-grid { grid-template-columns: 1fr; gap: var(--s2); }
html.touch .win[data-kind=abilities] .ab { grid-template-columns: 40px minmax(0, 1fr); align-items: start; gap: var(--s2); }
html.touch .win[data-kind=abilities] .ab-keys { grid-column: 2; justify-content: flex-start; gap: var(--s1); }
html.touch .win[data-kind=abilities] .ab-equip { min-width: var(--h-touch); min-height: var(--h-touch); padding: 0 var(--s2); }
html.touch .win[data-kind=abilities] .lo-row { gap: var(--s1); }
html.touch .win[data-kind=abilities] .lo-slot { min-height: 96px; grid-template-rows: var(--h-touch) 32px auto; padding: var(--s1); }
html.touch .win[data-kind=abilities] .lo-slot .lo-icon { height: 32px; }
html.touch .win[data-kind=abilities] .lo-slot .lo-x { width: var(--h-touch); height: var(--h-touch); min-width: var(--h-touch); min-height: var(--h-touch); }
html.touch .win[data-kind=abilities] .ab-filters .k-row { align-items: center; flex-wrap: wrap; }
html.touch .win[data-kind=abilities] .ab-discs { gap: var(--s1); }
html.touch .win[data-kind=abilities] .ab-filters .k-seg button,
html.touch .win[data-kind=abilities] .ab-filters .k-chip { min-height: var(--h-touch); }
html.touch .win[data-kind=abilities] .ab-filters { margin-inline: calc(-1 * var(--s3)); padding-inline: var(--s3); }
html.touch .win[data-kind=abilities] .ab-filter-options { grid-template-columns: minmax(0, 1fr); }
html.touch .win[data-kind=spireEnter] .dive-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.touch .win[data-kind=party] .party-invite { flex-wrap: nowrap; }
@media (orientation: portrait) {
  html.touch .win[data-kind=spireEnter] .dive-row { grid-template-columns: 1fr; }
}
@media (orientation: landscape) and (max-height: 520px) {
  html.touch .win[data-kind=abilities] .win-body { padding: var(--s2) var(--s3); }
  html.touch .win[data-kind=abilities] .ab-section + .ab-section { margin-top: var(--s2); }
  html.touch .win[data-kind=abilities] .ab-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.touch .win[data-kind=abilities] .ab { grid-template-columns: 32px minmax(0, 1fr); padding: var(--s2); }
  html.touch .win[data-kind=abilities] .ab > img { width: 32px; height: 32px; }
  html.touch .win[data-kind=abilities] .lo-slot { min-height: 96px; grid-template-rows: var(--h-touch) 32px auto; }
  html.touch .win[data-kind=abilities] .lo-slot .lo-icon { height: 32px; }
  html.touch .win[data-kind=abilities] .res-panel { margin-top: var(--s1); }
  html.touch .win[data-kind=abilities] .ab-filter-options { gap: var(--s2); }
  html.touch .win[data-kind=abilities] .ab-filter { min-width: 0; }
  html.touch .win[data-kind=abilities] .ab-cats,
  html.touch .win[data-kind=abilities] .ab-discs { display: flex; flex-wrap: wrap; min-width: 0; gap: var(--s1); }
}
@media (max-width: 560px) { html.touch .win[data-kind=spireEnter] .dive-row { grid-template-columns: 1fr; } }
html.touch .win[data-kind=abilities] .ab-cat { font-size: var(--f-xs); }
/* The "My creations" tab has flex:none on desktop, which overflows a phone-width sheet. */
html.touch .cyc .ar { width: 44px; height: 44px; font-size: 14px; }

html.touch .le-select { font-size: 16px; min-height: 44px; }
html.touch .presets { grid-template-columns: repeat(2, 1fr); }
html.touch .step .ar { width: var(--ar-w); height: var(--ar-w); font-size: 14px; }
html.touch .step-name { width: var(--name-w); padding: 8px 6px; font-size: 14px; }
html.touch .av-tabs button { min-height: 44px; padding: 8px 12px; font-size: 12px; }
html.touch .sq { width: 34px; height: 30px; font-size: 15px; }
html.touch .patchnotes summary { font-size: 15px; padding: 6px 0; }
html.touch .av-rail { width: var(--h-touch); height: var(--h-touch); }
html.touch .cr-shop, html.touch .cr-titles { gap: 8px; }
html.touch input, html.touch select, html.touch textarea { font-size: 16px; }
/* Nothing in a sheet reads smaller than 12px on a phone. */
html.touch .win small, html.touch .lo-slot .lo-name, html.touch .ab .lv, html.touch .pill, html.touch .ab-info small,
html.touch .av-card em, html.touch .av-card .deal, html.touch .av-card .ltd, html.touch .av-slots i { font-size: var(--f-xs); }
html.touch .av-left .muted[style] { font-size: 12px !important; }
html.touch .cell .eq { font-size: var(--f-xs); line-height: 1.2; }
@media (orientation: landscape) {
  html.touch .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  html.touch .recovery-talents { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
html.touch .win-head kbd { display: none; }
/* The loadout × stays small on the slot corner but takes a 44px hit area. */
html.touch .lo-x::after { content: ''; position: absolute; inset: -9px; }
html.touch .tooltip {
  max-width: min(320px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 24px));
  font-size: 12.5px; padding: 9px 11px; z-index: 120;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .62);
}
html.touch ::-webkit-scrollbar { width: 6px; height: 6px; }

/* ---------- Login / character creator ---------- */
html.touch .screen { padding: calc(var(--safe-t, 0px) + 10px) 0 calc(var(--safe-b, 0px) + 10px); -webkit-overflow-scrolling: touch; }
html.touch .login-card { width: min(560px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - var(--s5))); padding: var(--s4) var(--s3); }
html.touch .login-card .logo { font-size: var(--f-xl); letter-spacing: .09em; }
html.touch #authForm input { min-height: var(--h-touch); font-size: 16px; }
html.touch .tabs { margin-bottom: var(--s3); }

/* Portrait vitals use a compact card under the minimap; party frames follow beneath it. */
@media (orientation: portrait) {
  html.touch .hud-bottom {
    left: calc(var(--safe-l, 0px) + 8px); right: calc(var(--safe-r, 0px) + 8px);
    top: calc(var(--hud-cb, 130px) + 6px); bottom: auto;
  }
  html.touch .vitals { width: 100%; max-width: none; padding: 4px 8px; border-radius: 10px; }
  html.touch .vitals .top { min-height: 14px; margin-bottom: 2px; font-size: 12px; line-height: 14px; }
  html.touch .vitals .top b { font-size: 12.5px; }
  html.touch .bar.hp { height: 13px; margin-top: 2px; }
  html.touch .bar > span, html.touch .bar.hp > span { font-size: 12px; line-height: 13px; }
  html.touch .bar.mp, html.touch .bar.exp { height: 12px; margin-top: 2px; }
  html.touch .bar.mp > span, html.touch .bar.exp > span { font-size: 12px; line-height: 12px; }
  html.touch .chat {
    left: calc(var(--safe-l, 0px) + 10px); right: calc(var(--safe-r, 0px) + 10px);
    width: auto; bottom: calc(var(--safe-b, 0px) + var(--tz-h, 230px) + 8px);
  }
  html.touch .chatlog { max-height: 120px; }
  html.touch .party {
    top: calc(var(--hud-vb, 210px) + 6px); width: min(170px, 46vw);
    /* Keep the member cards clear of the chat line that sits above the touch band. */
    max-height: calc(100vh - var(--hud-vb, 210px) - var(--safe-b, 0px) - var(--tz-h, 230px) - 78px);
  }
  html.touch .split, html.touch .offer, html.touch .dive-row,
  html.touch .av-ed, html.touch .bq { grid-template-columns: 1fr; }
  html.touch .av-right, html.touch .bq-right { max-height: none; }
  html.touch .cr-stats { grid-template-columns: repeat(2, 1fr); }
  html.touch .cr-shop { grid-template-columns: 1fr; }
  html.touch .presets { grid-template-columns: repeat(2, 1fr); }
  html.touch .le { grid-template-columns: 1fr; }
}

/* ---------- Landscape: everything shares the strip above the pads ---------- */
@media (orientation: landscape) {
  html.touch .hud-bottom {
    left: calc(var(--safe-l, 0px) + var(--tz-l-w, 190px) + 8px);
    right: calc(var(--safe-r, 0px) + var(--tz-r-w, 270px) + 8px);
    bottom: calc(var(--safe-b, 0px) + 8px);
  }
  /* A short screen: name + EXP share one line, HP and MP below it, all inside ~50 px. The EXP bar
     grows into the rest of the name row; if a long name pushes it down, it spans the card like HP/MP. The bar
     labels sit on the bars (12 px text) instead of beside them. */
  html.touch .vitals {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px;
    width: 100%; max-width: 240px; padding: 3px 7px; border-radius: 10px;
  }
  html.touch .vitals .top {
    order: 1; flex: 0 1 auto; min-width: 0; min-height: 0; margin: 0;
    font-size: 12px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  html.touch .vitals .top b { font-size: 12.5px; }
  html.touch .vitals .bar.exp { order: 2; flex: 1 0 56px; height: 12px; margin: 0; }
  html.touch .vitals .bar.exp > span { font-size: 12px; line-height: 12px; }
  html.touch .vitals .bar.hp { order: 3; flex: 1 1 100%; height: 12px; margin: 0; }
  html.touch .vitals .bar.hp > span { font-size: 12px; line-height: 12px; }
  html.touch .vitals .bar.mp { order: 4; flex: 1 1 100%; height: 10px; margin: 0; }
  html.touch .vitals .bar.mp > span { font-size: 12px; line-height: 10px; }
  /* Two short chat lines: a third would scroll under the mask and clip. */
  html.touch .chatlog { max-height: 120px; }
  /* Party + boss bar live in the centre gap between the pads. */
  html.touch .party {
    left: calc(var(--safe-l, 0px) + var(--tz-l-w, 190px) + 8px);
    right: calc(var(--safe-r, 0px) + var(--tz-r-w, 270px) + 8px);
    width: auto; flex-direction: row; flex-wrap: wrap; gap: 4px;
    max-height: calc(var(--tz-h, 200px) - 60px);
  }
  html.touch .pm { flex: 1 1 46%; min-width: 0; }
  html.touch .boss-hud {
    left: calc(var(--safe-l, 0px) + var(--tz-l-w, 190px) + 8px);
    right: calc(var(--safe-r, 0px) + var(--tz-r-w, 270px) + 8px);
    top: auto; bottom: calc(var(--hud-b, 80px) + 6px);
  }
  /* Abyss panel: a one-line bar under the ☰ column, right of the chat. */
  html.touch .runpanel {
    left: auto; right: calc(var(--safe-r, 0px) + 8px);
    width: calc(var(--tz-r-w, 270px) - 16px);
    top: calc(var(--hud-tr-b, 130px) + 6px);
  }
  html.touch .runpanel .rp-body { max-height: calc(100vh - var(--safe-b, 0px) - var(--tz-h, 200px) - var(--hud-top-b, 130px) - 20px); }
  html.touch .menu-btns { width: min(360px, calc(100vw - var(--safe-l, 0px) - var(--safe-r, 0px) - 40px)); }
  html.touch .menu-btns button { height: 66px; }
}

/* Landscape with a thin gap between the pads (folded Duo): vital bar under the minimap (.vit-top
   below), chat beside it, party under the ☰ column (below the Abyss bar when there is one), boss bar in
   the slot between the minimap and the ☰ column. */
@media (orientation: landscape) {
  /* Chat lines sit beside the vitals card, between it and the Rift box (measureHud: --hud-v-r). */
  html.touch #hud.hud-narrow .chat:not(:focus-within) {
    left: calc(var(--hud-v-r, 250px) + 8px); right: calc(100vw - var(--hud-rk-l, 540px) + 8px);
    width: auto; top: calc(var(--hud-tl-b, 90px) + 6px); bottom: auto;
  }
  /* The Crucible bar wraps to two rows in the top slot: the chat moves above the right cluster. */
  html.touch #hud.hud-narrow:has(.pvp-top) .chat:not(:focus-within) {
    left: auto; right: calc(var(--safe-r, 0px) + 8px); top: auto;
    width: min(300px, calc(50vw - var(--safe-r, 0px) - 12px));
    bottom: calc(var(--safe-b, 0px) + var(--tz-h, 200px) + 8px);
  }
  html.touch #hud.hud-narrow .chatlog { max-height: 120px; }
  html.touch #hud.hud-narrow .party {
    --party-top: calc(var(--hud-tr-b, 120px) + 6px);
    left: auto; right: calc(var(--safe-r, 0px) + 6px + var(--c-tr, 0px)); top: var(--party-top);
    width: min(170px, 30vw); flex-direction: column; flex-wrap: nowrap;
    max-height: calc(100vh - var(--party-top) - var(--safe-b, 0px) - var(--tz-h, 200px) - 8px);
  }
  html.touch #hud.hud-narrow:has(#runPanel:not(.hidden)) .party { --party-top: calc(var(--hud-tr-b, 120px) + 54px); }
  html.touch #hud.hud-narrow .pm { flex: none; }
  html.touch #hud.hud-narrow .boss-hud {
    left: calc(var(--hud-tl-r, 200px) + 8px); right: calc(100vw - var(--hud-tr-l, 460px) + 8px);
    top: calc(var(--safe-t, 0px) + 6px); bottom: auto;
  }
}

/* Small screens (folded Duo, both orientations): the vital bar tucks under the minimap, beside the
   ☰ column, as the compact three-line card, so the world keeps the middle of the screen. measureHud()
   sets .vit-top (landscape with a thin pad gap, or portrait shorter than 800px). */
html.touch #hud.vit-top .hud-bottom {
  left: calc(var(--safe-l, 0px) + 6px + var(--c-tl, 0px)); right: auto; bottom: auto;
  top: calc(var(--hud-tl-b, 120px) + 6px);
  width: min(232px, calc(var(--hud-rk-l, var(--hud-tr-l, 260px)) - var(--safe-l, 0px) - var(--c-tl, 0px) - 14px));
}
html.touch #hud.vit-top .vitals {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px;
  width: 100%; max-width: none; padding: var(--s2); border-radius: var(--r-md);
}
html.touch #hud.vit-top .vitals .top {
  order: 1; flex: 0 1 auto; min-width: 0; min-height: 0; margin: 0;
  font-size: var(--f-xs); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html.touch #hud.vit-top .vitals .top b { font-size: var(--f-sm); }
html.touch #hud.vit-top .vitals .bar.exp { order: 2; flex: 1 0 56px; height: 12px; margin: 0; }
html.touch #hud.vit-top .vitals .bar.hp { order: 3; flex: 1 1 100%; height: 12px; margin: 0; }
html.touch #hud.vit-top .vitals .bar.mp { order: 4; flex: 1 1 100%; height: 10px; margin: 0; }
html.touch #hud.vit-top .vitals .bar > span { font-size: var(--f-xs); line-height: 12px; }
html.touch #hud.vit-top .vitals .bar.mp > span { line-height: 10px; }
/* Wide portrait (unfolded Duo): the same card, roomier. */
@media (orientation: portrait) and (min-width: 600px) {
  html.touch #hud.vit-top .hud-bottom { width: min(330px, calc(var(--hud-rk-l, var(--hud-tr-l, 260px)) - var(--safe-l, 0px) - 14px)); }
  html.touch #hud.vit-top .vitals { padding: 5px 9px; gap: 3px 8px; }
  html.touch #hud.vit-top .vitals .top, html.touch #hud.vit-top .vitals .top b { font-size: 14px; line-height: 16px; }
  html.touch #hud.vit-top .vitals .bar.exp { flex-basis: 70px; height: 14px; }
  html.touch #hud.vit-top .vitals .bar.hp { height: 15px; }
  html.touch #hud.vit-top .vitals .bar.mp { height: 13px; }
  html.touch #hud.vit-top .vitals .bar > span { font-size: 13px; line-height: 15px; }
  html.touch #hud.vit-top .vitals .bar.mp > span, html.touch #hud.vit-top .vitals .bar.exp > span { line-height: 13px; }
}
