:root{
  --ink:#241c14;
  --ink-soft:#3a2d20;
  --gold:#c7a028;
  --gold-dark:#8a6a1e;
  --parch:#e6d9b8;
  --madder:#9b3b2c;
  --slate:#3e5a75;
  --moss:#4f6b3c;
  --rail:clamp(22px, 3.2vw, 46px);
  --corner-w:calc(var(--rail) * 3.35);
  --corner-b:calc(var(--rail) * 2.65);
  --vellum-border:22px;
}

*{box-sizing:border-box;}

html,body{
  margin:0;
  padding:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:#1a1510;
  color:var(--ink);
  font-family:'Alegreya', Georgia, serif;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  overscroll-behavior:none;
}

#stage{
  position:fixed;
  inset:0;
  z-index:1;
  background:#2c3324;
}
#stage canvas{
  display:block;
  width:100% !important;
  height:100% !important;
  touch-action:none;
  filter:contrast(1.2) saturate(.7) sepia(.6) hue-rotate(-14deg) brightness(.85);
}

#grade{
  position:fixed;
  inset:0;
  z-index:4;
  pointer-events:none;
  background:
    radial-gradient(112% 96% at 50% 44%, rgba(10,8,6,0) 26%, rgba(10,8,6,.62) 100%),
    linear-gradient(180deg, rgba(30,34,34,.15) 0%, rgba(30,18,12,.24) 100%);
  mix-blend-mode:multiply;
}
#grade::before{
  display:none;
}
#grain{
  position:fixed;
  inset:0;
  z-index:5;
  pointer-events:none;
  background-image:url(assets/grain.png);
  background-size:128px 128px;
  opacity:.31;
  mix-blend-mode:multiply;
}

#frame{
  position:fixed;
  inset:0;
  z-index:80;
  pointer-events:none;
  filter:brightness(.82) saturate(.9) sepia(.22) contrast(1.05);
  opacity:.94;
}
#frame .rail{
  position:absolute;
  background-repeat:repeat;
  opacity:.96;
}
.rail-top{
  top:0; left:calc(var(--corner-w) * .55); right:calc(var(--corner-w) * .55);
  height:var(--rail);
  background-image:url(assets/manuscript_border_05_rail_horizontal.webp);
  background-size:auto 100%;
  background-repeat:repeat-x;
}
.rail-bottom{
  bottom:0; left:calc(var(--corner-b) * .62); right:calc(var(--corner-b) * .62);
  height:var(--rail);
  background-image:url(assets/manuscript_border_05_rail_horizontal.webp);
  background-size:auto 100%;
  background-repeat:repeat-x;
  transform:scaleY(-1);
}
.rail-left{
  left:0; top:calc(var(--corner-w) * .55); bottom:calc(var(--corner-b) * .55);
  width:var(--rail);
  background-image:url(assets/manuscript_border_06_rail_vertical.webp);
  background-size:100% auto;
  background-repeat:repeat-y;
}
.rail-right{
  right:0; top:calc(var(--corner-w) * .55); bottom:calc(var(--corner-b) * .55);
  width:var(--rail);
  background-image:url(assets/manuscript_border_06_rail_vertical.webp);
  background-size:100% auto;
  background-repeat:repeat-y;
  transform:scaleX(-1);
}
.corner{
  position:absolute;
  display:block;
  height:auto;
  user-select:none;
}
.corner-tl{top:0;left:0;width:var(--corner-w);}
.corner-tr{top:0;right:0;width:var(--corner-w);}
.corner-bl{bottom:0;left:0;width:var(--corner-b);}
.corner-br{bottom:0;right:0;width:var(--corner-b);}

