/* Residue — luminous anime-fantasy HUD (docs/art/HUD_DESIGN.md). ?hud=classic keeps prior chrome. */
:root {
  --bg: #0c101c;
  --panel: rgba(20, 28, 56, 0.88);
  --panel-2: rgba(28, 36, 64, 0.92);
  --gold: #c9a24a;
  --gold-hi: #f0d690;
  --gold-lo: #a07a34;
  --ink: #f3ecd8;
  --ink-soft: #dccfb0;
  --dim-c: #9aa6b4;
  --hp: #c0392b;
  --hp-hi: #ff8a6a;
  --mp: #2f6fd0;
  --mp-hi: #9ad8ff;
  --good: #8fd06a;
  --warn: #f0c050;
  --bad: #ff6a5a;
  --ley: #7fd8ec;
  --font: "Alegreya Sans", system-ui, sans-serif;
  --title: "Cinzel", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  /* HUD v2 tokens */
  --hud-navy: #141c38;
  --hud-navy-glass: rgba(20, 28, 56, 0.88);
  --hud-cream: #f3ecd8;
  --hud-ivory: #fffaf0;
  --hud-gold: #c9a24a;
  --hud-gold-hi: #f0d690;
  --hud-silver: #cfd6de;
  --hud-residue: #c070ff;
  --hud-gap: 0.75rem;
  --hud-slot: 3.9rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 15px/1.35 var(--font); user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui .frame, #ui button, #ui .overlay, #ui .prompt, #ui .touchbar, #ui select, #ui input, #ui .hotbar, #ui canvas { pointer-events: auto; }
.dim { color: var(--dim-c); font-size: 0.82rem; }
.bad { color: var(--bad); } .warn { color: var(--warn); }
.success { color: var(--good); } .weakened { color: var(--warn); } .fizzle, .backlash, .surge { color: var(--bad); }
h2, h3 { font-family: var(--title); font-weight: 700; letter-spacing: 0.06em; margin: 0 0 0.5rem; color: var(--gold-hi); }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }

/* gilt frame: dark fill, double gold rule, corner studs.
   When `html.ui-skinned` (assets/ui/manifest.json present), panels switch to
   border-image 9-slice via --ui-* custom properties set by applyUiManifest(). */
.frame, .overlay, .prompt, .hotbar, .toast, .card, #loading, .d-bar, .d-modal, .d-settings {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-lo);
  box-shadow: inset 0 0 0 1px rgba(240, 210, 138, 0.12), inset 0 0 0 3px rgba(0, 0, 0, 0.35), inset 0 0 0 4px rgba(201, 164, 92, 0.35), 0 8px 24px rgba(0, 0, 0, 0.5);
  border-radius: 6px;
}
.frame { padding: 0.55rem 0.8rem; position: relative; }
html.ui-skinned .frame.player-frame,
html.ui-skinned .overlay,
html.ui-skinned .prompt,
html.ui-skinned .d-modal,
html.ui-skinned .d-settings {
  background: transparent;
  border-style: solid;
  border-width: var(--ui-panel-width, 12px);
  border-image-source: var(--ui-panel, none);
  border-image-slice: var(--ui-panel-slice, 12) fill;
  border-image-width: var(--ui-panel-width, 12px);
  border-image-repeat: stretch;
  box-shadow: none;
  border-radius: 0;
}
html.ui-skinned .hotbar,
html.ui-skinned .d-bar {
  background: transparent;
  border-style: solid;
  border-width: var(--ui-slot-width, 8px);
  border-image-source: var(--ui-panel-glass, var(--ui-panel, none));
  border-image-slice: var(--ui-panel-glass-slice, var(--ui-panel-slice, 8)) fill;
  border-image-width: var(--ui-slot-width, 8px);
  border-image-repeat: stretch;
  box-shadow: none;
}
html.ui-skinned .slot,
html.ui-skinned .d-slot {
  background: transparent;
  border-style: solid;
  border-width: var(--ui-slot-width, 6px);
  border-image-source: var(--ui-slot-normal, none);
  border-image-slice: var(--ui-slot-normal-slice, 6) fill;
  border-image-width: var(--ui-slot-width, 6px);
  border-image-repeat: stretch;
  box-shadow: none;
  border-radius: 0;
}
html.ui-skinned .slot.sel,
html.ui-skinned .d-slot.sel { border-image-source: var(--ui-slot-selected, var(--ui-slot-normal, none)); }
html.ui-skinned .slot:hover,
html.ui-skinned .d-slot:hover { border-image-source: var(--ui-slot-hover, var(--ui-slot-normal, none)); }
html.ui-skinned .slot.dry,
html.ui-skinned .d-slot.dry { border-image-source: var(--ui-slot-disabled, var(--ui-slot-normal, none)); }
html.ui-skinned .bar {
  border-style: solid;
  border-width: var(--ui-bar-width, 4px);
  border-image-source: var(--ui-bar-frame, none);
  border-image-slice: var(--ui-bar-frame-slice, 4) fill;
  border-image-width: var(--ui-bar-width, 4px);
  background: transparent;
  box-shadow: none;
}
html.ui-skinned .pu-row b[data-rune] {
  background-color: transparent;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  color: transparent;
  text-shadow: none;
  border-color: transparent;
}
html.ui-skinned .pu-row b[data-rune="up"] { background-image: var(--ui-rune-up_normal); }
html.ui-skinned .pu-row b[data-rune="right"] { background-image: var(--ui-rune-right_normal); }
html.ui-skinned .pu-row b[data-rune="down"] { background-image: var(--ui-rune-down_normal); }
html.ui-skinned .pu-row b[data-rune="left"] { background-image: var(--ui-rune-left_normal); }
html.ui-skinned .pu-row b.now[data-rune="up"],
html.ui-skinned .pu-row b.ok[data-rune="up"] { background-image: var(--ui-rune-up_hit); }
html.ui-skinned .pu-row b.now[data-rune="right"],
html.ui-skinned .pu-row b.ok[data-rune="right"] { background-image: var(--ui-rune-right_hit); }
html.ui-skinned .pu-row b.now[data-rune="down"],
html.ui-skinned .pu-row b.ok[data-rune="down"] { background-image: var(--ui-rune-down_hit); }
html.ui-skinned .pu-row b.now[data-rune="left"],
html.ui-skinned .pu-row b.ok[data-rune="left"] { background-image: var(--ui-rune-left_hit); }
html.ui-skinned .pu-row b.miss[data-rune="up"] { background-image: var(--ui-rune-up_miss); }
html.ui-skinned .pu-row b.miss[data-rune="right"] { background-image: var(--ui-rune-right_miss); }
html.ui-skinned .pu-row b.miss[data-rune="down"] { background-image: var(--ui-rune-down_miss); }
html.ui-skinned .pu-row b.miss[data-rune="left"] { background-image: var(--ui-rune-left_miss); }
.overlay::before, .prompt::before, .frame.player-frame::before {
  content: ""; position: absolute; inset: 4px; pointer-events: none; border-radius: 3px;
  background:
    radial-gradient(circle at 0 0, var(--gold) 2px, transparent 3px) top left / 10px 10px no-repeat,
    radial-gradient(circle at 100% 0, var(--gold) 2px, transparent 3px) top right / 10px 10px no-repeat,
    radial-gradient(circle at 0 100%, var(--gold) 2px, transparent 3px) bottom left / 10px 10px no-repeat,
    radial-gradient(circle at 100% 100%, var(--gold) 2px, transparent 3px) bottom right / 10px 10px no-repeat;
}

/* ---------- loading ---------- */
#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(26rem, calc(100vw - 2rem)); margin: 0; padding: 1.6rem 1.5rem; white-space: pre-wrap; text-align: center; font: 1rem/1.5 var(--font); color: var(--ink-soft); }
#loading::before { content: "Residue"; display: block; font: 900 2.6rem/1 var(--title); letter-spacing: 0.12em; color: var(--gold-hi); text-shadow: 0 2px 0 #000; margin-bottom: 0.5rem; }
#loading[hidden] { display: none; }
.boot-load {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(26rem, calc(100vw - 2rem)); margin: 0; padding: 1.6rem 1.5rem;
  text-align: center; color: var(--ink-soft);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-lo);
  box-shadow: inset 0 0 0 1px rgba(240, 210, 138, 0.12), 0 8px 24px rgba(0, 0, 0, 0.5);
  border-radius: 6px; z-index: 40; pointer-events: none;
}
.boot-load[hidden] { display: none; }
.boot-load-title { font: 900 2.6rem/1 var(--title); letter-spacing: 0.12em; color: var(--gold-hi); text-shadow: 0 2px 0 #000; margin-bottom: 0.65rem; }
.boot-load-label { font: 1rem/1.4 var(--font); min-height: 1.4em; margin-bottom: 0.85rem; }
.boot-load-track { height: 0.55rem; border-radius: 999px; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(201, 164, 74, 0.35); overflow: hidden; }
.boot-load-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); transition: width 160ms ease-out; }
.boot-load-pct { margin-top: 0.45rem; font: 0.8rem/1 var(--mono); color: var(--dim-c); letter-spacing: 0.04em; }

