/* Focus remains available without a visual highlight. */
*:focus,
*:focus-visible {
  outline: none;
}

@font-face {
  font-family: "Noto Sans KR";
  src: url('../assets/fonts/NotoSansKR-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #111;
  --muted: #aaa;
  --grid: #ededed;
  --paper: #fff;
  /* Inline copy of ../assets/rpg_bag_frame.svg avoids file:// CSS-mask CORS failures. */
  --bag-frame-mask: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmlld0JveD0iMCAwIDEyOCAxMjgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMTggMTRDMTE4IDExLjc5MDkgMTE2LjIwOSAxMCAxMTQgMTBIOTFINjRIMzdIMTRDMTEuNzkwOSAxMCAxMCAxMS43OTA5IDEwIDE0VjM3VjY0Vjg3LjVMNy41IDkxLjVMMTAgOTkuNVYxMTRDMTAgMTE2LjIwOSAxMS43OTA5IDExOCAxNCAxMThIMzdINjRIOTFIMTE0QzExNi4yMDkgMTE4IDExOCAxMTYuMjA5IDExOCAxMTRWOTFWNjRWNTguNUwxMjAuNSA1N0wxMTggNTUuNVYxNFpNMTI2IDExOEMxMjYgMTIyLjQxOCAxMjIuNDE4IDEyNiAxMTggMTI2SDExMC41TDEwOS41IDEyNEwxMDYuNSAxMjZINjRIMzNIMTBDNS41ODE3MiAxMjYgMiAxMjIuNDE4IDIgMTE4Vjk1VjY0VjMzVjEwQzIgNS41ODE3MiA1LjU4MTcyIDIgMTAgMkg0My41TDQ4LjUgNUw1MC41IDJIOTVIMTE4QzEyMi40MTggMiAxMjYgNS41ODE3MiAxMjYgMTBWMzNWNjRWOTVWMTE4WiIgZmlsbD0iYmxhY2siLz4KPC9zdmc+Cg==");
}

* {
  box-sizing: border-box
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
}

button,
input {
  font: inherit
}

body {
  user-select: none;
  -webkit-user-select: none;
  display: grid;
  place-items: center;
}

#game {
  --field-unit: .3vh;
  position: relative;
  width: 60vh;
  height: 100%;
  aspect-ratio: 6 / 10;
  max-height: 100vh;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  isolation: isolate;
}

#game::before,
#game::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 58px;
  z-index: 800;
  pointer-events: none;
}

#game::before {
  left: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

#game::after {
  right: 0;
  background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

#grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  will-change: transform;
}

#world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
  isolation: isolate;
}

#fx {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 900;
  isolation: isolate;
}

.sprite {
  --sprite-pixel: 1px;
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 50% 86%;
  will-change: transform;
}

.sprite svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible
}

/* Field sizes share 0.3vh; small motion uses quarter units (0.075vh). */
#world .sprite {
  --sprite-pixel: calc(var(--field-unit) * .25);
  transform-origin: 50% 82%;
}

#world .player,
#world .bot {
  width: calc(var(--field-unit) * 24);
  height: calc(var(--field-unit) * 24);
}

.player {
  width: 88px;
  height: 88px;
}

.player .art {
  width: 100%;
  height: 100%;
  transform-origin: 50% 84%;
  animation: idle 1.45s ease-in-out infinite;
}

.player.walking .art {
  animation: walk .34s ease-in-out infinite
}

.player.attacking .art {
  animation: none
}

.player .art {
  position: relative;
  z-index: 2
}

.weaponLayer {
  position: absolute;
  left: 6.25%;
  top: 37.5%;
  /* 192 기준 top-left 12,72 */
  width: 50%;
  height: 50%;
  /* 96px weapon on a 192px character canvas */
  z-index: 3;
  pointer-events: none;
  transform-origin: 75% 75%;
  /* weapon-local 72,72 => character-global 84,144 */
  transform: rotate(0deg);
  will-change: transform;
}

.weaponLayer svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible
}

.weaponLayer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player.attacking .weaponLayer {
  animation: none
}

.player.scanning .art {
  animation: scanBob .36s ease-in-out
}

.chest {
  width: calc(var(--field-unit) * 20);
  height: calc(var(--field-unit) * 20);
}

.chestArt {
  position: absolute;
  inset: 0;
  transform-origin: 50% 83%;
  will-change: transform, opacity;
  animation: float 1.75s ease-in-out infinite;
}

.chest.spawning .chestArt {
  animation: spawn .42s cubic-bezier(.2, .9, .2, 1.18) both
}

.chest.hit .chestArt {
  animation: hit .18s cubic-bezier(.2, .8, .3, 1)
}

.chest.opening .chestArt {
  animation: openWhole .58s .16s ease-out forwards
}

.chestArt::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 18%;
  right: 18%;
  bottom: 5%;
  height: 9%;
  border-radius: 50%;
  background: rgba(0, 0, 0, .07);
  filter: none;
}

.chestArt svg {
  position: relative;
  z-index: 2
}

.chest .lid {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.chest.opening .lid {
  animation: lidOpen .58s cubic-bezier(.18, .85, .25, 1) forwards
}

.targetRing {
  position: absolute;
  left: 50%;
  bottom: calc(var(--field-unit) * -.5);
  width: calc(var(--field-unit) * 14);
  height: calc(var(--field-unit) * 6);
  transform: translateX(-50%);
  border: 1.5px solid #111;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: -1;
}

.chest.target .targetRing, .tree.target .targetRing {
  opacity: .9
}

.damage {
  position: absolute;
  z-index: 200;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.04em;
  color: #111;
  text-shadow:
    0 1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff, 0 -1px 0 #fff,
    1px 1px 0 #fff, -1px 1px 0 #fff;
  transform: translate(-50%, -50%);
  animation: damageFloat .64s cubic-bezier(.2, .75, .25, 1) forwards;
}

.spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #111;
  transform: translate(-50%, -50%);
  animation: spark .48s ease-out forwards;
}

#hud {
  position: absolute;
  z-index: 1000;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  height: 33px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1.5px solid #111;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .035);
}

#autoChip,
#statsBtn {
  pointer-events: auto;
  cursor: pointer
}

#autoChip.off {
  opacity: .42
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #111;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .055);
}

#state {
  min-width: 38px
}

#count {
  font-variant-numeric: tabular-nums
}

#statsBtn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  top: max(18px, env(safe-area-inset-top));
  z-index: 1020;
  border: 1.5px solid #111;
  background: #fff;
  color: #111;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .035);
}

#panel,
#zonePanel {
  position: absolute;
  z-index: 1030;
  right: max(18px, env(safe-area-inset-right));
  top: 64px;
  width: 38vh;
  padding: 16px;
  border: 1.5px solid #111;
  border-radius: 18px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: none;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .10);
  transform-origin: top right;
  transition: .16s ease;
}

#panel.hidden,
#zonePanel.hidden {
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panelTitle {
  font-size: 12px;
  font-weight: 900
}