#titlebar{
  position:fixed;
  z-index:86;
  top:0;
  left:50%;
  transform:translateX(-50%);
  padding:calc(var(--rail) * .20) 1.4rem .34rem;
  background:#1d1710;
  border:1px solid rgba(168,132,44,.5);
  text-align:center;
  pointer-events:none;
  max-width:78vw;
}
#titlebar h1{
  margin:0;
  font-family:'Cinzel Decorative', serif;
  font-weight:700;
  font-size:clamp(13px, 1.55vw, 23px);
  letter-spacing:.34em;
  text-indent:.34em;
  color:#b08a2a;
  white-space:nowrap;
  line-height:1;
}
#titlebar .sub{
  display:block;
  margin-top:5px;
  font-family:'Alegreya SC', serif;
  font-size:clamp(7px, .63vw, 10px);
  letter-spacing:.42em;
  text-indent:.42em;
  color:#7f6a2c;
  white-space:nowrap;
}
#titlebar::after{
  content:"";
  display:block;
  height:1px;
  margin-top:5px;
  background:linear-gradient(90deg, transparent, #6d5620 18%, #6d5620 82%, transparent);
}

#meters{
  position:fixed;
  z-index:47;
  top:calc(var(--rail) + 10px);
  right:calc(var(--rail) + 12px);
  display:flex;
  align-items:flex-start;
  gap:clamp(4px, .5vw, 10px);
}
.orb,.crest{
  position:relative;
  display:block;
  padding:0;
  border:0;
  background:none;
  width:clamp(62px, 7.2vw, 112px);
  aspect-ratio:1;
  cursor:pointer;
}
#meters img{
  display:block;
  width:100%;
  height:100%;
  pointer-events:none;
}
.orb{filter:drop-shadow(0 0 0 transparent);}
.orb-inner{
  position:absolute;
  left:17.4%;
  top:16.6%;
  width:65.2%;
  height:66.2%;
  border-radius:50%;
  overflow:hidden;
  background:#2b3d4d;
  box-shadow:inset 0 0 0 1px rgba(28,20,13,.35);
}
.orb-liquid{
  position:absolute;
  left:0; right:0; bottom:0;
  height:100%;
  background:
    radial-gradient(circle at 37% 30%, #6f8fa6 0%, #43637c 34%, #2c4459 68%, #22323f 100%);
  transition:height .22s linear;
}
.orb-glint{
  position:absolute;
  left:23%; top:13%;
  width:28%;
  height:20%;
  border-radius:50%;
  background:rgba(230,240,245,.52);
  filter:blur(1px);
}
.orb-num{
  position:absolute;
  left:0; right:0;
  bottom:calc(var(--rail) * -.08);
  text-align:center;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(9px, .9vw, 12px);
  letter-spacing:.08em;
  color:#e6d9b8;
  text-shadow:0 1px 0 #1b140d;
  pointer-events:none;
}
.crest-plate{
  position:absolute;
  left:50%;
  bottom:5%;
  transform:translateX(-50%);
  min-width:38%;
  padding:.06em .22em .1em;
  background:#c7a028;
  border:1px solid #241c14;
  color:#241c14;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(10px, 1.12vw, 16px);
  line-height:1.05;
  letter-spacing:.04em;
  text-align:center;
}
.crest.shimmer img{
  animation:crestShimmer .85s ease-out 1;
}
@keyframes crestShimmer{
  0%{filter:brightness(1);}
  28%{filter:brightness(1.55);}
  100%{filter:brightness(1);}
}

.vellum{
  background-color:#d9c79c;
  filter:brightness(.9) saturate(.9) sepia(.18) contrast(1.02);
  border-style:solid;
  border-color:transparent;
  border-width:var(--vellum-border);
  border-image:url(assets/interface_kit_01_vellum_panel.webp) 46 fill / var(--vellum-border) / 0 stretch;
  box-shadow:none;
}

#pack{
  position:fixed;
  z-index:47;
  right:calc(var(--rail) + 10px);
  top:calc(var(--rail) + 128px);
  width:clamp(226px, 19vw, 300px);
  height:min(600px, calc(100vh - var(--rail) * 2 - 150px));
  min-height:300px;
  display:flex;
  flex-direction:column;
  padding:0;
}
.pack-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:6px;
  padding:12px 26px 5px 18px;
  border-bottom:1px solid rgba(36,28,20,.42);
}
.pack-title{
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(10px, .95vw, 14px);
  letter-spacing:.2em;
  color:#6b5119;
  white-space:nowrap;
}
.pack-sub{
  font-family:'Alegreya SC', serif;
  font-size:clamp(6px, .58vw, 8px);
  letter-spacing:.16em;
  color:#8a7748;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.slots{
  flex:1;
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  grid-auto-rows:min-content;
  align-content:center;
  gap:clamp(5px, .55vw, 9px);
  padding:clamp(6px, .8vh, 12px) 7px;
  min-height:0;
}
.slot{
  position:relative;
  width:100%;
  aspect-ratio:1;
  background:url(assets/interface_kit_02_slot_frame.webp) center / 100% 100% no-repeat;
  overflow:hidden;
}
.slot .item{
  position:absolute;
  left:11%;
  top:9%;
  width:78%;
  height:74%;
  object-fit:contain;
  pointer-events:none;
}
.slot .count{
  position:absolute;
  right:7%;
  bottom:3%;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(9px, .88vw, 13px);
  line-height:1;
  color:#241c14;
  letter-spacing:.02em;
}
.pack-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 12px 4px;
  border-top:1px solid rgba(36,28,20,.42);
}
.purse{
  display:flex;
  align-items:center;
  gap:6px;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(11px, 1.05vw, 15px);
  color:#241c14;
  min-width:0;
}
.purse img{
  width:clamp(22px, 2.1vw, 30px);
  height:auto;
  display:block;
}
.gold-seal{
  position:relative;
  width:clamp(42px, 4.2vw, 62px);
  height:clamp(42px, 4.2vw, 62px);
  padding:0;
  border:0;
  background:url(assets/interface_kit_03_gold_button.webp) center / 100% 100% no-repeat;
  color:#241c14;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(8px, .72vw, 11px);
  letter-spacing:.06em;
  cursor:pointer;
  display:grid;
  place-items:center;
  transition:transform .09s ease, filter .15s ease;
}
.gold-seal span{transform:translateY(-1px);}
.gold-seal:active{transform:scale(.95);}
.gold-seal:disabled{
  filter:grayscale(.55) brightness(.82);
  opacity:.6;
  cursor:default;
}
.gold-seal.small{
  width:64px;
  height:64px;
  font-size:8px;
  letter-spacing:.02em;
}

