@font-face {
  font-family: 'Alegreya';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(../fonts/alegreya.woff2) format('woff2');
}
@font-face {
  font-family: 'Alegreya SC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/alegreya-sc.woff2) format('woff2');
}

:root {
  --bone: #e9e1cf;
  --bone-dim: #d7cbb2;
  --oat: #cbbd9f;
  --tallow: #b4924f;
  --tallow-bright: #ccab62;
  --moss: #5f6c4a;
  --ash: #2f2b25;
  --ink: #241f19;
  --ink-soft: #4a4237;
  --ember: #8d3d2c;
  --ember-bright: #b4553d;
  --slate: #4a4858;
  --violet: #6c3f8c;
  --line: rgba(36, 31, 25, .22);
  --serif: 'Alegreya', Georgia, serif;
  --sc: 'Alegreya SC', 'Alegreya', Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #17140f; color: var(--bone);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ---------- loading ---------- */
#loading {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: #17140f;
  transition: opacity .7s ease;
}
#loading.out { opacity: 0; pointer-events: none; }
.load-inner { text-align: center; width: min(340px, 76vw); }
.load-mark { font-family: var(--sc); font-size: 30px; letter-spacing: .34em; color: var(--bone); margin-bottom: 22px; }
.load-bar { height: 1px; background: rgba(233, 225, 207, .16); position: relative; overflow: hidden; }
.load-bar i { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: var(--tallow); transition: width .35s ease; }
.load-text { margin-top: 14px; font-size: 13px; letter-spacing: .12em; color: var(--oat); font-style: italic; }

/* ---------- menu ---------- */
.screen { position: absolute; inset: 0; z-index: 100; }
#menu { background: #1b1712; overflow: hidden; }
.menu-art { position: absolute; inset: -4%; }
.menu-art img {
  width: 100%; height: 100%; object-fit: cover;
  animation: drift 46s ease-in-out infinite alternate;
  filter: saturate(.94) contrast(1.01);
}
@keyframes drift {
  from { transform: scale(1.02) translate3d(-.6%, -.4%, 0); }
  to { transform: scale(1.09) translate3d(.9%, .7%, 0); }
}
.menu-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 100% at 62% 44%, rgba(24,20,16,0) 38%, rgba(24,20,16,.42) 74%, rgba(20,17,13,.82) 100%),
    linear-gradient(90deg, rgba(21,18,14,.72) 0%, rgba(21,18,14,.28) 38%, rgba(21,18,14,0) 62%);
}
.menu-inner {
  position: absolute; left: 8.5%; top: 22%;
  width: min(520px, 78vw);
  text-shadow: 0 2px 22px rgba(18,14,10,.65);
}
.wordmark {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(46px, 8.6vw, 118px);
  line-height: .9; letter-spacing: .16em;
  margin: 0 0 14px -4px;
  color: #efe7d5;
  text-shadow: 0 0 40px rgba(210,168,102,.12), 0 3px 26px rgba(16,12,8,.7);
}
.tagline {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(14px, 1.45vw, 19px);
  color: #e2d5bb; opacity: .9; margin: 0 0 clamp(22px, 4vh, 46px);
  letter-spacing: .02em;
}
.menu-list { display: flex; flex-direction: column; align-items: flex-start; gap: clamp(4px, .9vh, 10px); }
.menu-item {
  font-family: var(--sc); font-size: clamp(15px, 1.4vw, 20px);
  letter-spacing: .14em; color: var(--bone);
  padding: 7px 4px 7px 28px; position: relative;
  transition: color .18s ease, transform .18s ease, opacity .2s ease;
  opacity: .82;
}
.menu-item::before {
  content: ""; position: absolute; left: 2px; top: 50%;
  width: 15px; height: 8px; margin-top: -4px;
  border-left: 1.6px solid var(--tallow-bright);
  border-bottom: 1.6px solid var(--tallow-bright);
  transform: rotate(-45deg) scale(.4); opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
}
.menu-item:hover, .menu-item.sel { color: #fff8e6; transform: translateX(5px); opacity: 1; }
.menu-item:hover::before, .menu-item.sel::before { opacity: 1; transform: rotate(-45deg) scale(1); }
.menu-item[disabled] { opacity: .34; cursor: default; }
.menu-item[disabled]:hover { transform: none; color: var(--bone); }
.menu-item[disabled]:hover::before { opacity: 0; }
.menu-note { margin-top: clamp(18px, 4vh, 40px); font-size: 12.5px; letter-spacing: .09em; color: var(--oat); opacity: .62; font-style: italic; max-width: 360px; }
.menu-foot {
  position: absolute; left: 8.5%; right: 4%; bottom: 22px;
  display: flex; justify-content: space-between; gap: 14px;
  font-size: 11px; letter-spacing: .11em; color: var(--oat); opacity: .5;
}
#menuBuild:empty { display: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#questLine {
  position: absolute; left: max(18px, env(safe-area-inset-left)); top: max(16px, env(safe-area-inset-top));
  display: flex; gap: 10px; align-items: flex-start;
  max-width: min(430px, 62vw);
  text-shadow: 0 1px 3px rgba(18,14,10,.95), 0 0 12px rgba(18,14,10,.85), 0 2px 22px rgba(18,14,10,.6);
}
.quill { width: 20px; height: 20px; color: var(--tallow-bright); flex: 0 0 auto; margin-top: 1px; opacity: .9; }
.quest-kicker { font-family: var(--sc); font-size: 11px; letter-spacing: .17em; color: var(--tallow-bright); margin-bottom: 3px; }
.quest-goal { font-size: clamp(13px, 1.05vw, 15.5px); color: #f2ead8; letter-spacing: .01em; line-height: 1.28; }
#compass {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: 74px; height: 26px; text-align: center; opacity: .82;
}
.compass-track { font-family: var(--sc); font-size: 11px; letter-spacing: .24em; color: var(--tallow-bright); line-height: 1; padding-top: 3px; text-shadow: 0 1px 8px rgba(18,14,10,.8); }
.compass-mark { position: absolute; left: 50%; bottom: 0; width: 1px; height: 7px; background: var(--bone); transform: translateX(-50%); opacity: .6; }