#closePanel,
#closeZonePanel {
  border: 0;
  background: transparent;
  padding: 2px 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.statRow {
  display: grid;
  grid-template-columns: 1fr 88px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #eee;
}

.statRow:first-of-type {
  border-top: 0
}

.statLabel {
  font-size: 11px;
  font-weight: 700;
  color: #333;
}

.statSub {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 500;
  color: #aaa;
}

.statInput {
  width: 88px;
  height: 30px;
  border: 1px solid #d7d7d7;
  border-radius: 10px;
  padding: 0 8px;
  background: #fff;
  color: #111;
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  outline: none;
}


.panelFoot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 9px;
  color: #aaa;
}

#resetStats {
  border: 0;
  background: none;
  padding: 0;
  color: #111;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
}


#touchJoystick {
  position: absolute;
  z-index: 1010;
  left: 0;
  top: 0;
  width: 108px;
  height: 108px;
  transform: translate(-50%, -50%) scale(.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s ease, transform .08s ease;
}

#touchJoystick.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#touchJoyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  border: 1px solid rgba(155, 155, 155, 0.22);
  background: rgba(155, 155, 155, 0.2);
  box-shadow: 0 5px 12px rgba(0, 0, 0, .035);
  will-change: transform;
}

#touchJoystick::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(55, 55, 55, .1);
  transform: translate(-50%, -50%);
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, .025);
}

@keyframes idle {

  0%,
  100% {
    transform: translateY(0) rotate(-.3deg)
  }

  50% {
    transform: translateY(calc(var(--sprite-pixel) * -3)) rotate(.3deg)
  }
}

@keyframes walk {

  0%,
  100% {
    transform: translateY(0) scaleY(1)
  }

  50% {
    transform: translateY(calc(var(--sprite-pixel) * -5)) scaleY(.982)
  }
}

@keyframes scanBob {

  0%,
  100% {
    transform: translateY(0) scale(1)
  }

  50% {
    transform: translateY(calc(var(--sprite-pixel) * -2)) scale(1.02)
  }
}

@keyframes attack {
  0% {
    transform: translateX(0) translateY(0) scale(1)
  }

  18% {
    transform: translateX(-3px) translateY(1px) scaleX(.992) scaleY(1.008)
  }

  42% {
    transform: translateX(6px) translateY(-2px) scaleX(1.03) scaleY(.982)
  }

  58% {
    transform: translateX(2px) translateY(-1px) scaleX(1.012) scaleY(.992)
  }

  100% {
    transform: translateX(0) translateY(0) scale(1)
  }
}

@keyframes weaponSwing {
  0% {
    transform: rotate(0deg)
  }

  16% {
    transform: rotate(12deg)
  }

  42% {
    transform: rotate(120deg)
  }

  60% {
    transform: rotate(72deg)
  }

  100% {
    transform: rotate(0deg)
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(calc(var(--sprite-pixel) * -3))
  }
}

@keyframes spawn {
  0% {
    opacity: 0;
    transform: translateY(calc(var(--sprite-pixel) * -13)) scale(.6)
  }

  74% {
    opacity: 1;
    transform: translateY(calc(var(--sprite-pixel) * 2)) scale(1.06)
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1)
  }
}

@keyframes hit {
  0% {
    transform: translateX(0) rotate(0)
  }

  32% {
    transform: translateX(calc(var(--sprite-pixel) * -5)) rotate(-2deg)
  }

  64% {
    transform: translateX(calc(var(--sprite-pixel) * 4)) rotate(1.5deg)
  }

  100% {
    transform: translateX(0) rotate(0)
  }
}

@keyframes lidOpen {
  0% {
    transform: translateY(0) rotate(0)
  }

  58% {
    transform: translateY(calc(var(--sprite-pixel) * -17)) rotate(-8deg)
  }

  100% {
    transform: translateY(calc(var(--sprite-pixel) * -21)) rotate(-5deg)
  }
}

@keyframes openWhole {

  0%,
  55% {
    opacity: 1;
    transform: translateY(0) scale(1)
  }

  100% {
    opacity: 0;
    transform: translateY(calc(var(--sprite-pixel) * -8)) scale(.82)
  }
}

@keyframes damageFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(.78)
  }

  15% {
    opacity: 1;
    transform: translate(-50%, -58%) scale(1.15)
  }

  45% {
    opacity: 1;
    transform: translate(-50%, -85%) scale(1)
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -155%) scale(.94)
  }
}

@keyframes spark {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1)
  }

  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.15)
  }
}


/* ===== V10: independent bot ownership + fixed-size paginated inventory ===== */
#hud {
  flex-wrap: wrap;
  max-width: calc(100% - 112px)
}

#botChip {
  pointer-events: auto;
  cursor: pointer
}

#bagBtn,
#zoneBtn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  top: 62px;
  z-index: 1020;
  border: 1.5px solid #111;
  background: #fff;
  color: #111;
  min-width: 52px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 10px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .035);
  cursor: pointer;
}

.bot {
  width: 88px;
  height: 88px;
  opacity: 1
}

.bot .art {
  width: 100%;
  height: 100%;
  transform-origin: 50% 84%;
  animation: idle 1.45s ease-in-out infinite
}

.bot.walking .art {
  animation: walk .34s ease-in-out infinite
}

.bot.attacking .art {
  animation: none
}

.botName,
.playerName {
  position: absolute;
  left: 50%;
  top: -11px;
  transform: translateX(-50%) scaleX(var(--name-flip, 1));
  padding: 2px 6px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  font-size: 8px;
  line-height: 1.2;
  font-weight: 900;
  white-space: nowrap;
  color: #555;
  pointer-events: none;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 6;
}

#world .botName,
#world .playerName {
  top: calc(var(--field-unit) * -3);
  padding: calc(var(--field-unit) * .5) calc(var(--field-unit) * 1.5);
  font-size: calc(var(--field-unit) * 3);
  max-width: calc(var(--field-unit) * 24);
}

.nameInput {
  text-align: left
}

#inventoryPanel,
#botPanel {
  position: absolute;
  z-index: 1040;
  right: max(18px, env(safe-area-inset-right));
  width: min(350px, calc(100% - 36px));
  border: 1.5px solid #111;
  border-radius: 18px;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: none;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .10);
  transform-origin: top right;
  transition: .16s ease;
  box-sizing: border-box;
}

/* Inventory dimensions are content-independent: long text never grows the panel. */
#inventoryPanel {
  top: 106px;
  padding: 14px;
  height: min(600px, calc(100% - 150px));
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#botPanel {
  top: 64px;
  padding: 14px;
  max-height: calc(100% - 112px);
  overflow: auto
}

#inventoryPanel.hidden,
#botPanel.hidden {
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none
}

#inventoryPanel .panelBar {
  flex: 0 0 24px;
  height: 24px;
  margin-bottom: 8px
}

.panelBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0
}