#chat{
  position:fixed;
  z-index:47;
  left:calc(var(--rail) + 6px);
  bottom:calc(var(--rail) + 8px);
  width:clamp(250px, 25vw, 340px);
  aspect-ratio:421 / 315;
  background:url(assets/interface_kit_05_chat_scroll.webp) center / 100% 100% no-repeat;
  background-color:transparent;
  filter:brightness(.9) saturate(.9) sepia(.18) contrast(1.02);
}
#chatLines{
  position:absolute;
  left:12.6%;
  top:13.5%;
  width:72%;
  height:69%;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  gap:.14em;
}
#chatLines .line{
  font-family:'Alegreya', Georgia, serif;
  font-size:clamp(10px, .94vw, 13.5px);
  line-height:1.42;
  color:#2b2118;
  animation:lineIn .22s ease-out both;
  text-wrap:pretty;
}
#chatLines .line.villager{font-style:italic;color:#3b2c1e;}
@keyframes lineIn{
  from{opacity:0;transform:translateY(4px);}
  to{opacity:1;transform:none;}
}

.hint{
  display:none !important;
  position:fixed;
  z-index:55;
  left:50%;
  transform:translateX(-50%);
  bottom:calc(var(--rail) + 18px);
  width:min(560px, calc(100vw - 2 * var(--rail) - 24px));
  padding:12px 38px 12px 16px;
  border-width:14px;
  display:flex;
  align-items:center;
  gap:10px;
  transition:opacity .35s ease;
}
.hint.gone{opacity:0;pointer-events:none;}
#hintText{
  font-size:clamp(12px, 1.02vw, 15px);
  line-height:1.35;
  color:#2b2118;
}
#hintClose{
  position:absolute;
  top:4px; right:6px;
  width:26px;height:26px;
  border:1px solid rgba(36,28,20,.55);
  background:#d9c79c;
  color:#241c14;
  font-family:'Alegreya SC', serif;
  font-size:12px;
  line-height:1;
  cursor:pointer;
  padding:0;
}

