/* =====================================================================
   Full-screen stage + bottom dock + sliding sheets (loaded last).
   The stage fills everything above the dock. BAG and SKILLS slide up
   over the stage and slide away again.
   ===================================================================== */
#phone { position: relative; }
#stage { flex: 1 1 auto; min-height: 0; }

/* ---------------- dock */
#dock {
  position: relative; z-index: 22; flex: 0 0 auto; display: flex; gap: 8px; align-items: stretch;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: var(--stone), #17130f; background-size: 192px 192px;
  box-shadow: inset 0 2px 0 #6a5434, inset 0 4px 0 #050403, 0 -6px 14px rgba(0, 0, 0, .6);
}
#lvBadge {
  flex: 0 0 62px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #5a1a10, #250a06 70%);
  box-shadow: var(--bronze-hi); color: var(--gold); text-shadow: 0 2px 0 #000;
}
#lvBadge small { font-family: var(--title); font-size: 9px; letter-spacing: 1.5px; color: #c9a45c; line-height: 1; }
#lvBadge b { font-family: var(--title); font-size: 30px; line-height: 1; font-weight: 700; color: #ffd98a; }
#lvBadge.up { animation: lvPop .6s ease-out; }
@keyframes lvPop { 30% { transform: scale(1.18); filter: brightness(1.6); } }
#dockMain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#xpBar {
  position: relative; height: 14px; background: #0a0806;
  box-shadow: 0 0 0 2px #050403, 0 0 0 3px #6a5434;
}
#xpFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#b48aff, #5e2c96); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28); transition: width .25s; }
#xpTxt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--px); font-weight: 800; font-size: 11px; color: #f2e8d4; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
#dockBtns { display: flex; gap: 5px; height: 36px; }
#dockBtns > button { border: 0; border-radius: 0; color: var(--text); background: linear-gradient(180deg, #3a2f22 0%, #241c14 55%, #17120c 100%); box-shadow: var(--bronze); text-shadow: 0 1px 0 #000; }
.dbtn { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 4px; font-family: var(--title); font-weight: 700; font-size: 13px; letter-spacing: .5px; white-space: nowrap; padding: 0 4px; }
.dbtn.on { color: var(--gold); background: linear-gradient(180deg, #4a1a12, #2a0e08) !important; box-shadow: var(--bronze-hi) !important; }
.dbtn i { font-style: normal; font-family: var(--px); font-weight: 800; font-size: 12px; background: var(--red, #b0281e); color: #fff; padding: 0 5px; }
.dbtn i:empty { display: none; }
#dockBtns .icon { position: relative; flex: 0 0 36px; padding: 0; display: flex; align-items: center; justify-content: center; }
#dockBtns .icon img { width: 20px; height: 20px; image-rendering: pixelated; pointer-events: none; filter: sepia(.6) saturate(.8) brightness(.95) drop-shadow(1px 1px 0 #000); }
#dockBtns > button:active { transform: translateY(1px); }

/* ---------------- the sheet */
#panel {
  position: absolute; left: 0; right: 0; bottom: var(--dockH, 66px); z-index: 21;
  max-height: calc(100% - var(--dockH, 66px) - 60px);
  display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 10px;
  transform: translateY(calc(100% + var(--dockH, 66px))); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  box-shadow: inset 0 2px 0 #6a5434, inset 0 4px 0 #050403, 0 -8px 18px rgba(0, 0, 0, .7);
  pointer-events: none;
}
#panel.open { transform: translateY(0); pointer-events: auto; }
#sheetHead { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; height: 30px; }
#sheetTitle { font-family: var(--title); font-size: 15px; font-weight: 700; color: var(--gold); letter-spacing: 1px; text-shadow: 0 1px 0 #000; }
#money { margin-left: auto; display: flex; gap: 5px; height: 28px; }
#money[hidden] { display: none; }
#money .chip { padding: 0 8px; font-size: 15px; }
#sheetClose { flex: 0 0 30px; height: 28px; border: 0; color: var(--text); font-size: 14px; background: linear-gradient(180deg, #3a2f22, #17120c); box-shadow: var(--bronze); }
#money[hidden] + #sheetClose { margin-left: auto; }
.tab { flex: 0 1 auto; min-height: 0; }
#tabSkills { height: auto; max-height: min(62vh, 520px); overflow: hidden; display: flex; flex-direction: column; }
#tabSkills.hidden { display: none; }

/* ---------------- skills: two slots, then the lists */
#skillHead { display: grid; grid-template-columns: 1fr 1fr 54px; gap: 6px; white-space: normal; }
.sslot, .spts { display: flex; align-items: center; gap: 6px; min-width: 0; height: 44px; padding: 0 8px; background: #0a0806; box-shadow: inset 0 0 0 2px #050403, inset 0 0 0 3px #7a5e34; }
.sslot small, .spts small { font-family: var(--title); font-size: 9px; color: #c9a45c; letter-spacing: 1px; writing-mode: vertical-rl; transform: rotate(180deg); }
.sslot img { width: 26px; height: 26px; image-rendering: pixelated; }
.sslot b { font-family: var(--px); font-weight: 800; font-size: 13px; color: #f2e8d4; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.sslot.empty b { color: #6a5a44; font-weight: 700; }
.spts { justify-content: center; }
.spts b { font-family: var(--title); font-size: 20px; color: #6a5a44; }
.spts.has b { color: var(--gold); }
#skillList { overflow-y: auto; }
.sgroup { margin: 6px 0 0; font-family: var(--title); font-size: 11px; letter-spacing: 1.5px; color: #c9a45c; }
.skill.worn { box-shadow: inset 0 0 0 2px #c9a45c, inset 4px 0 0 #ffd23f !important; }
.skill .equip { flex: 0 0 auto; min-width: 54px; height: 30px; margin-right: 4px; border: 0; font-family: var(--title); font-size: 11px; font-weight: 700; color: var(--text); background: linear-gradient(180deg, #3a2f22, #17120c); box-shadow: var(--bronze); }
.skill .equip.on { color: var(--gold); background: linear-gradient(180deg, #4a1a12, #2a0e08); }
.skill .equip:disabled:not(.on) { opacity: .35; }

/* ---------------- top HUD: stage progress */
.unit.xpbar .hp i { background: linear-gradient(#e0a04a, #8a4a12) !important; }
.unit.xpbar.bossing .hp i { background: linear-gradient(#ff6a4a, #8a1a0a) !important; }

/* item sheet and pages sit above the sliding sheet */
#itemSheet { z-index: 30; }
.screen { z-index: 40; }

/* night vignette: the edges of the view fall into darkness */
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 80% 62% at 50% 50%, rgba(0, 0, 0, 0) 45%, rgba(4, 3, 6, .55) 78%, rgba(2, 1, 3, .9) 100%); }
#floaters, #bars, #hud, #status, #toast { z-index: 3; }
/* the bag's own header already says what it is */
.bayHead > span { display: none; }

/* ---------------- level badge opens the character sheet */
#lvBadge { position: relative; border: 0; padding: 0; cursor: pointer; }
#lvBadge.on { box-shadow: var(--bronze-hi), 0 0 0 2px #ffd23f; }
#lvBadge i { position: absolute; top: -6px; right: -6px; font-style: normal; font-family: var(--px); font-weight: 800; font-size: 11px; color: #fff; background: #b0281e; padding: 1px 4px; box-shadow: 0 0 0 2px #050403; animation: apBlink 1.2s steps(2) infinite; }
#lvBadge i:empty { display: none; }
@keyframes apBlink { 50% { background: #e0503a; } }
#tabStats {
  display: flex; flex: 1 1 auto; flex-direction: column; gap: 8px; min-height: 0;
  overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; padding-bottom: 8px;
}
#tabStats > * { flex-shrink: 0; }
#tabStats.hidden { display: none; }
.apHead { display: flex; align-items: center; gap: 10px; }
.apHead b { font-family: var(--title); font-size: 26px; color: #6a5a44; min-width: 34px; text-align: center; }
.apHead.has b { color: var(--gold); }
.apHead span { font-family: var(--title); font-size: 13px; color: #c9a45c; display: flex; flex-direction: column; }
.apHead small { font-family: var(--px); font-size: 12px; color: #9a8a70; letter-spacing: 0; }
.attrs { display: flex; flex-direction: column; gap: 4px; }
.attr { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; background: rgba(10, 8, 6, .85); box-shadow: inset 0 0 0 1px #3a2e1e; }
.attr .an { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attr .an b { font-family: var(--title); font-size: 14px; color: #f2e8d4; }
.attr .an small { font-family: var(--px); font-weight: 700; font-size: 12px; color: #9a8a70; }
.attr .av { font-family: var(--title); font-size: 20px; color: var(--gold); min-width: 30px; text-align: right; }
.derived { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 10px; margin: 2px 0 0; padding: 8px 10px; background: rgba(10, 8, 6, .7); box-shadow: inset 0 0 0 1px #3a2e1e; font-family: var(--px); font-size: 13px; font-weight: 700; }
.derived dt { color: #9a8a70; }
.derived dd { margin: 0; color: #f2e8d4; }
#attrReset { align-self: flex-end; height: 30px; padding: 0 12px; border: 0; font-family: var(--title); font-size: 11px; color: var(--text); background: linear-gradient(180deg, #3a2f22, #17120c); box-shadow: var(--bronze); }
#attrReset:disabled { opacity: .4; }
.dbtn { font-size: 12px; }
