/* 复用组件：左上角状态条、招牌、格子、列表行、卡片、花费小块。形状都走 base.css 的手绘画法。 */

/* ---------- 左上角状态条：等级经验、氧气、能量 ---------- */
.hud {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 5px var(--sp-2);
  width: 190px;
  max-width: 100%;
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.hud__label {
  white-space: nowrap;
}

.hud__bar {
  --sk-fill: var(--bar-bg);
  --sk-line: var(--line);
  --sk-lw: 2px;
  --sk-r: 8px;
  height: 20px;
  overflow: hidden;
}
.hud__fill {
  position: absolute;
  left: 3px;
  top: 3px;
  bottom: 3px;
  z-index: -1;
  width: calc((100% - 6px) * var(--p, 1));
  border-radius: 5px;
  background: var(--bar-color, var(--oxy));
  transition: width 240ms;
}
.hud__num {
  position: relative;
  display: block;
  padding: 0 7px;
  color: var(--text);
  font-size: 12px;
  line-height: 20px;
  text-align: right;
  text-shadow: 0 0 3px var(--bar-bg), 0 0 3px var(--bar-bg);
}
.hud__bar--xp {
  --bar-color: var(--xp);
}
.hud__bar--oxy {
  --bar-color: var(--oxy);
}
.hud__bar--energy {
  --bar-color: var(--energy);
}
.hud__bar.is-low {
  --sk-line: var(--taint);
}

/* ---------- 招牌：写着名字的灰色长条 ---------- */
.sign {
  flex: none;
  --sk-fill: var(--sign);
  --sk-line: transparent;
  --sk-r: 24px;
  align-self: center;
  max-width: 100%;
  padding: var(--sp-1) var(--sp-5);
  color: var(--text);
  font-size: var(--fs-l);
  line-height: 1.35;
  text-align: center;
}

/* ---------- 格子架：灰色长条 + 黑框格子（家里的东西、图鉴共用） ---------- */
.shelf {
  --sk-fill: var(--tray);
  --sk-line: transparent;
  --sk-r: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  color: var(--ink);
}

.shelf__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4) var(--sp-3);
}

.slot {
  --sk-line: var(--ink);
  --sk-lw: 4px;
  --sk-r: 10px;
  aspect-ratio: 1;
  min-width: 0;
  padding: 9px;
  color: var(--ink);
  cursor: pointer;
  --icon-bg: var(--tray);
}
/* 老内核（Chrome 88 以前）不认 aspect-ratio：每个格子里都有一张正方形图标（没图的放空白的），
   图标高度跟着宽度走，格子就是正方形 */
@supports not (aspect-ratio: 1) {
  .slot > .icon {
    height: auto;
  }
  .fly__icon {
    height: 80%;
    max-height: 72px;
  }
}
.slot:disabled {
  cursor: default;
}
.slot.is-picked {
  --sk-fill: var(--round);
  --icon-bg: var(--round);
}
.slot.is-shroom {
  color: var(--shroom);
  --icon-bg: var(--shroom-spot);
}
.slot.is-unknown {
  --sk-line: var(--ink-dim);
  color: var(--ink-dim);
}
/* 「?」盖在空白图标上面，格子大小由图标决定 */
.slot__q {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  font-size: var(--fs-xl);
  line-height: 1;
}
/* 污染度在右上角、数量在左下角，各自压住格子边角一点点，不挤 */
.slot .badge {
  top: -5px;
  right: -5px;
  min-width: 0;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 18px;
}

/* 选中格子的说明：固定高度，换选中不会挪动下面的东西 */
.shelf__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 112px;
}
.shelf__title {
  font-size: var(--fs-m);
  line-height: 1.35;
}
.shelf__lines {
  display: flex;
  flex-direction: column;
  font-weight: 400;
  font-size: var(--fs-s);
  line-height: 1.5;
}
.shelf__hint {
  color: var(--ink-dim);
}
.shelf__buttons:empty,
.shelf__foot:empty {
  display: none;
}

/* 大弹窗里的格子架：占满弹窗，格子区自己滚，下面的说明和按钮固定不动 */
.panel--large .shelf {
  flex: 1 1 auto;
  min-height: 0;
}
.panel--large .shelf__grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  align-content: start;
  padding: 12px 10px 4px 0;
}
.panel--large .shelf__info {
  flex: none;
}
/* 大弹窗里格子按宽度能放几个放几个，撑满一排；右上角的污染度伸出格子，留出位置 */
.panel--large .shelf__grid {
  grid-template-columns: repeat(auto-fill, minmax(3.75rem, 1fr));
  gap: var(--sp-4) var(--sp-4);
}

/* ---------- 小标题 ---------- */
.section {
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: var(--fs-s);
  color: var(--ink-dim);
}
.section:first-child {
  margin-top: 0;
}