.dialogue{
  position:fixed;
  z-index:62;
  left:50%;
  bottom:calc(var(--rail) + 26px);
  transform:translateX(-50%);
  width:min(600px, calc(100vw - 2 * var(--rail) - 40px));
  padding:8px 10px 8px;
  display:flex;
  align-items:flex-start;
  gap:clamp(8px, 1.1vw, 18px);
}
.portrait{
  width:clamp(74px, 9vw, 108px);
  height:auto;
  display:block;
  flex:0 0 auto;
  margin-top:2px;
}
.dlg-body{
  flex:1;
  min-width:0;
  padding-top:2px;
}
.dlg-body h2,.help h2{
  margin:0 0 6px;
  font-family:'Cinzel Decorative', serif;
  font-weight:700;
  font-size:clamp(13px, 1.45vw, 19px);
  letter-spacing:.16em;
  color:#7d5e12;
  text-transform:uppercase;
}
.dlg-body p{
  margin:0 0 10px;
  font-family:'Alegreya', Georgia, serif;
  font-size:clamp(13px, 1.16vw, 17px);
  line-height:1.38;
  color:#2b2118;
  text-wrap:pretty;
}
.dlg-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.ink-btn{
  border:1px solid rgba(36,28,20,.72);
  background:rgba(36,28,20,.06);
  color:#241c14;
  font-family:'Alegreya SC', serif;
  font-weight:700;
  font-size:clamp(10px, .9vw, 12px);
  letter-spacing:.13em;
  padding:6px 14px 7px;
  cursor:pointer;
  transition:background .15s ease;
}
.ink-btn:hover{background:rgba(199,160,40,.2);}
.ink-btn:active{background:rgba(36,28,20,.16);}
.ink-btn.gold{
  border-color:#8a6a1e;
  color:#6b5119;
  background:rgba(199,160,40,.14);
}
.ink-btn.hidden{display:none;}

.help{
  position:fixed;
  z-index:70;
  left:calc(var(--rail) + 8px);
  top:auto;
  bottom:calc(var(--rail) + 14px);
  transform:none;
  width:min(460px, calc(100vw - 2 * var(--rail) - 20px));
  max-height:min(56vh, 330px);
  overflow:auto;
  padding:12px 14px 8px 26px;
  border-width:18px;
}
.help-body p{
  margin:0 0 8px;
  font-size:clamp(12px, 1.02vw, 15px);
  line-height:1.36;
  color:#2b2118;
}
.help-body b{
  font-family:'Alegreya SC', serif;
  font-weight:700;
  color:#6b5119;
  letter-spacing:.04em;
}
.help-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-top:8px;
  padding-top:8px;
  border-top:1px solid rgba(36,28,20,.4);
}
.sound-set{
  display:flex;
  align-items:center;
  gap:10px;
}
.sound-label{
  font-family:'Alegreya SC', serif;
  font-weight:700;
  font-size:10px;
  letter-spacing:.16em;
  color:#6b5119;
}

