:root {
  --font: Georgia, serif;
  --ink: #f3e6cc;
  --dim: #b9a888;
  --ember: #f0b060;
  --teal: #50e0d0;
  --bad: #ff6a50;
  --good: #8fe07a;
  --outline: #120a04;
  --fs: clamp(13px, 2.1vh, 17px);
  --panel: url(assets/ui-panel.webp);
  --button: url(assets/ui-button.webp);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1114; color: var(--ink); font-family: var(--font); font-size: var(--fs); user-select: none; -webkit-user-select: none; touch-action: none; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
img { -webkit-user-drag: none; }
.ol, b, .btn, .mtitle, #timer, .bt, .bn, .blv, .hn { text-shadow: -1px -1px 0 var(--outline), 1px -1px 0 var(--outline), -1px 1px 0 var(--outline), 1px 1px 0 var(--outline), 0 2px 0 var(--outline), 0 3px 4px rgba(0,0,0,.7); }

/* ---------- plates & buttons (9-slice art) ---------- */
/* The art has transparent margins: the slices start at the picture's edges and the outsets push the empty part
   outside the box, so the plate's visible frame lines up with the element's border box. */
.plate, .panel {
  border-style: solid; border-width: 22px; background: none;
  border-image-source: var(--panel);
  border-image-slice: 173 63 182 64 fill;
  border-image-width: 69px 25px 73px 26px;
  border-image-outset: 47px 3px 50px 3px;
  border-image-repeat: stretch;
}
.plate { border-width: 8px 12px; border-image-width: 38px 14px 40px 14px; border-image-outset: 26px 2px 28px 2px; }
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 6px;
  font: 700 1em var(--font); color: var(--ink); letter-spacing: .02em;
  border-style: solid; border-width: 6px 14px; background: none;
  border-image-source: var(--button);
  border-image-slice: 154 44 164 48 fill;
  border-image-width: 46px 13px 49px 14px;
  border-image-outset: 35px 1px 38px 2px;
  border-image-repeat: stretch;
  cursor: pointer; outline: none;
  transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .12s;
}
.btn:hover { filter: brightness(1.18); transform: scale(1.04); }
.btn:active { transform: scale(.93); filter: brightness(.9); }
.btn.primary { filter: sepia(.4) saturate(2.2) hue-rotate(-12deg) brightness(1.1); color: #fff3d8; }
.btn.primary:hover { filter: sepia(.4) saturate(2.2) hue-rotate(-12deg) brightness(1.3); }
.btn.dim, .btn:disabled { filter: grayscale(.9) brightness(.6); }
.btn.small { min-height: 44px; padding: 0 4px; font-size: .92em; }
.btn.big { min-height: 58px; padding: 0 18px; font-size: 1.3em; }
.btn .bic { width: 26px; height: 26px; object-fit: contain; pointer-events: none; }
.btn .bl { pointer-events: none; white-space: nowrap; }
.tkey { position: absolute; right: 2px; bottom: 0; font: 700 11px var(--font); color: var(--ember); opacity: .85; pointer-events: none; }
body.touchdev .tkey { display: none; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: none; z-index: 40; overflow: hidden; cursor: pointer; }
#title.show { display: block; }
#title .tbg { position: absolute; inset: -3%; background: #0b1114 url(assets/title-bg.webp) center / cover no-repeat; animation: tdrift 26s ease-in-out infinite alternate; }
#title .tfog { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 18%, rgba(8,12,14,.55), rgba(8,12,14,0) 55%), linear-gradient(to top, rgba(6,8,10,.85), rgba(6,8,10,0) 35%); }
@keyframes tdrift { from { transform: scale(1.02) translateX(-1%); } to { transform: scale(1.08) translateX(1%); } }
#logo { position: absolute; left: 50%; top: 5%; width: min(64vw, 78vh * 1.6); max-height: 34vh; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 10px rgba(0,0,0,.8)); animation: logoIn .7s cubic-bezier(.3,1.5,.5,1) both, logoFloat 4s ease-in-out .7s infinite; }
@keyframes logoIn { from { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(.8); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes logoFloat { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
#promptWrap { position: absolute; left: 0; right: 0; bottom: 7%; text-align: center; pointer-events: none; }
#prompt { font: 900 clamp(18px, 3.6vh, 30px) var(--font); color: #ffe2b0; letter-spacing: .08em; animation: pulse 1.8s ease-in-out infinite; text-shadow: 0 0 12px rgba(240,140,60,.7), -2px -2px 0 var(--outline), 2px -2px 0 var(--outline), -2px 2px 0 var(--outline), 2px 2px 0 var(--outline); }
#keyhint { margin-top: 6px; font-size: 13px; color: var(--dim); text-shadow: 0 1px 2px #000; }
body.touchdev #keyhint { display: none; }
@keyframes pulse { 0%,100% { opacity: .65; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
#title.leaving { animation: fadeOut .4s ease forwards; }
@keyframes fadeOut { to { opacity: 0; } }
#trophyBtn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(240,176,96,.6); background: rgba(24,16,10,.6); color: var(--ember); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .12s; }
#trophyBtn:active { transform: scale(.9); }

/* ---------- intro ---------- */
#intro { position: fixed; inset: 0; z-index: 60; display: none; background: #000 url(assets/title-bg.webp) center / cover no-repeat; }
#intro.show { display: block; }
#introVideo { width: 100%; height: 100%; object-fit: cover; background: transparent; }
#skipBtn { position: absolute; right: 24px; bottom: 20px; }

/* ---------- expedition HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
#hud.show { display: block; }
#hud > * { pointer-events: auto; }
#tutPanel { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); width: min(560px, 46vw); display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--ink); z-index: 3; }
#tutPanel.pop { animation: tutPop .28s cubic-bezier(.3,1.6,.5,1); }
@keyframes tutPop { from { scale: .8; opacity: 0; } to { scale: 1; opacity: 1; } }
#tutPanel.ok .tuttxt { color: #a8f0a0; }
.tutnum { flex: none; min-width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 900 14px var(--font); color: #1a0f06; background: radial-gradient(circle at 40% 35%, #ffd890, var(--ember)); box-shadow: 0 0 10px rgba(240,176,96,.6); }
.tuttxt { flex: 1; font: 700 15px/1.35 var(--font); text-shadow: 0 1px 0 #000, 0 0 4px #000; transition: color .2s; }
.tutskip { flex: none; min-height: 44px; min-width: 44px; font-size: 13px !important; padding: 0 12px !important; }
/* phones held sideways: between the hero cards (left) and the minimap (right), compact text */
@media (max-height: 460px) {
  #tutPanel { top: 84px; left: calc(max(8px, env(safe-area-inset-left)) + 236px); right: calc(max(10px, env(safe-area-inset-right)) + 112px); width: auto; max-width: 460px; transform: none; gap: 8px; padding: 2px 6px; }
  .tuttxt { font-size: 13px; line-height: 1.3; }
  .tutnum { min-width: 26px; height: 26px; font-size: 11px; }
  .tutskip { font-size: 12px !important; padding: 0 8px !important; }
}
body.tut #toasts { top: 196px; }
body:has(#ui .modal-back) #labels { display: none; }
#btnDepart.pulse { animation: departPulse 1.3s ease-in-out infinite; }
@keyframes departPulse { 0%,100% { filter: drop-shadow(0 0 0 rgba(255,180,80,0)); transform: scale(1); } 50% { filter: drop-shadow(0 0 12px rgba(255,180,80,.95)); transform: scale(1.06); } }
body.tut #placeHint, body.tut #extractBar { top: 196px; }
#heroCards { position: absolute; left: max(8px, env(safe-area-inset-left)); top: 66px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.hcard { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 6px; width: clamp(170px, 19vw, 230px); height: clamp(50px, 8.6vh, 64px); padding: 3px 4px 3px 3px; border-radius: 8px; background: linear-gradient(90deg, rgba(20,14,10,.88), rgba(20,14,10,.6)); border: 2px solid rgba(120,96,70,.6); border-left: 4px solid var(--ac); cursor: pointer; transition: transform .15s, border-color .15s; }
.hcard.sel { border-color: var(--ember); border-left-color: var(--ac); box-shadow: 0 0 10px rgba(240,176,96,.5); transform: translateX(4px); }
.hcard.down { filter: grayscale(1) brightness(.6); }
.hcard.hurt { animation: hurt .3s; }
@keyframes hurt { 30% { background: rgba(140,30,20,.85); } }
.hpic { height: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #1a1410; border: 1px solid rgba(0,0,0,.6); }
.hinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hname { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: .95em; white-space: nowrap; }
.hdot { width: 8px; height: 8px; border-radius: 50%; background: var(--ac); box-shadow: 0 0 4px var(--ac); flex: none; }
.hbar { position: relative; height: 8px; border-radius: 4px; background: #2a0d0a; overflow: hidden; border: 1px solid #000; }
.hcap { position: absolute; left: 0; top: 0; bottom: 0; background: #5a3a2a; }
.hfill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ffd27a, #d0703a); transition: width .2s; }
.htr { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hskill { position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ember); background: #1a120c; padding: 0; cursor: pointer; overflow: hidden; transition: transform .12s; }
.hskill:active { transform: scale(.88); }
.hskill .skic { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.hskill.cool { border-color: #6a5a48; }
.hskill.cool .skic { filter: grayscale(1) brightness(.5); }
.hskill.cool::after { content: ''; position: absolute; inset: 0; background: conic-gradient(rgba(0,0,0,.65) calc(var(--p, 0) * 1%), transparent 0); pointer-events: none; }
.skcd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 900 16px var(--font); color: #fff; z-index: 2; pointer-events: none; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.hskill .tkey { right: 50%; transform: translateX(50%); bottom: -1px; z-index: 3; }

#topbar { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 0 4px; height: 52px; border-width: 10px; border-image-width: 10px; }
.tb-time { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 56px; }
#timer { font: 900 20px var(--font); color: #ffe2b0; }
#timer.low { color: var(--bad); animation: pulse .8s infinite; }
#depthInfo { font-size: 11px; color: var(--dim); margin-top: 2px; white-space: nowrap; }
.tb-cargo { display: flex; gap: 8px; }
.cc { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.cc img { width: 24px; height: 24px; object-fit: contain; }
.cc b { font: 800 16px var(--font); }
.ibtn { position: relative; width: 44px; height: 44px; border-radius: 8px; border: 2px solid rgba(240,176,96,.55); background: rgba(30,20,12,.8); padding: 3px; cursor: pointer; transition: transform .12s; }
.ibtn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ibtn:active { transform: scale(.88); }
#bagBtn .tkey { right: 3px; }

#minimap { position: absolute; right: max(10px, env(safe-area-inset-right)); top: 62px; width: clamp(96px, 22vh, 170px); height: clamp(96px, 22vh, 170px); border-radius: 6px; border: 3px solid #6a5032; box-shadow: 0 0 0 2px #120a04, 0 4px 10px rgba(0,0,0,.6); background: #0b1114; cursor: pointer; }
#actbar { position: absolute; right: max(10px, env(safe-area-inset-right)); top: calc(62px + clamp(96px, 22vh, 170px) + 12px); display: flex; flex-direction: column; gap: 8px; }
.tool { width: 56px; height: 56px; padding: 0; min-width: 0; min-height: 0; border-width: 4px; }
.tool .bic { width: 36px; height: 36px; }
.tool .tcount { position: absolute; left: 2px; top: -2px; font: 800 13px var(--font); color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.tool.empty { filter: grayscale(.9) brightness(.6); }
.tool.active { filter: brightness(1.4) drop-shadow(0 0 6px var(--ember)); }
body.touchdev #actbar { display: none; }

#extractBar { position: absolute; left: 50%; top: 68px; transform: translateX(-50%); width: min(280px, 40vw); display: none; text-align: center; pointer-events: none; }
#extractBar.show { display: block; }
.xlabel { font-weight: 700; color: var(--teal); text-shadow: 0 0 6px #000, 0 1px 2px #000; margin-bottom: 3px; }
.xtrack { height: 10px; border-radius: 5px; background: rgba(0,0,0,.6); border: 1px solid var(--teal); overflow: hidden; }
.xfill { height: 100%; width: 0; background: linear-gradient(90deg, #2aa89c, #9ffff0); }
#placeHint { position: absolute; left: 50%; top: 68px; transform: translateX(-50%); padding: 6px 14px; border-radius: 6px; background: rgba(20,14,10,.8); border: 1px solid var(--ember); font-weight: 700; display: none; pointer-events: none; white-space: nowrap; }
#placeHint.show { display: block; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 2px solid rgba(255,226,176,.85); border-radius: 50%; display: none; pointer-events: none; box-shadow: 0 0 0 1px #000; }
#crosshair::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #ffe2b0; border-radius: 50%; }
#crosshair.show { display: block; }

/* ---------- home ---------- */
#homeui { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
#homeui.show { display: block; }
#homeRes { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 0 6px; height: 50px; border-width: 10px; border-image-width: 10px; pointer-events: auto; }
#homeBtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 16px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; pointer-events: auto; min-width: 150px; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.blabel { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; padding: 4px 12px; min-width: 64px; min-height: 44px; border-radius: 8px; background: rgba(20,14,10,.78); border: 2px solid rgba(160,120,80,.7); cursor: pointer; transition: border-color .15s, filter .15s; }
.blabel:hover { filter: brightness(1.25); }
.blabel .bn { font-weight: 800; white-space: nowrap; }
.blabel .blv { font-size: 12px; color: var(--ember); }
.blabel.up { border-color: var(--good); box-shadow: 0 0 10px rgba(143,224,122,.45); }
.blabel.up::after { content: '▲'; position: absolute; right: -8px; top: -10px; color: var(--good); font-size: 14px; text-shadow: 0 0 3px #000; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- floating text, toasts, banners, subtitles ---------- */
#fxlayer { position: fixed; inset: 0; pointer-events: none; z-index: 8; overflow: hidden; }
.ftext { position: absolute; left: 0; top: 0; font: 900 16px var(--font); color: #fff; white-space: nowrap; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.ftext.loss { color: #ff7a5a; }
.ftext.adv { color: #ffd040; font-size: 19px; }
.ftext.dis { color: #9aa0a8; font-size: 13px; }
.ftext.gain { color: var(--good); }
.ftext.rare { color: #d48aff; }
.ftext.big { font-size: 21px; }
#toasts { position: fixed; left: 50%; top: 96px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 30; }
.toast { padding: 5px 14px; border-radius: 6px; background: rgba(20,14,10,.88); border: 1px solid rgba(240,176,96,.5); font-weight: 700; white-space: nowrap; animation: tin .2s cubic-bezier(.3,1.6,.5,1); transition: opacity .4s, transform .4s; }
.toast.good { border-color: var(--good); color: #d8ffcc; }
.toast.bad { border-color: var(--bad); color: #ffd0c4; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { transform: scale(.7); opacity: 0; } }
.banner { position: fixed; left: 50%; top: 28%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; z-index: 32; text-align: center; padding: 10px 46px; background: linear-gradient(90deg, transparent, rgba(16,10,6,.9) 18%, rgba(16,10,6,.9) 82%, transparent); transition: transform .25s cubic-bezier(.3,1.6,.5,1), opacity .25s; }
.banner.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.banner .bt { font: 900 clamp(24px, 5vh, 40px) var(--font); color: #ffe2b0; letter-spacing: .06em; white-space: nowrap; }
.banner .bs { margin-top: 2px; color: var(--dim); font-weight: 700; white-space: nowrap; }
.banner.gold .bt { color: #ffd060; }
.banner.bad .bt { color: #ff7a5a; }
#subtitle { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: 56vw; padding: 6px 16px; border-radius: 6px; background: rgba(0,0,0,.7); color: #fff; font-weight: 700; text-align: center; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 70; }
#subtitle.show { opacity: 1; }

/* ---------- modals ---------- */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.modal-back { position: absolute; inset: 0; pointer-events: auto; background: rgba(4,6,8,.62); display: flex; align-items: center; justify-content: center; animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { position: relative; width: min(460px, 92vw); max-height: 92vh; display: flex; flex-direction: column; animation: pop .25s cubic-bezier(.3,1.5,.5,1); }
.modal.wide { width: min(780px, 94vw); }
.modal.narrow { width: min(460px, 90vw); }
@keyframes pop { from { transform: scale(.75) translateY(-20px); opacity: 0; } }
.mhead { display: flex; align-items: center; justify-content: center; min-height: 40px; position: relative; padding: 0 48px; flex: none; }
.mtitle { font: 900 1.35em var(--font); color: #ffe2b0; letter-spacing: .05em; text-align: center; }
.xbtn, .tool { border-image: none; border: 2px solid rgba(240,176,96,.75); border-radius: 10px; background: radial-gradient(circle at 50% 35%, #4a3020, #1c120b 75%); box-shadow: 0 0 0 2px #120a04, 0 3px 6px rgba(0,0,0,.6); }
.xbtn { position: absolute; right: 0; top: 0; width: 44px; height: 44px; padding: 0; border-radius: 50%; }
body:has(.modal-back) #labels { visibility: hidden; }
.xmark { font-size: 16px; pointer-events: none; }
.mbody { flex: 1; overflow-y: auto; padding: 4px 6px; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-y; }
.mbody::-webkit-scrollbar { display: none; }
.mbtns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding-top: 8px; flex: none; }
.mtext { margin: 6px 2px; line-height: 1.45; }
.mtext.small { font-size: .85em; color: var(--dim); }
.mtext.help { margin: 5px 2px; }
.mtext.bad, .bad { color: #ff9a80; }
.subhead { margin: 10px 0 4px; padding-bottom: 2px; border-bottom: 1px solid rgba(240,176,96,.35); font-weight: 800; color: var(--ember); }
.effs { margin: 4px 0; }
.eff { font-size: .92em; margin: 2px 0; }
.eff.next { color: var(--good); }
.hrow { display: flex; align-items: center; gap: 8px; padding: 5px; margin: 4px 0; border-radius: 6px; background: rgba(0,0,0,.28); }
.hrow.warnrow { box-shadow: inset 3px 0 0 var(--bad); }
.hrpic { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex: none; background: #1a1410; }
.hrtx { flex: 1; min-width: 0; }
.hrn { font-weight: 800; }
.hrs { font-size: .85em; color: var(--dim); }
.okmark { color: var(--good); font-size: 20px; padding: 0 10px; }
.craft { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.costs { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.cost { display: inline-flex; align-items: center; gap: 3px; font-size: .85em; }
.cost.ok .cv { color: var(--good); }
.cost.bad .cv { color: var(--bad); }
.cic { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }
.uprow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 6px; border-radius: 6px; background: rgba(0,0,0,.28); }
.warn { color: var(--bad); font-size: .85em; }
.artgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.art { display: flex; align-items: center; gap: 6px; padding: 5px; border-radius: 6px; background: rgba(0,0,0,.3); }
.art.no { opacity: .5; }
.art.no .artic { filter: grayscale(1) brightness(.4); }
.artic { width: 40px; height: 40px; object-fit: contain; flex: none; }
.artn { font-weight: 800; }
.artd { font-size: .82em; color: var(--dim); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid rgba(160,130,90,.4); font-size: .88em; white-space: nowrap; }
.chip.q1 { border-color: #6fd06a; color: #c8ffc0; }
.chip.q2 { border-color: #6aa0ff; color: #cfe0ff; }
.chip.q3 { border-color: #d48aff; color: #f0d8ff; }
.chip.empty { opacity: .5; }
.storesec { margin: 6px 0; }
.storehd { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.tierrow { display: flex; flex-wrap: wrap; gap: 6px; }
.tierbtn { min-width: 52px; }
.tierbtn.on { filter: sepia(.5) saturate(2.4) hue-rotate(-12deg) brightness(1.25); transform: scale(1.06); }
.foodline { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 700; }
.baglist { display: flex; flex-direction: column; gap: 4px; }
.bagrow { display: flex; align-items: center; gap: 8px; padding: 5px; border-radius: 6px; background: rgba(0,0,0,.28); }
.bagic { width: 40px; height: 40px; object-fit: contain; flex: none; }
.bagtx { flex: 1; min-width: 0; }
.bagn { font-weight: 800; }
.bagd { font-size: .82em; color: var(--dim); }
.cargo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px; border-radius: 6px; background: rgba(0,0,0,.28); }
.cchip { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.cval { width: 100%; color: #ffd060; font-weight: 800; }
.maprow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.mapcard { flex: 1 1 170px; max-width: 230px; min-height: 120px; padding: 10px; border-radius: 8px; background: linear-gradient(rgba(30,24,18,.9), rgba(12,10,8,.9)); border: 2px solid rgba(160,120,80,.6); cursor: pointer; transition: transform .15s, border-color .15s; }
.mapcard:hover { transform: translateY(-3px); border-color: var(--ember); }
.mapcard:active { transform: scale(.96); }
.mapcard.home { border-color: rgba(80,224,208,.6); }
.mapcard.disabled { opacity: .5; cursor: default; }
.mct { font: 900 1.1em var(--font); color: #ffe2b0; }
.mcs { font-size: .85em; color: var(--ember); margin: 2px 0 4px; }
.mapcard[style*="--ec"] { border-color: var(--ec); box-shadow: inset 0 0 18px color-mix(in srgb, var(--ec) 25%, transparent); }
.mdanger { font-weight: 800; }
.mdanger.d1 { color: #6af0e0; } .mdanger.d2 { color: #c8f070; } .mdanger.d3 { color: #ffa050; } .mdanger.d4 { color: #ff6a8e; }
.exitTag { position: absolute; left: 0; top: 0; display: none; flex-direction: column; align-items: center; padding: 4px 12px; border-radius: 8px; background: rgba(8,10,12,.8); border: 2px solid var(--c, #50f0e0); color: #f3e6cc; font-family: var(--font); white-space: nowrap; pointer-events: none; text-shadow: 0 2px 0 #000; z-index: 3; }
.exitTag.show { display: flex; }
.exitTag b { font-size: 15px; font-weight: 900; color: var(--c, #50f0e0); }
.exitTag span { font-size: 13px; font-weight: 700; }
.gbar { position: absolute; left: 0; top: 0; width: 46px; height: 8px; display: none; border-radius: 4px; background: rgba(6,8,10,.85); border: 1.5px solid #120a04; box-shadow: 0 0 0 1px rgba(240,176,96,.5); pointer-events: none; overflow: hidden; z-index: 2; }
.gbar.show { display: block; }
.gbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c87a28, #ffd27a); }
.mcd { font-size: .85em; color: var(--dim); line-height: 1.35; }
.mcf { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-weight: 800; }
.mcr { font-size: .8em; color: var(--dim); }
.mcx { font-size: .85em; color: var(--bad); font-weight: 700; margin-top: 4px; }

/* phones held sideways: tighter */
@media (max-height: 460px) {
  :root { --fs: 13px; }
  #heroCards { top: 60px; gap: 4px; }
  .hcard { width: 168px; height: 50px; }
  .htr { font-size: 11px; }
  #topbar { height: 46px; gap: 6px; }
  #timer { font-size: 17px; }
  .tb-cargo { gap: 5px; }
  .cc img { width: 20px; height: 20px; }
  .cc b { font-size: 14px; }
  #minimap { width: 92px; height: 92px; top: 58px; }
  #homeRes { height: 44px; gap: 8px; }
  .modal { border-width: 18px; border-image-width: 55px 20px 58px 21px; border-image-outset: 38px 2px 40px 2px; max-height: 86vh; }
  .mhead { min-height: 34px; }
  .mtitle { font-size: 1.15em; }
  .btn.big { min-height: 50px; font-size: 1.1em; padding: 6px 20px; }
}
body:has(#intro.show) #promptWrap, body:has(#intro.show) #trophyBtn { display: none; }
#prompt { display: inline-block; }
/* plates sit low enough that their carved top edge shows */
#topbar, #homeRes { top: max(14px, env(safe-area-inset-top)); border-image-width: 38px 14px 40px 14px; }
#heroCards { top: 84px; }
#minimap { top: 80px; }
#actbar { top: calc(80px + clamp(96px, 22vh, 170px) + 12px); }
#extractBar, #placeHint { top: 86px; }
#toasts { top: 112px; }
@media (max-height: 460px) {
  #topbar, #homeRes { top: max(12px, env(safe-area-inset-top)); }
  #heroCards { top: 74px; }
  #minimap { top: 72px; }
  #extractBar, #placeHint { top: 74px; }
  #toasts { top: 100px; }
}
/* auto-cast switches */
.hcard { width: clamp(222px, 24vw, 284px); }
.hauto { flex: none; width: 44px; height: 44px; border-radius: 10px; border: 2px solid #5a4a3a; background: #1a120c; color: #8a7a68; font: 900 11px var(--font); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0; cursor: pointer; line-height: 1.05; transition: transform .12s, box-shadow .15s; text-shadow: 0 1px 0 #000; }
.hauto:active { transform: scale(.88); }
.hauto .agl { font-size: 15px; }
.hauto.on { border-color: #6fe0c0; color: #d8fff4; background: radial-gradient(circle at 50% 40%, #1f5a4a, #0e1f1a 75%); box-shadow: 0 0 8px rgba(111,224,192,.55); }
.hauto .bl { max-width: 40px; overflow: hidden; white-space: nowrap; }
#autoAllBtn { pointer-events: auto; align-self: flex-start; min-height: 44px; min-width: 44px; display: flex; align-items: center; gap: 7px; padding: 0 14px; border-radius: 22px; border: 2px solid #5a4a3a; background: rgba(20,14,10,.88); color: var(--dim); font: 800 13px var(--font); cursor: pointer; text-shadow: 0 1px 0 #000; transition: transform .12s; }
#autoAllBtn:active { transform: scale(.92); }
#autoAllBtn.on { border-color: #6fe0c0; color: #d8fff4; box-shadow: 0 0 8px rgba(111,224,192,.45); }
.adot { width: 10px; height: 10px; border-radius: 50%; background: #554a40; flex: none; }
.on > .adot { background: #6fe0c0; box-shadow: 0 0 6px #6fe0c0; }
#autoAllBtn .tkey { position: static; }
.hcard.reviving .htr { color: #8fe0ff; }
body.lowtier #actbar .tool[data-tool="trap"], body.lowtier #actbar .tool[data-tool="smoke"] { display: none; }
.chip .cic { width: 18px; height: 18px; margin-right: 3px; }
/* during an expedition toasts sit between the hero cards and the minimap and wrap */
body:has(#hud.show) #toasts { left: clamp(244px, calc(24vw + 20px), 304px); right: calc(clamp(96px, 22vh, 170px) + 22px); transform: none; }
body:has(#hud.show) .toast { white-space: normal; text-align: center; max-width: 100%; line-height: 1.35; }
@media (max-height: 460px) {
  body:has(#hud.show) #toasts { left: 236px; right: 112px; }
  .modal .xbtn { top: 16px; } /* clear of the platform's pause button */
  .hcard { width: 220px; }
  #autoAllBtn { min-height: 44px; font-size: 12px; padding: 0 10px; }
}

/* ---------- main materials ---------- */
.cc.main b { color: #e8f4ff; }
.cc.main img { filter: drop-shadow(0 0 4px rgba(150,220,255,.55)); }
#homeRes .cc b { min-width: 2.2em; }

/* ---------- item grid (bag, storage, results) ---------- */
.igwrap { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 6px; }
.igrid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; }
.icell { --tc: #8a7a68; position: relative; aspect-ratio: 1; min-width: 52px; min-height: 52px; padding: 4px; border-radius: 8px; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--tc) 28%, #2a1d14), #120c08 78%);
  border: 2px solid color-mix(in srgb, var(--tc) 55%, #3a2c20); box-shadow: inset 0 0 0 1px #000, 0 2px 4px rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .12s; color: var(--ink); font-family: var(--font); }
.icell:hover { filter: brightness(1.2); transform: scale(1.05); }
.icell:active { transform: scale(.92); }
.icell.on { outline: 2px solid var(--ember); outline-offset: 2px; }
.icell.q1 { border-color: #d8e4f0; box-shadow: inset 0 0 0 1px #000, 0 0 6px rgba(220,235,255,.55); }
.icell.q2 { border-color: #ffc848; box-shadow: inset 0 0 0 1px #000, 0 0 10px rgba(255,200,72,.75); }
.icell.q3 { border-color: #e090ff; animation: prism 2.4s linear infinite; }
@keyframes prism { 0% { box-shadow: inset 0 0 0 1px #000, 0 0 12px #e090ff; border-color: #e090ff; } 33% { box-shadow: inset 0 0 0 1px #000, 0 0 12px #70e8ff; border-color: #70e8ff; } 66% { box-shadow: inset 0 0 0 1px #000, 0 0 12px #ffd060; border-color: #ffd060; } 100% { box-shadow: inset 0 0 0 1px #000, 0 0 12px #e090ff; border-color: #e090ff; } }
.icell.main { --tc: #8ccfff; }
.icell.art { --tc: #ffb050; }
.icic { width: 78%; height: 78%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.7)); }
.iclb { position: absolute; left: 3px; top: 1px; font: 800 11px var(--font); color: var(--tc); text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 2px #000; pointer-events: none; filter: brightness(1.4); }
.icn { position: absolute; right: 3px; bottom: 1px; font: 900 14px var(--font); color: #fff; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; pointer-events: none; }
.icq { position: absolute; right: 3px; top: 1px; font-size: 9px; color: #ffe08a; letter-spacing: -1px; text-shadow: 0 0 2px #000; pointer-events: none; }
.icell.q1 .icq { color: #e8f0ff; } .icell.q3 .icq { color: #f0b0ff; }
.icdur { position: absolute; left: 5px; right: 5px; bottom: 3px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.7); overflow: hidden; pointer-events: none; }
.icdur i { display: block; height: 100%; background: linear-gradient(90deg, #ff7050, #ffd060 50%, #8fe07a); }
.icell.slot { width: 60px; height: 60px; aspect-ratio: auto; flex: none; }
.icell.empty, .icell.ghost { border-style: dashed; }
.icell.ghost .icic { opacity: .3; filter: grayscale(1); }
.icplus { font: 900 26px var(--font); color: rgba(240,176,96,.55); pointer-events: none; }
.ictag { position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); padding: 0 4px; border-radius: 5px; font: 800 10px var(--font); white-space: nowrap; pointer-events: none; }
.ictag.stock { background: #1d4a3a; color: #c8fff0; }
.ictag.craft { background: #6a3a14; color: #ffe2b0; }
.icell.slot .iclb { max-width: 54px; overflow: hidden; white-space: nowrap; }
.iginfo { flex: 0 0 34%; min-height: 96px; padding: 8px; border-radius: 8px; background: rgba(0,0,0,.35); border: 1px solid rgba(160,120,80,.35); display: flex; flex-direction: column; gap: 4px; }
.ign { font-weight: 900; display: flex; gap: 6px; justify-content: space-between; }
.ignn { color: var(--dim); }
.igq { font-weight: 800; font-size: .88em; }
.igq.q1 { color: #e0eaff; } .igq.q2 { color: #ffd060; } .igq.q3 { color: #f0a0ff; }
.igd { font-size: .85em; color: var(--dim); line-height: 1.35; }
.iginfo .btn { align-self: flex-start; margin-top: 4px; }
.igempty { grid-column: 1 / -1; padding: 10px; color: var(--dim); font-style: italic; }
.igwrap.lost .icell { filter: grayscale(.7) brightness(.75); }
.igwrap.lost .icell::after { content: '✕'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 900 30px var(--font); color: rgba(255,90,70,.75); pointer-events: none; }

/* ---------- results ---------- */
.results .mbody { animation: fadeIn .4s; }
.resstats { display: flex; gap: 8px; justify-content: center; margin: 4px 0 6px; }
.rstat { flex: 1; max-width: 200px; padding: 8px 6px; border-radius: 8px; background: rgba(0,0,0,.35); border: 1px solid rgba(160,120,80,.4); text-align: center; animation: pop .35s cubic-bezier(.3,1.5,.5,1) both; }
.rstat:nth-child(2) { animation-delay: .08s; } .rstat:nth-child(3) { animation-delay: .16s; }
.rsv { font: 900 1.7em var(--font); color: #ffe2b0; }
.rstat.gold .rsv { color: #ffd060; }
.rsl { font-size: .85em; color: var(--dim); font-weight: 700; }
.subhead.bad { color: #ff9a80; border-color: rgba(255,106,80,.4); }

/* ---------- outfitting ---------- */
.ptabs { display: flex; gap: 6px; margin-bottom: 6px; }
.ptab { --ac: #888; flex: 1; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 3px 6px 3px 3px; border-radius: 8px; cursor: pointer; background: rgba(0,0,0,.35); border: 2px solid rgba(120,96,70,.6); border-left: 4px solid var(--ac); color: var(--ink); font-family: var(--font); transition: transform .12s; }
.ptab.on { border-color: var(--ember); border-left-color: var(--ac); box-shadow: 0 0 8px rgba(240,176,96,.45); background: rgba(60,36,18,.55); }
.ptab:active { transform: scale(.95); }
.ptpic { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; pointer-events: none; }
.ptn { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; pointer-events: none; font-size: .9em; }
.ptn span { color: var(--dim); font-size: .9em; }
.prow { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 4px 0; border-radius: 6px; background: rgba(0,0,0,.25); }
.plabel { flex: 0 0 92px; font-weight: 800; color: var(--ember); }
.pctl { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.btn.sq { min-width: 44px; font-size: 1.2em; }
.stv { min-width: 74px; text-align: center; font-weight: 900; }
.pname { font-weight: 700; }
.pname.dim { color: var(--dim); font-weight: 400; font-size: .9em; }
.aslot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.aslot .stepper .stv { min-width: 30px; }
.pfoot .costs { margin-top: 4px; }

/* ---------- conversion & crafting ---------- */
.cvrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px; margin: 4px 0; border-radius: 6px; background: rgba(0,0,0,.28); }
.cvside { display: flex; align-items: center; gap: 5px; }
.cvn { font-weight: 800; white-space: nowrap; }
.cvarrow { font: 900 18px var(--font); color: var(--ember); }
.cvwhy { color: var(--dim); font-size: .85em; }
.cvbtns { margin-left: auto; display: flex; gap: 6px; }
.hrpic.gear { object-fit: contain; padding: 3px; }
.storebtns { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }

/* hero card: weapon and its durability */
.hwep { position: relative; flex: none; width: 30px; height: 30px; border-radius: 6px; background: #1a120c; border: 1px solid #5a4a3a; }
.hwep img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.hwep .hwd { position: absolute; left: 2px; right: 2px; bottom: 1px; height: 3px; background: #000; border-radius: 2px; overflow: hidden; }
.hwep .hwd i { display: block; height: 100%; background: linear-gradient(90deg, #ff7050, #ffd060 50%, #8fe07a); }
.hwep .hwn { position: absolute; right: -3px; top: -5px; font: 800 10px var(--font); color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.hwep.none { opacity: .35; }
.hwep.broken { filter: grayscale(1); opacity: .6; }
#cWeightChip.full b { color: var(--bad); }
#cWeightChip.full { animation: wfull 1s ease-in-out infinite; }
@keyframes wfull { 50% { filter: drop-shadow(0 0 6px #ff4030); } }
/* troop bar: healthy (ember) · wounded (dark cap) · severe (deep red) · dead (black) */
.hsev { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, #8a1a14 0 3px, #5a0e0a 3px 6px); }
.hdead { position: absolute; top: 0; bottom: 0; background: #050505; }
.hquick { position: relative; flex: none; width: 30px; height: 30px; border-radius: 6px; background: #1a120c; border: 1px solid #7a6040; padding: 0; cursor: pointer; }
.hquick img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.hquick .hqn { position: absolute; right: -3px; bottom: -4px; font: 800 10px var(--font); color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.hquick.empty { opacity: .4; }
.hpic { cursor: pointer; }
.hchips { flex: none; display: flex; flex-direction: column; gap: 3px; }
.hchips .hwep, .hchips .hquick { width: 26px; height: 26px; }
.hcard .htr { font-size: 11px; }
@media (max-height: 460px) { .hchips .hwep, .hchips .hquick { width: 22px; height: 22px; } }
.igacts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.icell.broken, .icell.off { filter: grayscale(1); opacity: .5; }
.icell.gtool { box-shadow: inset 0 0 0 2px rgba(80, 200, 190, .55); }
.icell.gtool.off { box-shadow: none; }
.icell.quick { box-shadow: inset 0 0 0 2px rgba(240, 176, 96, .8); }
.prow.party { background: rgba(80, 200, 190, .08); border-radius: 8px; }
.bagbars { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.bagbar { flex: 1 1 160px; }
.bagbar .bbl { font: 800 14px var(--font); color: var(--ink); text-shadow: 0 1px 0 #000; }
.bagbar .bbt { height: 8px; background: #120c08; border: 1px solid #5a4a3a; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bagbar .bbt i { display: block; height: 100%; background: linear-gradient(90deg, #6fb070, #f0b060); }
.bagbar.full .bbt i { background: #d04030; }
.bagbar.full .bbl { color: var(--bad); }
.mtext.bad, .bagwarn { color: var(--bad); }
.cptroops { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.cpchip { display: inline-flex; align-items: center; gap: 5px; font: 800 14px var(--font); color: var(--ink); background: rgba(0,0,0,.35); border-radius: 6px; padding: 3px 8px; }
.cpchip i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; background: #f0b060; }
.cpchip.w i { background: #5a3a2a; } .cpchip.s i { background: #8a1a14; } .cpchip.d i { background: #111; border: 1px solid #555; }
body:not(:has(#title.show)) #trophyBtn { display: none; }
#title #trophyBtn { right: calc(max(10px, env(safe-area-inset-right)) + 58px); }
body:has(#title.show) #homeui, body:has(#title.show) #labels, body:has(#intro.show) #homeui, body:has(#intro.show) #labels { visibility: hidden; }
body:has(#ui .modal) .blabel, body:has(#ui .modal) #subtitle { visibility: hidden; }
.blabel.unplaced { visibility: hidden; }

/* ---------- Diablo-style gear figure ---------- */
.modal.prep, .modal.charp { width: min(920px, 96vw); }
.doll { --cs: 56px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.doll.compact { --cs: 48px; }
.dfig { position: relative; display: grid; grid-template-columns: repeat(3, var(--cs)); grid-template-rows: repeat(3, var(--cs)); gap: 5px 10px;
  grid-template-areas: "amulet helm ." "weapon body gloves" ". boots ."; padding: 6px 10px; border-radius: 10px;
  background: radial-gradient(ellipse at 50% 45%, rgba(240,176,96,.14), rgba(0,0,0,.45) 70%); border: 1px solid rgba(160,120,80,.35); }
.dsil { position: absolute; left: 50%; top: 50%; height: 104%; width: auto; transform: translate(-50%, -50%); opacity: .5; pointer-events: none; filter: drop-shadow(0 0 6px rgba(80,200,190,.35)); }
.icell.dcell { width: var(--cs); height: var(--cs); min-width: 0; min-height: 0; aspect-ratio: auto; z-index: 1; }
.ds-weapon { grid-area: weapon; } .ds-helm { grid-area: helm; } .ds-body { grid-area: body; } .ds-gloves { grid-area: gloves; } .ds-boots { grid-area: boots; } .ds-amulet { grid-area: amulet; }
.dfig .icell.empty { background: rgba(10,7,5,.55); }
.drow { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dlab { font: 800 12px var(--font); color: var(--dim); }
.dcells { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.icell.hot { border-color: #7ff0e0; animation: hotglow 1s ease-in-out infinite; }
@keyframes hotglow { 50% { box-shadow: inset 0 0 0 1px #000, 0 0 12px #7ff0e0; filter: brightness(1.3); } }
.icell.spare.over { outline: 2px dashed var(--bad); outline-offset: 1px; }
.icell.craft .icic { opacity: .45; }
.icell.craft .iclb { color: #ffd8a0; max-width: calc(100% - 6px); overflow: hidden; white-space: nowrap; font-size: 10px; }
.icell .icwt { position: absolute; left: 3px; bottom: 1px; font: 700 9px var(--font); color: #cfc2a8; text-shadow: 0 0 2px #000, 0 0 2px #000; pointer-events: none; }
/* outfitting: one column per hero */
.locols { display: flex; gap: 8px; align-items: stretch; }
.locol { --ac: #888; flex: 1 1 0; min-width: 0; padding: 6px; border-radius: 8px; background: rgba(0,0,0,.3); border: 1px solid rgba(120,96,70,.5); border-top: 3px solid var(--ac); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lohead { display: flex; align-items: center; gap: 6px; width: 100%; }
.lonm { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lonm b { color: var(--ac); filter: brightness(1.3); white-space: nowrap; }
.locol .stv { min-width: 58px; font-size: .9em; }
.loinfo { flex: none; min-height: 0; margin: 8px 0 2px; }
.loinfo .igacts .btn { margin-top: 0; }
.lostore { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
/* battle / home character panel */
.cpmain { display: flex; gap: 12px; align-items: flex-start; }
.cpleft { flex: none; }
.cpright { flex: 1; min-width: 0; }
.cpright .iginfo { flex: none; min-height: 80px; }
.cphome { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 12px; align-items: start; }
.cphome > .locols { grid-column: 1; grid-row: 1 / span 3; justify-content: center; }
.cphome > :not(.locols) { grid-column: 2; }
.cphome > .iginfo { margin-top: 0; }
.cphome > .subhead { margin-top: 6px; }
.cphome .locol { flex: 0 1 auto; padding: 8px 14px; }
.cphome .lohead { display: none; }
/* empty vs filled cells: empty = a dark hollow with a faint line mark and the slot's word; filled = bright tier border + glow + colour icon */
.icell.empty { background: radial-gradient(circle at 50% 40%, #15100c, #070504 80%); border: 2px dashed rgba(140,110,80,.32); box-shadow: inset 0 3px 8px rgba(0,0,0,.85); flex-direction: column; gap: 0; padding: 2px; }
.icell.empty:hover { filter: brightness(1.35); }
.dmark { width: 54%; height: 54%; fill: none; stroke: rgba(200,180,150,.28); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; margin-top: -4px; }
.dslab { position: absolute; left: 1px; right: 1px; bottom: 2px; font: 700 11px var(--font); color: rgba(200,180,150,.5); text-align: center; white-space: nowrap; overflow: hidden; letter-spacing: -.2px; pointer-events: none; }
.icell.full { border: 2px solid color-mix(in srgb, var(--tc) 85%, #fff); background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--tc) 42%, #3a281a), #160e08 80%);
  box-shadow: inset 0 0 0 1px #000, 0 0 9px color-mix(in srgb, var(--tc) 65%, transparent), 0 2px 4px rgba(0,0,0,.6); }
.icell.full .icic { filter: drop-shadow(0 2px 2px rgba(0,0,0,.8)) saturate(1.15) brightness(1.08); }
.icell.full.broken { filter: grayscale(1); opacity: .55; }
.icell.on, .icell.full.on { outline: 3px solid #ffe2a0; outline-offset: 2px; box-shadow: 0 0 16px rgba(240,176,96,.9), inset 0 0 0 1px #000; z-index: 2; }
.icell.dcell.gtool.full { box-shadow: inset 0 0 0 2px rgba(80,200,190,.6), 0 0 8px rgba(80,200,190,.45); border-color: #7fe0d4; }
.icell.dcell.quick.full { border-color: #ffc070; }
.icell.empty.gtool, .icell.empty.quick { box-shadow: inset 0 3px 8px rgba(0,0,0,.85); }
/* the one "Pack" block under the figure: tools ×3, quick ×1, spares */
.dpack { width: 100%; box-sizing: border-box; padding: 6px 8px 8px; border-radius: 10px; background: rgba(0,0,0,.34); border: 1px solid rgba(160,120,80,.45); display: flex; flex-direction: column; gap: 6px; }
.dpackt { font: 900 14px var(--font); color: var(--ember); text-align: center; text-shadow: 0 1px 0 #000; padding-bottom: 3px; border-bottom: 1px solid rgba(160,120,80,.35); }
.dprow { display: flex; flex-direction: column; gap: 3px; }
.dph { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 28px; }
.dph .dlab { font: 800 12px var(--font); color: #e0d0b0; text-shadow: 0 1px 0 #000; line-height: 1.2; }
.dprow .dcells { justify-content: flex-start; }
.qhelp { position: relative; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(240,176,96,.6); background: rgba(40,26,14,.9); color: var(--ember); font: 900 15px var(--font); cursor: pointer; padding: 0; line-height: 1; }
.qhelp::before { content: ''; position: absolute; inset: -8px; }
.qhelp:active { transform: scale(.88); }
/* drag and drop */
.dragghost { position: fixed; left: 0; top: 0; width: 60px; height: 60px; z-index: 9999; pointer-events: none; border-radius: 10px; background: rgba(30,20,12,.85); border: 2px solid var(--ember); box-shadow: 0 6px 18px rgba(0,0,0,.7), 0 0 14px rgba(240,176,96,.6); display: flex; align-items: center; justify-content: center; }
.dragghost .icic { width: 82%; height: 82%; }
.dragghost.back { transition: transform .2s ease-in, opacity .2s; opacity: .3; }
.dragsrc { opacity: .4; }
.icell.dropok, .igrid.dropok { outline: 3px solid #7ff07a; outline-offset: 2px; box-shadow: 0 0 14px #5fe05a; }
.icell.dropbad, .igrid.dropbad, .flashbad { outline: 3px solid #ff5040 !important; outline-offset: 2px; box-shadow: 0 0 14px #ff3020 !important; }
/* item info: tags, stats, rule note, big buttons */
.igtags { display: flex; gap: 4px; flex-wrap: wrap; }
.igtag { font: 800 12px var(--font); padding: 1px 7px; border-radius: 10px; background: rgba(240,176,96,.12); border: 1px solid rgba(240,176,96,.35); color: #f0dcb8; }
.igstats { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 14px; padding: 4px 6px; border-radius: 6px; background: rgba(0,0,0,.28); }
.igk { color: var(--dim); white-space: nowrap; }
.igv { color: var(--ink); font-weight: 800; }
.ignote { font-size: 13px; line-height: 1.35; color: #d8c4a0; font-style: italic; padding: 3px 0 3px 8px; border-left: 3px solid var(--ember); }
.btn.iact { min-height: 44px; font-size: 15px; padding-left: 14px; padding-right: 14px; margin-top: 0; }
.iginfo .igacts .btn { align-self: auto; }
#bagBtn { width: auto; display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 3px; }
#bagBtn img { width: 34px; height: 34px; flex: none; }
#bagBtn .ibl { font: 900 14px var(--font); color: var(--ink); text-shadow: -1px -1px 0 #000, 1px 1px 0 #000; white-space: nowrap; pointer-events: none; }
@media (max-height: 460px) {
  .cptroopsub { display: none; }
  .cphome .locol { padding: 6px; }
  .cphome .doll { --cs: 44px; flex-direction: row; align-items: flex-start; gap: 8px; }
  .cphome .dpack { width: auto; padding: 4px 6px 6px; gap: 3px; }
  .dph { min-height: 26px; }
  .igstats { font-size: 13px; }
  .ignote { font-size: 12px; }
}
@media (max-height: 460px) {
  .doll { --cs: 50px; gap: 4px; }
  .doll.compact { --cs: 44px; }
  .dfig { gap: 4px 8px; padding: 4px 8px; }
  .locols { gap: 5px; }
  .locol { padding: 4px; }
  .locol .ptpic { width: 30px; height: 30px; }
  .locol .stv { min-width: 46px; }
  .cpmain { gap: 8px; }
}
.rstat.sev .rsv { color: #e05040; } .rstat.dead .rsv { color: #9a9a9a; }
.storeinfo { position: sticky; top: 0; z-index: 3; min-height: 64px; margin: 0 0 6px; background: rgba(20,14,10,.96); }
/* shorter screens: figure and pack side by side so every row shows without scrolling */
@media (max-height: 820px) {
  .cphome .doll, .cpleft .doll { flex-direction: row; align-items: flex-start; gap: 10px; }
  .cphome .dpack, .cpleft .dpack { width: auto; min-width: 190px; }
}
@media (max-height: 460px) {
  .charp .ptabs { gap: 5px; margin-bottom: 4px; }
  .charp .ptab { min-height: 44px; padding: 2px 8px; }
  .charp .ptab .ptpic { width: 30px; height: 30px; }
  .charp .mhead { min-height: 28px; }
  .cphome .dpack, .cpleft .dpack { min-width: 0; }
  .dph .dlab { font-size: 11px; }
}

@media (max-height: 460px) {
  .igrid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
  .iginfo { flex-basis: 38%; }
  .plabel { flex-basis: 70px; font-size: .9em; }
  .prow { padding: 3px 5px; margin: 3px 0; }
  .icell.slot { width: 52px; height: 52px; }
  .rsv { font-size: 1.35em; }
  .ptab { min-height: 44px; }
  .ptpic { width: 34px; height: 34px; }
  .hwep { width: 24px; height: 24px; }
}