#vitals {
  position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 13px;
  text-shadow: 0 1px 8px rgba(18,14,10,.8);
}
.levelplate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 46px; height: 46px; border: 1px solid rgba(233,225,207,.42); border-radius: 50%;
  background: rgba(24,20,16,.28); backdrop-filter: blur(2px);
}
.lvl-label { font-family: var(--sc); font-size: 7.5px; letter-spacing: .16em; color: var(--oat); opacity: .72; }
#levelNum { font-size: 21px; line-height: .92; color: #fbf3e2; }
.bars { width: min(270px, 40vw); display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 7px; }
.bar-label { font-family: var(--sc); font-size: 8.5px; letter-spacing: .13em; color: var(--oat); opacity: .78; width: 49px; flex: 0 0 auto; }
.trough { position: relative; flex: 1 1 auto; height: 5px; background: rgba(20,17,13,.55); border: 1px solid rgba(233,225,207,.2); overflow: hidden; }
.trough.health { height: 7px; }
.trough i { position: absolute; inset: 0 auto 0 0; width: 100%; display: block; }
.trough.health i { background: linear-gradient(180deg, #a34a34, #7d3023); }
.trough.health b { position: absolute; right: 0; top: 0; bottom: 0; width: 0; background: rgba(233,225,207,.55); transition: width .45s ease; }
.trough.stamina i { background: linear-gradient(180deg, #c8a65e, #a2803e); width: 100%; transition: width .12s linear; }
.trough.xp i { background: linear-gradient(180deg, #6f7d56, #52603f); width: 0; transition: width .4s ease; }
.bar-num { font-size: 10px; color: var(--bone); opacity: .82; width: 62px; text-align: right; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

#quickbar {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 9px;
}
.quick {
  position: relative; width: 46px; height: 46px;
  border: 1px solid rgba(233,225,207,.28); background: rgba(24,20,16,.34);
  display: flex; align-items: center; justify-content: center;
}
.quick img { width: 33px; height: 33px; object-fit: contain; }
.quick-glyph { font-size: 20px; color: var(--tallow-bright); }
.quick-key { position: absolute; left: 3px; top: 2px; font-size: 8.5px; letter-spacing: .06em; color: var(--oat); opacity: .8; }
.quick-count { position: absolute; right: 4px; bottom: 1px; font-size: 12px; color: #f6eeda; }
.quick-cd { position: absolute; inset: 0; background: rgba(16,13,10,.66); transform-origin: bottom; transform: scaleY(0); }
.quick-lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--sc); font-size: 10px; letter-spacing: .08em; color: var(--oat); background: rgba(20,17,13,.6); }
.quick-lock.hidden { display: none !important; }
.quick.ready { border-color: rgba(204,171,98,.55); }
.coinbox { display: flex; align-items: center; gap: 5px; margin-left: 4px; font-size: 14px; color: #f4ecd9; }
.coinbox img { width: 21px; height: 21px; }

#weaponBadge {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 54px);
  font-family: var(--sc); font-size: 10px; letter-spacing: .12em; color: var(--oat);
  display: flex; gap: 9px; align-items: baseline; opacity: .8;
}
#weaponAtk { color: var(--tallow-bright); font-family: var(--serif); letter-spacing: 0; }

#interactPrompt {
  position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  background: rgba(24,20,16,.56); border: 1px solid rgba(233,225,207,.26);
  padding: 7px 14px 7px 7px; font-size: 14px; letter-spacing: .03em;
  backdrop-filter: blur(3px);
}
.keycap {
  width: 24px; height: 24px; border: 1px solid rgba(233,225,207,.55);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--sc); color: var(--tallow-bright);
}
#subtitle {
  position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%);
  max-width: min(620px, 86vw); text-align: center;
  font-style: italic; font-size: 15px; color: #f1e8d6; line-height: 1.4;
  text-shadow: 0 2px 14px rgba(16,12,8,.9), 0 0 3px rgba(16,12,8,.9);
}

#toasts {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 92px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 7px;
  width: min(320px, 78vw);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(233,225,207,.94); color: var(--ink);
  border-left: 2px solid var(--tallow);
  padding: 7px 12px 7px 8px; min-width: 190px;
  transform: translateX(24px); opacity: 0;
  animation: toastIn .35s ease forwards;
  box-shadow: 0 6px 22px rgba(12,9,6,.3);
}
.toast.out { animation: toastOut .4s ease forwards; }
.toast img { width: 34px; height: 34px; object-fit: contain; }
.toast .t-name { font-family: var(--sc); font-size: 12.5px; letter-spacing: .06em; }
.toast .t-sub { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }
.toast.gold { border-left-color: #a98b46; }
@keyframes toastIn { to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateX(26px); opacity: 0; } }