.seal-btn{
  position:fixed;
  z-index:48;
  top:calc(var(--rail) + 10px);
  left:calc(var(--rail) + 10px);
  width:clamp(32px, 3vw, 42px);
  height:clamp(32px, 3vw, 42px);
  padding:0;
  border:1px solid rgba(199,160,40,.62);
  background:#1d1710;
  color:var(--gold);
  font-family:'Cinzel Decorative', serif;
  font-weight:700;
  font-size:clamp(15px, 1.5vw, 20px);
  line-height:1;
  cursor:pointer;
}
.seal-btn:hover{background:#2a2116;}

.levelup{
  position:fixed;
  z-index:66;
  left:50%;
  top:26%;
  transform:translate(-50%,-50%);
  text-align:center;
  pointer-events:none;
  animation:levelUpFloat 2.6s ease-out both;
}
.lv-small{
  display:block;
  font-family:'Alegreya SC', serif;
  font-weight:700;
  font-size:clamp(10px, 1vw, 14px);
  letter-spacing:.38em;
  color:#e6d9b8;
  text-shadow:0 1px 0 #1b140d;
}
.lv-big{
  display:block;
  margin-top:2px;
  font-family:'Cinzel Decorative', serif;
  font-weight:900;
  font-size:clamp(34px, 5vw, 68px);
  line-height:1;
  color:var(--gold);
  text-shadow:0 2px 0 #241c14;
}

@keyframes levelUpFloat{
  0%{opacity:0;transform:translate(-50%,-46%) scale(.94);}
  14%{opacity:1;transform:translate(-50%,-50%) scale(1);}
  72%{opacity:1;}
  100%{opacity:0;transform:translateY(-56%) translateX(-50%);}
}

.tooltip{
  position:fixed;
  z-index:90;
  pointer-events:none;
  padding:4px 9px 5px;
  background:#1d1710;
  border:1px solid rgba(199,160,40,.55);
  color:#e6d9b8;
  font-family:'Alegreya SC', serif;
  font-size:11px;
  letter-spacing:.1em;
  white-space:nowrap;
  transform:translate(-50%,-140%);
}
.tooltip b{color:var(--gold);font-weight:700;}

.hidden{display:none !important;}

@keyframes unfurl{
  0%{opacity:0;transform:translateX(-50%) scaleY(.82);}
  70%{opacity:1;}
  100%{opacity:1;transform:translateX(-50%) scaleY(1);}
}
.dialogue.unfurl{transform-origin:50% 100%;animation:unfurl .24s ease-out both;}
@keyframes unfurlCenter{
  0%{opacity:0;transform:translate(-50%,-50%) scale(.94);}
  100%{opacity:1;transform:translate(-50%,-50%) scale(1);}
}
.help.unfurl{animation:helpIn .22s ease-out both;}
@keyframes helpIn{
  0%{opacity:0;transform:translateY(8px);}
  100%{opacity:1;transform:none;}
}
.gold-seal.off{filter:grayscale(.65) brightness(.76);opacity:.72;}
.vellum .gold-seal:not(:disabled){filter:brightness(1.3) saturate(1.2);}
.sound-tab{
  position:fixed;
  z-index:48;
  top:calc(var(--rail) + 48px);
  left:calc(var(--rail) + 10px);
  padding:4px 7px 5px;
  border:1px solid rgba(168,132,44,.55);
  background:#15110c;
  color:#b08a2a;
  font-family:'Alegreya SC', serif;
  font-weight:700;
  font-size:8px;
  letter-spacing:.12em;
  line-height:1;
  cursor:pointer;
}
.sound-tab.off{color:#6f5a2c;background:#100d09;}
#orb.running .orb-inner{box-shadow:inset 0 0 0 1px rgba(28,20,13,.35), inset 0 0 14px rgba(130,170,195,.4);}

@keyframes slotSettle{
  0%{transform:translateY(-9px) scale(.9);opacity:.2;}
  65%{transform:translateY(1px) scale(1.02);opacity:1;}
  100%{transform:none;opacity:1;}
}
.slot.settled .item{animation:slotSettle .32s cubic-bezier(.2,.7,.3,1) both;}

@media (max-height: 559px) and (min-width: 560px){
  #pack{
    top:calc(var(--rail) + 8px);
    bottom:calc(var(--rail) + 8px);
    height:auto;
    width:clamp(178px, 24vw, 214px);
  }
  .slots{
    grid-template-columns:repeat(4, minmax(0,1fr));
    gap:4px;
  }
  .pack-head{padding-bottom:2px;}
  .pack-foot{padding-top:3px;}
  .gold-seal{width:38px;height:38px;}
  #meters{
    right:calc(var(--rail) + clamp(190px, 26vw, 226px));
    top:calc(var(--rail) + 34px);
  }
  #chat{width:clamp(186px, 26vw, 228px);}
  .hint{
    bottom:calc(var(--rail) + 8px);
    left:calc(var(--rail) + 8px);
    transform:none;
    width:min(340px, 48vw);
  }
  #dialogue{bottom:calc(var(--rail) + 12px);}
  .hint{display:none;}
  #help{
    left:calc(var(--rail) + 8px);
    bottom:calc(var(--rail) + 8px);
    width:min(330px, 40vw);
    max-height:calc(100vh - 2 * var(--rail) - 16px);
  }
  .help-body p{font-size:11.5px;line-height:1.28;margin-bottom:4px;}
}

