/* ui.css — shared HUD / panels / character-creation styles (index.html 2D game and proto3d.html 3D town).
   Tokens = project/UI_UX_SPEC.md §8 (ADR-005). Layout modes (§3.4): default = phone portrait;
   desktop = (min-width:900px) and (min-height:431px); phone landscape = (orientation:landscape) and (max-height:430px) (wins, comes last).
   All CSS, so an orientation change re-lays out live (no reload). */
:root {
  --ui-scale: 1;
  /* surfaces */ --c-bg: #1e272e; --c-surface: #2f3640; --c-surface-hud: rgba(30,39,46,.9); --c-overlay: rgba(20,24,30,.97); --c-border: #576574;
  --c-hud-soft: rgba(20,24,30,.55); --c-bar-bg: rgba(0,0,0,.55); --c-dim: rgba(0,0,0,.4);
  /* text */ --c-text: #ecf0f1; --c-text-dim: #b2bec3; --c-text-on-accent: #111; --c-zone: #dff0ff;
  /* accent + semantic */ --c-accent: #f1c40f; --c-primary: #0984e3; --c-gold: #e1b12c; --c-danger: #c0392b;
  --c-hp: #e74c3c; --c-sp: #3498db; --c-xp: #f1c40f; --c-ok: #2ecc71; --c-warn: #f1c40f; --c-bad: #e74c3c; --c-info: #1abc9c;
  /* type */ --f-ui: system-ui, sans-serif; --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 19px;
  /* space (4-pt) */ --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-6: 24px;
  /* shape */ --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px; --shadow-text: 0 1px 2px #000;
  /* touch */ --hit-min: 44px; --slot: 58px; --slot-phone: 44px;   /* 44 = the touch minimum; was 48 (HUD area 21% -> <= 20% at 375x667) */
  /* motion */ --t-fast: 120ms; --t-med: 200ms; --ease: cubic-bezier(.2,.7,.2,1);
  /* safe areas (needs viewport-fit=cover) + HUD geometry per mode (overridden in the media blocks below) */
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
  --edge: var(--s-2);
  --hud-fs: calc(11.5px * var(--ui-scale));
  --vitals-w: min(calc(186px * var(--ui-scale)), 48vw);
  --target-w: var(--vitals-w);
  --bar-h: calc(11px * var(--ui-scale));
  --atk: calc(56px * var(--ui-scale));
  --menu-btn: calc(42px * var(--ui-scale));
  --slot-gap: 6px; --mm: 56px;
  /* ORVANTHIA window palette (UI_STYLE_DIRECTION §1.1): wood title ribbon + slate plate, gold = things to press */
  --c-wood-d: #3b2a1a; --c-wood: #6b4a2b; --c-wood-l: #a67c4e; --c-parch: #f3e6c8; --c-bevel-hi: #8fb0d8; --c-bevel-lo: #06101c; --c-win: rgba(22,38,62,.96); --c-win-2: #1c3150; --c-up: #2ecc71; --c-down: #ff8a7a;
  --cell: 56px;
  /* 5 slots + attack button must fit one row on the narrowest phone: shrink slots before they collide */
  --slot-size: min(calc(var(--slot-phone) * var(--ui-scale)), calc((100vw - var(--sa-l) - var(--sa-r) - 2 * var(--edge) - var(--atk) - 12px - 4 * var(--slot-gap)) / 5));
  --zone-w: calc(46vw - 24px);
  --log-w: calc(100vw - var(--sa-l) - var(--sa-r) - 2 * var(--edge) - var(--atk) - var(--s-4));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--c-bg); color: var(--c-text); font-family: var(--f-ui); overflow: hidden; overscroll-behavior: none; }
body { max-width: 100vw; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
button { font: inherit; color: #fff; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 6px 10px; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .4; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
button.on, .row.on { border-color: var(--c-accent); }
small { color: var(--c-text-dim); font-weight: normal; }
.tag { color: var(--c-text-on-accent); border-radius: var(--r-sm); padding: 0 5px; font-size: var(--fs-xs); font-weight: bold; }
kbd { display: none; font: bold 10px var(--f-ui); color: var(--c-text-dim); border: 1px solid var(--c-border); border-radius: var(--r-sm); padding: 0 3px; background: rgba(0,0,0,.4); }
@media (hover: hover) and (pointer: fine) { kbd { display: inline-block; } }   /* key hints on desktop only (§6) */

/* creation + panels share the scroll sheet look */
#create, #panel { display: none; position: fixed; inset: 0; overflow-y: auto; padding: var(--s-4) 14px 80px; background: var(--c-overlay); z-index: 10; }
#create { padding: calc(var(--s-4) + var(--sa-t)) calc(14px + var(--sa-r)) calc(80px + var(--sa-b)) calc(14px + var(--sa-l)); }
#create > * { max-width: 720px; margin-left: auto; margin-right: auto; }
h1 { margin: 4px 0 12px; font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); margin: 18px 0 8px; } h3 { font-size: 15px; margin: 14px 0 6px; color: var(--c-accent); }
label input { width: 100%; margin-top: 4px; padding: 8px; border-radius: var(--r-md); border: 1px solid var(--c-border); background: var(--c-surface); color: #fff; font: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-2); }
.card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.big { display: block; width: 100%; min-height: var(--hit-min); padding: 12px; margin-top: 12px; font-size: 16px; font-weight: bold; background: var(--c-primary); border: none; }
.gold { background: var(--c-gold); color: var(--c-text-on-accent); } .danger { background: var(--c-danger); }
.rolled { border: 2px solid; border-radius: 10px; padding: 10px; }
.srow { display: grid; grid-template-columns: 44px 1fr 44px 34px 44px; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--c-surface); }
#panel .srow { grid-template-columns: 44px 1fr 34px 44px; }
.srow button { min-height: var(--hit-min); }
.srow span small { display: block; font-size: var(--fs-xs); } .srow i { text-align: center; font-style: normal; font-weight: bold; }
.preview { background: var(--c-surface); padding: 10px; border-radius: var(--r-md); font-size: var(--fs-md); }
.row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); padding: 6px 4px; border-bottom: 1px solid var(--c-surface); border-left: 3px solid transparent; font-size: var(--fs-md); }
.row button { min-height: var(--hit-min); min-width: var(--hit-min); }
.slots { display: inline-flex; gap: 2px; } .slots button { padding: 4px 6px; min-width: var(--hit-min); min-height: var(--hit-min); }