/* ---------- player frame ---------- */
.player-frame { position: absolute; top: 0.9rem; left: 0.9rem; display: flex; gap: 0.7rem; align-items: center; width: 22rem; max-width: calc(100vw - 1.8rem); padding: 0.6rem 0.9rem 0.6rem 0.6rem; }
.portrait { width: 4.4rem; height: 4.4rem; flex: none; filter: drop-shadow(0 2px 4px #000); }
.frame-body { flex: 1; min-width: 0; }
.pname { font: 700 1.05rem var(--title); letter-spacing: 0.06em; color: var(--gold-hi); }
.ptitle { font-size: 0.78rem; color: var(--ink-soft); text-transform: capitalize; margin-bottom: 0.25rem; }
.bar { position: relative; height: 0.95rem; background: #0a0705; border: 1px solid #000; box-shadow: inset 0 1px 3px #000, 0 0 0 1px var(--gold-lo); border-radius: 2px; margin: 0.22rem 0; overflow: hidden; }
.bar .chip { position: absolute; inset: 0 auto 0 0; width: 100%; background: rgba(255, 210, 180, 0.45); transition: none; pointer-events: none; z-index: 0; }
.bar.pool .chip { background: rgba(140, 190, 255, 0.4); }
.bar.xp .chip { background: rgba(240, 210, 138, 0.35); }
.bar .fill { position: absolute; inset: 0 auto 0 0; transition: width 0.12s ease; z-index: 1; }
.bar .fill::after { content: ""; position: absolute; inset: 0 0 50% 0; background: linear-gradient(180deg, rgba(255,255,255,0.35), transparent); }
.bar.hp .fill { background: linear-gradient(90deg, #6a1410, var(--hp), var(--hp-hi)); }
.bar.pool .fill { background: linear-gradient(90deg, #102a6a, var(--mp), var(--mp-hi)); }
.bar span { position: relative; z-index: 2; display: block; text-align: center; font: 800 0.7rem/0.95rem var(--font); letter-spacing: 0.04em; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; font-variant-numeric: tabular-nums; }
.bar.shake { animation: barShake 0.32s ease-out; }
@keyframes barShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.ward { color: var(--gold-hi); font-size: 0.75rem; font-weight: 700; }
.inv { display: flex; flex-wrap: wrap; gap: 0.15rem 0.7rem; font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.15rem; }
.inv .taint { color: #c9a0e8; }

/* ---------- zone banner ---------- */
.zone-banner { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; transition: opacity 0.4s; }
.zname { white-space: nowrap; font: 900 clamp(1.4rem, 3.2vw, 2.6rem)/1 var(--title); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-hi); text-shadow: 0 2px 0 #000, 0 0 18px rgba(0,0,0,0.8); }
.zname::before, .zname::after { content: ""; display: inline-block; width: 3.5rem; height: 1px; margin: 0 1rem; vertical-align: middle; background: linear-gradient(90deg, transparent, var(--gold)); }
.zname::after { background: linear-gradient(90deg, var(--gold), transparent); }
.zsub { margin-top: 0.4rem; font: 500 0.95rem var(--title); letter-spacing: 0.2em; color: var(--ink); text-shadow: 0 1px 3px #000; }

/* ---------- target frame ---------- */
.target-frame { position: absolute; top: 0.9rem; left: 50%; transform: translateX(-50%); width: 17rem; text-align: center; padding: 0.4rem 0.8rem 0.5rem; }
.tname { font: 700 0.95rem var(--title); letter-spacing: 0.05em; color: var(--ink); }
.tname.hostile { color: var(--bad); }
.tsub { font-size: 0.72rem; color: var(--dim-c); text-transform: capitalize; }

/* ---------- minimap cluster ---------- */
.map-box { position: absolute; top: 0.9rem; right: 0.9rem; width: 13.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.minimap { width: 11.9rem; height: 11.9rem; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 0 2px #000, 0 0 0 5px var(--gold-lo), 0 8px 20px #000; background: #1a140e; }
.compass { position: absolute; top: 0; left: 50%; width: 11.9rem; height: 11.9rem; margin-left: -5.95rem; pointer-events: none; }
.compass span { position: absolute; font: 700 0.75rem var(--title); color: var(--gold-hi); text-shadow: 0 1px 2px #000; width: 1.2rem; height: 1.2rem; line-height: 1.2rem; text-align: center; border-radius: 50%; background: #1a120c; border: 1px solid var(--gold-lo); }
.compass .c-N { top: 2px; left: 50%; } .compass .c-S { bottom: -16px; left: 50%; }
.compass .c-E { top: 50%; right: -16px; } .compass .c-W { top: 50%; left: 2px; }
.status { width: 100%; text-align: center; padding: 0.35rem 0.6rem; font-size: 0.78rem; }
.status .date { font: 700 0.8rem var(--title); letter-spacing: 0.06em; color: var(--gold-hi); }
.banner { margin-top: 0.3rem; color: var(--ley); font-size: 0.75rem; }
.w-gauge { width: 100%; }
.g-track { position: relative; height: 0.5rem; background: #0a0705; border: 1px solid var(--gold-lo); border-radius: 2px; overflow: hidden; }
.g-track i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(240,210,138,0.6); z-index: 2; }
.g-fill { position: absolute; inset: 0 auto 0 0; transition: width 0.3s; }
.g-label { text-align: center; font-size: 0.78rem; margin-top: 0.15rem; text-shadow: 0 1px 2px #000; }
.g-label b { font-family: var(--title); color: var(--ink); }

/* ---------- quest tracker ---------- */
.goals { position: absolute; top: 21.2rem; right: 0.9rem; width: 15rem; padding: 0.5rem 0.75rem; background: linear-gradient(90deg, transparent, rgba(18,14,10,0.75) 20%); border: none; box-shadow: none; text-align: right; }
.ghead { font: 700 0.85rem var(--title); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--gold-lo); padding-bottom: 0.2rem; margin-bottom: 0.3rem; }
.quest { margin-bottom: 0.35rem; }
.qtitle { font: 700 0.85rem var(--title); color: var(--gold-hi); text-shadow: 0 1px 2px #000; }
.qstep { font-size: 0.78rem; color: var(--ink); text-shadow: 0 1px 2px #000; }

/* ---------- skill bar ---------- */
.hotbar { position: absolute; left: 50%; bottom: 0.9rem; transform: translateX(-50%); display: flex; gap: 0.3rem; padding: 0.45rem 0.55rem; max-width: calc(100vw - 1rem); overflow-x: auto; }
.slot { position: relative; width: 3.6rem; height: 3.6rem; flex: none; padding: 0; cursor: pointer; border-radius: 4px; background: #0d0a07; border: 1px solid #000; box-shadow: inset 0 0 0 1px var(--gold-lo), inset 0 0 12px #000; overflow: hidden; transition: transform 0.1s; }
.slot svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.slot:hover { transform: translateY(-2px); }
.slot.press { transform: scale(0.86); }
.slot.sel { box-shadow: inset 0 0 0 2px var(--gold-hi), 0 0 12px rgba(240, 210, 138, 0.55); }
.slot .cd {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: conic-gradient(from -90deg, rgba(0, 0, 0, 0.72) calc(var(--cd, 0) * 1%), transparent 0);
}
.slot.dry svg { filter: grayscale(0.8) brightness(0.5); }
.slot.empty { opacity: 0.5; }
.slot .key { position: absolute; top: 1px; left: 3px; font: 800 0.72rem var(--title); color: var(--gold-hi); text-shadow: 0 1px 2px #000; }
.slot .cost { position: absolute; bottom: 1px; right: 3px; font: 800 0.72rem var(--font); color: var(--mp-hi); text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.slot .pip { position: absolute; bottom: 4px; left: 4px; width: 0.45rem; height: 0.45rem; border-radius: 50%; box-shadow: 0 0 4px currentColor; background: currentColor; }
.pip.success { color: var(--good); } .pip.weakened { color: var(--warn); } .pip.fizzle, .pip.backlash, .pip.surge { color: var(--bad); } .pip.none { color: #555; }
.slot-tip { position: absolute; left: 50%; bottom: 5.4rem; transform: translateX(-50%); font-size: 0.8rem; padding: 0.3rem 0.8rem; text-align: center; white-space: nowrap; max-width: calc(100vw - 1rem); overflow: hidden; text-overflow: ellipsis; }
.slot-tip b { font-family: var(--title); color: var(--gold-hi); }
.castbar { position: absolute; left: 50%; bottom: 10.3rem; transform: translateX(-50%); width: min(22rem, 80vw); height: 1.1rem; background: #0a0705; border: 1px solid var(--gold-lo); box-shadow: 0 0 0 1px #000, 0 4px 12px #000; border-radius: 2px; }
.castbar .cfill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3a6ad0, #8fd0ff); }
.castbar.is-haste .cfill { background: linear-gradient(90deg, #8a2a1a, #ff7a4a); }
.castbar.is-ritual .cfill { background: linear-gradient(90deg, #a07a20, #ffe08a); box-shadow: 0 0 12px #ffe08a; }
.castbar .cmark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--gold-hi); }
.castbar span { position: absolute; inset: 0; text-align: center; font: 800 0.72rem/1.1rem var(--font); color: #fff; text-shadow: 0 1px 2px #000; }
.hint { position: absolute; left: 50%; bottom: 8.5rem; transform: translateX(-50%); white-space: nowrap; font: 700 0.8rem var(--title); letter-spacing: 0.04em; color: var(--ink); text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.hint.act { color: var(--gold-hi); }
.hint.act::before { content: "F"; display: inline-block; width: 1.3rem; height: 1.3rem; margin-right: 0.4rem; line-height: 1.3rem; text-align: center; border: 1px solid var(--gold); border-radius: 3px; background: #1a120c; }

/* ---------- the sum ---------- */
.calc { position: absolute; left: 0.9rem; bottom: 6rem; margin: 0; max-width: min(36rem, calc(100vw - 2rem)); white-space: pre-wrap; font: 0.76rem/1.55 var(--mono); color: var(--ink); background: var(--panel); border: 1px solid var(--gold-lo); padding: 0.6rem 0.8rem; border-radius: 4px; }

/* ---------- toasts: a log feed, left ---------- */
.toasts { position: absolute; left: 0.9rem; top: 9.4rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; max-width: 24rem; }
.toast { background: rgba(18, 14, 10, 0.72); border: none; box-shadow: none; border-left: 2px solid var(--gold); border-radius: 0; padding: 0.15rem 0.6rem; font-size: 0.82rem; color: var(--ink); text-shadow: 0 1px 2px #000; }
.toast.place { font: 700 0.95rem var(--title); color: var(--gold-hi); }
.toast.warn { border-left-color: var(--warn); color: var(--warn); } .toast.bad { border-left-color: var(--bad); color: #ffb0a6; }

/* ---------- dialogs ---------- */
.prompt { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(28rem, calc(100vw - 2rem)); max-height: min(80vh, 40rem); overflow-y: auto; padding: 1.1rem 1.3rem 1.2rem; }
.prompt { box-shadow: 0 0 0 100vmax rgba(0,0,0,0.45), inset 0 0 0 1px rgba(240,210,138,0.12), inset 0 0 0 4px rgba(201,164,92,0.35), 0 8px 24px #000; }
.prompt h3 { text-align: center; border-bottom: 1px solid var(--gold-lo); padding-bottom: 0.4rem; }
.prompt p { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.5; }
.choice { display: block; width: 100%; text-align: left; margin-top: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 3px; border: 1px solid var(--gold-lo); background: linear-gradient(180deg, #2c2218, #1a140e); color: var(--ink); font: 700 0.92rem var(--font); cursor: pointer; transition: border-color 0.1s, background 0.1s; }
.choice:hover { border-color: var(--gold-hi); background: linear-gradient(180deg, #3a2c1e, #241a12); }
.choice.act { border-color: var(--gold); color: var(--gold-hi); }
.choice.bad { color: #ffb0a6; }
.choice.dim { color: var(--dim-c); background: transparent; }
.choice:disabled { opacity: 0.4; cursor: not-allowed; }
.note { font-size: 0.8rem; color: var(--dim-c); padding: 0.15rem 0.9rem 0; }
.note.today { color: var(--ley); }
.buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; } .buttons .choice { width: auto; }
.bark { position: absolute; left: 50%; bottom: 11.2rem; transform: translateX(-50%); width: min(30rem, calc(100vw - 2rem)); font-size: 0.86rem; }
.bark b { font-family: var(--title); color: var(--gold-hi); }

/* ---------- full overlays ---------- */
.overlay { position: absolute; inset: 6vh 8vw; overflow: auto; padding: 1.3rem 1.6rem; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.55), inset 0 0 0 1px rgba(240,210,138,0.12), inset 0 0 0 4px rgba(201,164,92,0.35), 0 8px 24px #000; }
.overlay h2 { text-align: center; border-bottom: 1px solid var(--gold-lo); padding-bottom: 0.5rem; }
.overlay p { color: var(--ink-soft); line-height: 1.5; }
.overlay table { border-collapse: collapse; }
.overlay td, .overlay th { padding: 0.25rem 0.9rem 0.25rem 0; text-align: left; vertical-align: top; }
.overlay th { color: var(--gold); font: 700 0.8rem var(--title); }
.overlay td.key { color: var(--gold-hi); font-weight: 800; white-space: nowrap; }
.overlay tr.me td { color: var(--ley); } .overlay tr.nearest td { font-weight: 800; color: var(--gold-hi); }
.bigmap { width: 100%; max-width: 56rem; height: auto; border: 2px solid var(--gold-lo); cursor: pointer; display: block; margin: 0 auto; }
.events { font: 0.78rem/1.55 var(--mono); color: var(--ink-soft); }

/* ---------- book ---------- */
.book-head { display: flex; align-items: center; justify-content: center; position: relative; }
.book-head h2 { border: none; }
.book-close { position: absolute; right: 0; top: 0; width: auto; margin: 0; padding: 0.2rem 0.7rem; }
.tab-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; margin: 0.2rem 0 0.9rem; border-bottom: 1px solid var(--gold-lo); }
.tab-btn { font: 700 0.85rem var(--title); letter-spacing: 0.05em; cursor: pointer; border: 1px solid var(--gold-lo); border-bottom: none; background: #1a140e; color: var(--ink-soft); border-radius: 4px 4px 0 0; padding: 0.35rem 1rem; white-space: nowrap; }
.tab-btn[aria-selected='true'] { background: linear-gradient(180deg, #4a3820, #2a2016); color: var(--gold-hi); border-color: var(--gold); }
.card .tab-btn { border-bottom: 1px solid var(--gold-lo); border-radius: 3px; padding: 0.2rem 0.7rem; font-size: 0.75rem; margin-top: 0.35rem; }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.55rem; }
.card { padding: 0.6rem 0.85rem; font-size: 0.85rem; border-radius: 4px; }
.card.is-locked { opacity: 0.55; filter: grayscale(0.5); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-bottom: 0.2rem; }
.card-head b { font: 700 0.95rem var(--title); color: var(--gold-hi); margin-right: 0.2rem; }
.chip { font-size: 0.68rem; font-weight: 800; padding: 0.02rem 0.5rem; border-radius: 2px; background: #2a2016; border: 1px solid var(--gold-lo); color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.chip.on { background: var(--gold-lo); color: #fff; }
.chip.el-fire { color: #ffb070; } .chip.el-water { color: #8ac8ff; } .chip.el-earth { color: #e0c08a; } .chip.el-air { color: #c8f4ff; }
.chip.el-light { color: #ffe98a; } .chip.el-shadow { color: #c8b0f0; } .chip.el-mind { color: #ffb0e0; }
.wform { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.7rem 1rem; margin: 0.8rem 0; }
.wform label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--gold); font: 700 0.75rem var(--title); letter-spacing: 0.04em; }
.wform input, .wform select { background: #0d0a07; color: var(--ink); border: 1px solid var(--gold-lo); border-radius: 3px; padding: 0.35rem 0.6rem; font: 600 0.9rem var(--font); }
.checks { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.checks label { flex-direction: row; align-items: center; color: var(--ink); font: 600 0.85rem var(--font); }
.wout { position: static !important; max-width: none !important; margin: 0.6rem 0; padding: 0.7rem 1rem; background: #0d0a07; border: 1px solid var(--gold-lo); border-radius: 3px; font: 0.78rem/1.55 var(--mono); white-space: pre-wrap; color: var(--ink); }
.newgame { inset: 4vh 10vw; }
.look-picker { margin: 0.8rem 0 0.4rem; }
.look-preview {
  display: block; width: 192px; height: 192px; margin: 0.6rem 0 0;
  image-rendering: pixelated; background: #0d121c; border: 1px solid var(--gold-lo); border-radius: 4px;
}
.bag-look { margin-bottom: 0.8rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--gold-lo); }

/* ---------- world labels & numbers ---------- */
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font: 900 1.05rem var(--title); text-shadow: 0 2px 0 #000, 0 0 6px #000; font-variant-numeric: tabular-nums; }
.float.hit { color: var(--gold-hi); } .float.hurt { color: var(--bad); } .float.heal { color: var(--good); }
.label { position: absolute; transform: translate(-50%, -100%); padding: 0 0.4rem; font: 700 0.75rem var(--title); color: var(--ink); text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; }
.label.hunt, .label.blight { color: var(--bad); }
.label i { display: block; height: 3px; margin-top: 1px; background: var(--hp); box-shadow: 0 0 0 1px #000; }

/* ---------- touch ---------- */
.stick { position: absolute; width: 100px; height: 100px; border-radius: 50%; border: 2px solid var(--gold); background: rgba(18,14,10,0.4); pointer-events: none; }
.touchbar { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 0.35rem; }
.touchbar button { min-width: 3.4rem; padding: 0.4rem 0.5rem; border-radius: 4px; border: 1px solid var(--gold-lo); background: var(--panel); color: var(--gold-hi); font: 700 0.75rem var(--title); }

button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--gold-lo); border-radius: 4px; } ::-webkit-scrollbar-track { background: #0d0a07; }

@media (max-width: 760px) {
  .player-frame { width: calc(100vw - 1.8rem); }
  .map-box, .goals, .target-frame, .hint, .slot-tip { display: none; }
  .zone-banner { top: 22%; }
  .slot { width: 3rem; height: 3rem; }
  .toasts { top: 7.6rem; }
  .overlay { inset: 2vh 3vw; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ======================= Delve (dungeon) ======================= */
.delve-ui { font-family: var(--font); }
.delve-ui button, .delve-ui .d-slot, .delve-ui .d-modal, .delve-ui .d-title { pointer-events: auto; }
.d-title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6rem; padding: 1rem; background: radial-gradient(ellipse at 50% 40%, #2a1e14 0%, #0a0807 70%); overflow: auto; }
.d-title h1 { margin: 0; font: 900 clamp(2.6rem, 7vw, 4.6rem)/1 var(--title); letter-spacing: 0.2em; color: var(--gold-hi); text-shadow: 0 3px 0 #000, 0 0 30px rgba(255, 150, 60, 0.35); }
.d-title .tag { font: 500 1rem var(--title); letter-spacing: 0.35em; text-transform: uppercase; color: var(--ink-soft); }
.d-title h3 { margin-top: 1rem; }
.d-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem; width: min(64rem, 100%); }
.d-class { text-align: left; padding: 0.8rem 1rem; cursor: pointer; color: var(--ink); background: linear-gradient(180deg, #2c2218, #16110c); border: 1px solid var(--gold-lo); border-radius: 6px; box-shadow: inset 0 0 0 3px rgba(0,0,0,0.35), inset 0 0 0 4px rgba(201,164,92,0.25); transition: transform 0.12s, border-color 0.12s; font: inherit; }
.d-class:hover { transform: translateY(-3px); border-color: var(--gold-hi); box-shadow: 0 0 18px rgba(240,210,138,0.25), inset 0 0 0 4px rgba(201,164,92,0.4); }
.d-class b { display: block; font: 700 1.15rem var(--title); color: var(--gold-hi); letter-spacing: 0.06em; }
.d-class span { display: block; font-size: 0.86rem; margin: 0.2rem 0; }
.d-class em { display: block; font-size: 0.75rem; color: var(--dim-c); font-style: normal; }
.d-class em.warn { color: var(--warn); }
.d-class.on { border-color: var(--gold-hi); box-shadow: 0 0 14px rgba(240,210,138,0.35), inset 0 0 0 4px rgba(201,164,92,0.45); }
.d-class:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.d-hire-purse { font: 700 1rem var(--title); color: var(--gold); letter-spacing: 0.06em; }
.d-hire-roster { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; max-width: 40rem; font-size: 0.85rem; color: var(--ink-soft); }
.d-hire-roster b { color: var(--gold-hi); margin-right: 0.4rem; }
.d-hire .buttons { margin-top: 0.6rem; }
.d-party { position: absolute; top: 0.9rem; left: 16.5rem; display: flex; flex-direction: column; gap: 0.35rem; min-width: 11rem; pointer-events: none; }
.d-mate { position: relative; padding: 0.35rem 0.55rem 0.45rem; background: rgba(10,8,6,0.65); border: 1px solid var(--gold-lo); border-radius: 4px; text-shadow: 0 1px 2px #000; overflow: hidden; }
.d-mate b { display: block; font: 700 0.85rem var(--title); color: var(--gold-hi); }
.d-mate span { display: block; font-size: 0.7rem; color: var(--ink-soft); margin-bottom: 0.2rem; }
.d-mate i { display: block; height: 4px; background: linear-gradient(90deg, #5ad070, #c8f090); border-radius: 1px; box-shadow: 0 0 6px #5ad070; }
.d-mate.down { opacity: 0.45; } .d-mate.down i { background: #664; box-shadow: none; }
.d-title .keys { margin-top: 0.8rem; font-size: 0.78rem; color: var(--dim-c); text-align: center; }

.d-top { position: absolute; top: 0.9rem; left: 0.9rem; width: 15rem; }
.d-depth { font: 900 1.4rem var(--title); letter-spacing: 0.1em; color: var(--gold-hi); text-shadow: 0 2px 0 #000; }
.d-air { height: 0.4rem; margin: 0.3rem 0 0.15rem; background: #0a0705; border: 1px solid var(--gold-lo); border-radius: 2px; overflow: hidden; }
.d-air span { display: block; height: 100%; box-shadow: 0 0 10px currentColor; transition: width 0.4s; }
.d-airname { font: 700 0.85rem var(--title); letter-spacing: 0.08em; text-shadow: 0 1px 2px #000; }
.d-coins { font-size: 0.85rem; color: var(--gold); margin-top: 0.15rem; text-shadow: 0 1px 2px #000; }
.d-map { position: absolute; top: 0.9rem; right: 0.9rem; width: 11rem; height: 11rem; background: rgba(10,8,6,0.6); border: 1px solid var(--gold-lo); border-radius: 6px; }
.d-map.open { width: 20rem; height: 20rem; z-index: 12; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.45); }
.d-door-icon { position: absolute; transform: translate(-50%, -120%); font: 700 1.35rem/1 Georgia, serif; color: #f0d28a; text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,0.8); pointer-events: none; white-space: nowrap; }

.d-banner { position: absolute; top: 10%; left: 50%; transform: translate(-50%, -10px) scale(0.96); opacity: 0; pointer-events: none; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; font: 900 clamp(1.1rem, 2.4vw, 1.7rem) var(--title); letter-spacing: 0.12em; color: var(--gold-hi); text-shadow: 0 3px 0 #000, 0 0 24px rgba(0,0,0,0.9); transition: opacity 0.25s, transform 0.25s; }
.d-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.d-banner.big { font-size: clamp(1.4rem, 3.2vw, 2.2rem); }
.d-banner.bad { color: #ff7a6a; } .d-banner.good { color: #b8f08a; }
.d-feed { position: absolute; left: 0.9rem; top: 7rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--ink); text-shadow: 0 1px 2px #000; }

.d-bottom { position: absolute; left: 50%; bottom: 0.8rem; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 1rem; }
.orb { position: relative; width: 6.6rem; height: 6.6rem; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 35%, #2a2018, #0a0705); border: 3px solid var(--gold); box-shadow: 0 0 0 2px #000, 0 0 0 5px var(--gold-lo), 0 6px 18px #000, inset 0 -10px 20px #000; }
.orb .chip { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255, 200, 170, 0.4); z-index: 0; pointer-events: none; }
.orb.mp .chip { background: rgba(140, 190, 255, 0.35); }
.orb i.fill { position: absolute; left: 0; right: 0; bottom: 0; transition: height 0.12s ease-out; z-index: 1; }
.orb.hp i.fill { background: radial-gradient(circle at 40% 30%, #ff8a6a, #b0201a 45%, #4a0806); }
.orb.mp i.fill { background: radial-gradient(circle at 40% 30%, #9ad8ff, #2050c0 45%, #08143a); }
.orb::after { content: ""; position: absolute; inset: 8% 18% 55% 18%; border-radius: 50%; background: linear-gradient(180deg, rgba(255,255,255,0.45), transparent); z-index: 2; pointer-events: none; }
.orb.low { animation: pulse 0.7s infinite alternate; }
.orb.ward { box-shadow: 0 0 0 2px #000, 0 0 0 5px #e8c870, 0 0 22px #ffd870; }
.orb.shake { animation: barShake 0.32s ease-out; }
@keyframes pulse { to { box-shadow: 0 0 0 2px #000, 0 0 0 5px #ff3020, 0 0 26px #ff3020; } }
.d-bar { display: flex; gap: 0.35rem; padding: 0.4rem 0.5rem; margin-bottom: 0.6rem; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--gold-lo); border-radius: 6px; box-shadow: inset 0 0 0 4px rgba(201,164,92,0.3), 0 8px 20px #000; }
.d-slot { position: relative; width: 3.7rem; height: 3.7rem; border-radius: 4px; overflow: hidden; background: #0d0a07; border: 1px solid #000; box-shadow: inset 0 0 0 1px var(--gold-lo), inset 0 0 12px #000; cursor: pointer; transition: transform 0.1s; }
.d-slot svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.d-slot.press { transform: scale(0.86); }
.d-slot.sel { box-shadow: inset 0 0 0 2px var(--gold-hi), 0 0 12px rgba(240,210,138,0.5); }
.d-slot.dry svg, .d-slot.dry b { filter: grayscale(0.9) brightness(0.45); }
.d-slot.empty { opacity: 0.45; }
.d-slot .k { position: absolute; top: 1px; left: 4px; z-index: 2; font: 800 0.7rem var(--title); color: var(--gold-hi); text-shadow: 0 1px 2px #000; }
.d-slot .mana { position: absolute; bottom: 2px; right: 3px; z-index: 2; font-size: 0.5rem; letter-spacing: 1px; color: #7fc0ff; text-shadow: 0 0 3px #000; }
.d-slot b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; color: var(--gold-hi); }
.d-slot em { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-style: normal; font-size: 0.5rem; color: #8ad0ff; }
.d-slot .cd {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: conic-gradient(from -90deg, rgba(0, 0, 0, 0.72) calc(var(--cd, 0) * 1%), transparent 0);
}
.d-slot.basic, .d-slot.dash, .d-slot.pot { width: 3rem; height: 3rem; align-self: flex-end; }
.d-xp { position: absolute; left: 50%; bottom: 0.25rem; transform: translateX(-50%); width: min(30rem, 70vw); height: 0.25rem; background: #0a0705; border-radius: 2px; overflow: hidden; }
.d-xp i { display: block; height: 100%; background: linear-gradient(90deg, #a07a20, #ffe08a); box-shadow: 0 0 8px #ffe08a; transition: width 0.3s; }
.d-sum { position: absolute; left: 0.9rem; bottom: 8.5rem; margin: 0; font: 0.75rem/1.5 var(--mono); color: var(--ink); background: var(--panel); border: 1px solid var(--gold-lo); padding: 0.5rem 0.7rem; border-radius: 4px; white-space: pre-wrap; max-width: 30rem; }
.d-labels { position: absolute; inset: 0; pointer-events: none; }
.d-label { position: absolute; transform: translate(-50%, -100%); width: 3.4rem; text-align: center; }
.d-label b { display: block; font: 700 0.72rem var(--title); color: #ffd060; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.d-label.boss { width: 9rem; } .d-label.boss b { font-size: 0.9rem; color: #ff8a6a; }
.d-label i { display: block; height: 4px; background: linear-gradient(90deg, #ff5040, #ff9a6a); box-shadow: 0 0 0 1px #000; border-radius: 1px; }
.d-modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(40rem, calc(100vw - 2rem)); max-height: 86vh; overflow: auto; padding: 1.3rem 1.5rem; text-align: center; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--gold-lo); border-radius: 6px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.55), inset 0 0 0 4px rgba(201,164,92,0.35), 0 10px 30px #000; }
.d-modal p { color: var(--ink-soft); }
.d-modal .d-event-text { font-size: 1.05rem; line-height: 1.45; color: var(--ink); margin: 0.4rem 0 0.8rem; }
.d-modal .d-recap { text-align: left; white-space: pre-wrap; font: 0.92rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-soft); background: rgba(0,0,0,0.25); padding: 0.75rem 1rem; border-radius: 4px; border: 1px solid rgba(201,164,92,0.25); }
.d-cards { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
/* opacity:1 default — never rely on animation fill (headless / reduced-motion leave `backwards` stuck at 0) */
.d-card { position: relative; width: 11rem; min-height: 8rem; padding: 1rem 0.8rem; cursor: pointer; color: var(--ink); background: linear-gradient(180deg, #3a2c1c, #16110c); border: 1px solid var(--gold); border-radius: 6px; box-shadow: inset 0 0 0 3px rgba(0,0,0,0.35), 0 0 0 1px #000; transition: transform 0.12s, box-shadow 0.12s; font: inherit; opacity: 1; animation: none; }
.d-card.ready, .d-modal.is-levelup .d-card { opacity: 1 !important; animation: none !important; transform: none; }
.d-modal.is-levelup ~ .ui-levelup,
.d-modal.is-levelup ~ .guide-toast,
.d-modal.is-levelup ~ .hud-notify,
.d-modal.is-levelup ~ .hint { display: none !important; }
.d-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: 0 0 24px rgba(240,210,138,0.45); }
.d-card b { display: block; font: 700 1.05rem var(--title); color: var(--gold-hi); margin-bottom: 0.35rem; }
.d-card .kind { display: block; font: 600 0.72rem var(--title); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-lo); margin-bottom: 0.35rem; }
.d-card span { display: block; font-size: 0.85rem; line-height: 1.35; color: var(--ink-soft, #c8b8a0); }
.d-card .cost { display: block; margin-top: 0.55rem; font: 700 0.8rem var(--title); color: var(--gold-hi); }
.d-card em { position: absolute; top: 4px; left: 8px; font: 800 0.75rem var(--title); color: var(--gold-lo); font-style: normal; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .d-card { animation: none; opacity: 1; transform: none; }
}
.d-runes { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; margin: 0.5rem 0; }
.d-rune { min-width: 5.2rem; padding: 0.4rem 0.6rem; cursor: pointer; color: var(--ink); background: #1a140e; border: 1px solid var(--gold-lo); border-radius: 4px; font: 700 0.82rem var(--title); text-transform: capitalize; }
.d-rune em { display: block; font-style: normal; font-size: 0.55rem; color: var(--gold); min-height: 0.7rem; }
.d-rune.on { border-color: var(--gold-hi); background: #3a2c1c; box-shadow: 0 0 10px rgba(240,210,138,0.4); }
.d-rune.none { opacity: 0.35; cursor: not-allowed; }
.d-preview { display: flex; align-items: center; justify-content: center; gap: 0.8rem; margin: 0.6rem 0; }
.d-preview svg { width: 3.4rem; height: 3.4rem; border: 1px solid var(--gold); border-radius: 4px; background: #0d0a07; }
.d-preview b { display: block; font: 700 1.05rem var(--title); color: var(--gold-hi); text-transform: capitalize; }
.d-preview span { font-size: 0.85rem; color: var(--ink-soft); }
.d-go { margin: 0.6rem 0.3rem 0; padding: 0.55rem 1.4rem; cursor: pointer; font: 700 0.95rem var(--title); letter-spacing: 0.06em; color: #1a120c; background: linear-gradient(180deg, #ffe08a, #c9a45c); border: 1px solid #000; border-radius: 4px; box-shadow: 0 0 14px rgba(240,210,138,0.35); }
.d-go.ghost { color: var(--gold-hi); background: transparent; border-color: var(--gold-lo); box-shadow: none; }
.d-go:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 760px) { .d-map { width: 7rem; height: 7rem; } .orb { width: 4.6rem; height: 4.6rem; } .d-slot { width: 2.9rem; height: 2.9rem; } .d-bottom { gap: 0.4rem; } }

/* --- action layer: practice bar, dash, rifts, boons --- */
.bar.xp { height: 0.8rem; }
.bar.xp .fill { background: linear-gradient(90deg, #4a3410, #c9a24a, #f0d28a); }
.bar.xp span { font-size: 0.62rem; line-height: 0.8rem; }
.slot.dash-pip { cursor: default; opacity: 0.55; }
.slot.dash-pip.ready { opacity: 1; box-shadow: inset 0 0 0 1px var(--gold), 0 0 10px rgba(160, 230, 255, 0.45); }
.slot.dash-pip:hover { transform: none; }
.slot.dash-pip .cd { opacity: 0.85; }
.slot.dash-pip b { position: absolute; left: 0; right: 0; bottom: 0.25rem; text-align: center; font: 800 0.68rem var(--title); letter-spacing: 0.05em; color: #dff6ff; text-shadow: 0 1px 2px #000; }
.rift-banner { position: absolute; top: 5.6rem; left: 50%; transform: translateX(-50%); padding: 0.25rem 1rem; white-space: nowrap; max-width: calc(100vw - 1rem); font: 700 0.9rem var(--title); letter-spacing: 0.05em; color: #e2c8ff; background: rgba(24, 12, 34, 0.78); border: 1px solid #7a4ab0; border-radius: 3px; text-shadow: 0 1px 2px #000; pointer-events: none; }
.rift-banner.live { color: #ffd0e0; border-color: #ff4a8a; box-shadow: 0 0 14px rgba(255, 74, 138, 0.45); }
.float.mana { color: var(--mp-hi); }
.float.big { font-size: 1.7rem; letter-spacing: 0.12em; }
.label.elite { font-size: 0.9rem; color: #ff9ab8; }
@media (max-width: 640px) { .rift-banner { top: 7.2rem; font-size: 0.75rem; } .slot.dash-pip { display: none; } }

/* --- delve: rune scripts, bag, creature labels --- */
.d-script { width: 100%; box-sizing: border-box; background: #0c0907; color: #f0e6cc; border: 1px solid var(--gold-lo); border-radius: 3px; padding: 0.5rem 0.7rem; font: 0.9rem/1.35 ui-monospace, Menlo, Consolas, monospace; tab-size: 2; resize: vertical; }
.d-script-status { margin: 0.4rem 0; padding: 0.3rem 0.6rem; font: 0.8rem/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; text-align: left; border-left: 2px solid var(--gold); }
.d-script-status.ok { color: var(--good); border-left-color: var(--good); } .d-script-status.bad { color: #ffb0a6; border-left-color: var(--bad); }
.d-vocab { font: 0.74rem/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-soft); text-align: left; margin: 0.3rem 0 0.5rem; }
.d-vocab b { color: var(--gold-hi); display: inline-block; min-width: 5.2rem; }
.d-item { display: block; width: 100%; margin: 0.2rem 0; padding: 0.35rem 0.6rem; text-align: left; background: #17110c; color: var(--ink); border: 1px solid var(--gold-lo); border-radius: 3px; cursor: pointer; font: 0.82rem var(--font); }
.d-item:hover { border-color: var(--gold-hi); }
.d-modal { max-height: 88vh; overflow-y: auto; }
.d-label span { display: block; font: 600 0.62rem var(--font); color: var(--ink-soft); letter-spacing: 0.04em; }
.d-label.calm b { color: #a8e6b4; }
.d-feed div { max-width: 30rem; }

/* --- delve: purifying the mana (Audition row: dance + Space on the beat) --- */
.d-purify { position: absolute; left: 50%; bottom: 9.2rem; transform: translateX(-50%); padding: 0.55rem 0.9rem 0.5rem; text-align: center; background: rgba(12, 9, 7, 0.86); border: 1px solid var(--gold); border-radius: 5px; box-shadow: 0 0 22px rgba(120, 200, 255, 0.25); pointer-events: none; min-width: 16rem; }
.pu-name { font: 700 0.78rem var(--title); letter-spacing: 0.08em; color: var(--gold-hi); margin-bottom: 0.35rem; }
.pu-row { display: flex; gap: 0.3rem; justify-content: center; }
.pu-row b { width: 2.3rem; height: 2.3rem; line-height: 2.3rem; font: 900 1.4rem/2.3rem var(--font); color: #8a8072; background: #17110c; border: 1px solid #3a2e22; border-radius: 4px; transition: background 0.1s; }
.pu-row b.now { color: #fff; border-color: #9fdcff; box-shadow: 0 0 12px rgba(159, 220, 255, 0.8); }
.pu-row b.ok { color: #0c1a10; background: #7fe0a0; border-color: #7fe0a0; }
.pu-row b.miss { color: #2a0a08; background: #c060d8; border-color: #e08aff; box-shadow: 0 0 10px rgba(200, 100, 255, 0.55); }
.pu-row b.dance.wait, .pu-row b.dance.now {
  animation: puDance 0.55s ease-in-out infinite;
  animation-delay: calc(var(--bob, 0) * -0.55s);
}
.pu-row b.now.dance { animation-name: puDanceNow; }
@keyframes puDance {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-0.28rem) scale(1.06); }
}
@keyframes puDanceNow {
  0%, 100% { transform: translateY(0) scale(1.12); }
  50% { transform: translateY(-0.34rem) scale(1.22); }
}
.pu-time { height: 5px; margin-top: 0.45rem; background: #0a0705; border-radius: 3px; overflow: hidden; }
.pu-time i { display: block; height: 100%; background: linear-gradient(90deg, #e06a5a, #f0d28a, #9fdcff); }
.pu-beat { position: relative; height: 0.7rem; margin: 0.55rem 0.2rem 0.2rem; }
.pu-track { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: #1a1410; border: 1px solid #3a2e22; border-radius: 2px; }
.pu-cursor { position: absolute; top: 50%; width: 0.55rem; height: 0.55rem; margin: -0.28rem 0 0 -0.28rem; border-radius: 50%; background: #9fdcff; box-shadow: 0 0 10px #9fdcff, 0 0 2px #fff; }
.pu-mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: linear-gradient(180deg, #ffe08a, #c9a45c); box-shadow: 0 0 8px rgba(255, 220, 120, 0.7); border-radius: 1px; }
.pu-mark::after { content: "␣"; position: absolute; top: -1.1rem; left: 50%; transform: translateX(-50%); font: 700 0.65rem var(--title); color: var(--gold-hi); text-shadow: 0 1px 2px #000; }
.pu-hint { margin-top: 0.3rem; font-size: 0.66rem; color: var(--ink-soft); }
.d-purify.result { border: none; background: none; box-shadow: none; }
.pu-grade { font: 900 1.6rem var(--title); letter-spacing: 0.12em; text-shadow: 0 2px 0 #000, 0 0 14px currentColor; }
.pu-grade span { font-size: 1rem; }
.pu-timing { font: 900 clamp(1.8rem, 5vw, 3rem) var(--title); letter-spacing: 0.14em; text-shadow: 0 3px 0 #000, 0 0 24px currentColor; animation: puPop 0.55s cubic-bezier(0.2, 1.4, 0.3, 1) both; }
.pu-timing.perfect { color: #9fe8ff; } .pu-timing.great { color: #b8f08a; }
.pu-timing.cool { color: #f0d28a; } .pu-timing.bad { color: #ffb07a; } .pu-timing.miss { color: #ff8a7a; }
.pu-grade { animation: puPop 0.45s 0.08s cubic-bezier(0.2, 1.35, 0.3, 1) both; }
@keyframes puPop {
  0% { opacity: 0; transform: scale(0.35) translateY(18px); filter: blur(2px); }
  60% { opacity: 1; transform: scale(1.12) translateY(-2px); filter: blur(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
.d-purify.pure { color: #9fe8ff; } .d-purify.clean { color: #9fe0a8; } .d-purify.rough { color: #f0d28a; } .d-purify.raw { color: #ff8a7a; }
.d-purify.danger {
  border-color: #ff5038 !important;
  box-shadow: 0 0 0 2px rgba(255, 80, 56, 0.85), 0 0 28px rgba(255, 60, 40, 0.55), inset 0 0 18px rgba(255, 40, 30, 0.18) !important;
  animation: puDangerFlash 0.35s ease-in-out infinite alternate;
}
.d-purify.danger .pu-hint { color: #ffb0a0; font-weight: 700; }
@keyframes puDangerFlash {
  from { border-color: #ff5038; }
  to { border-color: #ffd0a0; box-shadow: 0 0 0 2px rgba(255, 180, 80, 0.9), 0 0 34px rgba(255, 70, 40, 0.7), inset 0 0 22px rgba(255, 50, 30, 0.28); }
}

/* --- GAME_JUICE §7: low-Vitality vignette, level-up banner --- */
.ui-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(120, 8, 16, var(--vig, 0)) 100%);
  opacity: 0; transition: opacity 0.2s;
}
.ui-vignette.on { opacity: 1; }
.ui-levelup {
  position: absolute; left: 50%; top: 18%; transform: translate(-50%, -12px) scale(0.9);
  opacity: 0; pointer-events: none; z-index: 5; text-align: center;
  font: 900 clamp(1.6rem, 4vw, 3rem) var(--title); letter-spacing: 0.18em;
  color: #ffe08a; text-shadow: 0 3px 0 #000, 0 0 28px rgba(255, 220, 120, 0.7);
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.2, 1.4, 0.3, 1);
}
.ui-levelup.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.ui-levelup em { display: block; margin-top: 0.35rem; font: 600 0.95rem var(--title); letter-spacing: 0.12em; color: var(--ink); font-style: normal; text-shadow: 0 1px 3px #000; }
.d-settings { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; padding: 1.2rem 1.4rem; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--gold-lo); border-radius: 6px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.55), inset 0 0 0 4px rgba(201,164,92,0.35); text-align: center; pointer-events: auto; }
.d-settings h3 { margin: 0 0 0.4rem; color: var(--gold-hi); font: 700 1.2rem var(--title); }
.d-settings .d-go.on { border-color: var(--gold-hi); box-shadow: 0 0 12px rgba(240,210,138,0.4); }

/* --- delve: character sheet, class skill, mastery --- */
.d-build { width: min(62rem, calc(100vw - 2rem)); pointer-events: auto; text-align: left; }
.d-build h3 { text-align: center; } .b-hint { color: var(--ink-soft); font-size: 0.85rem; text-align: center; margin: 0.2rem 0 0.8rem; }
.b-grid { display: grid; grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.6fr); gap: 1.4rem; }
@media (max-width: 760px) { .b-grid { grid-template-columns: 1fr; } }
.b-row { display: block; margin: 0.5rem 0; font-size: 0.85rem; color: var(--ink); }
.b-row span { display: block; margin-bottom: 0.15rem; } .b-row b { color: var(--gold-hi); font-size: 1.05rem; } .b-row em { color: var(--ink-soft); font-style: normal; font-size: 0.75rem; }
.b-row input[type=range] { width: 100%; accent-color: #d8b050; } .b-row select { width: 100%; background: #17110c; color: var(--ink); border: 1px solid var(--gold-lo); padding: 0.3rem; border-radius: 3px; }
.b-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem 0.8rem; margin-bottom: 0.7rem; }
.b-stats span { font-size: 0.8rem; color: var(--ink); } .b-stats b { display: block; font: 800 1.35rem var(--title); color: var(--gold-hi); font-variant-numeric: tabular-nums; } .b-stats em { display: block; font-style: normal; font-size: 0.68rem; color: var(--ink-soft); }
.b-tiers { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.b-tiers th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 0.15rem 0.4rem; border-bottom: 1px solid var(--gold-lo); }
.b-tiers td { padding: 0.18rem 0.4rem; border-bottom: 1px solid rgba(120, 96, 60, 0.25); }
.b-tiers tr.success td:nth-child(4) { color: var(--good); } .b-tiers tr.weakened td:nth-child(4) { color: var(--warn); } .b-tiers tr.fizzle td:nth-child(4), .b-tiers tr.backlash td:nth-child(4), .b-tiers tr.surge td:nth-child(4) { color: #ff9a8a; }
.b-skill { margin-top: 0.5rem; font-size: 0.82rem; color: var(--ink); } .b-skill b { color: var(--gold-hi); margin-right: 0.3rem; } .b-skill em { color: var(--ink-soft); font-style: normal; }
.d-slot .mast { position: absolute; top: 1px; right: 3px; font: 800 0.66rem var(--font); color: #9fdcff; text-shadow: 0 1px 2px #000; }
.d-slot .mast.done { color: #ffe08a; font-size: 0.8rem; }
.d-slot .ch { position: absolute; bottom: 2px; left: 3px; z-index: 2; font: 800 0.62rem var(--font); color: #e8c878; text-shadow: 0 0 4px #000, 0 0 6px rgba(232,200,120,0.55); }
.d-slot.channel { box-shadow: inset 0 0 0 1px rgba(232,200,120,0.45), inset 0 0 12px #000; }
.d-slot.skill b { color: #9fdcff; }

/* --- delve: the turbine, the dry run, scrolls --- */
.pu-row.wheel b { border-radius: 50%; }
.d-try-title { margin-top: 0.7rem; font: 700 0.74rem var(--title); letter-spacing: 0.06em; color: var(--gold-hi); text-align: left; }
.d-try { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.3rem 0; }
.d-try .d-rune { padding: 0.15rem 0.5rem; font-size: 0.72rem; }
.d-try-out { font: 0.8rem ui-monospace, Menlo, Consolas, monospace; color: #9fdcff; text-align: left; min-height: 1.1rem; }

/* --- monster feel: boss health bar + entrance beat & elite affix styling --- */
.d-boss-hud {
  position: absolute; top: 0.9rem; left: 50%; transform: translateX(-50%);
  width: min(32rem, 62vw); padding: 0.45rem 0.75rem 0.55rem;
  background: linear-gradient(180deg, rgba(28, 16, 14, 0.9), rgba(12, 8, 8, 0.92));
  border: 1px solid #c97a4a; border-radius: 5px;
  box-shadow: 0 0 0 1px #000, 0 6px 20px rgba(0, 0, 0, 0.85), inset 0 0 14px rgba(255, 80, 48, 0.18);
  pointer-events: none; z-index: 6;
  transition: transform 0.28s cubic-bezier(0.2, 1.3, 0.3, 1);
}
.d-boss-hud.intro {
  transform: translateX(-50%) scale(1.06);
  box-shadow: 0 0 0 1px #000, 0 0 28px rgba(255, 96, 64, 0.65), inset 0 0 18px rgba(255, 160, 96, 0.35);
}
.d-boss-hud.shake { animation: barShake 0.28s ease-out; }
.d-boss-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.28rem; gap: 0.6rem; }
.d-boss-name { font: 900 1.02rem var(--title); letter-spacing: 0.1em; color: #ffca88; text-shadow: 0 2px 0 #000, 0 0 10px rgba(255, 110, 60, 0.6); }
.d-boss-phase { font: 700 0.74rem var(--title); letter-spacing: 0.08em; text-transform: uppercase; color: #ff8a6a; text-shadow: 0 1px 2px #000; }
.d-boss-track { position: relative; height: 0.62rem; background: #090505; border: 1px solid #5a2e22; border-radius: 3px; overflow: hidden; box-shadow: inset 0 1px 4px #000; }
.d-boss-chip { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 210, 160, 0.55); z-index: 1; }
.d-boss-fill { position: absolute; left: 0; top: 0; bottom: 0; display: block; background: linear-gradient(90deg, #8a1812, #e03824 55%, #ff8a50); box-shadow: 0 0 10px rgba(255, 90, 60, 0.65); z-index: 2; transition: width 0.08s ease-out; }
.d-boss-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 230, 180, 0.75); box-shadow: 0 0 3px #000; z-index: 3; text-decoration: none; }
.d-label.elite { width: auto; min-width: 5.2rem; padding: 0.08rem 0.35rem 0.16rem; background: rgba(10, 8, 12, 0.68); border: 1px solid var(--affix-col, #ffd060); border-radius: 3px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.75); overflow: hidden; }
.d-label.elite b { color: var(--affix-col, #ffd060); font-size: 0.78rem; }
.d-label.elite i { background: linear-gradient(90deg, var(--affix-col, #ffd060), #ffffff); }
.d-affix-tag { font-style: normal; font-weight: 800; text-shadow: 0 1px 2px #000; }

/* ========== HUD v2 — luminous anime-fantasy (docs/art/HUD_DESIGN.md) ========== */
.hud-notify {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  z-index: 20; max-width: min(28rem, 72vw); min-width: 14rem;
  padding: 0.7rem 1.05rem 0.85rem; pointer-events: none;
  background: linear-gradient(180deg, var(--hud-ivory), var(--hud-cream));
  color: var(--hud-navy);
  border: 1px solid var(--hud-gold-lo, var(--gold-lo));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 250, 240, 0.55);
  font: 500 0.95rem/1.4 var(--font);
  text-align: left;
}
.hud-notify[hidden] { display: none !important; }
.hud-notify .hud-notify-who,
.hud-notify > b {
  display: block; margin-bottom: 0.3rem;
  font: 700 0.88rem var(--title); letter-spacing: 0.06em; color: #6a4a1e;
}
.hud-notify p { margin: 0 0 0.3rem; }
.hud-notify p:last-child { margin-bottom: 0; }
.hud-notify[data-kind="guide"] { border-color: #8a6a40; }
.hud-notify[data-kind="bad"],
.hud-notify[data-kind="warn"] { border-color: var(--bad); }
.hud-notify[data-kind="good"] { border-color: var(--good); }

html.hud-v2 .guide-toast { display: none !important; } /* routed through .hud-notify */
html.hud-v2 .story-toast { display: none !important; }

html.hud-v2 .frame,
html.hud-v2 .overlay,
html.hud-v2 .prompt,
html.hud-v2 .hotbar,
html.hud-v2 .d-bar,
html.hud-v2 .d-modal,
html.hud-v2 .d-settings {
  background: linear-gradient(180deg, rgba(28, 36, 64, 0.94), var(--hud-navy-glass));
  border-color: var(--hud-gold);
  box-shadow:
    inset 0 0 0 1px rgba(207, 214, 222, 0.22),
    inset 0 0 0 3px rgba(20, 28, 56, 0.45),
    0 10px 28px rgba(0, 0, 0, 0.45);
}

html.hud-v2 .player-frame {
  width: 23.5rem; padding: 0.75rem 1rem 0.75rem 0.75rem;
  gap: var(--hud-gap);
}
html.hud-v2 .pname { color: var(--hud-gold-hi); font-size: 1.1rem; }
html.hud-v2 .ptitle { color: var(--hud-silver); margin-bottom: 0.35rem; }
html.hud-v2 .bar {
  height: 1.05rem; margin: 0.28rem 0; border-radius: 3px;
  background: rgba(8, 10, 20, 0.9); border-color: rgba(207, 214, 222, 0.25);
  box-shadow: inset 0 1px 3px #000, 0 0 0 1px rgba(160, 122, 52, 0.45);
}
html.hud-v2 .bar span { font-size: 0.72rem; line-height: 1.05rem; letter-spacing: 0.03em; }
html.hud-v2 .inv { gap: 0.25rem 0.85rem; color: var(--hud-silver); margin-top: 0.3rem; }

html.hud-v2 .toasts {
  top: auto; bottom: 7.2rem; left: 1rem; max-width: 22rem; gap: 0.35rem;
}
html.hud-v2 .toast {
  background: var(--hud-navy-glass);
  border: 1px solid rgba(201, 162, 74, 0.45);
  border-left: 3px solid var(--hud-gold);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  color: var(--hud-cream);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
html.hud-v2 .toast.place { color: var(--hud-gold-hi); }

html.hud-v2 .map-box { width: 14rem; gap: 0.5rem; }
html.hud-v2 .minimap {
  width: 12.2rem; height: 12.2rem;
  border: 3px solid var(--hud-gold);
  box-shadow:
    0 0 0 1px rgba(207, 214, 222, 0.5),
    0 0 0 5px rgba(20, 28, 56, 0.85),
    0 10px 24px rgba(0, 0, 0, 0.55),
    inset 0 0 18px rgba(90, 140, 200, 0.12);
  background: #0a0e1a;
}
html.hud-v2 .compass { width: 12.2rem; height: 12.2rem; margin-left: -6.1rem; }
html.hud-v2 .status {
  background: var(--hud-navy-glass);
  border: 1px solid rgba(201, 162, 74, 0.4);
  border-radius: 4px;
  padding: 0.4rem 0.65rem;
}
html.hud-v2 .w-gauge .g-track {
  height: 0.55rem; border-radius: 3px;
  border-color: rgba(201, 162, 74, 0.5);
  background: rgba(8, 10, 20, 0.95);
}

html.hud-v2 .hotbar {
  gap: 0.45rem; padding: 0.55rem 0.7rem;
  bottom: 1rem;
}
html.hud-v2 .slot {
  width: var(--hud-slot); height: calc(var(--hud-slot) + 0.15rem);
  border-radius: 5px;
  overflow: hidden;
  background: rgba(10, 12, 24, 0.92);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.45), inset 0 0 14px #000;
}
html.hud-v2 .slot .cd,
html.hud-v2 .d-slot .cd {
  border-radius: 4px;
}
html.hud-v2 .slot .key,
html.hud-v2 .d-slot .k {
  top: auto; left: 50%; right: auto; bottom: 0.12rem;
  transform: translateX(-50%);
  min-width: 1.85rem; height: 1.05rem; line-height: 1.05rem;
  padding: 0 0.35rem; text-align: center;
  font: 800 0.7rem/1.05rem var(--title);
  letter-spacing: 0.03em;
  color: var(--hud-navy);
  background: linear-gradient(180deg, var(--hud-ivory), var(--hud-cream));
  border: 1px solid var(--hud-gold);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  text-shadow: none;
  z-index: 4;
  pointer-events: none;
}
html.hud-v2 .slot .cost {
  bottom: 0.2rem; right: 0.25rem;
  font-size: 0.7rem; color: var(--hud-mp-hi, var(--mp-hi));
}
html.hud-v2 .slot-tip {
  bottom: 6.4rem;
  background: var(--hud-navy-glass);
  border: 1px solid rgba(201, 162, 74, 0.45);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
}
html.hud-v2 .hint {
  bottom: 9.4rem;
  font-size: 0.88rem;
  color: var(--hud-cream);
  letter-spacing: 0.05em;
}
html.hud-v2 .hint.act {
  color: var(--hud-gold-hi);
  padding: 0.35rem 0.85rem;
  background: var(--hud-navy-glass);
  border: 1px solid var(--hud-gold);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
html.hud-v2 .hint.act::before {
  border-color: var(--hud-gold);
  background: linear-gradient(180deg, var(--hud-ivory), var(--hud-cream));
  color: var(--hud-navy);
  text-shadow: none;
  border-radius: 3px;
  font-weight: 800;
}

/* Delve top ribbon + W gauge */
html.hud-v2 .d-top {
  width: auto; min-width: 15.5rem; max-width: 22rem;
  padding: 0.55rem 0.85rem 0.65rem;
  background: var(--hud-navy-glass);
  border: 1px solid rgba(201, 162, 74, 0.55);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(207, 214, 222, 0.18), 0 8px 20px rgba(0, 0, 0, 0.4);
}
html.hud-v2 .d-depth {
  font: 800 1.15rem/1.15 var(--title);
  letter-spacing: 0.12em;
  color: var(--hud-gold-hi);
  text-shadow: 0 1px 0 #000, 0 0 12px rgba(240, 214, 144, 0.25);
}
html.hud-v2 .d-air {
  height: 0.48rem; margin: 0.4rem 0 0.2rem;
  border-radius: 3px; border-color: rgba(201, 162, 74, 0.45);
  background: rgba(8, 10, 20, 0.95);
}
html.hud-v2 .d-airname {
  font-size: 0.8rem; letter-spacing: 0.1em; color: var(--hud-cream);
}
html.hud-v2 .d-coins {
  margin-top: 0.25rem; font-size: 0.82rem; color: var(--hud-gold-hi);
  letter-spacing: 0.03em;
}

html.hud-v2 .d-map {
  width: 12rem; height: 12rem;
  background: rgba(10, 14, 28, 0.78);
  border: 2px solid var(--hud-gold);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(207, 214, 222, 0.35),
    0 8px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 16px rgba(90, 140, 200, 0.1);
}
html.hud-v2 .d-map.open { width: 20rem; height: 20rem; }

html.hud-v2 .d-feed {
  top: 8.6rem; left: 1rem; gap: 0.28rem; max-width: 22rem;
  font-size: 0.8rem; color: var(--hud-silver);
}
html.hud-v2 .d-feed div {
  padding: 0.2rem 0.55rem;
  background: rgba(20, 28, 56, 0.55);
  border-left: 2px solid rgba(201, 162, 74, 0.45);
  border-radius: 0 3px 3px 0;
  max-width: 22rem;
}

html.hud-v2 .d-bottom {
  bottom: 1rem; gap: 1.1rem; align-items: flex-end;
}
html.hud-v2 .d-bar {
  gap: 0.55rem; padding: 0.55rem 0.75rem 0.7rem;
  margin-bottom: 0.45rem;
  border-radius: 8px;
}

/* hud-v2: keep navy/gold chrome, restore glossy round orbs (vials read worse than baseline) */
html.hud-v2 .orb {
  width: 5.6rem; height: 5.6rem; border-radius: 50%;
  border: 3px solid var(--hud-gold);
  background: radial-gradient(circle at 50% 35%, #243056, #080a14);
  box-shadow:
    0 0 0 2px #000,
    0 0 0 5px rgba(201, 162, 74, 0.55),
    0 8px 20px rgba(0, 0, 0, 0.5),
    inset 0 -10px 20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
html.hud-v2 .orb::after {
  inset: 8% 18% 55% 18%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent);
}
html.hud-v2 .orb.hp i.fill {
  background: radial-gradient(circle at 40% 30%, #ff8a6a, #b0201a 45%, #4a0806);
  box-shadow: none;
}
html.hud-v2 .orb.mp i.fill {
  background: radial-gradient(circle at 40% 30%, #9ad8ff, #2050c0 45%, #08143a);
  box-shadow: none;
}
html.hud-v2 .orb .chip { border-radius: 0; }
html.hud-v2 .orb.low { animation: pulse 0.7s infinite alternate; }
html.hud-v2 .orb.ward {
  box-shadow: 0 0 0 2px #000, 0 0 0 5px #e8c870, 0 0 22px #ffd870, inset 0 -10px 20px rgba(0, 0, 0, 0.45);
}
html.hud-v2 .orb .vial-read {
  position: absolute; left: 0; right: 0; bottom: 18%; z-index: 3;
  text-align: center; font: 800 0.72rem var(--font); color: #fff;
  text-shadow: 0 1px 2px #000; pointer-events: none; letter-spacing: 0.02em;
}

html.hud-v2 .d-slot {
  width: var(--hud-slot); height: calc(var(--hud-slot) + 0.15rem);
  border-radius: 5px;
  overflow: hidden;
  background: rgba(10, 12, 24, 0.92);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 74, 0.45), inset 0 0 14px #000;
}
html.hud-v2 .d-slot svg {
  inset: 0 0 1.05rem 0;
  height: auto;
  border-radius: 4px 4px 0 0;
}
html.hud-v2 .d-slot.basic,
html.hud-v2 .d-slot.dash,
html.hud-v2 .d-slot.pot {
  width: 3.45rem; height: 3.6rem; align-self: flex-end;
}
html.hud-v2 .d-slot .mana {
  bottom: 1.2rem; right: 0.25rem;
  font-size: 0.55rem; letter-spacing: 1px; color: var(--mp-hi);
}
html.hud-v2 .d-slot .mast {
  top: 0.15rem; right: 0.2rem;
}
html.hud-v2 .d-slot b {
  inset: 0 0 1.05rem 0;
}
html.hud-v2 .d-slot b {
  font-size: 1.45rem; color: var(--hud-gold-hi);
}
html.hud-v2 .d-xp {
  bottom: 0.3rem; height: 0.32rem; width: min(34rem, 72vw);
  border-radius: 3px; background: rgba(8, 10, 20, 0.9);
  box-shadow: 0 0 0 1px rgba(201, 162, 74, 0.35);
}

html.hud-v2 .d-purify {
  bottom: 10.2rem;
  padding: 0.65rem 1.05rem 0.6rem;
  background: var(--hud-navy-glass);
  border: 1px solid var(--hud-gold);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(207, 214, 222, 0.2),
    0 0 24px rgba(120, 180, 255, 0.22),
    0 10px 28px rgba(0, 0, 0, 0.4);
  min-width: 18rem;
}
html.hud-v2 .d-purify.danger {
  background: rgba(48, 12, 14, 0.92);
}
html.hud-v2 .pu-name { font-size: 0.82rem; color: var(--hud-gold-hi); letter-spacing: 0.1em; }
html.hud-v2 .pu-row b {
  width: 2.45rem; height: 2.45rem; line-height: 2.45rem;
  border-radius: 5px;
  background: rgba(10, 12, 24, 0.9);
  border-color: rgba(201, 162, 74, 0.4);
}
html.hud-v2 .pu-hint { color: var(--hud-silver); font-size: 0.7rem; }

html.hud-v2 .d-boss-hud {
  top: 0.85rem;
  background: linear-gradient(180deg, rgba(36, 24, 40, 0.92), rgba(16, 12, 24, 0.94));
  border-color: #c97a4a;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(207, 214, 222, 0.15), 0 8px 22px rgba(0, 0, 0, 0.55), inset 0 0 14px rgba(255, 80, 48, 0.15);
}
html.hud-v2 .d-banner {
  top: 11%;
  font-weight: 800;
  letter-spacing: 0.14em;
}
html.hud-v2 .d-party { left: 18.5rem; top: 0.9rem; }
html.hud-v2 .d-mate {
  background: var(--hud-navy-glass);
  border-color: rgba(201, 162, 74, 0.45);
  border-radius: 5px;
  padding: 0.4rem 0.6rem 0.5rem;
}

html.hud-v2 .goals {
  background: linear-gradient(90deg, transparent, rgba(20, 28, 56, 0.78) 18%);
}
html.hud-v2 .ghead { color: var(--hud-gold); }

@media (max-width: 760px) {
  html.hud-v2 .orb { width: 4.2rem; height: 4.2rem; }
  html.hud-v2 .d-slot { width: 3.1rem; height: 3.1rem; }
  html.hud-v2 .slot { width: 3.1rem; height: 3.1rem; }
  html.hud-v2 .toasts { bottom: 6.2rem; }
}

/* --- Online M1 (Emberfall hub, ?online=1) --------------------------------- */
.online-chip {
  position: absolute; top: 0.7rem; right: 0.7rem; z-index: 40;
  font: 700 0.72rem/1.2 var(--title); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.35rem 0.7rem; border-radius: 3px; cursor: pointer;
  background: rgba(18, 14, 10, 0.88); border: 1px solid var(--gold-lo); color: var(--ink-soft);
}
.online-chip.online { border-color: #6fd8a8; color: #b8f0d0; }
.online-chip.connecting { border-color: #e0c068; color: #f0e0a0; }
.online-chip.offline { border-color: var(--gold-lo); }

.online-town-btn, .online-chat-toggle {
  position: absolute; top: 0.7rem; z-index: 40;
  font: 700 0.7rem/1.2 var(--title); letter-spacing: 0.03em; text-transform: uppercase;
  padding: 0.32rem 0.65rem; border-radius: 3px; cursor: pointer;
  background: rgba(18, 14, 10, 0.88); border: 1px solid var(--gold-lo); color: var(--gold-hi);
}
.online-town-btn { right: 9.2rem; }
.online-chat-toggle { right: 14.2rem; }

.online-hint {
  position: absolute; left: 50%; bottom: 6.5rem; transform: translateX(-50%);
  z-index: 35; max-width: min(28rem, 90vw); text-align: center;
  padding: 0.4rem 0.9rem; font: 600 0.85rem/1.35 var(--body); color: var(--ink);
  background: rgba(12, 10, 8, 0.78); border: 1px solid rgba(201, 164, 92, 0.45); border-radius: 3px;
  pointer-events: none;
}

.online-chat {
  position: absolute; left: 0.8rem; bottom: 6.2rem; z-index: 42;
  width: min(22rem, calc(100vw - 1.6rem)); height: 14rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 0.55rem 0.65rem 0.6rem;
  background: rgba(12, 10, 8, 0.9); border: 1px solid var(--gold-lo); border-radius: 4px;
  box-shadow: inset 0 0 0 3px rgba(201, 164, 92, 0.2), 0 8px 20px #000;
}
.online-chat[hidden] { display: none !important; }
.online-chat-toggle[hidden], .online-town-btn[hidden], .online-chip[hidden] { display: none !important; }
.online-chat header {
  font: 700 0.78rem/1.2 var(--title); color: var(--gold); letter-spacing: 0.04em; text-transform: uppercase;
}
.online-chat-tabs { display: flex; gap: 0.35rem; }
.online-chat-tabs button, .online-auth-tabs button {
  font: 700 0.68rem/1 var(--title); text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.25rem 0.55rem; border-radius: 2px; cursor: pointer;
  background: #2a2016; border: 1px solid var(--gold-lo); color: var(--ink-soft);
}
.online-chat-tabs button.on, .online-auth-tabs button.on { background: var(--gold-lo); color: #1a120c; }
.online-chat-log {
  flex: 1; overflow-y: auto; font: 500 0.78rem/1.35 var(--body); color: var(--ink-soft);
  border-top: 1px solid rgba(201, 164, 92, 0.25); padding-top: 0.3rem;
}
.online-chat-line { margin: 0.15rem 0; }
.online-chat-line b { color: var(--gold-hi); margin-right: 0.35rem; font-weight: 800; }
.online-chat-line.ch-whisper b { color: #c8b0f0; }
.online-chat-form, .online-chat-whisper { display: flex; gap: 0.35rem; }
.online-chat input, .online-auth-form input {
  flex: 1; min-width: 0; padding: 0.35rem 0.5rem;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--gold-lo); border-radius: 2px;
  color: var(--ink); font: 500 0.82rem/1.2 var(--body);
}
.online-chat-form button {
  font: 700 0.7rem/1 var(--title); text-transform: uppercase;
  padding: 0.35rem 0.6rem; cursor: pointer;
  background: var(--gold-lo); border: 1px solid var(--gold); color: #1a120c; border-radius: 2px;
}

.online-modal.overlay { z-index: 60; }
.online-modal.prompt { z-index: 55; }
.online-auth-form { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.online-auth-form label { font: 700 0.72rem/1.2 var(--title); color: var(--gold); letter-spacing: 0.03em; text-transform: uppercase; }
.online-auth-tabs { display: flex; gap: 0.4rem; margin: 0.5rem 0; }
.online-auth-actions, .online-station-actions {
  display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.75rem;
}
.online-auth-actions button, .online-station-actions button {
  font: 700 0.75rem/1.2 var(--title); padding: 0.45rem 0.75rem; cursor: pointer;
  background: var(--gold-lo); border: 1px solid var(--gold); color: #1a120c; border-radius: 3px;
}
.online-auth-actions button.ghost, .online-station-actions button.ghost {
  background: transparent; color: var(--ink-soft); border-color: var(--gold-lo);
}
.online-err { color: var(--bad); font-size: 0.85rem; }
.online-modal .muted, .online-chat .muted { color: var(--ink-soft); opacity: 0.85; font-size: 0.82rem; }

.online-portal-board, .online-portal-reward {
  max-width: min(42rem, 94vw); max-height: 82vh; overflow: auto;
}
.online-portal-list { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.75rem 0 1rem; }
.online-portal-row {
  display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.75rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--gold-lo); border-radius: 4px;
  background: rgba(20, 14, 10, 0.45);
}
.online-portal-row.closed { opacity: 0.55; }
.online-portal-row .title { font: 700 0.95rem/1.25 var(--title); color: var(--gold-hi); grid-column: 1 / -1; }
.online-portal-row .meta { font-size: 0.78rem; color: var(--ink-soft); grid-column: 1 / 2; }
.online-portal-row button { align-self: center; }
.online-portal-lb { margin: 0.5rem 0 1rem; padding-left: 1.2rem; font-size: 0.85rem; }

@media (max-width: 760px) {
  .online-chip { top: 0.45rem; right: 0.45rem; font-size: 0.65rem; }
  .online-town-btn { right: 7.6rem; top: 0.45rem; }
  .online-chat-toggle { right: 0.45rem; top: 2.4rem; }
  .online-chat { left: 0.45rem; bottom: 5.6rem; height: 11rem; }
  .online-hint { bottom: 5.2rem; }
}

/* PM QA fix: the 9-slice bar border ate the bar's content box and clipped its label */
html.ui-skinned .bar { height: calc(1.05rem + 2 * var(--ui-bar-width, 4px)); overflow: hidden; }
html.ui-skinned .bar span { line-height: 1.05rem; }
/* PM QA fix: the player frame shows the mage herself, not a letter */
.portrait.mage-face { width: 4.2rem; height: 4.2rem; border-radius: 50%; border: 3px solid var(--ring, #c9a45c);
  box-shadow: 0 0 0 2px #000, 0 0 0 4px rgba(201, 164, 92, 0.55), inset 0 0 12px #000;
  background-color: #1b1a2a; background-repeat: no-repeat; background-size: 330%; background-position: 50% 14%;
  image-rendering: pixelated; flex: none; }

/* Cinzel has no Vietnamese glyphs: use Alegreya Sans (self-hosted vi subset) for titles in Vietnamese */
html[lang="vi"] { --title: "Alegreya Sans", system-ui, sans-serif; }

/* PM QA fix: the portal settlement sizes to its content and uses the HUD button style */
.online-portal-reward { height: auto !important; max-height: 70vh; width: min(30rem, 92vw) !important; bottom: auto !important; right: auto !important; left: 50% !important; top: 18% !important; transform: translateX(-50%); overflow: auto; }
.online-modal button { appearance: none; font: 700 0.8rem var(--font); letter-spacing: 0.04em; color: #f3e6c4; background: linear-gradient(180deg, #2a3350, #161c30); border: 1px solid rgba(201, 164, 92, 0.7); border-radius: 3px; padding: 0.4rem 1rem; cursor: pointer; box-shadow: 0 1px 0 #000; }
.online-modal button:hover { border-color: #e6c27a; color: #fff6dc; }
.online-modal button:disabled { opacity: 0.45; cursor: default; }

/* Meadow skills HUD: compact status, delve-style hotbar, aim, declutter */
.player-frame.meadow-compact {
  width: auto; max-width: 11rem; padding: 0.3rem 0.55rem; gap: 0.2rem;
  align-items: flex-start;
  background: rgba(12, 14, 28, 0.72);
  box-shadow: inset 0 0 0 1px rgba(201, 164, 92, 0.35), 0 4px 12px rgba(0,0,0,0.35);
}
.player-frame.meadow-compact .portrait { display: none; }
.player-frame.meadow-compact .bar.hp,
.player-frame.meadow-compact .bar.pool,
.player-frame.meadow-compact .inv,
.player-frame.meadow-compact .ward { display: none; }
.player-frame.meadow-compact .pname { font-size: 0.78rem; letter-spacing: 0.04em; }
.player-frame.meadow-compact .ptitle { font-size: 0.66rem; margin: 0; opacity: 0.9; }
.player-frame.meadow-compact .bar.xp { height: 0.55rem; margin: 0.15rem 0 0; }
.player-frame.meadow-compact .bar.xp span { font-size: 0.55rem; line-height: 0.55rem; }

.meadow-bottom {
  position: absolute; left: 50%; bottom: 0.7rem; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 0.55rem; z-index: 20;
  pointer-events: none;
}
.meadow-bottom .hotbar,
.meadow-bottom .d-bar,
.meadow-bottom .orb { pointer-events: auto; }
.meadow-bottom .hotbar {
  position: static; left: auto; bottom: auto; transform: none;
  margin: 0;
}
.meadow-bottom .d-slot button,
.meadow-bottom button.d-slot {
  appearance: none; border: none; padding: 0; color: inherit; font: inherit;
}

.aim-reticle {
  position: fixed; top: 0; left: 0; width: 14px; height: 14px; z-index: 15;
  border: 1.5px solid rgba(240, 220, 160, 0.85); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.45), inset 0 0 4px rgba(255,230,160,0.25);
  pointer-events: none; opacity: 0; transition: opacity 0.08s;
}
.aim-reticle.on-target { border-color: #ff8a6a; box-shadow: 0 0 0 1px #000, 0 0 10px rgba(255,100,80,0.45); }
.aim-line {
  position: fixed; top: 0; left: 0; height: 1px; z-index: 14;
  background: linear-gradient(90deg, transparent, rgba(230, 210, 150, 0.55));
  transform-origin: 0 50%; pointer-events: none; opacity: 0;
}

/* Quest tracker is a map-box child: flows under calendar/W with the flex gap */
.map-box > .goals.goals-compact {
  position: static; top: auto; right: auto;
  width: 100%; max-width: 100%;
  margin: 0; padding: 0.35rem 0.5rem;
  text-align: center;
  background: rgba(12, 14, 28, 0.72);
  border: 1px solid rgba(201, 164, 92, 0.35);
  border-radius: 4px;
  box-shadow: none;
}
.map-box > .goals.goals-compact:not(.expanded) .quest,
.map-box > .goals.goals-compact:not(.expanded) .qstep { display: none; }
.map-box > .goals.goals-compact .ghead {
  font: 700 0.72rem/1.25 var(--title); color: var(--gold-hi);
  letter-spacing: 0.03em; cursor: default;
  border-bottom: none; padding-bottom: 0; margin-bottom: 0;
  text-transform: none;
}
.map-box > .goals.goals-compact.expanded {
  padding: 0.45rem 0.55rem;
  text-align: right;
  background: rgba(12, 14, 28, 0.88);
}
.map-box > .goals.goals-compact.expanded .ghead {
  border-bottom: 1px solid rgba(201, 164, 92, 0.35);
  padding-bottom: 0.2rem; margin-bottom: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
html.hud-v2 .map-box { gap: 0.65rem; }
html.hud-v2 .map-box > .goals.goals-compact {
  background: rgba(20, 28, 56, 0.82);
  border-color: rgba(201, 162, 74, 0.4);
  margin-top: 0.15rem;
}

.slot-tip .tip-blurb { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.1rem; }
.slot-tip .tip-cost { font-size: 0.72rem; color: #7fc0ff; margin-top: 0.05rem; }

.target-frame.hover-aim { outline: 1px solid rgba(255, 160, 120, 0.55); }

/* Keep the centre playfield clear: push toast feed down near the bar */
html.hud-v2 .toasts {
  top: auto; bottom: 6.4rem; left: 0.8rem; max-width: 18rem;
}
html.hud-v2 .zone-banner { display: none !important; }
html.hud-v2 .bark { display: none; } /* NPC bark yields the centre; journal/F covers talk */
html.hud-v2 .map-box .status { font-size: 0.7rem; padding: 0.25rem 0.45rem; }
html.hud-v2 .map-box .w-gauge { font-size: 0.68rem; }
html.hud-v2 .meadow-bottom .orb { width: 4.2rem; height: 4.2rem; }
html.hud-v2 .slot-tip { bottom: 5.6rem; }