@media (max-width: 759px) and (orientation: portrait), (max-width: 559px){
  #titlebar{max-width:70vw;padding-left:.65rem;padding-right:.65rem;}
  #titlebar .sub{display:none;}
  #helpBtn{top:calc(var(--rail) + 8px);left:calc(var(--rail) + 8px);}
  #meters{
    top:calc(var(--rail) + 34px);
    right:calc(var(--rail) + 6px);
  }
  .orb,.crest{width:clamp(55px, 16vw, 76px);}
  #pack{
    top:auto;
    left:calc(var(--rail) + 5px);
    right:calc(var(--rail) + 5px);
    bottom:calc(var(--rail) + 5px);
    width:auto;
    height:auto;
    min-height:0;
    border-width:16px;
  }
  .pack-head{padding:0 2px 4px;margin:0 0 4px;gap:4px;}
  .pack-main{flex-direction:row;align-items:stretch;gap:8px;}
  .views{flex:1;aspect-ratio:3 / 1.04;}
  .skills{grid-template-columns:repeat(3, minmax(0,1fr));gap:3px;}
  .skill{grid-template-columns:24px 1fr auto;padding:1px 4px;}
  .skill img{width:24px;height:24px;}
  .sk-name{font-size:9.5px;}
  .sk-lv{font-size:12px;}
  .sk-total{display:none;}
  .quest b{font-size:11px;}
  .quest span span{font-size:10px;}
  .bank-slots{grid-template-columns:repeat(6, minmax(0,1fr));max-height:min(150px, 26vh);}
  .slots{
    flex:1;
    grid-template-columns:repeat(6, minmax(0,1fr));
    grid-auto-rows:min-content;
    align-content:center;
    gap:5px;
    padding:0;
  }
  .slot{max-width:none;}
  .slot .count{font-size:9px;}
  .pack-foot{
    flex-direction:column;
    justify-content:center;
    gap:4px;
    padding-top:0;
    border-top:0;
    border-left:1px solid rgba(36,28,20,.42);
    padding-left:8px;
    flex:0 0 auto;
  }
  .purse{font-size:11px;gap:3px;}
  .purse img{width:20px;}
  .gold-seal{width:38px;height:38px;font-size:8px;}
  #chat{
    width:clamp(168px, 44vw, 220px);
    bottom:calc(var(--rail) + 166px);
    left:calc(var(--rail) + 6px);
  }
  #chatLines .line{font-size:clamp(9.5px, 2.4vw, 11.5px);}
  .hint{display:none;}
  #dialogue,#bank{
    bottom:calc(var(--rail) + 172px);
    width:calc(100vw - 2 * var(--rail) - 18px);
    gap:8px;
  }
  .portrait{width:64px;}
  .dlg-body h2{font-size:13px;letter-spacing:.1em;}
  .dlg-body p{font-size:13px;}
  .dialogue{padding:0;}
  .dialogue.vellum{border-width:16px;}
  .help{
    left:calc(var(--rail) + 5px);
    right:calc(var(--rail) + 5px);
    bottom:calc(var(--rail) + 172px);
    width:auto;
    max-height:min(300px, calc(100vh - 2 * var(--rail) - 230px));
    padding:8px 10px 4px 20px;
    border-width:16px;
  }
  .help h2{font-size:12px;letter-spacing:.1em;margin-bottom:4px;}
  .help-body p{font-size:11px;line-height:1.2;margin-bottom:3px;}
  .help-foot{margin-top:4px;padding-top:4px;}
  .levelup{top:22%;}
}

@media (max-width: 390px){
  #titlebar h1{font-size:12px;letter-spacing:.22em;text-indent:.22em;}
  #chat{width:158px;bottom:calc(var(--rail) + 158px);}
}

@media (max-height: 430px){
  #chat{bottom:calc(var(--rail) + 6px);}
}

@media (prefers-reduced-motion: reduce){
  *{animation-duration:.001s !important;transition-duration:.001s !important;}
}