.panelBar strong {
  font-size: 12px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.panelBar button {
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  flex: 0 0 auto
}

.wallet {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid #eee;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 8px;
  flex: 0 0 34px;
  height: 34px;
  align-items: center;
  overflow: hidden
}

.wallet>span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.walletCurrencies,
.rpgWalletCurrency {
  display: flex;
  align-items: center;
}

.walletCurrencies {
  gap: 10px;
}

.rpgWalletCurrency {
  gap: 3px;
}

.rpgWalletCurrency img,
.rpgSoilInlineIcon {
  width: 15px;
  height: 15px;
  object-fit: contain;
  vertical-align: middle;
}

.equipGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, 44px);
  gap: 6px;
  margin-bottom: 8px;
  flex: 0 0 94px;
  height: 94px;
  overflow: hidden
}

.equipSlot {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 6px 8px;
  background: #fff;
  height: 44px;
  min-height: 44px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  min-width: 0
}

.equipSlot.empty {
  color: #aaa
}

.slotEnh {
  font-size: 7px;
  color: #777;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.inventoryBagControls {
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
  margin-bottom: 7px;
}

.inventoryActionsBar {
  display: flex;
  align-items: center;
  min-height: 28px;
  gap: 6px;
}

.inventoryTabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 0;
  flex: 0 0 31px;
  height: 31px
}

.inventoryTab {
  height: 31px;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  color: #999;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.inventoryTab.active {
  border-color: #111;
  color: #111;
  box-shadow: inset 0 0 0 1px #111
}

.itemGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  flex: 0 0 180px;
  height: 180px;
  overflow: hidden
}

.itemSlot {
  position: relative;
  height: 56px;
  min-height: 56px;
  border: 1px solid #e1e1e1;
  background: #fff;
  border-radius: 11px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  overflow: hidden
}

.itemSlot:hover {
  border-color: #aaa
}

.itemSlot.empty {
  border-style: dashed;
  background: rgba(0, 0, 0, .012);
  cursor: default
}

.itemSlotIcon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid #ddd;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 900;
  color: #555;
  background: #fafafa;
  overflow: hidden
}

.itemSlotName {
  font-size: 8px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.itemSlotMeta {
  font-size: 7px;
  color: #aaa;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.inventoryPager {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  flex: 0 0 28px;
  height: 28px
}

.inventoryPager button {
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 9px;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer
}

.inventoryPager button:disabled {
  opacity: .25;
  cursor: default
}

#pageLabel {
  text-align: center;
  font-size: 8px;
  font-weight: 900;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.emptyBag {
  grid-column: 1/-1;
  padding: 18px 8px;
  text-align: center;
  font-size: 9px;
  color: #aaa;
  border: 1px dashed #ddd;
  border-radius: 12px;
  overflow: hidden
}

.itemDetail {
  margin-top: 8px;
  border-top: 1px solid #eee;
  padding-top: 8px;
  flex: 1 1 auto;
  min-height: 92px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.detailTitle {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  flex: 0 0 20px;
  height: 20px;
  min-width: 0;
  overflow: hidden
}

.detailTitle strong {
  font-size: 11px;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.gradeBadge {
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 8px;
  font-weight: 900;
  white-space: nowrap;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto
}

.statLines {
  display: grid;
  align-content: start;
  gap: 3px;
  margin: 5px 0;
  font-size: 9px;
  color: #555;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 2px
}

.statLines>div {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word
}

.actionRow {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  flex: 0 0 31px;
  height: 31px
}

.actionRow button {
  border: 1px solid #111;
  border-radius: 10px;
  background: #fff;
  height: 31px;
  min-width: 0;
  padding: 0 4px;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.actionRow button:disabled {
  opacity: .3;
  cursor: default
}

/* Item focus is explicit-only. The tooltip overlays the fixed inventory layout and never changes panel dimensions. */
.itemDetail {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 8;
  height: 172px;
  min-height: 172px;
  margin: 0;
  padding: 10px;
  border: 1.5px solid #111;
  border-radius: 14px;
  background: rgba(255, 255, 255, .985);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
  overflow: hidden;
}

.itemDetail.hidden {
  display: none
}

.detailClose {
  border: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0 2px
}

.detailTitleActions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto
}

.actionRow.four {
  grid-template-columns: repeat(4, 1fr)
}

.magicSummary {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px
}

.magicDot {
  width: 17px;
  height: 17px;
  border: 1px solid #ccc;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 7px;
  font-weight: 900;
  background: #fff
}

.magicDot.success {
  border-color: #111
}

.magicDot.sealed {
  background: #eee;
  color: #999
}

.magicDot.unused {
  border-style: dashed;
  color: #bbb
}

.modalBackdrop {
  position: absolute;
  inset: 0;
  z-index: 1300;
  background: rgba(255, 255, 255, .70);
  backdrop-filter: none;
  display: grid;
  place-items: center;
  padding: 16px
}

.modalBackdrop.hidden {
  display: none
}

.upgradeDialog {
  width: min(330px, 100%);
  max-height: calc(100% - 24px);
  overflow: hidden;
  border: 1.5px solid #111;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .16);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px
}

.upgradeHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto
}

.upgradeHead strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.upgradeHead button {
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer
}

.upgradeItem {
  border: 1px solid #e4e4e4;
  border-radius: 12px;
  padding: 9px;
  font-size: 9px;
  line-height: 1.55;
  overflow: hidden
}

.upgradeItem strong {
  display: block;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.upgradeBody {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  font-size: 9px;
  color: #555
}

.upgradePrimary {
  height: 34px;
  border: 1px solid #111;
  border-radius: 11px;
  background: #fff;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer
}

.upgradePrimary:disabled {
  opacity: .3;
  cursor: default
}

.magicSlots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px
}

.magicSlot {
  height: 42px;
  border: 1px solid #ddd;
  border-radius: 9px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 7px;
  line-height: 1.2;
  overflow: hidden
}

.magicSlot.success {
  border-color: #111
}

.magicSlot.sealed {
  background: #f3f3f3;
  color: #999
}

.magicSlot.unused {
  border-style: dashed;
  color: #aaa
}

.scrollGroup {
  display: grid;
  gap: 5px
}

.scrollRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 7px 8px
}

.scrollInfo {
  min-width: 0
}

.scrollInfo strong {
  display: block;
  font-size: 9px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.scrollInfo span {
  display: block;
  margin-top: 2px;
  font-size: 7px;
  color: #999;
  line-height: 1.3
}

.scrollRow button {
  height: 28px;
  min-width: 54px;
  border: 1px solid #111;
  border-radius: 9px;
  background: #fff;
  font-size: 8px;
  font-weight: 900;
  cursor: pointer
}

.scrollRow button:disabled {
  opacity: .3;
  cursor: default
}

.upgradeNote {
  font-size: 7px;
  line-height: 1.45;
  color: #999
}

.botRows {
  display: grid;
  gap: 7px
}

.botRow {
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 9px
}

.botTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px
}

.botTop strong {
  font-size: 10px
}

.botState {
  font-size: 8px;
  color: #888;
  font-weight: 900
}

.botSpec {
  margin-top: 5px;
  font-size: 8px;
  line-height: 1.55;
  color: #777
}

.botNote {
  font-size: 8px;
  color: #aaa;
  margin-top: 8px;
  line-height: 1.45
}

@media(max-width:640px) {
  .bot {
    width: 78px;
    height: 78px
  }

  #inventoryPanel {
    height: calc(100% - 150px)
  }
}