/* ---- panels (P1–P8): one at a time, dim behind, header with title + close ---- */
#dim { display: none; position: fixed; inset: 0; background: var(--c-dim); z-index: 9; }
#panel { inset: auto; top: calc(var(--sa-t) + var(--edge)); bottom: calc(var(--sa-b) + var(--edge)); left: calc(var(--sa-l) + var(--edge)); right: calc(var(--sa-r) + var(--edge));
  background: linear-gradient(#1c3150, #142238); border: 1px solid var(--c-bevel-hi); border-radius: var(--r-lg); padding: 0; overflow: hidden; flex-direction: column; font-size: calc(var(--fs-md) * var(--ui-scale));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 2px 0 var(--c-bevel-lo), 0 8px 16px rgba(0,0,0,.35); }
/* title bar = wood ribbon with a gold under-line and a grip (RO-like draggable bar; drag is desktop-only) */
.phead { display: flex; align-items: center; gap: var(--s-2); padding: 4px 6px 4px 8px; background: linear-gradient(#5a4128, #3b2a1a); border-bottom: 2px solid var(--c-wood-l); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); flex: none; user-select: none; }
.grip { flex: none; width: 10px; height: 22px; opacity: .55; background: radial-gradient(circle, var(--c-parch) 1.2px, transparent 1.6px) 0 0 / 5px 6px; }
.ptitle { flex: 1; font-size: var(--fs-lg); font-weight: bold; margin: 0; color: var(--c-parch); text-shadow: 0 1px 0 #000; }
.pclose, .pback { width: var(--hit-min); height: var(--hit-min); padding: 0; font-size: 18px; flex: none; background: linear-gradient(#34506f, #1c3150); border: 1px solid var(--c-bevel-hi); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 1px 0 var(--c-bevel-lo); }
.pclose:active, .pback:active { background: #16263e; box-shadow: inset 0 2px 3px rgba(0,0,0,.6); }
#panel.dragging .phead { cursor: grabbing; }
#panel.open { display: flex !important; }
#panelbody { flex: 1; overflow-y: auto; padding: 4px 14px var(--s-6); overscroll-behavior: contain; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; margin: 10px 0 0; border-bottom: 2px solid var(--c-bevel-hi); }
.tabs button { flex: 1; min-height: var(--hit-min); padding: 4px 6px; font-size: var(--fs-md); background: #16263e; border: 1px solid var(--c-bevel-lo); border-bottom: none; border-radius: var(--r-md) var(--r-md) 0 0; color: var(--c-text-dim); }
.tabs button[aria-selected=true] { background: var(--c-win-2); border-color: var(--c-bevel-hi); border-top: 3px solid var(--c-accent); color: var(--c-accent); font-weight: bold; margin-bottom: -2px; }
.menugrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--s-2); margin-top: 12px; }
.menugrid button { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--fs-md); position: relative; }
.menugrid .ic { width: 32px; height: 32px; object-fit: contain; pointer-events: none; }
.gic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; object-fit: contain; }
.badge { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: var(--r-pill); background: var(--c-accent); color: var(--c-text-on-accent); border: 1px solid #7a5d00; display: flex; align-items: center; justify-content: center; }
.badge[hidden] { display: none; }
.badge .tri { border-left-width: 4px; border-right-width: 4px; border-bottom-width: 7px; margin-top: -1px; }
.menugrid .sub { display: block; font-size: var(--fs-xs); color: var(--c-accent); }
.optrow { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin: 6px 0 12px; }
.optrow button { min-height: var(--hit-min); min-width: 64px; }
.confirm { border: 1px solid var(--c-danger); border-radius: var(--r-md); padding: 10px; margin-top: 12px; }
.empty { color: var(--c-text-dim); padding: var(--s-4) 0; }
button.dis, button[aria-disabled=true] { opacity: .45; }                          /* looks disabled but stays focusable/tappable: the reason line (.why) explains */
.why { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--c-warn); background: var(--c-surface); border-radius: var(--r-sm); font-size: var(--fs-md); }
.why.shake { animation: shake .3s; }
.eff { font-weight: bold; white-space: nowrap; }
.req { white-space: nowrap; } .req .mk { font-size: 1.25em; line-height: 1; margin-right: 1px; } .req.ok { color: var(--c-ok); } .req.low { color: var(--c-warn); }
.wi { width: 20px; height: 20px; margin-right: 6px; vertical-align: -4px; }
.gloss { margin: 12px 0; } .gloss summary { cursor: pointer; min-height: var(--hit-min); display: flex; align-items: center; font-size: 15px; font-weight: bold; color: var(--c-accent); }
.gloss summary::before { content: '▸'; margin-right: 8px; } .gloss[open] summary::before { content: '▾'; }
.gloss dl { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--c-surface); } .gloss dt { font-weight: bold; } .gloss dd { margin: 2px 0 0; color: var(--c-text-dim); }

/* ---- HUD ---- */
#hud { display: none; font-size: var(--hud-fs); }
#hud .box { background: var(--c-hud-soft); border-radius: var(--r-md); padding: 5px 8px; text-shadow: var(--shadow-text); }
#tl { position: fixed; top: calc(var(--sa-t) + var(--edge)); left: calc(var(--sa-l) + var(--edge)); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#top { width: var(--vitals-w); }
#who { display: flex; gap: 6px; white-space: nowrap; font-weight: bold; line-height: 18px; }
#who .nm { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#who .lv { flex: none; }
#gold { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 3px; white-space: nowrap; font-weight: bold; font-size: 11px; line-height: 15px; }
#gold .gd { color: var(--c-gold); flex: none; margin-left: auto; }   /* chip left, coin + number right, under the XP bar */
/* free-stat-points chip: amber pill with a CSS triangle (no image). Visual height 17 px; the real hit area is >= 44 px tall via ::after (grows down/sideways, not up over the XP bar) */
.chip { position: relative; display: inline-flex; align-items: center; gap: 4px; height: 17px; padding: 0 7px 0 5px; border: 1px solid #7a5d00; border-radius: var(--r-pill); background: var(--c-accent); color: var(--c-text-on-accent); font: bold 11px/15px var(--f-ui); text-shadow: none; min-width: 0; }
.chip[hidden] { display: none; }
.chip::after { content: ''; position: absolute; left: -8px; right: -8px; top: 2px; height: var(--hit-min); }
.chip:active { transform: scale(.96); }
.tri { display: inline-block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid currentColor; flex: none; }
.bar { position: relative; height: var(--bar-h); background: var(--c-bar-bg); border-radius: var(--r-sm); margin-top: 3px; overflow: hidden; }
.bar div { height: 100%; } .bar span { position: absolute; inset: 0; text-align: center; font-size: var(--fs-xs); line-height: var(--bar-h); }
/* Ragnarok-style status window: bevelled bluish panel, label + bar rows, glossy fills */
#hud #top { background: rgba(22,38,62,.82); border: 1px solid #8fb0d8; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.vrow { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.vrow .bar { flex: 1; margin-top: 0; border-radius: 2px; border: 1px solid #06101c; background: #0b1624; box-shadow: inset 0 1px 2px rgba(0,0,0,.7); }
.vrow .bar::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgba(255,255,255,.38), rgba(255,255,255,.05)); pointer-events: none; }
.vl { width: 17px; font: bold 10px/1 var(--f-ui); color: #bcd6ff; text-shadow: 1px 1px 0 #000; letter-spacing: .3px; }
.vrow .bar span { line-height: calc(var(--bar-h) - 2px); font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
#hpbar.ok div { background: linear-gradient(#8be88b, #2f9f3a); } #hpbar.mid div { background: linear-gradient(#ffd45e, #d98a12); } #hpbar.crit div { background: linear-gradient(#ff8a7a, #c0271a); }
#spbar div { background: linear-gradient(#8fd2ff, #2166b8); } #xpwrap { padding: 6px 0; margin: -3px 0; cursor: pointer; } #xpwrap .bar { margin-top: 0; }
#xpbar { height: 10px; } #xpbar div { background: var(--c-xp); } #xpbar span { font-size: 9px; line-height: 10px; }
#top.dead { filter: grayscale(1); opacity: .7; }
#top.low #hpbar { animation: pulse 1s ease-in-out infinite; }
#target { display: none; width: var(--target-w); position: relative; padding-right: 48px; transition: opacity 1s; }
#target.on { display: block; }
#target.gone { opacity: .35; }
#target .tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
#target .tname small { margin-left: 4px; }
#target .bar div { background: var(--c-hp); }
#target .tx { position: absolute; top: 2px; right: 2px; width: var(--hit-min); height: var(--hit-min); padding: 0; background: transparent; border: none; font-size: 16px; }
#target.npc .bar { display: none; }
#tr { position: fixed; top: calc(var(--sa-t) + var(--edge)); right: calc(var(--sa-r) + var(--edge)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 5; }
#camctl { display: flex; gap: var(--s-2); }
.rot { width: var(--hit-min); height: var(--hit-min); padding: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.6); background: var(--c-hud-soft); color: #fff; font-size: 22px; cursor: pointer; touch-action: manipulation; }
#minimap { position: relative; width: var(--mm); height: var(--mm); padding: 0; border: 2px solid var(--c-border, #5a4a32); border-radius: 50%; overflow: hidden; background: var(--c-bar-bg); cursor: pointer; }
#mmc { display: block; width: 100%; height: 100%; }
#mapname { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 6px 3px; font-size: 10px; line-height: 1.1; color: var(--c-zone); background: rgba(0,0,0,.55); text-shadow: var(--shadow-text); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
#buffs { display: flex; flex-wrap: wrap; gap: 4px; max-width: var(--vitals-w); } #buffs:empty { display: none; }
.buff { display: inline-flex; align-items: center; gap: 3px; background: var(--c-hud-soft); border-radius: var(--r-pill); padding: 1px 8px 1px 3px; font-size: var(--fs-xs); white-space: nowrap; text-shadow: var(--shadow-text); } .buff small { color: var(--c-text-dim); }
.buff .bic { width: 20px; height: 20px; object-fit: contain; flex: none; } .buff.bad { border: 1px solid var(--c-bad); }
#fullmap { display: block; margin: 0 auto 8px; max-width: 100%; border: 2px solid var(--c-border, #5a4a32); border-radius: var(--r-md); }
.lgs { font-style: normal; display: inline-block; width: 1.2em; text-align: center; } .lgs.npc { color: #f1c40f; } .lgs.mob { color: #e74c3c; } .lgs.me { color: #fff; text-shadow: 0 0 2px #000; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 8px 10px; border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); background: rgba(0,0,0,.25); margin-top: 8px; font-size: var(--fs-md); } .legend b { flex: 0 0 100%; font-size: var(--fs-sm); color: var(--c-text-dim); }
.lbl { margin: 8px 0 0; color: var(--c-text-dim); font-size: var(--fs-sm); } .adv { margin-top: 4px; padding: 0 0 4px 10px; border-left: 3px solid var(--c-danger); }
#bl { position: fixed; left: calc(var(--sa-l) + var(--edge)); bottom: calc(var(--sa-b) + var(--edge) + var(--slot-size) + 10px); width: var(--log-w); max-width: 360px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; z-index: 5; }
#quest { display: none; font-size: var(--fs-sm); max-width: 100%; }
#quest.on { display: block; } #quest.done { color: var(--c-info); }
#log { font-size: var(--fs-sm); text-shadow: var(--shadow-text); max-width: 100%; cursor: pointer; border-radius: var(--r-md); padding: 2px 6px; background: var(--c-hud-soft); }
#log:empty { display: none; }
#log > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log > div:nth-last-child(n+4) { display: none; }            /* collapsed: last 3 lines */
#log.open { background: var(--c-overlay); padding: 6px 8px; }
#log.open > div { display: block; white-space: normal; }
#skillbar { position: fixed; bottom: calc(var(--sa-b) + var(--edge)); left: calc(var(--sa-l) + var(--edge)); display: flex; gap: var(--slot-gap); z-index: 5; }
.slot { position: relative; width: var(--slot-size); height: var(--slot-size); padding: 2px; font-size: var(--fs-xs); line-height: 1.15; border-width: 2px; overflow: hidden; background: var(--c-surface-hud); }
.slot i { position: absolute; left: 0; bottom: 0; width: 100%; background: rgba(0,0,0,.6); }
.slot span { position: relative; z-index: 1; display: block; overflow: hidden; max-height: 100%; word-break: break-word; }
.slot b { position: absolute; top: 1px; left: 3px; z-index: 2; font-size: 10px; color: var(--c-text-dim); }
.slot em { position: absolute; inset: 0; z-index: 2; display: none; align-items: center; justify-content: center; font: bold 16px var(--f-ui); color: #fff; text-shadow: var(--shadow-text); }
.slot.cd em { display: flex; }
.slot.nosp { box-shadow: inset 0 0 0 40px rgba(52,152,219,.35); }
.slot u { display: none; position: absolute; right: 2px; bottom: 1px; z-index: 2; text-decoration: none; font: bold 10px/1.1 var(--f-ui); color: #fff; background: rgba(33,102,184,.9); border-radius: var(--r-sm); padding: 0 3px; }
.slot.nosp u { display: block; }
.slot.empty { opacity: .55; }
.slot:active { transform: scale(.94); }
.slot.shake { animation: shake .3s; }
#br { position: fixed; right: calc(var(--sa-r) + var(--edge)); bottom: calc(var(--sa-b) + var(--edge)); display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); z-index: 5; }
#quick { display: flex; gap: var(--slot-gap); }
.qslot { width: var(--hit-min); height: var(--hit-min); }   /* hotkey slots 6/7 (ADR-010): reuse .slot; count badge = u */
.qslot .qic { width: 26px; height: 26px; object-fit: contain; margin-top: 8px; }
.qslot u { display: block; background: rgba(0,0,0,.65); }
.qslot.empty:not(.cd) { opacity: .55; }
#menubtn { position: relative; width: var(--menu-btn); height: var(--menu-btn); padding: 0; background: var(--c-surface-hud); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; }
#menubtn .mi { font-size: 22px; line-height: 22px; } #menubtn .ml { font-size: 10px; line-height: 11px; color: var(--c-text-dim); }
#menubtn .badge { top: -4px; right: -4px; }
#attack { width: var(--atk); height: var(--atk); padding: 0; border-radius: 50%; background: var(--c-danger); border: 2px solid #fff8; font-weight: bold; font-size: var(--fs-md); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#attack:active { transform: scale(.94); } #attack.idle { opacity: .65; }
#menubtn kbd, #attack kbd { font-size: 9px; }
#toasts { position: fixed; top: 30%; left: 50%; transform: translateX(-50%); width: min(80vw, 360px); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 8; pointer-events: none; }
.toast { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--c-overlay); border-left: 4px solid var(--c-border); border-radius: var(--r-md); padding: 6px 12px; font-size: var(--fs-md); text-align: center; animation: toastin var(--t-med) var(--ease); }
.toast .tg { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; color: var(--c-text-on-accent); background: var(--c-border); }
.toast.bad .tg { background: var(--c-bad); } .toast.success .tg { background: var(--c-accent); } .toast.info .tg { background: var(--c-info); }
.toast .tact { pointer-events: auto; margin-left: 8px; min-height: 32px; padding: 2px 10px; background: var(--c-primary); border: none; font-weight: bold; }
.toast.bad { border-color: var(--c-bad); } .toast.success { border-color: var(--c-accent); } .toast.info { border-color: var(--c-info); }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3; box-shadow: inset 0 0 90px 20px rgba(231,76,60,.55); opacity: 0; transition: opacity var(--t-med); }
#vignette.on { opacity: 1; animation: pulse 1.2s ease-in-out infinite; }
#deathcard { display: none; position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 11; width: min(86vw, 320px); text-align: center; background: var(--c-overlay); border: 1px solid var(--c-danger); border-radius: var(--r-lg); padding: var(--s-4); }
#deathcard.on { display: block; }
#deathcard h2 { margin: 0 0 6px; color: var(--c-bad); }
#dbg { display: none !important; }
html.show-fps #dbg { display: block !important; left: 50% !important; transform: translateX(-50%); top: calc(var(--sa-t) + 2px); bottom: auto !important; }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes toastin { from { opacity: 0; transform: translateY(-6px); } }

/* ---- desktop: keyboard + mouse, more room ---- */
@media (min-width: 900px) and (min-height: 431px) {
  :root { --bar-h: calc(12px * var(--ui-scale)); --vitals-w: calc(240px * var(--ui-scale)); --target-w: calc(200px * var(--ui-scale)); --atk: calc(60px * var(--ui-scale));
    --slot-size: calc(var(--slot) * var(--ui-scale)); --zone-w: 200px; --mm: 96px; --log-w: min(360px, calc(50vw - 200px)); }
  #tl { flex-direction: row; align-items: flex-start; gap: 12px; }
  #skillbar { left: 50%; transform: translateX(-50%); }
  #bl { bottom: calc(var(--sa-b) + var(--edge)); }
  #log > div:nth-last-child(n+4) { display: block; }       /* 6 lines */
  #panel { top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(calc(-50% + var(--wx, 0px)), calc(-50% + var(--wy, 0px))); width: min(720px, 90vw); height: min(85vh, 760px); }
}

/* ---- phone landscape: short height -> compact status, actions on the right thumb, panels as right drawer ---- */
@media (orientation: landscape) and (max-height: 430px) {
  :root { --hud-fs: calc(12px * var(--ui-scale)); --vitals-w: min(calc(180px * var(--ui-scale)), 32vw); --target-w: min(calc(180px * var(--ui-scale)), 28vw);
    --bar-h: calc(10px * var(--ui-scale)); --atk: calc(60px * var(--ui-scale)); --menu-btn: calc(44px * var(--ui-scale));
    --slot-size: min(calc(48px * var(--ui-scale)), calc((100vw - 34vw - var(--sa-l) - var(--sa-r) - var(--atk) - 48px - 4 * var(--slot-gap)) / 5));
    --zone-w: 30vw; --mm: 64px; --log-w: min(34vw, 300px); }
  #hud .box { padding: 4px 6px; }
  #tl { flex-direction: row; align-items: flex-start; }
  #gold { font-size: 10px; line-height: 13px; margin-top: 1px; } .chip { height: 15px; font-size: 10px; line-height: 13px; }
  #xpbar { height: 6px; } #xpbar span { display: none; } #xpwrap { padding: 8px 0; margin: -5px 0; }
  .bar { margin-top: 2px; } .bar span { font-size: 10px; }
  #skillbar { left: auto; right: calc(var(--sa-r) + var(--edge) + var(--atk) + 10px); }
  #bl { bottom: calc(var(--sa-b) + var(--edge)); }
  #log > div:nth-last-child(n+3) { display: none; }       /* 2 lines */
  #log.open > div { display: block; }
  #toasts { top: 22%; }
  #panel { top: 0; bottom: 0; right: 0; left: auto; width: 60vw; border-radius: var(--r-lg) 0 0 var(--r-lg); border-right: none;
    padding: var(--sa-t) var(--sa-r) var(--sa-b) 0; }
  #dim { background: rgba(0,0,0,.2); }
  .menugrid { grid-template-columns: repeat(3, 1fr); }
  .menugrid button { min-height: 56px; }
}

/* ---- reduced motion: OS setting or Settings toggle (html.reduce-motion) — no pulse/shake/slide ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
  #vignette.on { opacity: .6; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; transition-duration: 0s !important; }
html.reduce-motion #vignette.on { opacity: .6; }

/* 3D hair picker (proto3d.html): swatches + bottom sheet that keeps the character visible */
.h3colors { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.sw { width: 36px; height: 36px; min-width: 36px; padding: 0; border-radius: 50%; border: 2px solid var(--c-border); }
.sw.on { border-color: var(--c-accent); box-shadow: 0 0 0 2px #f1c40f55; }
.h3free { display: flex; align-items: center; gap: 6px; font-size: 13px; } .h3free input { width: 38px; height: 32px; padding: 0; border: none; background: none; }
.h3styles { grid-template-columns: repeat(2, 1fr); }
#hairbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; max-height: 46%; overflow-y: auto; padding: 8px calc(12px + var(--sa-r)) calc(12px + var(--sa-b)) calc(12px + var(--sa-l)); background: rgba(20,24,30,.94); border-top: 1px solid var(--c-border); }
#hairbar h2 { margin: 8px 0 4px; font-size: var(--fs-md); } #hairbar .card { padding: 8px; }
.h3head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
@media (orientation: landscape) and (max-height: 430px) { #hairbar { left: auto; width: 50vw; top: 0; max-height: none; border-top: none; border-left: 1px solid var(--c-border); } }
body > #camctl { position: fixed; top: calc(var(--sa-t) + var(--edge)); right: calc(var(--sa-r) + var(--edge)); z-index: 5; }   /* before the HUD exists */

/* ---- RO-style windows: status table, skill list, bag (grid + equip strip + detail card). Pure CSS: no image needed (skins come later, see project/UI_ASSET_PROMPTS.md) ---- */
.stathead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 8px 10px; margin-top: 10px; background: rgba(0,0,0,.25); border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); }
.stathead .nm { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-lg); }
.ptsline { margin: 8px 0 4px; font-size: var(--fs-lg); } .ptsline b { color: var(--c-accent); }
.stwin { display: grid; gap: 12px; }
.stats .srow:nth-child(odd) { background: rgba(255,255,255,.04); } .srow > b { color: var(--c-accent); }
.dstats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; align-content: start; border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); overflow: hidden; background: rgba(0,0,0,.2); }
.dstats > div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,.08); } .dstats dt { color: var(--c-text-dim); } .dstats dd { margin: 0; font-weight: bold; }
[data-act=addstat], [data-act=plus], .plus, .minus { background: linear-gradient(#e8c14a, #b98a1a); color: var(--c-text-on-accent); border: 1px solid #7a5d00; font-weight: bold; font-size: 22px; line-height: 1; min-width: var(--hit-min); min-height: var(--hit-min); }
.skrow { display: grid; grid-template-columns: 52px 1fr; gap: 6px 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid rgba(255,255,255,.1); }
.skrow:nth-child(odd) { background: rgba(255,255,255,.03); }
.sktile, .cell { position: relative; border: 2px solid var(--c-border); background: #0b1624; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), inset 0 2px 4px rgba(0,0,0,.6); }
.sktile { width: 52px; height: 52px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; }
.sktile img { width: 36px; height: 36px; object-fit: contain; }
.rk { position: absolute; top: 1px; left: 2px; font: bold 9px/1 var(--f-ui); font-style: normal; color: var(--c-parch); text-shadow: 0 0 2px #000, 1px 1px 0 #000; }
.cn { display: none; } .noimg .cn { display: block; font-size: 11px; line-height: 1.1; text-align: center; word-break: break-word; overflow: hidden; max-height: 100%; }
.skmain { min-width: 0; } .skmain small { display: block; } .skname { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; } .lvl { color: var(--c-accent); font-weight: bold; }
.skact { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; } .noslot { color: var(--c-text-dim); }
.bagtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 6px; } .mvhint { color: var(--c-accent); font-size: var(--fs-sm); text-align: right; }
.eqrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.eq { display: flex; align-items: center; gap: 8px; min-height: var(--hit-min); padding: 4px 8px; text-align: left; color: #fff; background: rgba(0,0,0,.3); border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); position: relative; }
div.eq.empty { border-style: dashed; color: var(--c-text-dim); } .eqt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; } .eqt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cic { width: 32px; height: 32px; object-fit: contain; flex: none; }
.bagwrap { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; } .bagcol { min-width: 0; }
.bag { --cols: 5; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; }
.cell { aspect-ratio: 1; min-width: var(--hit-min); min-height: var(--hit-min); padding: 2px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: #fff; }
.cell .cic { width: 68%; height: 68%; pointer-events: none; } .cell.empty { border-color: #2a3b52; background: rgba(0,0,0,.28); }
.cell.sel { outline: 2px solid var(--c-accent); outline-offset: 1px; } .cell.mv { opacity: .55; }
.cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: bold; color: #fff; text-shadow: 0 0 2px #000, 1px 1px 0 #000, -1px -1px 0 #000; }
.bagcard { position: sticky; bottom: 0; z-index: 2; padding: 8px 10px; background: var(--c-win-2); border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); box-shadow: 0 -4px 8px rgba(0,0,0,.4); }
.bchead { display: flex; align-items: center; gap: 10px; } .bchead .cic { width: 40px; height: 40px; }
.mods { display: flex; flex-direction: column; margin-top: 4px; } .mod.up { color: var(--c-up); } .mod.dn { color: var(--c-down); }
.bcbtn { display: flex; gap: 6px; margin-top: 8px; } .bcbtn button { flex: 1; min-height: var(--hit-min); } .primary { background: var(--c-primary); }
/* sort button (bag top) + split stepper (detail card) */
.bagtop .bsort { min-height: var(--hit-min); min-width: var(--hit-min); padding: 0 14px; }
.splitbox { margin-top: 8px; padding: 8px; border: 1px solid var(--c-bevel-hi); border-radius: var(--r-md); background: rgba(0,0,0,.2); }
.splitbox .stp { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0; } .splitbox .stp output { min-width: 3.2em; text-align: center; font-weight: bold; font-size: var(--fs-lg, 18px); }
.splitbox small { display: block; text-align: center; color: var(--c-text-dim); }
.bagcard .why { margin: 0 0 6px; } .bagcard .confirm { margin-top: 8px; }

/* layout modes for the windows (placed after the base rules above so they win) */
@media (min-width: 900px) and (min-height: 431px) {
  .phead { cursor: grab; } .phead button { cursor: pointer; }
  .bag { --cols: 8; } .bagwrap { display: grid; grid-template-columns: minmax(0, 1fr) 230px; align-items: start; } .bagcard { position: sticky; top: 0; bottom: auto; box-shadow: none; }
  .stwin { grid-template-columns: 1.5fr 1fr; align-items: start; } .dstats { grid-template-columns: 1fr; }
  .skrow { grid-template-columns: 52px 1fr auto; } .skact { grid-column: auto; flex-direction: column; align-items: flex-end; }
}
@media (orientation: landscape) and (max-height: 430px) {   /* short screens: the detail card sits beside the grid instead of covering it */
  .bag { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .bagwrap { display: grid; grid-template-columns: minmax(0, 1fr) 190px; align-items: start; } .bagcard { position: sticky; top: 0; bottom: auto; box-shadow: none; }
  .bchead .cic { width: 32px; height: 32px; } .bcbtn { flex-wrap: wrap; } .bcbtn button { flex: 1 1 70px; }
  .stwin { grid-template-columns: 1fr; }
}

/* ================= ORVANTHIA skin: ChatGPT sheets -> assets/ui/skin/*.webp (tools/slice_icon_sheet.py + tools/optimize_skin.py; sizes/slices in the latter) =================
   Progressive enhancement: ui.js skinProbe() adds html.sk-<group> ONLY when that group's images load. Without the files (or without JS) none of the rules below apply
   and the pure-CSS look above stays. Every url() lives once, here in :root (single-file build inlines each once); rules use var(--sk-*). Groups: win btn tab slot bar icon. */
:root {
  --sk-win-frame: url("assets/ui/skin/win_frame.webp"); --sk-win-title: url("assets/ui/skin/win_title.webp");
  --sk-btn-close: url("assets/ui/skin/btn_close.webp"); --sk-btn-close-down: url("assets/ui/skin/btn_close_down.webp"); --sk-btn-close-off: url("assets/ui/skin/btn_close_off.webp");
  --sk-btn-back: url("assets/ui/skin/btn_back.webp"); --sk-btn-back-down: url("assets/ui/skin/btn_back_down.webp"); --sk-btn-back-off: url("assets/ui/skin/btn_back_off.webp");
  --sk-btn-plus: url("assets/ui/skin/btn_plus.webp"); --sk-btn-plus-down: url("assets/ui/skin/btn_plus_down.webp"); --sk-btn-plus-off: url("assets/ui/skin/btn_plus_off.webp");
  --sk-btn-minus: url("assets/ui/skin/btn_minus.webp"); --sk-btn-minus-down: url("assets/ui/skin/btn_minus_down.webp"); --sk-btn-minus-off: url("assets/ui/skin/btn_minus_off.webp");
  --sk-btn-primary: url("assets/ui/skin/btn_primary.webp"); --sk-btn-primary-down: url("assets/ui/skin/btn_primary_down.webp"); --sk-btn-primary-off: url("assets/ui/skin/btn_primary_off.webp");
  --sk-btn-gold: url("assets/ui/skin/btn_gold.webp"); --sk-btn-gold-down: url("assets/ui/skin/btn_gold_down.webp"); --sk-btn-gold-off: url("assets/ui/skin/btn_gold_off.webp");
  --sk-btn-danger: url("assets/ui/skin/btn_danger.webp"); --sk-btn-danger-down: url("assets/ui/skin/btn_danger_down.webp"); --sk-btn-danger-off: url("assets/ui/skin/btn_danger_off.webp");
  --sk-tab: url("assets/ui/skin/tab.webp"); --sk-tab-active: url("assets/ui/skin/tab_active.webp"); --sk-tab-off: url("assets/ui/skin/tab_off.webp");
  --sk-slot: url("assets/ui/skin/slot_empty.webp"); --sk-slot-sel: url("assets/ui/skin/slot_selected.webp");
  --sk-rar-common: url("assets/ui/skin/rarity_common.webp"); --sk-rar-magic: url("assets/ui/skin/rarity_magic.webp"); --sk-rar-rare: url("assets/ui/skin/rarity_rare.webp");
  --sk-rar-legendary: url("assets/ui/skin/rarity_legendary.webp"); --sk-rar-unique: url("assets/ui/skin/rarity_unique.webp"); --sk-rar-master: url("assets/ui/skin/rarity_master.webp");
  --sk-hp-track: url("assets/ui/skin/hp_track.webp"); --sk-hp-track-crit: url("assets/ui/skin/hp_track_crit.webp"); --sk-sp-track: url("assets/ui/skin/sp_track.webp"); --sk-exp-track: url("assets/ui/skin/exp_track.webp");
  --sk-hp-fill-ok: url("assets/ui/skin/hp_fill_ok.webp"); --sk-hp-fill-mid: url("assets/ui/skin/hp_fill_mid.webp"); --sk-hp-fill-crit: url("assets/ui/skin/hp_fill_crit.webp");
  --sk-sp-fill: url("assets/ui/skin/sp_fill.webp"); --sk-exp-fill: url("assets/ui/skin/exp_fill.webp");
  --sk-ic-hp: url("assets/ui/skin/icon_hp.webp"); --sk-ic-sp: url("assets/ui/skin/icon_sp.webp"); --sk-ic-coin: url("assets/ui/skin/icon_exp.webp");   /* icon_exp = the gold medallion = the Mora coin */
  --sk-st-str: url("assets/ui/skin/stat_str.webp"); --sk-st-pow: url("assets/ui/skin/stat_pow.webp"); --sk-st-edr: url("assets/ui/skin/stat_edr.webp"); --sk-st-agi: url("assets/ui/skin/stat_agi.webp"); --sk-st-int: url("assets/ui/skin/stat_int.webp");
  --sk-st-con: url("assets/ui/skin/stat_con.webp"); --sk-st-wis: url("assets/ui/skin/stat_wis.webp"); --sk-st-vit: url("assets/ui/skin/stat_vit.webp"); --sk-st-dex: url("assets/ui/skin/stat_dex.webp"); --sk-st-luk: url("assets/ui/skin/stat_luk.webp");
  --sk-cat-sword: url("assets/ui/skin/skcat_sword.webp"); --sk-cat-shooting: url("assets/ui/skin/skcat_shooting.webp"); --sk-cat-element: url("assets/ui/skin/skcat_element.webp");
  --sk-cat-holy: url("assets/ui/skin/skcat_holy.webp"); --sk-cat-smithing: url("assets/ui/skin/skcat_smithing.webp"); --sk-cat-trade: url("assets/ui/skin/skcat_trade.webp");
  --sk-cat-stealth: url("assets/ui/skin/skcat_stealth.webp"); --sk-cat-knowledge: url("assets/ui/skin/skcat_knowledge.webp"); --sk-cat-dragon: url("assets/ui/skin/skcat_dragon.webp");
  --sk-eq-weapon: url("assets/ui/skin/eq_weapon.webp"); --sk-eq-shield: url("assets/ui/skin/eq_shield.webp");
}

/* -- window: wood+brass frame (9-slice, 24 px slice of a 56 px image shown as a 12 px border; hollow centre keeps the slate gradient) + wood title bar (grip dots are in the image) -- */
html.sk-win #panel { border: 12px solid transparent; border-image: var(--sk-win-frame) 24 / 12px / 0 stretch; border-radius: 0; background: linear-gradient(#1c3150, #142238) padding-box; box-shadow: none; }
html.sk-win .phead { border: solid transparent; border-width: 0 8px; border-image: var(--sk-win-title) 0 30 0 36 fill / 0 17px 0 20px / 0 stretch; background: none; box-shadow: none; min-height: 52px; padding: 4px 0; }
html.sk-win .grip { display: none; }

/* -- square buttons X < + - (3 states) -- */
html.sk-btn .pclose { --b: var(--sk-btn-close); --bd: var(--sk-btn-close-down); --bo: var(--sk-btn-close-off); }
html.sk-btn .pback { --b: var(--sk-btn-back); --bd: var(--sk-btn-back-down); --bo: var(--sk-btn-back-off); }
html.sk-btn :is([data-act=plus], [data-act=addstat], .plus) { --b: var(--sk-btn-plus); --bd: var(--sk-btn-plus-down); --bo: var(--sk-btn-plus-off); }
html.sk-btn :is([data-act=minus], .minus) { --b: var(--sk-btn-minus); --bd: var(--sk-btn-minus-down); --bo: var(--sk-btn-minus-off); }
html.sk-btn :is(.pclose, .pback, [data-act=plus], [data-act=addstat], .plus, [data-act=minus], .minus) {
  width: var(--hit-min); height: var(--hit-min); min-width: var(--hit-min); min-height: var(--hit-min); padding: 0; border: 0; border-radius: 0; box-shadow: none; opacity: 1;
  color: transparent; font-size: 0; text-shadow: none; background: var(--b) center / 100% 100% no-repeat; }      /* the glyph is in the image; aria-label stays for screen readers */
html.sk-btn :is(.pclose, .pback, [data-act=plus], [data-act=addstat], .plus, [data-act=minus], .minus):active { background-image: var(--bd); box-shadow: none; }
html.sk-btn :is(.pclose, .pback, [data-act=plus], [data-act=addstat], .plus, [data-act=minus], .minus):is(:disabled, .dis, [aria-disabled=true]) { background-image: var(--bo); opacity: 1; }

/* -- wide pill buttons: blue (.big/.primary) · gold (.gold) · red (.danger); 100x88 image, 44 px caps -> 20 px at the button ends (text area keeps 8 px borders) -- */
html.sk-btn :is(.big, .primary, .danger, .bcbtn button) { --pb: var(--sk-btn-primary); --pbd: var(--sk-btn-primary-down); --pbo: var(--sk-btn-primary-off); }
html.sk-btn .gold { --pb: var(--sk-btn-gold); --pbd: var(--sk-btn-gold-down); --pbo: var(--sk-btn-gold-off); }
html.sk-btn .danger { --pb: var(--sk-btn-danger); --pbd: var(--sk-btn-danger-down); --pbo: var(--sk-btn-danger-off); }
html.sk-btn :is(.big, .primary, .gold, .danger, .bcbtn button) { min-height: var(--hit-min); border: solid transparent; border-width: 0 8px; border-radius: 0; background: none; box-shadow: none; text-shadow: 0 1px 1px rgba(0,0,0,.55);
  border-image: var(--pb) 0 44 fill / 0 20px / 0 stretch; }
html.sk-btn .gold { color: var(--c-text-on-accent); text-shadow: none; }
html.sk-btn :is(.big, .primary, .gold, .danger, .bcbtn button):active { border-image-source: var(--pbd); }
html.sk-btn :is(.big, .primary, .gold, .danger, .bcbtn button):is(:disabled, .dis, [aria-disabled=true]) { border-image-source: var(--pbo); opacity: 1; }

/* -- tabs: 88x88 image, 38 px caps -> 19 px (the image has no bottom edge: it sits on the .tabs line) -- */
html.sk-tab .tabs button { border: solid transparent; border-width: 0 8px; padding: 4px 0; border-radius: 0; background: none; border-image: var(--sk-tab) 0 38 fill / 0 19px / 0 stretch; }
html.sk-tab .tabs button[aria-selected=true] { border-image-source: var(--sk-tab-active); }
html.sk-tab .tabs button:disabled { border-image-source: var(--sk-tab-off); opacity: 1; }

/* -- item slot + rarity frame (hollow overlay, picked by .r-<rarity> = D.skills.RARITY_ORDER keys) -- */
html.sk-slot :is(.cell, .sktile) { border: 0; border-radius: 0; box-shadow: none; outline: 0; background: var(--sk-slot) center / 100% 100% no-repeat; }
html.sk-slot .cell.sel { background-image: var(--sk-slot-sel); }
html.sk-slot .cell.sel::after { filter: drop-shadow(0 0 3px #f1c40f) drop-shadow(0 0 1px #fff3b0); }   /* the rarity frame covers the gold outline of slot_selected: glow keeps the selection visible */
html.sk-slot :is(.cell, .sktile)::after { content: ''; position: absolute; inset: 0; background: var(--rf, none) center / 100% 100% no-repeat; pointer-events: none; }
html.sk-slot .r-common { --rf: var(--sk-rar-common); } html.sk-slot .r-magic { --rf: var(--sk-rar-magic); } html.sk-slot .r-rare { --rf: var(--sk-rar-rare); }
html.sk-slot .r-legendary { --rf: var(--sk-rar-legendary); } html.sk-slot .r-unique { --rf: var(--sk-rar-unique); } html.sk-slot .r-master { --rf: var(--sk-rar-master); }
html.sk-slot .cell .cic { width: 60%; height: 60%; }
html.sk-slot :is(.cell, .sktile) :is(.rk, .cnt) { z-index: 2; }

/* -- HP / SP / EXP: track (::before, 3-slice) + fill layer (child div, width = %) as two separate layers. Groove = y 27-75 % of the bar, x inset 27 % (EXP 31-69 % / 33 %) -- */
html.sk-bar .bar { --bh: var(--bar-h); --ts: 21; --tr: .583; }
html.sk-bar #xpbar { --bh: 10px; --ts: 17; --tr: .708; height: var(--bh); }
html.sk-bar :is(.vrow .bar, #xpbar, #target .bar) { padding: calc(var(--bh) * .27) calc(var(--bh) * .27) calc(var(--bh) * .25); background: none; border: 0; border-radius: 0; box-shadow: none; }
html.sk-bar #xpbar { padding: calc(var(--bh) * .31) calc(var(--bh) * .33) calc(var(--bh) * .31); }
html.sk-bar :is(.vrow .bar, #xpbar, #target .bar)::before { content: ''; position: absolute; inset: 0; border: solid transparent; border-width: 0 calc(var(--bh) * var(--tr)); border-image: var(--trk, var(--sk-hp-track)) 0 var(--ts) fill / 0 calc(var(--bh) * var(--tr)) / 0 stretch; pointer-events: none; }
html.sk-bar .vrow .bar::after { content: none; }
html.sk-bar #hpbar.crit { --trk: var(--sk-hp-track-crit); } html.sk-bar #spbar { --trk: var(--sk-sp-track); } html.sk-bar #xpbar { --trk: var(--sk-exp-track); }
html.sk-bar :is(.vrow .bar, #xpbar, #target .bar) > div { position: relative; z-index: 1; border-radius: 999px; background-color: transparent; background-position: 0 0; background-size: 100% 100%; background-repeat: no-repeat; }
html.sk-bar :is(.vrow .bar, #xpbar, #target .bar) > span { z-index: 2; }
html.sk-bar #hpbar.ok > div { background-image: var(--sk-hp-fill-ok); } html.sk-bar #hpbar.mid > div { background-image: var(--sk-hp-fill-mid); } html.sk-bar #hpbar.crit > div { background-image: var(--sk-hp-fill-crit); }
html.sk-bar #spbar > div { background-image: var(--sk-sp-fill); } html.sk-bar #xpbar > div { background-image: var(--sk-exp-fill); } html.sk-bar #target .bar > div { background-image: var(--sk-hp-fill-crit); }
@media (orientation: landscape) and (max-height: 430px) { html.sk-bar #xpbar { --bh: 8px; height: var(--bh); } }

/* -- icons: HP heart / SP drop in front of the bars, Mora coin (>= 20 px) in the HUD, stat icons, skill-category tiles, empty equipment silhouettes -- */
html.sk-icon .vl { font-size: 0; width: 18px; height: 18px; margin: -2px 0; background: center / contain no-repeat; }
html.sk-icon .vl[data-v=hp] { background-image: var(--sk-ic-hp); } html.sk-icon .vl[data-v=sp] { background-image: var(--sk-ic-sp); }
html.sk-icon #coin .gic { width: 0; height: 0; padding: 10px; margin: -3px 3px -3px 0; vertical-align: -5px; background: var(--sk-ic-coin) center / contain no-repeat; }   /* 20 px coin; the old <img> is squeezed to 0 so only this shows */
html.sk-icon .srow > b[data-st] { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10px; line-height: 1.1; }
html.sk-icon .srow > b[data-st]::before { content: ''; width: 26px; height: 26px; background: var(--si) center / contain no-repeat; }
html.sk-icon [data-st=STR] { --si: var(--sk-st-str); } html.sk-icon [data-st=POW] { --si: var(--sk-st-pow); } html.sk-icon [data-st=EDR] { --si: var(--sk-st-edr); } html.sk-icon [data-st=AGI] { --si: var(--sk-st-agi); } html.sk-icon [data-st=INT] { --si: var(--sk-st-int); }
html.sk-icon [data-st=CON] { --si: var(--sk-st-con); } html.sk-icon [data-st=WIS] { --si: var(--sk-st-wis); } html.sk-icon [data-st=VIT] { --si: var(--sk-st-vit); } html.sk-icon [data-st=DEX] { --si: var(--sk-st-dex); } html.sk-icon [data-st=LUK] { --si: var(--sk-st-luk); }
html.sk-icon .sktile[data-cat] > img { display: none; }
html.sk-icon .sktile[data-cat]::before { content: ''; width: 34px; height: 34px; background: var(--ci) center / contain no-repeat; }
html.sk-icon [data-cat=sword] { --ci: var(--sk-cat-sword); } html.sk-icon [data-cat=shooting] { --ci: var(--sk-cat-shooting); } html.sk-icon [data-cat=element] { --ci: var(--sk-cat-element); }
html.sk-icon [data-cat=holy] { --ci: var(--sk-cat-holy); } html.sk-icon [data-cat=smithing] { --ci: var(--sk-cat-smithing); } html.sk-icon [data-cat=trade] { --ci: var(--sk-cat-trade); }
html.sk-icon [data-cat=stealth] { --ci: var(--sk-cat-stealth); } html.sk-icon [data-cat=knowledge] { --ci: var(--sk-cat-knowledge); } html.sk-icon [data-cat=dragon] { --ci: var(--sk-cat-dragon); }
html.sk-icon .eq.empty::before { content: ''; flex: none; width: 32px; height: 32px; opacity: .9; background: var(--eqi) center / contain no-repeat; }
html.sk-icon .eq.empty[data-slot=weapon] { --eqi: var(--sk-eq-weapon); } html.sk-icon .eq.empty[data-slot=shield] { --eqi: var(--sk-eq-shield); }

/* ---- weight line (bag) + skill points bar (skills) — T API (ADR-008). Amber = >90% / over, always with words, never colour alone ---- */
.wline { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px 8px; font-size: var(--fs-sm); } .wline em { font-style: normal; font-weight: bold; color: var(--c-warn); }
.wline.over em::before, .wline.hi em::before { content: '▲ '; }
.wbar { display: inline-block; width: 72px; height: 8px; border-radius: 4px; background: var(--c-bar-bg); border: 1px solid rgba(255,255,255,.25); overflow: hidden; vertical-align: middle; }
.wbar i { display: block; height: 100%; background: var(--c-ok); } .wline.hi .wbar i, .wline.over .wbar i { background: var(--c-warn); }
.wt { color: var(--c-text-dim); }
.sktop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 4px 0 8px; padding: 6px 10px; background: rgba(0,0,0,.25); border-radius: var(--r-sm); border-left: 3px solid var(--c-accent); } .sktop b { color: var(--c-accent); font-size: var(--fs-lg, 17px); }
.ok { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--c-ok); background: var(--c-surface); border-radius: var(--r-sm); }
.plusbox { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; } .skwhy { max-width: 150px; text-align: right; color: var(--c-warn); font-size: var(--fs-xs); line-height: 1.2; }

/* ---- skills window (ADR-017): mastery bar, discovered / locked / rumour rows, Raphael bar ---- */
.sksec { margin: 12px 0 4px; font-size: var(--fs-md, 14px); color: var(--c-accent); border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 2px; }
.skbar { display: block; height: 8px; margin: 4px 0 2px; border-radius: 4px; background: var(--c-bar-bg); border: 1px solid rgba(255,255,255,.25); overflow: hidden; }
.skbar i { display: block; height: 100%; background: var(--c-info, #3498db); } .skbar.rbar i { background: var(--c-accent); }
.skmp { color: var(--c-text-dim); }
.skconds { margin: 4px 0 0; padding-left: 16px; font-size: var(--fs-sm); list-style: none; } .skconds li { margin: 1px 0; } .skconds li.done { color: var(--c-ok); }
.skwarn { color: var(--c-warn); }
.skrow.locked { opacity: .65; } .skrow.hint .sktile { background: rgba(0,0,0,.3); border-style: dashed; }
.skmain .primary { margin-top: 4px; }