@media (max-width: 759px) and (max-height: 640px) and (orientation: portrait){
  #help{
    max-height:calc(100vh - 2 * var(--rail) - 220px);
    padding:7px 9px 3px 18px;
  }
  .help h2{font-size:11px;margin-bottom:3px;}
  .help-body p{font-size:10px;line-height:1.18;margin-bottom:2px;}
  .help-foot{margin-top:3px;padding-top:3px;}
}

@media (max-height: 559px){
  #help{
    left:calc(var(--rail) + 8px);
    right:auto;
    bottom:calc(var(--rail) + 8px);
    width:min(250px, 36vw);
    max-height:calc(100vh - 2 * var(--rail) - 16px);
  }
  .help-body p{font-size:10.5px;line-height:1.2;margin-bottom:3px;}
  .help h2{font-size:12px;margin-bottom:3px;}
}

/* ---- v3: tabs, skills, quests, hitpoints, strongbox ---- */
.pack-head{align-items:center;padding:10px 14px 6px 14px;gap:6px;justify-content:flex-start;}
.tab{
  flex:1;
  border:1px solid rgba(36,28,20,.5);
  background:rgba(36,28,20,.05);
  color:#6b5119;
  font-family:'Alegreya SC', serif;
  font-weight:800;
  font-size:clamp(9px, .8vw, 12px);
  letter-spacing:.12em;
  padding:4px 2px 5px;
  cursor:pointer;
  white-space:nowrap;
}
.tab.on{background:rgba(199,160,40,.28);border-color:#8a6a1e;color:#241c14;}
.pack-main{flex:1;display:flex;flex-direction:column;min-height:0;}
.views{position:relative;flex:1;min-height:0;}
.views > *{display:none;}
#pack[data-tab="satchel"] .view-satchel{display:grid;}
#pack[data-tab="skills"] .view-skills{display:grid;}
#pack[data-tab="quests"] .view-quests{display:block;}
.view-skills,.view-quests{position:absolute;inset:0;overflow:auto;}
.view-satchel{height:100%;}
button.slot{border:0;padding:0;cursor:pointer;display:block;font:inherit;}
button.slot:active .item{transform:scale(.92);}
.skills{
  grid-template-columns:repeat(2, minmax(0,1fr));
  grid-auto-rows:min-content;
  align-content:start;
  gap:6px;
  padding:8px 8px;
}
.skill{
  display:grid;
  grid-template-columns:34px 1fr auto;
  align-items:center;
  gap:5px;
  padding:3px 6px;
  border:1px solid rgba(36,28,20,.38);
  background:rgba(36,28,20,.04);
  cursor:pointer;
  text-align:left;
  font:inherit;
  color:#241c14;
  min-width:0;
}
.skill img{width:34px;height:34px;object-fit:contain;display:block;}
.sk-name{font-family:'Alegreya SC', serif;font-weight:700;font-size:clamp(10px,.82vw,12px);letter-spacing:.04em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sk-lv{font-family:'Alegreya SC', serif;font-weight:800;font-size:clamp(13px,1.1vw,17px);color:#6b5119;}
.sk-total{grid-column:1 / -1;text-align:center;font-family:'Alegreya SC', serif;font-weight:700;font-size:11px;letter-spacing:.18em;color:#6b5119;padding-top:4px;}
.quests{padding:6px 10px 8px;}
.q-count{font-family:'Alegreya SC', serif;font-weight:700;font-size:10px;letter-spacing:.18em;color:#6b5119;margin-bottom:4px;}
.quest{display:flex;gap:7px;align-items:flex-start;padding:4px 0;border-bottom:1px solid rgba(36,28,20,.2);}
.q-mark{flex:0 0 auto;width:9px;height:9px;margin-top:4px;border:1px solid #241c14;transform:rotate(45deg);}
.quest.active .q-mark{background:#c7a028;}
.quest.done .q-mark{background:#4f6b3c;}
.quest.done b{text-decoration:line-through;text-decoration-color:rgba(36,28,20,.5);}
.q-body{display:flex;flex-direction:column;min-width:0;}
.quest b{font-family:'Alegreya SC', serif;font-weight:800;font-size:clamp(11px,.9vw,13px);color:#241c14;letter-spacing:.03em;}
.quest span span{font-size:clamp(10.5px,.85vw,12.5px);line-height:1.25;color:#3a2d20;}
.orb.hp .orb-inner{background:#3a1e18;}
.orb.hp .orb-liquid{background:radial-gradient(circle at 37% 30%, #b8604c 0%, #9b3b2c 38%, #6e2a1f 72%, #4a1d16 100%);}
#chatLines .line.quest{color:#6b5119;font-weight:700;}
#chatLines .line.place{font-variant:small-caps;letter-spacing:.02em;}
.bank{flex-direction:column;}
.bank .dlg-body{width:100%;}
.bank-note{font-size:clamp(11px,.95vw,14px) !important;margin-bottom:6px !important;}
.bank-slots{
  display:grid;
  grid-template-columns:repeat(8, minmax(0,1fr));
  gap:5px;
  max-height:min(220px, 32vh);
  overflow:auto;
  margin-bottom:8px;
  padding:2px;
}
.help{z-index:72;}
.help.hidden{display:none !important;}
@media (max-height: 559px) and (min-width: 560px){
  .pack-head{padding:6px 10px 3px;}
  .tab{font-size:8.5px;padding:3px 1px;}
  .slots{align-content:start;}
  .skills{grid-template-columns:1fr;gap:3px;padding:4px;}
  .skill{grid-template-columns:22px 1fr auto;padding:1px 4px;}
  .skill img{width:22px;height:22px;}
  .sk-total{display:none;}
  #bank{bottom:calc(var(--rail) + 8px);width:min(520px, calc(100vw - 2 * var(--rail) - 250px));left:calc(50% - 110px);}
  .bank-slots{max-height:30vh;}
}
@media (max-width: 759px) and (orientation: portrait), (max-width: 559px){
  .pack-head{padding:0 2px 4px;margin:0 0 4px;gap:4px;}
  .tab{font-size:9px;padding:3px 1px 4px;letter-spacing:.08em;}
  .pack-main{flex-direction:row;align-items:stretch;gap:8px;}
  .views{flex:1;aspect-ratio:3 / 1.04;}
  .skills{grid-template-columns:repeat(3, minmax(0,1fr));gap:3px;padding:2px;}
  .skill{grid-template-columns:22px 1fr auto;padding:1px 3px;gap:3px;}
  .skill img{width:22px;height:22px;}
  .sk-name{font-size:9px;letter-spacing:0;}
  .sk-lv{font-size:12px;}
  .sk-total{display:none;}
  .quests{padding:0 4px;}
  .q-count{display:none;}
  .quest{padding:2px 0;}
  .quest b{font-size:10.5px;}
  .quest span span{font-size:10px;line-height:1.15;}
  .bank-slots{grid-template-columns:repeat(6, minmax(0,1fr));max-height:min(150px, 26vh);}
}
@media (max-width: 759px) and (orientation: portrait), (max-width: 559px){
  #bank.vellum{padding:8px 14px 6px;}
  #bank h2{margin-left:14px;}
}
.help.unfurl{animation:helpRise .22s ease-out both;}
@keyframes helpRise{0%{transform:translateY(8px);}100%{transform:none;}}
body.help-open #chat{visibility:hidden;}
#chatLines{justify-content:flex-end;}

@media (max-height: 559px) and (min-width: 560px){
  #help{
    width:min(560px, calc(100vw - 2 * var(--rail) - 250px));
    max-height:calc(100vh - 2 * var(--rail) - 12px);
    padding:6px 12px 4px 18px;
  }
  .help-body{column-count:2;column-gap:16px;}
  .help-body p{break-inside:avoid;font-size:10.5px;line-height:1.22;margin-bottom:4px;}
  .help-foot{margin-top:2px;padding-top:4px;}
  .help-foot .ink-btn{padding:4px 12px 5px;}
}
@media (max-height: 559px) and (min-width: 560px){
  .tab{letter-spacing:.02em;font-size:8.5px;}
}
@media (max-height: 559px) and (min-width: 560px){
  #pack{width:clamp(196px, 27vw, 232px);}
  #meters{right:calc(var(--rail) + clamp(206px, 28vw, 244px));}
  .pack-head{padding:6px 6px 3px;gap:3px;}
}