/* The display canvas clips a height-locked 6:10 game stage. */
body {
  display: block;
}

#displayCanvas {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  overflow: hidden;
  isolation: isolate;
}

#game {
  position: absolute;
  top: 0;
  left: 50%;
  width: auto;
  height: 100%;
  max-height: none;
  aspect-ratio: 6 / 10;
  transform: translateX(-50%);
  flex: none;
}

#game::before,
#game::after {
  display: none;
}

#fieldFeathers {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

#fieldFeathers::before,
#fieldFeathers::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(6vh + 12px);
}

#fieldFeathers::before {
  left: var(--feather-left, 0px);
  background: linear-gradient(to right, #fff 0 12px, rgba(255, 255, 255, 0) 100%);
}

#fieldFeathers::after {
  right: var(--feather-right, 0px);
  background: linear-gradient(to left, #fff 0 12px, rgba(255, 255, 255, 0) 100%);
}

/* Embedded field edges match the lobby arrows; the moving panel owns the carousel seam. */
body[data-embedded] #fieldFeathers::before,
body[data-embedded] #fieldFeathers::after {
  width: 5.2vh;
}
body[data-embedded] #fieldFeathers::before {
  background: linear-gradient(to right, #fff, #fff0);
}
body[data-embedded] #fieldFeathers::after {
  background: linear-gradient(to left, #fff, #fff0);
}

#gameUi {
  position: absolute;
  top: 0;
  left: 50%;
  width: auto;
  height: 100%;
  aspect-ratio: 6 / 10;
  transform: translateX(-50%);
  z-index: 920;
  pointer-events: none;
}

/* Follow the same visible stage edges as the feathers; keep artwork and type at their set size. */
#edgeControls {
  position: absolute;
  top: 0;
  left: var(--visible-stage-left, 0px);
  width: var(--visible-stage-width, 60vh);
  height: 100%;
  z-index: 910;
  pointer-events: none;
}

#gameUi #bagBtn,
#gameUi #zoneBtn,
#gameUi #zonePanel:not(.hidden),
#gameUi #panel:not(.hidden),
#gameUi #inventoryPanel:not(.hidden),
#gameUi #botPanel:not(.hidden) {
  pointer-events: auto;
}

#gameUi #panel.hidden,
#gameUi #zonePanel.hidden,
#gameUi #inventoryPanel.hidden,
#gameUi #botPanel.hidden {
  visibility: hidden;
}

#hud {
  left: 1.8vh;
  right: 8.4vh;
}

#panel,
#inventoryPanel,
#zonePanel,
#botPanel {
  right: 1.8vh;
  width: min(42vh, calc(100vw - 6vh));
  border-color: #555;
  background: #ededed;
  box-shadow: .45vh .6vh 0 rgba(40, 40, 40, .28);
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  padding: 3vh;
  background: rgba(20, 20, 20, .58);
  backdrop-filter: none;
}

.upgradeDialog {
  width: min(42vh, 100%);
  max-height: none;
  border-color: #555;
  background: #ededed;
}

.upgradeBody {
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

#enhanceModal .upgradeDialog {
  height: 76vh;
}

#enhanceModal .upgradeBody {
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.equipSlot,
.itemSlot,
.magicSlot,
.scrollCard {
  background: #faf8f2;
  border: 1px solid #ded9cb;
  border-radius: 10px;
}

.inventoryTab.active {
  border-color: #8b9876;
  background: #eef2e7;
  color: #38452e;
}

.panelBar strong,
.upgradeHead strong {
  font-size: 14px;
  letter-spacing: -.3px;
}

.magicWorkbench {
  display: grid;
  grid-template-columns: minmax(92px, .85fr) minmax(0, 1.6fr);
  gap: 10px;
  align-items: start;
}

.magicSlots {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.magicSlot {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  padding: 8px;
  font-size: 10px;
}

.magicSlot span {
  overflow-wrap: anywhere;
}

.magicSlot.sealed {
  background: #f2e9e7;
}

.scrollInventory {
  display: grid;
  gap: 8px;
  font-size: 11px;
}

.scrollGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.scrollCard {
  min-width: 0;
  padding: 8px 3px;
  display: grid;
  gap: 5px;
  font-size: 10px;
  cursor: grab;
  touch-action: none;
}

.scrollCard b {
  font-size: 18px;
}

.scrollCard small {
  font-size: 9px;
}

.scrollCard:disabled {
  opacity: .35;
  cursor: default;
}

.scrollGhost {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  width: 90px;
  opacity: .9;
  box-shadow: 0 8px 24px #0003;
  transform: rotate(-5deg);
}

.bulkBar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin: 0;
}

.bulkBar button {
  border: 1px solid #d8d3c9;
  background: #f5f2ea;
  border-radius: 8px;
  padding: 7px;
  font-size: 10px;
}

#inventoryPanel .itemGrid {
  flex-shrink: 0;
}


.damage {
  font-size: 16px;
}

#statsBtn,
#bagBtn,
#zoneBtn {
  right: 1.8vh;
  border-color: #555;
  background: #ededed;
}

#hud {
  max-width: none;
  flex-wrap: wrap;
  gap: .6vh;
}

.chip {
  border-color: #d8d3c9;
  background: #fffefa;
  height: 29px;
  padding: 0 8px;
  font-size: 9px;
}

.upgradeNote {
  font-size: 1.05vh;
  line-height: 1.45;
  color: #666;
}

.upgradeDialog,
.equipmentDialog {
  box-sizing: border-box;
  border: .28vh solid #555;
  border-radius: 5.2vh .5vh 4.5vh .55vh / .55vh 4.6vh .6vh 5.1vh;
  background: #ededed;
  box-shadow: .45vh .6vh 0 rgba(40, 40, 40, .3);
}

.upgradeDialog {
  padding: 2.2vh;
  gap: 1.2vh;
}

.upgradeHead {
  min-height: 3.4vh;
}

.upgradeHead strong {
  font-size: 1.8vh;
}

.upgradeHead button,
.detailClose {
  font-size: 2.5vh;
}

.equipmentDialog {
  width: min(42vh, 100%);
  padding: 2.4vh;
}

.itemDetail {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: grid;
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 3vh;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: rgba(20, 20, 20, .58);
  box-shadow: none;
  backdrop-filter: none;
  overflow: hidden;
}

.itemDetail.hidden {
  display: none;
}

.equipmentDialog {
  position: relative;
}

.equipmentDialog>.detailClose {
  position: absolute;
  top: 1.2vh;
  right: 1.2vh;
  z-index: 2;
  border: 0;
  background: transparent;
}

.itemSlot.rarity-normal {
  border-color: #777;
}

.itemSlot.rarity-rare {
  border-color: #4f9bd9;
}

.itemSlot.rarity-epic {
  border-color: #a85bc5;
}

