/* Rucksack-Rumpel on top of Survivor's HerpDerp skin (../css/style.css), like Angelpfütze:
   orange .btn buttons, .panel/.screen overlays, wood status tab, parchment. Own parts here:
   backpack, slots, shop offers, arena. Jersey 10 is sharp only at 56/3 px or twice that. */
:root { --cell: 52px; --mcell: 26px; }
body { background: #1d2a12 url(../assets/herpderp/tex_grass.png); background-size: 128px; image-rendering: pixelated;
  background-color: #5d6a48; background-blend-mode: multiply; -webkit-touch-callout: none; }
img { image-rendering: pixelated; -webkit-user-drag: none; pointer-events: none; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom); }
/* status bar: wood tab hanging from the top edge, numbers in gold (Survivor #topbar, Angelpfütze #atop) */
#rtop { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; white-space: nowrap; line-height: 1;
  background: var(--wood); border: 3px solid #2b1a0e; border-top: 0; border-radius: 0 0 22px 22px; padding: 4px 18px 6px;
  box-shadow: 0 6px 0 rgba(0,0,0,.28), inset 0 2px 0 var(--wood-light); }
#rtop:empty { visibility: hidden; }
.tb { flex: none; display: inline-flex; align-items: center; gap: 0; color: var(--muted); text-shadow: var(--ink-outline); line-height: 1; }
.tb b { color: var(--gold); text-shadow: var(--ink-outline); }
/* 12x12 HUD icons, always at 2x so every icon has the same size and stays pixel-sharp */
img.ic { width: 24px; height: 24px; flex: none; margin-right: 4px; }
.tb.hearts img.ic { margin-right: 2px; }
img.ic1 { width: 12px; height: 12px; vertical-align: 0; }
/* phones: keep clear of the menu button top right */
@media (max-width: 520px) { #rtop { align-self: flex-start; gap: 10px; padding: 4px 12px 6px; max-width: calc(100vw - 120px); } }
.tb .long { margin-right: 5px; }
@media (max-width: 370px) { #rtop { gap: 8px; } }

.screen-part { width: min(100%, 440px); flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; }
.lbl { color: var(--muted); text-shadow: var(--ink-outline); line-height: 1; }
.foe-line { text-shadow: var(--ink-outline); line-height: 1.05; text-align: center; min-height: 20px; }
.foe-line b { color: var(--gold); }

/* Leather backpack (own pixel sprite, 9-slice at 1:1) with a brass buckle on top. */
.bagwrap { position: relative; border: 16px solid transparent; border-image: url(sprites/pack.png) 16 fill / 16px round; padding: 2px; margin-top: 10px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.3)); }
.bagwrap::before { content: ''; position: absolute; top: -28px; left: 50%; width: 28px; height: 24px; margin-left: -14px; background: url(sprites/buckle.png); z-index: 1; }
.grid { position: relative; }
.cell { position: absolute; width: var(--cell); height: var(--cell); border: 6px solid transparent; border-image: url(../assets/herpderp/ui/slot.png) 9 fill / 9px stretch; }
/* Highlights are tinted copies of the slot sprite. */
.cell.syn { border-image-source: url(sprites/slot_syn.png); }
.cell.ok { border-image-source: url(sprites/slot_ok.png); }
.cell.bad { border-image-source: url(sprites/slot_bad.png); }
.cell.merge { border-image-source: url(sprites/slot_merge.png); }