#damageLayer { position: absolute; inset: 0; overflow: hidden; }
.dmg {
  position: absolute; font-family: var(--serif); font-weight: 700; font-size: 15px;
  color: #f4ecd9; -webkit-text-stroke: 2.5px rgba(30,24,18,.78); paint-order: stroke fill;
  transform: translate(-50%, -50%); will-change: transform, opacity; pointer-events: none;
}
.dmg.heal { color: #cfe0a8; }
.dmg.crit { font-size: 19px; color: #ffd9a0; }
#enemyBars { position: absolute; inset: 0; overflow: hidden; }
.ebar { position: absolute; width: 72px; height: 4px; transform: translate(-50%, -50%); background: rgba(20,17,13,.6); border: 1px solid rgba(233,225,207,.24); }
.ebar i { display: block; height: 100%; background: #983f2d; transition: width .12s linear; }
.ebar.target { border-color: rgba(204,171,98,.65); }

#areaBanner {
  position: absolute; left: 50%; top: 15%; transform: translateX(-50%);
  text-align: center; opacity: 0; transition: opacity .7s ease;
  text-shadow: 0 2px 16px rgba(16,12,8,.9);
}
#areaBanner.show { opacity: .92; }
.area-kicker { font-family: var(--sc); font-size: 10px; letter-spacing: .3em; color: var(--tallow-bright); display: block; margin-bottom: 4px; }
#areaName { font-size: clamp(22px, 2.6vw, 34px); letter-spacing: .05em; color: #f4ecd9; }
#hintStrip {
  position: absolute; left: 50%; bottom: 8.5%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: .04em; color: #e6dcc8; opacity: .9;
  text-align: center; max-width: 92vw;
  padding: 7px 14px;
  background: rgba(22,18,13,.3);
  border: 1px solid rgba(233,225,207,.1);
  backdrop-filter: blur(2px);
  text-shadow: 0 1px 8px rgba(18,14,10,.9);
  transition: opacity .8s ease;
}
#hintStrip.fade { opacity: 0; }

/* ---------- touch controls ---------- */
#touchUI { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#stick {
  position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(96px, env(safe-area-inset-bottom));
  width: 116px; height: 116px; border-radius: 50%;
  border: 1px solid rgba(233,225,207,.28); background: rgba(24,20,16,.18);
  pointer-events: auto; touch-action: none;
}
#stickKnob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; border: 1px solid rgba(233,225,207,.52); background: rgba(233,225,207,.12);
}
#touchRight {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(90px, env(safe-area-inset-bottom));
  width: 168px; height: 168px; pointer-events: none;
}
.tbtn {
  position: absolute; pointer-events: auto; touch-action: manipulation;
  border-radius: 50%; border: 1px solid rgba(233,225,207,.4);
  background: rgba(24,20,16,.38); color: var(--bone);
  font-family: var(--sc); font-size: 10px; letter-spacing: .05em;
  backdrop-filter: blur(2px);
}
.tbtn:active { background: rgba(180,146,79,.35); }
.tbtn.attack { width: 66px; height: 66px; right: 4px; bottom: 6px; }
.tbtn.heavy { width: 54px; height: 54px; right: 74px; bottom: 22px; }
.tbtn.roll { width: 52px; height: 52px; right: 20px; bottom: 82px; }
.tbtn.act { width: 48px; height: 48px; right: 84px; bottom: 84px; }
.tbtn.pot { width: 42px; height: 42px; right: 132px; bottom: 70px; }
#touchMenu {
  position: absolute; right: max(16px, env(safe-area-inset-right)); top: max(56px, calc(env(safe-area-inset-top) + 46px));
  width: 38px; height: 32px; pointer-events: auto; border: 1px solid rgba(233,225,207,.36);
  font-family: var(--sc); font-size: 10px; letter-spacing: .1em; color: var(--bone);
  background: rgba(24,20,16,.34);
}