.equipmentHeader {
  display: grid;
  grid-template-columns: 8vh minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.4vh;
  margin-bottom: 1.4vh;
}

.equipmentIcon {
  display: grid;
  width: 8vh;
  height: 8vh;
  place-items: center;
  border: 0;
  background: #ddd;
  font-size: 2.2vh;
  font-weight: 900;
}

.equipmentName {
  min-width: 0;
  font-size: 1.8vh;
  font-weight: 800;
  color: var(--grade-color, #777);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rarity-normal {
  --grade-color: #777;
}

.rarity-rare {
  --grade-color: #4f9bd9;
}

.rarity-epic {
  --grade-color: #a85bc5;
}

.equipmentSlots {
  display: flex;
  gap: .35vh;
  margin-top: .8vh;
}

.equipmentSlots img {
  display: block;
  width: 1.8vh;
  height: 1.8vh;
  object-fit: contain;
}

.equipmentStats {
  display: grid;
  gap: .45vh;
  min-height: 11vh;
  padding: 1.2vh 1vh;
  font-size: 1.25vh;
  line-height: 1.35;
}

.equipmentStats div {
  display: flex;
  justify-content: space-between;
  gap: 1vh;
}

.equipmentActions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1vh;
  margin-top: 1.4vh;
}

.equipmentActions.four {
  grid-template-columns: repeat(4, 1fr);
}

.equipmentActions.five {
  grid-template-columns: repeat(5, 1fr);
}

.equipmentActions button,
.upgradePrimary {
  min-height: 3.8vh;
  border: .2vh solid #555;
  border-radius: 0;
  background: #ff9292;
  font-size: 1.35vh;
  font-weight: 800;
}

.upgradeItem {
  border: 0;
  padding: 0;
}

.upgradePreview {
  display: grid;
  gap: .7vh;
  text-align: center;
}

.upgradeLevel {
  font-size: 2.7vh;
  font-weight: 900;
}

.upgradeArrow {
  font-size: 2.6vh;
  line-height: 1;
}

.magicWorkbench {
  grid-template-columns: 12vh minmax(0, 1fr);
}

.magicSlot {
  min-height: 3.2vh;
  height: 3.2vh;
  padding: .3vh .6vh;
  font-size: 1vh;
  border-radius: 0;
}

.scrollGrid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45vh;
}

.scrollCard {
  min-height: 5.8vh;
  padding: .45vh;
  border-radius: 0;
  font-size: 1vh;
}

.scrollCard b {
  font-size: 1.5vh;
}

.scrollCard small {
  font-size: .85vh;
}

.scrollGhost {
  width: 9vh;
}

/* Shared hand-cut controls from the main game. */
#statsBtn,
#bagBtn,
#zoneBtn,
#zoneList button,
#cancelZoneTravel,
.inventorySortToggle,
.panelBar button,
.inventoryTab,
.inventoryPager button,
.bulkBar button,
.equipSlot,
.itemSlot,
.equipmentActions button,
.upgradePrimary,
.upgradeHead button,
.scrollCard,
.magicPager button {
  border-width: .22vh;
  border-style: solid;
  border-color: #666;
  border-radius: 1.7vh .35vh 1.45vh .4vh / .38vh 1.5vh .42vh 1.75vh;
  box-shadow: .18vh .24vh 0 rgba(60, 60, 60, .24);
}

#statsBtn:active,
#bagBtn:active,
#zoneBtn:active,
#zoneList button:active,
#cancelZoneTravel:active,
.inventorySortToggle:active,
.panelBar button:active,
.inventoryTab:active,
.inventoryPager button:active,
.bulkBar button:active,
.equipmentActions button:active,
.upgradePrimary:active,
.upgradeHead button:active,
.magicPager button:active {
  transform: translate(.12vh, .12vh);
  box-shadow: .06vh .08vh 0 rgba(60, 60, 60, .24);
}

#inventoryPanel,
#botPanel,
#zonePanel,
#panel {
  border: .28vh solid #555;
  border-radius: 4.2vh .5vh 3.8vh .55vh / .55vh 3.8vh .6vh 4.1vh;
  background: #ededed;
  box-shadow: .45vh .6vh 0 rgba(40, 40, 40, .3);
}

.equipSlot,
.itemSlot {
  position: relative;
  border-color: var(--grade-color, #777);
  background: #dedede;
}

.equipSlot.rarity-normal,
.itemSlot.rarity-normal {
  --grade-color: #777;
}

.equipSlot.rarity-rare,
.itemSlot.rarity-rare {
  --grade-color: #4f9bd9;
}

.equipSlot.rarity-epic,
.itemSlot.rarity-epic {
  --grade-color: #a85bc5;
}

.slotEnh,
.itemEnhanceMark {
  position: absolute;
  right: .45vh;
  bottom: .25vh;
  margin: 0;
  color: #222;
  font-size: 1.05vh;
  font-weight: 900;
  line-height: 1;
}

.magicWorkbench {
  display: block;
}

.magicStatusBoard {
  display: grid;
  gap: .45vh;
  margin: 1.2vh 1.4vh 2.2vh;
  padding: 1.6vh 2.4vh;
  border: .3vh dotted #aaa;
  border-radius: 1.3vh;
}

.magicStatusCell {
  display: grid;
  min-width: 0;
  height: 2.15vh;
  place-items: center;
  border: 0;
  border-bottom: .18vh solid currentColor;
  background: transparent;
  font-size: 1.1vh;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.magicStatusCell.success {
  color: #3998bd;
}

.magicStatusCell.sealed {
  color: #bd6565;
}

.magicStatusCell.unused {
  color: #888;
}

.scrollInventory {
  display: block;
}

.scrollGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, 5.8vh);
  gap: .45vh;
}

.scrollCard,
.scrollEmpty {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 5.8vh;
  padding: .25vh;
  border: .18vh solid #777;
  border-radius: .7vh .15vh .62vh .18vh / .16vh .65vh .18vh .72vh;
  background: #d9d9d9;
  box-shadow: .1vh .14vh 0 rgba(60, 60, 60, .18);
  overflow: hidden;
}

.scrollCard {
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
}

.scrollCard b {
  font-size: 1.55vh;
}

.scrollCard span {
  position: absolute;
  right: .25vh;
  bottom: .12vh;
  font-size: .78vh;
  font-weight: 900;
}

.scrollCard small {
  display: none;
}

.scrollCard:disabled {
  opacity: .28;
}

.scrollEmpty {
  border-style: solid;
}

.magicPager {
  display: grid;
  grid-template-columns: 3vh 1fr 3vh;
  align-items: center;
  gap: .8vh;
  margin-top: 1vh;
  text-align: center;
  font-size: 1vh;
}

.magicPager button {
  height: 2.6vh;
  background: #ededed;
  font-size: 1.2vh;
}

/* Equipment redesign: two slots, 24 visual-only bag cells, and one eight-slot magic board. */
.equipGrid {
  grid-template-columns: repeat(2, 6.8vh);
  grid-template-rows: 6.8vh;
  height: 6.8vh;
  flex-basis: 6.8vh;
  gap: .7vh;
  justify-content: space-around;
  overflow: visible;
}