.item { position: absolute; display: grid; place-items: center; touch-action: none; cursor: grab; }
.item img { position: absolute; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.item.sel { outline: 3px solid var(--gold); outline-offset: -2px; border-radius: 8px; }
.item .lv { position: absolute; left: 2px; top: 2px; display: flex; gap: 1px; z-index: 2; }
.item .lv img { position: static; width: 12px; height: 12px; filter: none; }
.item .cdbar { position: absolute; left: 5px; right: 5px; bottom: 4px; height: 6px; background: var(--ink); border: 1px solid var(--ink); border-radius: 3px; overflow: hidden; z-index: 3; }
.item .cdbar i { display: block; height: 100%; width: 0; background: var(--gold); }
/* main value of an item, bottom right */
.item .val { position: absolute; right: 3px; bottom: 1px; z-index: 3; line-height: 1; text-shadow: var(--ink-outline); }
.grid.mini .item .val { bottom: 9px; }
.v-dmg { color: #ff8a6a; } .v-heal { color: #9be07a; } .v-block { color: #9cc8ff; } .v-poison { color: #d4a2ff; } .v-hp { color: #ffb0a0; } .v-gold { color: var(--gold); }
/* an item that just fired: gold slot sprite under it, art pops */
.item::before { content: ''; position: absolute; inset: 0; border: 9px solid transparent; border-image: url(sprites/slot_merge.png) 9 fill / 9px stretch; opacity: 0; z-index: 0; }
.item img { z-index: 1; }
.item.fired::before { animation: flash .45s ease-out; }
.item.fired img { animation: pop .3s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pop { 30% { transform: var(--rot) scale(1.25); } 100% { transform: var(--rot) scale(1); } }
.flt { position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, -50%); font-size: var(--nx2, 28px); font-weight: 700; line-height: 1; text-shadow: var(--ink-outline), 2px 2px 0 var(--ink); animation: rise .9s ease-out forwards; white-space: nowrap; }
@keyframes rise { 0% { opacity: 0; margin-top: 6px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -34px; } }
.bag-stats { text-shadow: var(--ink-outline); line-height: 1; text-align: center; color: var(--muted); }
.bag-stats b { font-weight: 400; }
/* a long name is cut with an ellipsis; the "look" link at the end stays readable.
   The right margin keeps the line clear of the menu button. */
.foe-line { cursor: pointer; display: flex; justify-content: center; align-items: baseline; gap: 0 6px; white-space: nowrap;
  align-self: stretch; margin-right: 60px; }
.foe-line > * { flex: none; min-width: 0; }
.foe-line > b, .foe-line > span { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.foe-line u { color: var(--gold); }

.grid.mini .item { cursor: default; }
.bagwrap.fight { margin-top: 0; }
.bagwrap.fight::before { display: none; }

.bench-row { display: flex; align-items: center; gap: 6px; }
.bench { display: flex; gap: 3px; }
.bslot { position: relative; width: var(--bslot, 44px); height: var(--bslot, 44px); border: 6px solid transparent; border-image: url(../assets/herpderp/ui/slot.png) 9 fill / 9px stretch; display: grid; place-items: center; touch-action: none; }
.bslot img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.bslot .lv { position: absolute; left: -2px; top: -2px; display: flex; }
.bslot .lv img { width: 12px; height: 12px; }
.bslot.sel { outline: 3px solid var(--gold); border-radius: 6px; }
.bench.drop .bslot, .shop.drop .offer { outline: 3px dashed var(--gold); outline-offset: 1px; border-radius: 8px; }

.info { flex: none; width: 100%; min-height: 64px; color: var(--ink); line-height: 1.05; padding: 4px 10px; border: 10px solid transparent;
  border-image: url(../assets/herpderp/ui/parchment.png) 30 fill / 30px round; display: flex; gap: 10px; align-items: center; }
.info .txt { flex: 1; min-width: 0; }
.info b { color: #7a2f10; }
.info .istats { color: #5a3a18; }
.info .btns { display: flex; flex-direction: column; gap: 6px; }
.info .btn { margin: 0; padding: 2px 10px; min-height: 44px; }

.shop { display: flex; gap: 6px; justify-content: center; width: 100%; }
.offer { position: relative; flex: none; width: var(--card, 70px); height: calc(var(--card, 70px) + 14px); border: 8px solid transparent; border-image: url(sprites/card.png) 8 fill / 8px round;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; touch-action: none; cursor: grab; padding: 0 0 2px; }
.offer img.it { flex: none; }
.offer .price { text-shadow: var(--ink-outline); color: var(--gold); line-height: 1; display: flex; align-items: center; gap: 2px; }
.offer.poor .price { color: #e08a6a; }
.offer.sold { visibility: hidden; }
.offer.sel { outline: 3px solid var(--gold); border-radius: 8px; }
.offer .tier { position: absolute; top: -4px; right: -2px; display: flex; }
.offer .tier img { width: 12px; height: 12px; }

.actions { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: auto; padding-bottom: 8px; }

.drag { position: fixed; z-index: 800; pointer-events: none; opacity: .9; }
.drag img { position: absolute; object-fit: contain; }

/* Battle */
.fbar { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; text-shadow: var(--ink-outline); line-height: 1; }
.fbar .nm { color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.fbar .st { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.fbar .st > span { display: inline-flex; align-items: center; gap: 2px; }
.fbar .bar { grid-column: 1 / -1; }
.bar .fill { transition: width .15s; }
.arena-wrap { position: relative; width: 100%; flex: none; }
#arena { width: 100%; height: var(--arena, 130px); display: block; border: 3px solid var(--ink); border-radius: 10px; image-rendering: pixelated; }
/* health bars sit on the arena's top corners to leave room for the backpacks */
.arena-wrap .fbar { position: absolute; top: 6px; width: calc(50% - 12px); }
.arena-wrap .fbar.left { left: 8px; }
.arena-wrap .fbar.right { right: 8px; }
.arena-wrap .fbar.right .nm { justify-self: end; grid-column: 2; grid-row: 1; }
.arena-wrap .fbar.right .st { grid-column: 1; grid-row: 1; justify-content: flex-start; }
#battle-screen { gap: 4px; }

/* Windows: start, result, end, ghosts. Layout and buttons come from ../css/phone.css (.hpanel). */
#overlay { z-index: 700; }
.hpanel .hearts { display: flex; gap: 4px; justify-content: center; margin: 0; }
.hpanel .hearts img.ic { margin: 0; }
.hpanel p { margin: 0; }
.hpanel .tb { color: var(--phm-muted); }
.hpanel .tb b { color: var(--phm-gold); }
.hpanel .bagwrap { margin-top: 0; }
.hpanel .bag-stats { color: var(--phm-muted); line-height: 1.05; }
.hpanel .grid { margin: 0 auto; }
.hpanel .hart { min-height: 90px; }
.hdev { color: var(--phm-muted); opacity: .8; text-shadow: var(--phm-outline); }
.hcard .hdev { color: var(--phm-brown); text-shadow: none; text-align: center; }
.hpanel textarea { width: 100%; box-sizing: border-box; height: 70px; font-family: inherit; color: var(--phm-ink); background: var(--phm-parch-hi); border: 3px solid var(--phm-ink); border-radius: 8px; resize: none; user-select: text; -webkit-user-select: text; touch-action: auto; }
.hpanel input[type=text] { width: 100%; box-sizing: border-box; }
.hcard .grow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }
.hcard .grow span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hcard .grow .phm-btn { flex: none; min-height: 40px; padding: 2px 10px; }

/* HerpDerp v6: atmosphere layer and red hurt edge, same as Survivor and Siege. */
#atmosphere { z-index: 1; }
#hurt-edge { z-index: 650; transition: opacity .35s ease-out; }
#hurt-edge.flash { opacity: .6; transition: none; }
#hurt-edge.low { animation: hurt-pulse 1s ease-in-out infinite alternate; }
@keyframes hurt-pulse { from { opacity: .15; } to { opacity: .5; } }

.actions .btn { margin: 0; min-height: 44px; }
.actions .btn.big { min-width: 150px; }