/* ---------- overlays and panels ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 110;
  display: flex; align-items: center; justify-content: center;
  background: rgba(19,15,11,.58); backdrop-filter: blur(2px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.panel {
  position: relative; width: min(980px, 94vw); max-height: 92vh;
  overflow: auto; scrollbar-width: thin;
  box-shadow: 0 24px 70px rgba(10,7,4,.55);
}
.bone-panel {
  background:
    radial-gradient(130% 100% at 20% 0%, rgba(255,250,236,.5), rgba(255,250,236,0) 55%),
    linear-gradient(180deg, #ece4d2, #ddd2ba);
  color: var(--ink);
  border: 1px solid rgba(74,66,55,.35);
}
.bone-panel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(74,66,55,.07) 1px, transparent 1px);
  background-size: 4px 4px; opacity: .5;
}
.ink-panel {
  background: rgba(26,22,17,.88);
  border: 1px solid rgba(233,225,207,.22);
  color: var(--bone);
  backdrop-filter: blur(4px);
}
.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  position: relative; z-index: 1;
}
.panel-head h2 { font-family: var(--sc); font-size: 15px; letter-spacing: .18em; margin: 0; font-weight: 400; }
.close-x {
  margin-left: auto; font-family: var(--sc); font-size: 10px; letter-spacing: .14em;
  color: var(--ink-soft); border: 1px solid rgba(74,66,55,.32); padding: 6px 11px;
}
.close-x:hover { background: rgba(74,66,55,.08); }
.panel p { margin: 0; }

/* dialogue */
#dialogue { background: rgba(19,15,11,.18); align-items: flex-end; backdrop-filter: none; padding: 0; z-index: 75; }
.dialog-panel {
  width: 100%; min-height: min(272px, 38vh);
  background: linear-gradient(180deg, rgba(233,225,207,.94), rgba(222,211,190,.96));
  color: var(--ink);
  display: flex; align-items: stretch;
  border-top: 1px solid rgba(233,225,207,.6);
  box-shadow: 0 -18px 60px rgba(10,7,4,.45);
  animation: dlgUp .35s ease both;
}
@keyframes dlgUp { from { transform: translateY(22px); opacity: .6; } to { transform: none; opacity: 1; } }
.portrait-wrap {
  flex: 0 0 min(23vw, 230px); min-height: 180px;
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 74%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 74%, transparent 100%);
}
.portrait-wrap img { width: 100%; height: 100%; max-height: 280px; object-fit: contain; object-position: bottom center; filter: saturate(.94); }
.dlg-body { flex: 1 1 auto; padding: 20px 28px 18px 6px; display: flex; flex-direction: column; min-width: 0; }
.dialg-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
#dlgName { font-family: var(--sc); font-size: 12.5px; letter-spacing: .2em; color: #8c6a2c; }
.dialg-rule { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(74,66,55,.35), transparent); }
#dlgText { font-size: clamp(15px, 1.35vw, 18.5px); line-height: 1.58; color: #3b332a; max-width: 70ch; letter-spacing: .005em; }
.dlg-choices { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.dlg-choices button, .ink-btn {
  font-family: var(--sc); font-size: 11.5px; letter-spacing: .11em;
  padding: 9px 15px; border: 1px solid rgba(74,66,55,.38); color: var(--ink);
  background: rgba(255,250,238,.28); transition: background .16s ease;
}
.dlg-choices button:hover, .ink-btn:hover { background: rgba(180,146,79,.22); }
.ink-btn.small { padding: 7px 12px; font-size: 10.5px; }
.dlg-foot { margin-top: auto; display: flex; justify-content: flex-end; padding-top: 12px; }
#dlgNext { pointer-events: auto; }

/* inventory */
.inv-panel { width: min(1040px, 95vw); }
.inv-wrap { display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 22px; padding: 20px; position: relative; z-index: 1; }
.inv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; align-content: start; }
.slot {
  position: relative; aspect-ratio: 1 / 1; background: #2c2822;
  border: 1px solid rgba(74,66,55,.2); overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.slot img { width: 78%; height: 78%; object-fit: contain; opacity: .96; }
.slot .rar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.slot .qty { position: absolute; right: 4px; bottom: 2px; font-size: 11px; color: #e9e1cf; }
.slot:hover, .slot.sel { outline: 1px solid rgba(180,146,79,.85); outline-offset: -1px; }
.slot.empty { cursor: default; background: rgba(44,40,34,.28); border-style: dashed; border-color: rgba(74,66,55,.25); }
.slot.empty:hover { outline: none; }
.rar.ash { background: #7c7466; }
.rar.ochre { background: #a37b3c; }
.rar.moss { background: #64744b; }
.rar.violet { background: #6c3f8c; }

.inv-detail { border-left: 1px solid var(--line); padding-left: 22px; min-height: 300px; display: flex; flex-direction: column; }
.detail-icon { position: relative; width: 96px; height: 96px; background: #2c2822; display: flex; align-items: center; justify-content: center; margin-bottom: 13px; }
.detail-icon img { width: 84%; height: 84%; object-fit: contain; }
.detail-icon .rarity-rule { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.detail-name { font-family: var(--sc); font-size: 17px; letter-spacing: .06em; }
.detail-type { font-size: 11.5px; letter-spacing: .13em; color: var(--ink-soft); text-transform: uppercase; margin-top: 3px; }
.inv-desc { font-size: 14px; line-height: 1.55; color: #4a4237; margin-top: 12px !important; font-style: italic; }
.inv-stats { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: #3b332a; }
.inv-stats span b { color: #7a5a25; font-weight: 700; }
.inv-actions { margin-top: auto; padding-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.inv-actions button { font-family: var(--sc); font-size: 11px; letter-spacing: .1em; padding: 8px 14px; border: 1px solid rgba(74,66,55,.4); }
.inv-actions button:hover { background: rgba(180,146,79,.22); }
.equip-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px;
  padding: 0 20px 14px; position: relative; z-index: 1;
}
.equip-slot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.equip-slot .eq-label { font-family: var(--sc); font-size: 9px; letter-spacing: .18em; color: var(--ink-soft); }
.equip-slot .eq-item { font-size: 13px; color: #3b332a; display: flex; align-items: center; gap: 7px; }
.equip-slot img { width: 20px; height: 20px; object-fit: contain; }
.equip-slot .eq-item.empty { color: #8b8272; font-style: italic; }
.inv-foot { display: flex; justify-content: space-between; gap: 16px; padding: 12px 20px 15px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-soft); position: relative; z-index: 1; }

/* journal */
.journal-panel { width: min(760px, 94vw); }
.journal-wrap { padding: 20px 24px 26px; position: relative; z-index: 1; }
.qblock { border-bottom: 1px solid var(--line); padding: 14px 0 18px; }
.qblock:last-child { border-bottom: 0; }
.qblock h3 { font-family: var(--sc); font-size: 14px; letter-spacing: .14em; margin: 0 0 3px; font-weight: 400; }
.qblock .qkind { font-size: 10.5px; letter-spacing: .16em; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 10px; }
.qobj { display: flex; gap: 9px; font-size: 14.5px; line-height: 1.5; color: #433a30; padding: 2px 0; }
.qobj .qmark { width: 14px; flex: 0 0 auto; color: #8b8272; }
.qobj.done { color: #7d7768; text-decoration: line-through; text-decoration-color: rgba(74,66,55,.35); }
.qobj.done .qmark { color: #5f6c4a; }
.qobj.active { color: #2f2b25; font-weight: 600; }
.qempty { font-style: italic; color: var(--ink-soft); padding: 8px 0; }

/* map */
.map-panel { width: min(980px, 95vw); }
.map-frame { padding: 16px 20px 6px; position: relative; z-index: 1; }
#mapSvg { width: 100%; height: auto; display: block; border: 1px solid rgba(74,66,55,.3); background: #e6dcc6; }
.map-foot { display: flex; justify-content: space-between; gap: 14px; padding: 9px 20px 16px; font-size: 11.5px; color: var(--ink-soft); position: relative; z-index: 1; }

/* merchant */
.trade-panel { width: min(880px, 95vw); }
.trade-gold { display: flex; align-items: center; gap: 5px; font-size: 14px; color: #7a5a25; }
.trade-gold img { width: 18px; height: 18px; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; position: relative; z-index: 1; }
.trade-col { padding: 16px 20px 20px; }
.trade-col:first-child { border-right: 1px solid var(--line); }
.trade-h { font-family: var(--sc); font-size: 10px; letter-spacing: .2em; color: var(--ink-soft); margin-bottom: 10px; }
.trade-list { display: flex; flex-direction: column; }
.trade-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid rgba(74,66,55,.12); }
.trade-list .trade-row:last-child { border-bottom: 0; }
.trade-row img { width: 32px; height: 32px; object-fit: contain; background: #2c2822; padding: 2px; }
.trade-row .tname { font-family: var(--sc); font-size: 12.5px; letter-spacing: .05em; }
.trade-row .tsub { font-size: 11px; color: var(--ink-soft); }
.trade-row .tprice { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #7a5a25; }
.trade-row button { font-family: var(--sc); font-size: 9.5px; letter-spacing: .1em; padding: 5px 9px; border: 1px solid rgba(74,66,55,.35); }
.trade-row button:hover { background: rgba(180,146,79,.2); }
.trade-row button:disabled { opacity: .35; cursor: default; }
.trade-foot { padding: 11px 20px 15px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-soft); position: relative; z-index: 1; }

/* settings */
.settings-panel { width: min(560px, 94vw); }
.settings-body { padding: 8px 22px 4px; position: relative; z-index: 1; }
.set-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid rgba(74,66,55,.14); font-size: 14px; color: #3b332a; }
.set-row > span { flex: 0 0 175px; }
.set-row input[type="range"] { flex: 1; accent-color: #8c6a2c; height: 20px; }
.set-row b { width: 30px; text-align: right; font-weight: 400; font-size: 12.5px; color: #7a5a25; }
.set-row select { flex: 1; font-family: var(--serif); font-size: 14px; padding: 6px 8px; background: rgba(255,250,238,.4); border: 1px solid rgba(74,66,55,.32); color: var(--ink); }
.settings-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 22px 18px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-soft); position: relative; z-index: 1; }

/* pause */
.pause-panel { width: min(420px, 90vw); text-align: center; padding: 24px 26px 24px; }
.pause-portrait {
  width: 82px; height: 82px; margin: 0 auto 12px; border-radius: 50%;
  overflow: hidden; border: 1px solid rgba(233,225,207,.32); background: rgba(20,17,13,.5);
  box-shadow: 0 0 30px rgba(200,160,90,.08);
}
.pause-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.pause-title { font-family: var(--sc); font-size: 28px; letter-spacing: .3em; margin: 0; font-weight: 400; }
.pause-sub { font-size: 12px; letter-spacing: .1em; color: var(--oat); margin-top: 6px; font-style: italic; }
.pause-list { display: flex; flex-direction: column; gap: 2px; margin: 26px 0 18px; }
.pause-list button { font-family: var(--sc); font-size: 14px; letter-spacing: .13em; padding: 9px 0; color: var(--bone); opacity: .82; }
.pause-list button:hover { color: #fff8e6; opacity: 1; }
.pause-foot { font-size: 11px; color: var(--oat); opacity: .62; font-style: italic; }

/* credits and quit */
.credits-panel { width: min(620px, 94vw); }
.credits-body { padding: 22px 28px 8px; position: relative; z-index: 1; }
.credits-body .big { font-family: var(--sc); font-size: 26px; letter-spacing: .22em; margin-bottom: 4px; }
.credits-body .tagline { color: #6a5c44; margin: 0 0 18px; }
.tagline.small { font-size: 14px; }
.credits-body p { font-size: 14px; line-height: 1.6; color: #433a30; margin-bottom: 12px; }
.credits-rule { font-style: italic; color: #6a5c44; border-top: 1px solid var(--line); padding-top: 14px; }
.muted { opacity: .7; }

/* death */
#death { background: rgba(18,14,10,.82); z-index: 90; }
.death-inner { text-align: center; max-width: 440px; padding: 24px; }
.death-inner h2 { font-family: var(--sc); font-size: clamp(26px, 5vw, 40px); letter-spacing: .16em; font-weight: 400; margin: 0 0 10px; color: #e9e1cf; }
.death-inner p { font-size: 15px; color: var(--oat); font-style: italic; margin-bottom: 24px; }
.death-inner .ink-btn { color: var(--bone); border-color: rgba(233,225,207,.4); }
.death-inner .ink-btn:hover { background: rgba(233,225,207,.12); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .menu-inner { top: 15%; left: 7%; width: 86vw; }
  .wordmark { letter-spacing: .1em; }
  .menu-foot { left: 7%; right: 7%; flex-direction: column; gap: 5px; font-size: 10px; }
  .menu-foot span:last-child { opacity: .8; }
  .menu-vignette { background: radial-gradient(120% 100% at 50% 40%, rgba(24,20,16,0) 30%, rgba(24,20,16,.5) 72%, rgba(20,17,13,.9) 100%), linear-gradient(180deg, rgba(21,18,14,.4), rgba(21,18,14,.12) 40%, rgba(21,18,14,.55)); }
  #questLine { max-width: 66vw; }
  .quest-kicker { font-size: 9.5px; }
  .bars { width: min(210px, 50vw); }
  .bar-label { width: 49px; font-size: 8px; opacity: .95; text-shadow: 0 1px 4px rgba(18,14,10,1); }
  .bar-num { width: 52px; font-size: 9px; }
  .levelplate { width: 40px; height: 40px; }
  #levelNum { font-size: 18px; }
  #hud { padding-bottom: 0; }
  #vitals {
    bottom: auto;
    top: calc(max(14px, env(safe-area-inset-top)) + 66px);
    left: 14px;
    gap: 9px;
  }
  .bars { width: min(230px, 52vw); }
  #quickbar {
    bottom: auto;
    top: calc(max(14px, env(safe-area-inset-top)) + 156px);
    right: 12px;
    gap: 7px;
  }
  .quick { width: 40px; height: 40px; }
  .quick img { width: 28px; height: 28px; }
  .coinbox { margin-left: 0; font-size: 12px; }
  #weaponBadge { display: none; }
  #compass { display: none; }
  #toasts { bottom: auto; top: 20%; }
  .inv-wrap { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
  .inv-detail { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 14px; min-height: 0; }
  .detail-icon { width: 72px; height: 72px; }
  .inv-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .inv-actions { margin-top: 4px; }
  .equip-row { padding: 0 14px 12px; gap: 6px; }
  .equip-slot .eq-label { font-size: 7.5px; letter-spacing: .12em; }
  .equip-slot .eq-item { font-size: 11px; }
  .inv-foot { flex-direction: column; gap: 4px; padding: 10px 14px 14px; font-size: 10.5px; }
  .dialog-panel { min-height: 0; max-height: 54vh; }
  .portrait-wrap { flex-basis: 30vw; min-height: 120px; }
  .dlg-body { padding: 14px 15px 13px 2px; }
  #dlgText { font-size: 14.5px; line-height: 1.5; max-height: 30vh; overflow: auto; }
  .dialg-head { margin-bottom: 5px; }
  .portrait-wrap img { max-height: 200px; }
  .trade-cols { grid-template-columns: 1fr; }
  .trade-col:first-child { border-right: 0; border-bottom: 1px solid var(--line); }
  .trade-col { padding: 12px 14px 16px; }
  .set-row { flex-wrap: wrap; gap: 6px 12px; }
  .set-row > span { flex: 1 0 100%; font-size: 13px; }
  .set-row b { width: 26px; }
  .map-frame { padding: 10px; }
  .map-foot { flex-direction: column; gap: 3px; padding: 8px 14px 13px; font-size: 10px; }
  .panel-head { padding: 12px 14px; }
  .pause-panel { padding: 22px 18px 18px; }
  #interactPrompt { bottom: 34%; }
  #subtitle { bottom: 27%; }
  #hintStrip { bottom: auto; top: 22%; font-size: 10.5px; line-height: 1.55; max-width: 78vw; }
  #areaBanner { top: 19%; }
  .toast { min-width: 150px; }
}
@media (max-width: 420px) {
  .wordmark { font-size: 42px; }
  .tagline { font-size: 13px; }
  .menu-item { font-size: 14px; }
  .inv-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu-inner { top: 10%; }
  .wordmark { font-size: 44px; }
  .tagline { margin-bottom: 12px; }
  .menu-list { flex-direction: row; flex-wrap: wrap; gap: 2px 16px; max-width: 70vw; }
  .menu-item { padding-top: 3px; padding-bottom: 3px; }
  .menu-note { display: none; }
  .menu-foot { bottom: 8px; }
  .dialog-panel { min-height: 0; }
  .portrait-wrap { flex-basis: 120px; min-height: 100px; }
  #dlgText { font-size: 13px; }
  .pause-panel { padding: 14px; }
  .pause-list { margin: 12px 0 8px; }
  .pause-list button { padding: 5px 0; font-size: 12px; }
}
@media (pointer: coarse) {
  #stick { background: rgba(24,20,16,.32); border-color: rgba(233,225,207,.42); }
  #stickKnob { background: rgba(233,225,207,.2); }
  #touchMenu { font-size: 8.5px; letter-spacing: .04em; }
}
@media (pointer: coarse) and (min-width: 700px) {
  #quickbar {
    top: calc(max(14px, env(safe-area-inset-top)) + 96px);
    right: 14px;
    bottom: auto;
  }
  #weaponBadge { display: none; }
  #hintStrip { display: none; }
  #toasts { bottom: auto; top: 24%; right: 14px; }
}
@media (pointer: fine) {
  #touchUI { display: none !important; }
}

/* ---------- abilities and boss bar ---------- */
#abilityTray {
  position: absolute; left: max(18px, env(safe-area-inset-left));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px);
  transform: none;
  display: flex; align-items: center; gap: 8px;
  pointer-events: auto; z-index: 21;
}
.ab {
  position: relative; width: 42px; height: 42px;
  border: 1px solid rgba(233,225,207,.28); background: rgba(24,20,16,.34);
  color: var(--tallow-bright); display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; padding: 0;
  backdrop-filter: blur(2px); cursor: pointer;
}
.ab .ab-key { position: absolute; left: 3px; top: 1px; font-size: 8.5px; letter-spacing: .06em; color: var(--oat); opacity: .8; }
.ab .ab-cd { position: absolute; inset: 0; background: rgba(16,13,10,.66); transform-origin: bottom; transform: scaleY(0); pointer-events: none; }
.ab .ab-glyph { opacity: .92; }
.ab.locked .ab-glyph { opacity: .2; }
.ab.locked { border-color: rgba(233,225,207,.14); }
.ab.ready { border-color: rgba(204,171,98,.6); box-shadow: 0 0 10px rgba(204,171,98,.12) inset; }
.ab:active { background: rgba(180,146,79,.35); }

#bossBar {
  position: absolute; left: 50%; top: max(48px, calc(env(safe-area-inset-top) + 36px));
  transform: translateX(-50%);
  width: min(560px, 84vw); text-align: center;
  text-shadow: 0 2px 12px rgba(14,10,16,.9);
  pointer-events: none;
}
#bossName {
  font-family: var(--sc); font-size: 13px; letter-spacing: .2em;
  color: #e9dcff; margin-bottom: 5px;
}
.boss-trough {
  position: relative; height: 9px; background: rgba(20,14,26,.72);
  border: 1px solid rgba(190,150,235,.55); overflow: hidden;
}
#bossFill {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: linear-gradient(180deg, #a66fe0, #5e2f8a);
  transition: width .16s linear;
}

@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  #abilityTray {
    left: max(22px, env(safe-area-inset-left));
    transform: none;
    bottom: calc(max(96px, env(safe-area-inset-bottom)) + 124px);
    display: grid;
    grid-template-columns: repeat(2, 38px);
    gap: 6px;
  }
  .ab { width: 38px; height: 38px; font-size: 16px; }
  #bossBar { top: max(64px, calc(env(safe-area-inset-top) + 50px)); width: min(84vw, 360px); }
  #bossBar .boss-trough { height: 8px; }
}

@media (max-aspect-ratio: 1/1) {
  #bossBar { top: calc(max(14px, env(safe-area-inset-top)) + 205px); }
}

@media (pointer: coarse) and (min-width: 700px) {
  #abilityTray {
    left: 50%; transform: translateX(-50%);
    bottom: max(18px, env(safe-area-inset-bottom));
    display: flex;
  }
}