.itemGrid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, 5.8vh);
  height: calc(23.2vh + 1.8vh);
  flex-basis: calc(23.2vh + 1.8vh);
  gap: .6vh;
  overflow: visible;
}

.equipSlot,
.itemSlot {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: .35vh;
  place-items: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}

.equipSlot::before,
.itemSlot::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--grade-color, #777);
  -webkit-mask: var(--bag-frame-mask) center / 100% 100% no-repeat;
  mask: var(--bag-frame-mask) center / 100% 100% no-repeat;
  pointer-events: none;
}

.equipSlot.empty::before,
.itemSlot.empty::before {
  opacity: .35;
}

.bagItemAsset {
  position: relative;
  z-index: 1;
  display: block;
  width: 78%;
  height: 78%;
  object-fit: contain;
  pointer-events: none;
}

.equipSlot .bagItemAsset {
  width: 64%;
  height: 64%;
}

.slotEnh,
.itemEnhanceMark {
  right: .55vh;
  bottom: .45vh;
  z-index: 2;
  color: #111;
  font-size: 1.05vh;
  text-shadow: 0 1px #fff, 1px 0 #fff, 0 -1px #fff, -1px 0 #fff;
}

.itemSlotIcon {
  position: relative;
  z-index: 1;
  width: 62%;
  height: 62%;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.2vh;
}

.equipmentHeader {
  grid-template-columns: 8vh minmax(0, 1fr);
}

.equipmentIcon {
  overflow: hidden;
  background: transparent;
}

.equipmentIcon img {
  display: block;
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.equipmentNameEnhance {
  margin-left: .65vh;
  color: #a14f54;
  font-weight: 900;
}

.magicStatusBoard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, 2.15vh);
  column-gap: 4.5vh;
  row-gap: .45vh;
  min-height: 13.4vh;
  transition: background .1s ease, outline-color .1s ease;
}

.magicStatusCell {
  width: 100%;
  height: 2.15vh;
}

.scrollGhost {
  position: fixed;
  z-index: 99999;
  display: grid;
  width: 5.8vh;
  height: 5.8vh;
  min-width: 0;
  min-height: 0;
  padding: .3vh;
  place-items: center;
  overflow: hidden;
  border: .18vh solid #777;
  border-radius: .7vh .15vh .62vh .18vh / .16vh .65vh .18vh .72vh;
  background: #d9d9d9;
  box-shadow: .35vh .5vh 1.2vh rgba(0, 0, 0, .24);
  opacity: .92;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-5deg);
}

.scrollGhost b {
  font-size: 1.55vh;
}

.scrollGhost span {
  position: absolute;
  right: .3vh;
  bottom: .15vh;
  font-size: .8vh;
  font-weight: 900;
}

/* Both inventories use the same slot frame, centered artwork, and corner labels. */
#magicEnhanceModal .upgradeDialog {
  padding: 14px;
}

.scrollInventory .scrollGrid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, 5.8vh);
  gap: .6vh;
  height: calc(23.2vh + 1.8vh);
}

.scrollGrid .itemSlot,
.scrollGrid .scrollEmpty,
.scrollGhost.itemSlot {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: .35vh;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.bagItemAsset,
.itemSlotIcon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.itemSlotIcon {
  display: grid;
  place-items: center;
  font-weight: 900;
}

.itemEnhanceMark,
.slotEnh {
  position: absolute;
  top: .35vh;
  right: .45vh;
  bottom: auto;
}

#equipmentGrid .itemEnhanceMark {
  top: .45vh;
  right: .55vh;
  font-size: 1.3vh;
}

.itemEquippedBadge {
  position: absolute;
  z-index: 2;
  left: .35vh;
  bottom: .25vh;
  display: grid;
  width: 1.7vh;
  height: 1.7vh;
  place-items: center;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 1vh;
  font-weight: 900;
  line-height: 1;
}

.equipmentHeader {
  grid-template-columns: 8vh minmax(0, 1fr) 3vh;
}

.itemLockButton {
  display: grid;
  width: 3vh;
  height: 3vh;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.itemLockButton img {
  display: block;
  width: 2.6vh;
  height: 2.6vh;
  object-fit: contain;
}

.scrollCard .bagItemAsset {
  display: block;
  width: 78%;
  height: 78%;
}

.scrollGhost.itemSlot {
  position: fixed;
  width: 5.8vh;
  height: 5.8vh;
  transform: translate(-50%, -50%) rotate(-5deg);
  pointer-events: none;
  opacity: .92;
}

.itemQuantity {
  position: absolute;
  right: .35vh;
  bottom: .25vh;
  z-index: 3;
  padding: 0 .25vh;
  border-radius: .3vh;
  background: #111c;
  color: #fff;
  font: 900 max(10px, 1.15vh)/1.3 "Noto Sans KR", sans-serif;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px #000;
  pointer-events: none;
}

.scrollCard .itemQuantity {
  right: .35vh;
  bottom: .25vh;
  font-size: max(10px, 1.15vh);
}

.scrollGhost {
  position: fixed;
  z-index: 99999;
  width: 9vh;
  height: 9vh;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  opacity: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.scrollGhost .bagItemAsset {
  width: 100%;
  height: 100%;
  opacity: 1;
  filter: drop-shadow(0 3px 5px #0007);
}

.scrollGhost .itemQuantity {
  right: -.15vh;
  bottom: -.1vh;
  font-size: max(12px, 1.5vh);
}

/* Controls sit on the visible stage edges, outside the external top and bottom navigation zones. */
#hud {
  left: auto;
  right: 0;
  top: auto;
  bottom: 12vh;
  max-width: none;
  flex-wrap: nowrap;
}

#topControls {
  position: absolute;
  left: calc((100% - var(--visible-stage-width, 60vh)) / 2 + 4vh);
  top: 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#topControls #bagBtn,
#topControls #statsBtn,
#topControls #zoneBtn {
  position: static;
  pointer-events: auto;
}

#autoChip {
  position: relative;
  right: 4vh;
  display: block;
  width: 8vh;
  height: 8vh;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

#autoChip.off {
  opacity: 1;
}

#autoChip img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#autoChip .autoIconOff,
#autoChip.off .autoIconOn,
#autoChip.off .autoIconSpin {
  display: none;
}

#autoChip.off .autoIconOff {
  display: block;
}

#autoChip .autoIconSpin {
  animation: autoIconSpin 2.8s linear infinite;
}

@keyframes autoIconSpin {
  to {
    transform: rotate(360deg);
  }
}

#edgeControls #autoChip {
  pointer-events: auto;
}

#panel,
#inventoryPanel,
#zonePanel {
  left: 50%;
  right: auto;
  top: 47%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  transition: opacity .16s ease, transform .16s ease;
}

#panel.hidden,
#inventoryPanel.hidden,
#zonePanel.hidden {
  transform: translate(-50%, -50%) scale(.98);
}