/* ---------- 小标签 ---------- */
.pill {
  --sk-fill: var(--ink);
  --sk-line: transparent;
  --sk-r: var(--radius-pill);
  display: inline-block;
  padding: 1px 12px;
  color: var(--text);
  font-size: var(--fs-s);
  line-height: 1.5;
  white-space: nowrap;
}
.pill--taint {
  --sk-fill: var(--taint);
  color: #fff;
}
.pill--seal {
  --sk-fill: var(--seal);
  color: var(--ink);
}
.pill--light {
  --sk-fill: transparent;
  --sk-line: var(--ink);
  --sk-lw: 2px;
  color: var(--ink);
}

/* ---------- 物品详情 ---------- */
.detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}
.detail__icon {
  --sk-line: var(--ink);
  --sk-lw: 4px;
  width: 88px;
  height: 88px;
  padding: 13px;
  color: var(--ink);
  --icon-bg: var(--panel);
}
.detail__desc {
  margin: 0;
}
.detail__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
}

.empty {
  margin: var(--sp-3) 0;
  color: var(--ink-dim);
  text-align: center;
}

/* ---------- 卡片：面板里一块描边的区域（商店、设备） ---------- */
.card {
  --sk-fill: var(--row);
  --sk-line: var(--ink);
  --sk-lw: 3px;
  --sk-r: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  color: var(--ink);
}
.card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card__label {
  color: var(--ink-dim);
  font-size: var(--fs-s);
  font-weight: 700;
}
.card__value {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 提示位：弹窗、商店、家里的东西上方各留一条固定高度的空位，提示居中放在里面，不盖任何文字；空着也占位，布局不跳 */
.toast-slot {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 32px;
  pointer-events: none;
}
.toast-slot .toast {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-s);
  line-height: 1.3;
}
.panel__toast {
  padding: 0 var(--sp-5);
}
.panel__toast.is-last {
  margin-bottom: var(--sp-4);
}
.panel__toast .toast {
  margin: var(--sp-1) 0;
}
@media (max-height: 700px) {
  .panel__toast.is-last {
    margin-bottom: var(--sp-2);
  }
}
@media (max-height: 600px) {
  .toast-slot {
    height: 28px;
  }
  .panel__toast .toast {
    margin: 0;
  }
}

/* 花费：一排小块，够的打勾、不够的红字 */
.costs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.cost {
  --sk-fill: var(--panel);
  --sk-line: var(--ink);
  --sk-lw: 2px;
  --sk-r: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px;
  overflow-wrap: anywhere;
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
}
/* 现有多少：撑满一整行，不画底色和描边，直接写字 */
.cost--have {
  --sk-fill: transparent;
  --sk-lw: 0px;
  align-self: stretch;
  justify-content: flex-start;
  width: 100%;
  padding: 0;
  text-align: left;
  font-weight: 700;
}
.cost.is-short {
  --sk-line: var(--taint);
  color: var(--taint);
}
.cost__icon {
  width: 22px;
  height: 22px;
}

.shelf__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: auto;
  padding-top: var(--sp-2);
}
/* 两个按钮放得下就并排，窄了各占一行，字不被挤成两行 */
.shelf__buttons .btn {
  flex: 1 1 9rem;
  min-width: 0;
}
.shelf__foot .btn {
  width: 100%;
}
.shelf.is-empty .shelf__grid {
  display: none;
}
.shelf.is-empty .shelf__info {
  min-height: 0;
}

/* ---------- 物品格子（slots.js）：黑框方格 + 红色污染度 + 数量 + 格子下面的名字 ---------- */
/* 格子大小固定，一排放几个看宽度；多出来的换行（家里的东西）或左右滑（背包） */
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, calc(var(--slot-size) + 10px));
  justify-content: start;
  gap: var(--sp-2) 0;
  /* 角标伸出格子外，给它们留出位置，不被外层裁掉 */
  padding: 6px 6px 0;
}
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.item__box {
  width: var(--slot-size);
  padding: 11px;
}
.slot--empty {
  cursor: default;
}
.item__name {
  max-width: 100%;
  font-size: var(--fs-xs);
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.slot .badge--count {
  top: auto;
  right: auto;
  bottom: -4px;
  left: -5px;
}
.slot.is-sealed {
  --sk-fill: var(--seal);
  --icon-bg: var(--seal);
}
.slot.is-lost {
  --sk-fill: var(--shroom);
  color: var(--shroom-spot);
  --icon-bg: var(--shroom);
}

/* 横屏手机：格子架左边格子、右边说明；物品格子一排放更多 */
@media (orientation: landscape) and (max-height: 540px) {
  .shelf {
    flex-direction: row;
    align-items: flex-start;
  }
  .shelf__grid {
    flex: 1 1 0;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--sp-3);
  }
  .shelf__info {
    flex: 0 0 40%;
  }
  .panel--large .shelf {
    align-items: stretch;
  }
  .panel--large .shelf__buttons .btn {
    flex-basis: 100%;
  }
}

/* 标签页：一排等宽按钮 */
.tabs {
  flex: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--sp-2);
}