#panel,
#zonePanel {
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#inventoryPanel {
  height: min(600px, 80vh);
}

#inventorySortWrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  z-index: 20;
}

#inventorySortBtn,
#inventorySortBtn:active {
  display: block;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  cursor: pointer;
}

#inventorySortBtn img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#inventorySortBubble {
  position: absolute;
  top: calc(100% + 9px);
  right: -4px;
  width: min(190px, calc(100vw - 10vh));
  padding: 10px;
  border: 1px solid #555;
  border-radius: 10px;
  background: #ededed;
  box-shadow: .25vh .35vh 0 #0003;
}

#inventorySortBubble::before {
  content: "";
  position: absolute;
  right: 11px;
  top: -5px;
  width: 8px;
  height: 8px;
  background: #ededed;
  border-top: 1px solid #555;
  border-left: 1px solid #555;
  transform: rotate(45deg);
}

#inventorySortBubble[hidden] {
  display: none;
}

#inventorySortBubble .inventorySortToggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  margin-bottom: 7px;
  background: #ededed;
  font-size: 11px;
  font-weight: 800;
  color: #111;
}

#inventorySortBubble .inventorySortToggle[aria-pressed="true"] {
  background: #d8d8d8;
}

.inventorySortState {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

#inventorySortBubble p {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: #555;
}

#panel #botPanel {
  position: static;
  width: auto;
  padding: 0;
  margin-top: 18px;
  border: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.menuHeading {
  font-size: 13px;
  margin: 12px 0;
  font-weight: 800;
}

summary.menuHeading {
  cursor: pointer;
}

.balanceControls {
  border-bottom: 1px solid #ccc;
  padding-bottom: 10px;
}

.balanceControls p {
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.balanceControls select,
.balanceControls textarea {
  width: 100%;
  font: inherit;
  font-size: 11px;
}

.balanceControls textarea {
  user-select: text;
  -webkit-user-select: text;
}

.balanceButtons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}

.balanceButtons button,
.balanceButtons a {
  font-size: 11px;
  padding: 6px;
  cursor: pointer;
}

.portal {
  width: calc(var(--field-unit) * 28);
  height: calc(var(--field-unit) * 28);
}

.portal img {
  width: 100%;
  height: 100%;
}

.portalMeter {
  position: absolute;
  top: calc(var(--field-unit) * -2);
  left: calc(var(--field-unit) * 5);
  right: calc(var(--field-unit) * 5);
  height: calc(var(--field-unit) * 1.25);
  border-radius: 4px;
  overflow: hidden;
  background: #d5e7ea;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}

.portalMeter.charging {
  opacity: 1;
}

.commonPortalTimer {
  position: absolute;
  top: calc(var(--field-unit) * -6);
  left: calc(var(--field-unit) * 5);
  right: calc(var(--field-unit) * 5);
  color: #d7263d;
  font-size: calc(var(--field-unit) * 3);
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.portalMeter i {
  display: block;
  height: 100%;
  background: #007bc8;
  transform-origin: left;
  transform: scaleX(0);
}

#portalArrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 920;
  pointer-events: none;
}

#portalArrow img {
  position: absolute;
  --sprite-pixel: calc(var(--field-unit) * .25);
  left: calc(var(--field-unit) * -4);
  top: calc(var(--field-unit) * -4);
  width: calc(var(--field-unit) * 8);
  height: calc(var(--field-unit) * 8);
  animation: portalGuide 1.3s ease-in-out infinite alternate;
}

#timeIndicator {
  position: absolute;
  left: 4vh;
  bottom: 12vh;
  pointer-events: none;
  color: #111;
  font: 500 14px/1.2 "Noto Sans KR", sans-serif;
  font-variant-numeric: tabular-nums;
}

#timeIndicator.emphasized {
  color: #d9272d;
  font-size: 24px;
  font-weight: 900;
}

#timeIndicator[hidden] {
  display: none;
}

@keyframes portalGuide {
  from {
    transform: translateX(calc(var(--sprite-pixel) * -3)) scale(.94);
  }

  to {
    transform: translateX(calc(var(--sprite-pixel) * 3)) scale(1);
  }
}

#dungeonScene {
  position: absolute;
  inset: 0;
  z-index: 600;
  pointer-events: none;
  background: #fff;
}

#dungeonScene[hidden],
#portalArrow[hidden],
.portal[hidden],
#dungeonResult[hidden] {
  display: none;
}

#dungeonCanvas,
#dungeonActors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#dungeonActors .sprite {
  width: 88px;
  height: 88px;
}

#dungeonActors .bot {
  opacity: .72;
}

#dungeonActors .bot .playerName {
  display: none;
}

#dungeonActors .knocked {
  opacity: .75;
}

#dungeonMeter {
  position: absolute;
  top: 76px;
  z-index: 20;
  pointer-events: auto;
  padding: 5px 7px;
  border-radius: 6px;
  background: #fffffff0;
  color: #193a4c;
  font-size: 9px;
}

#dungeonMeter summary {
  cursor: pointer;
  padding: 1px 0;
  font-weight: 700;
}

#dungeonMeter ol {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

#dungeonMeter li {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 3px;
  margin-top: 2px;
  isolation: isolate;
}

#dungeonMeter li[hidden] {
  display: none;
}

#dungeonMeter li i {
  position: absolute;
  inset: 0;
  z-index: -1;
  transform-origin: left;
  background: #dce7ec;
}

#dungeonMeter li[data-player="true"] i {
  background: #bde3f0;
}

#dungeonMeter li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#dungeonMeter li b {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

#displayCanvas.inDungeon #grid,
#displayCanvas.inDungeon #floorDecorations,
#displayCanvas.inDungeon #world,
#displayCanvas.inDungeon #hud,
#displayCanvas.inDungeon #statsBtn,
#displayCanvas.inDungeon #bagBtn,
#displayCanvas.inDungeon #touchJoystick,
#displayCanvas.inDungeon #fieldFeathers {
  visibility: hidden;
}

#dungeonResult {
  position: absolute;
  inset: 0;
  z-index: 950;
  display: grid;
  place-items: center;
  background: #f8fafbe8;
  padding: 28px;
  pointer-events: auto;
}

.dungeonCard {
  display: flex;
  flex-direction: column;
  width: min(42vh, calc(100vw - 6vh));
  max-height: 80vh;
  padding: 1.8vh;
  border: .28vh solid #555;
  border-radius: 4.2vh .5vh 3.8vh .55vh / .55vh 3.8vh .6vh 4.1vh;
  background: #ededed;
  box-shadow: .45vh .6vh 0 rgba(40, 40, 40, .3);
  box-sizing: border-box;
}

.dungeonResultHead {
  flex: 0 0 2.4vh;
  height: 2.4vh;
  margin-bottom: 1vh;
}

.dungeonWinner.equipmentHeader {
  grid-template-columns: 8vh minmax(0, 1fr);
  margin-bottom: 1vh;
}

.dungeonWinnerAvatar {
  position: relative;
}

.dungeonWinnerAvatar .sprite {
  position: relative;
  width: 100%;
  height: 100%;
  inset: auto;
  transform: none;
}

.dungeonWinnerMeta {
  display: flex;
  align-items: center;
  gap: .7vh;
  margin-top: .8vh;
  color: #555;
  font-size: 1.1vh;
}

.dungeonWinnerTitle {
  display: flex;
  align-items: center;
  gap: .7vh;
}

.dungeonMvpBadge {
  padding: .25vh .6vh;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: .95vh;
  font-weight: 900;
  letter-spacing: .04em;
}

.dungeonWinner .equipmentName {
  color: #111;
}

.dungeonWinnerMeta b,
.rpgDungeonGoldReward b {
  color: #111;
  font-variant-numeric: tabular-nums;
}

.dungeonMyDamageText {
  margin: 0 0 .8vh;
  color: #777;
  font-size: 1vh;
  text-align: center;
}

.dungeonMyDamageText b {
  font-variant-numeric: tabular-nums;
}

.dungeonRewards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4vh;
  min-height: 5.8vh;
  margin: .2vh 0 .8vh;
}

.dungeonRewards .itemSlot {
  width: 5.8vh;
  height: 5.8vh;
  flex: 0 0 5.8vh;
}

.rpgDungeonGoldReward {
  display: flex;
  align-items: center;
  gap: .45vh;
  color: #555;
  font-size: 1.4vh;
  font-weight: 800;
}

.rpgDungeonGoldReward img {
  width: 3.4vh;
  height: 3.4vh;
  object-fit: contain;
}

.equipmentHeader.readOnly {
  grid-template-columns: 8vh minmax(0, 1fr);
}

.dungeonCard .equipmentActions {
  grid-template-columns: 1fr;
  margin-top: .2vh;
}

.dungeonCard .equipmentActions button {
  cursor: pointer;
}

#zoneBoundaries {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.zoneBoundary {
  position: absolute;
  border: 1px solid #dedede;
  border-radius: 50%;
  box-sizing: border-box;
}

#zonePanel p {
  font-size: 11px;
  line-height: 1.6;
  color: #555;
}

.zoneTravelStatus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 11px;
}

#cancelZoneTravel {
  padding: 5px 8px;
  background: #ededed;
  color: #111;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

#zoneList {
  display: grid;
  gap: .8vh;
}

#zoneList button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1vh;
  padding: 1vh 1.2vh;
  background: #ededed;
  color: #111;
  font-size: 11px;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

#zoneList button[aria-current="true"] {
  background: #dedede;
  border-color: #333;
}

#zoneList small {
  color: #555;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.6;
}

#displayCanvas.inDungeon #zoneBoundaries,
#displayCanvas.inDungeon #zoneBtn {
  visibility: hidden;
}

.player .art>img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.player .art>.lumiAngry,
.player.angry .art>.lumiIdle {
  display: none;
}

.player.angry .art>.lumiAngry {
  display: block;
}

.player.angry .art {
  animation: none;
}

.player.angry .art,
.player.angry .weaponLayer {
  translate: 0 var(--anger-hop, 0px);
}

@media (prefers-reduced-motion: reduce) {

  #portalArrow img,
  #autoChip .autoIconSpin {
    animation: none;
  }
}
.tree { width: calc(var(--field-unit) * 36); height: calc(var(--field-unit) * 36); }
.treeArt { width: 100%; height: 100%; transform-origin: 50% 84%;
  transition: opacity .7s ease, transform .7s ease; }
.treeArt img { display: block; width: 100%; height: 100%; }
.tree.felled .treeArt { opacity: 0; transform: scale(.65); }
.tree .targetRing { bottom: calc(var(--field-unit) * 4); width: calc(var(--field-unit) * 16); }

/* Field controls keep a 1vh gap after the 7.8vh lobby swipe strip (1.5 x 5.2vh). */
body[data-embedded] { --field-side-inset: 8.8vh; }
body[data-embedded] #topControls {
  left: calc((100% - var(--visible-stage-width, 60vh)) / 2 + var(--field-side-inset));
}
body[data-embedded] #autoChip { right: var(--field-side-inset); }
body[data-embedded] #panel,
body[data-embedded] #inventoryPanel,
body[data-embedded] #zonePanel {
  width: min(42vh, calc(100vw - var(--field-side-inset) * 2));
}
body[data-embedded] .dungeonCard {
  width: min(42vh, calc(100vw - 14.4vh));
}
body[data-embedded] .modalBackdrop,
body[data-embedded] .itemDetail { padding-inline: var(--field-side-inset); }
body[data-embedded] #panel,
body[data-embedded] #inventoryPanel,
body[data-embedded] #zonePanel {
  top: 54%;
  max-height: 64vh;
}
body[data-embedded] #inventoryPanel { height: min(600px, 64vh); }
body[data-embedded] .modalBackdrop,
body[data-embedded] .itemDetail { padding-block: 22vh 14vh; }
body[data-embedded] .upgradeDialog,
body[data-embedded] .equipmentDialog { max-height: 64vh; overflow-y: auto; }
body[data-paused] *,
body[data-paused] *::before,
body[data-paused] *::after { animation-play-state: paused !important; }

/* The field is frozen behind the independent boss canvas, including its CSS motion. */
#displayCanvas.inDungeon #world *,
#displayCanvas.inDungeon #world *::before,
#displayCanvas.inDungeon #world *::after { animation-play-state: paused !important; }
#displayCanvas.inDungeon #gameUi,
#displayCanvas.inDungeon #zoneBoundaries { visibility: hidden; }
body[data-rpg-scene="boss-result"] .dungeonCard {
  width: min(42vh, calc(100vw - 6vh));
}
body[data-rpg-scene="boss-result"] #itemDetail { padding: 3vh; }

.commonPortalControls p { font-size: 11px; line-height: 1.7; }
.commonPortalControls .statInput { max-width: 96px; }
.commonDropRow { display: flex; gap: 8px; margin: 8px 0; }
.commonDropRow select { min-width: 0; flex: 1; }
.commonDropRow input { width: 72px; }
body[data-rpg-scene="common-result"] .dungeonCard { width: min(42vh, calc(100vw - 6vh)); }
body[data-rpg-scene="common-result"] #itemDetail { padding: 3vh; }

/* These switches hide only field artwork; world and zone state remain intact. */
#game.hideFloorTiles #grid,
#game.hideZoneGrid #zoneBoundaries {
  visibility: hidden;
}

.rpgDisplayToggle {
  width: 88px;
  height: 30px;
  border: 1px solid #111;
  border-radius: 10px;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.rpgDisplayToggle[aria-pressed="false"] {
  border-color: #d7d7d7;
  background: #ededed;
  color: #777;
}

/* Decorative artwork is independent of the two field line switches. */
#floorDecorations {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#floorDecorationWorld {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

#floorDecorationWorld img {
  width: calc(var(--field-unit) * 12);
  height: calc(var(--field-unit) * 12);
  position: absolute;
  display: block;
  object-fit: contain;
  user-select: none;
}
