/* HUD：金币（顶）、物品栏（底中）、操作按钮（右） */

/* ---------------------------------------------------------------- 金币 + 体力 */

.stats {
  position: fixed;
  z-index: 70;   /* 金币/体力永远在最上面，弹窗关不关都能看见 */
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid rgba(75, 58, 44, 0.14);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.stat b {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
  margin-left: -2px;
}

.stat.low b,
.stat.low i {
  color: #d3563f;
}

/* ---------------------------------------------------------------- 右上：地块信息 */

.tileinfo {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  width: 194px;
  padding: 9px 12px 10px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(75, 58, 44, 0.14);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  z-index: 5;
  font-size: 12.5px;
  line-height: 1.45;
}

/* 归属行上的买地按钮 */
.ti-buy {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 6px 8px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.08s ease;
}

.ti-buy:hover:not(:disabled) {
  filter: brightness(1.06);
}

.ti-buy:active:not(:disabled) {
  transform: translateY(1px);
}

.ti-buy:disabled {
  background: #ece6d8;
  color: #a79d8a;
  cursor: not-allowed;
}

.tileinfo:empty {
  display: none;
}

.ti-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.ti-xy {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.ti-title {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ti-tag {
  padding: 0 6px;
  border-radius: 999px;
  background: #eef3e2;
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 800;
  line-height: 15px;
}

.ti-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
}

.ti-bar {
  margin-top: 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(75, 58, 44, 0.13);
  overflow: hidden;
}

.ti-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.ti-bar.ripe i {
  background: #e0a12e;
}

/* ---------------------------------------------------------------- 物品栏 */

.hotbar {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  padding: 5px;
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(75, 58, 44, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  z-index: 5;
}

.slot {
  position: relative;
  width: 50px;
  height: 56px;
  padding: 2px 2px 1px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #f6efdf;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.slot svg {
  width: 26px;
  height: 26px;
  margin-top: 3px;
}

.slot .nm {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 名字和数量并排躺在格子底部：名字在左，×N 紧跟着 */
.slot .lb {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
}

.slot .key {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 8.5px;
  font-weight: 700;
  color: #b9ab93;
}

.slot .cnt {
  position: static;
  padding: 0;
  background: none;
  border: none;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  color: #b06a12;
  white-space: nowrap;
}

/* 水壶右上角的小水表：还剩几份水 */
.slot .wlv {
  position: absolute;
  top: 2px;
  right: 3px;
  padding: 0 4px;
  border-radius: 6px;
  background: #dcf0fa;
  color: #2f6f96;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.slot:hover {
  background: #fffaf0;
}

.slot.on {
  border-color: var(--accent);
  background: #eef3e2;
  transform: translateY(-3px);
  box-shadow: 0 4px 0 rgba(90, 163, 70, 0.28);
}

.slot.empty {
  opacity: 0.45;
}

/* ---------------------------------------------------------------- 操作按钮 */

/* 左手方向、右手动作，两边都抬到物品栏上方 */
.dpad {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px);
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
  z-index: 5;
}

.use {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 110px);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 250, 240, 0.94);
  color: var(--ink);
  font: inherit;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(75, 58, 44, 0.16), 0 10px 24px rgba(75, 58, 44, 0.18);
  display: grid;
  place-items: center;
  transition: transform 0.08s ease;
  touch-action: none;
  z-index: 5;
}

.use:active {
  transform: scale(0.94);
}

.use span {
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

/* 四字以上的标签缩小一点，别折成两行 */
.use.long {
  font-size: 13.5px;
  letter-spacing: -0.2px;
}

/* 体力：用按钮外圈的那道环表示，满了就是一圈绿 */
.use .ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.use .ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.use .ring .track {
  stroke: rgba(75, 58, 44, 0.12);
}

.use .ring .fill {
  stroke: var(--accent);
  stroke-dasharray: 289;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s ease, stroke 0.25s ease;
}

.dpad button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(75, 58, 44, 0.14);
  background: rgba(255, 250, 240, 0.92);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(75, 58, 44, 0.12);
  backdrop-filter: blur(4px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dpad button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(75, 58, 44, 0.12);
  background: #eef3e2;
}

.dpad .up {
  grid-area: 1 / 2;
}

.dpad .left {
  grid-area: 2 / 1;
}

.dpad .right {
  grid-area: 2 / 3;
}

.dpad .down {
  grid-area: 3 / 2;
}

/* ---------------------------------------------------------------- 悬停提示 */

.tip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -140%);
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(43, 31, 22, 0.88);
  color: #fff6e8;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 6;
}

.tip.show {
  opacity: 1;
}

kbd {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  vertical-align: 1px;
}

/* ---------------------------------------------------------------- 窄屏 */

@media (max-width: 560px) {
  .slot {
    width: 44px;
    height: 50px;
  }

  .slot svg {
    width: 22px;
    height: 22px;
  }

  .slot .nm {
    display: none;
  }

  .use {
    width: 60px;
    height: 60px;
    font-size: 17px;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 96px);
  }

  .dpad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 66px);
  }

  .dpad button {
    width: 40px;
    height: 40px;
  }
}

/* 窄屏：金币体力靠左，地块信息靠右，两边留够位置不打架 */
@media (max-width: 560px) {
  .stats {
    left: max(10px, env(safe-area-inset-left));
    transform: none;
    gap: 10px;
    padding: 5px 12px;
  }

  .stat b {
    font-size: 14px;
  }

  .stat svg {
    width: 16px;
    height: 16px;
  }

  .tileinfo {
    width: 152px;
    padding: 7px 9px 8px;
    font-size: 11.5px;
  }

  .ti-title {
    font-size: 12.5px;
  }

  .ti-sub {
    font-size: 10.5px;
  }
}
/* 物品栏最后一格：背包 */
.slot.bag {
  background: #efe6d3;
  border-color: transparent;
}

.slot.bag:hover {
  background: #f7efe0;
}

/* 「用」按钮：当前格没活可干时压暗 */
.use.off {
  opacity: 0.55;
  box-shadow: 0 4px 0 rgba(75, 58, 44, 0.1);
}

.use.off:active {
  transform: none;
}

/* 「用」按钮上的字可能是两个汉字，小一号更稳 */
.use span {
  font-size: 17px;
  letter-spacing: 0.02em;
}
/* 体力见底：数字更暗更红一点 */
.stat.empty b,
.stat.empty i {
  color: #b83c26;
}
/* ---------------------------------------------------------------- 手机端可读性
   旧规则在小屏把格子缩到 44px 还隐藏了物品名称，导致"看不清图标与描述"。
   这里改成：格子放大、名称显示、格子可横向滚动，触控目标 ≥ 54px。 */

@media (max-width: 640px) {
  .hotbar {
    gap: 6px;
    padding: 6px;
    border-radius: 16px;
    max-width: calc(100vw - 12px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .hotbar::-webkit-scrollbar {
    display: none;
  }

  .slot {
    flex: 0 0 56px;
    width: 56px;
    height: 66px;
    padding: 3px 3px 2px;
    border-radius: 12px;
  }

  .slot svg {
    width: 32px;
    height: 32px;
    margin-top: 3px;
  }

  /* 关键：小屏也要显示名称，字号够大才读得清 */
  .slot .nm {
    display: block;
    font-size: 11.5px;
    line-height: 1.15;
    font-weight: 600;
    color: #6b5b47;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .slot .key {
    font-size: 9.5px;
    top: 2px;
    left: 5px;
  }

  .slot .cnt {
    font-size: 10.5px;
    min-width: 17px;
    line-height: 16px;
    top: 2px;
    right: 4px;
  }

  /* 右侧「用」按钮：别被屏幕边缘切掉 */
  .use {
    width: 62px;
    height: 62px;
    font-size: 17px;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 112px);
  }
}

/* 手机端细节修正：让 6 格完整放下，方向键/「用」抬到物品栏上方，避免互相压住 */
@media (max-width: 640px) {
  .hotbar {
    max-width: calc(100vw - 20px);
    gap: 5px;
    padding: 5px;
  }

  .slot {
    flex: 0 0 52px;
    width: 52px;
    height: 64px;
  }

  .slot svg {
    width: 30px;
    height: 30px;
  }

  .slot .nm {
    font-size: 11px;
  }

  /* 底部物品栏约 74px 高 + 10px 边距；方向键与「用」抬到 96px 以上 */
  .dpad {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 96px);
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
  }

  .dpad button {
    width: 44px;
    height: 44px;
  }

  .use {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 100px);
  }
}

/* 再放大一档：手机上以"看清、好点"优先，6 格放不下时横向滑动 */
@media (max-width: 640px) {
  .hotbar {
    gap: 6px;
    padding: 6px;
    border-radius: 18px;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .hotbar::-webkit-scrollbar { display: none; }

  .slot {
    flex: 0 0 62px;
    width: 62px;
    height: 78px;
    padding: 4px 3px 3px;
    border-radius: 14px;
    scroll-snap-align: center;
  }

  .slot svg {
    width: 38px;
    height: 38px;
    margin-top: 2px;
  }

  .slot .nm {
    display: block;
    font-size: 12.5px;
    line-height: 1.2;
    font-weight: 700;
    color: #5c4d3c;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .slot .key {
    font-size: 10.5px;
    top: 3px;
    left: 6px;
  }

  .slot .cnt {
    font-size: 11.5px;
    min-width: 18px;
    line-height: 17px;
    top: 3px;
    right: 5px;
    border-radius: 7px;
  }

  /* 方向键与「用」同步放大，并抬到更高的位置（物品栏现在 90px 高） */
  .dpad {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 106px);
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 6px;
  }

  .dpad button {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .use {
    width: 72px;
    height: 72px;
    font-size: 20px;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 112px);
  }
}

/* 背包固定在右侧：物品栏可横向滑动，但背包永远可见可点 */
@media (max-width: 640px) {
  .hotbar .slot.bag {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #efe6d3;
    box-shadow: -8px 0 12px -6px rgba(75, 58, 44, 0.25);
    border-radius: 14px;
  }
}

/* 定稿：6 格刚好铺满一屏（不滑动、不遮挡），图标与名称尽量大 */
@media (max-width: 640px) {
  .hotbar {
    gap: 4px;
    padding: 4px;
    max-width: calc(100vw - 12px);
    overflow: visible;
    scroll-snap-type: none;
  }

  .slot {
    flex: 1 1 0;
    width: auto;
    min-width: 54px;
    max-width: 62px;
    height: 76px;
  }

  .slot svg {
    width: 36px;
    height: 36px;
    margin-top: 2px;
  }

  .slot .nm {
    font-size: 12.5px;
    font-weight: 700;
  }

  /* 取消上一版的固定背包（已经不滑动了） */
  .hotbar .slot.bag {
    position: relative;
    right: auto;
    box-shadow: none;
  }
}

/* ---------------------------------------------------------------- 头顶提示
   站在哪一格，就在角色头顶显示这一格的状态：可买 / 开垦进度 / 倒计时 /
   可播种 / 可收获 / 可偷。跟随相机移动，位置由 JS 每帧写入 transform。 */

.headhint {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  will-change: transform;
  pointer-events: none;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 10px 6px;
  margin-top: -8px;
  border-radius: 12px;
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid rgba(75, 58, 44, 0.18);
  box-shadow: 0 4px 14px rgba(75, 58, 44, 0.18);
  backdrop-filter: blur(3px);
  white-space: nowrap;
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--ink);
  /* 以"底边中点"对齐头顶 */
  translate: -50% -100%;
}

.headhint[hidden] { display: none; }

/* 小尾巴，指着头顶 */
.headhint::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  background: rgba(255, 250, 240, 0.94);
  border-right: 1px solid rgba(75, 58, 44, 0.18);
  border-bottom: 1px solid rgba(75, 58, 44, 0.18);
  transform: rotate(45deg);
}

.hh-line {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.hh-line.ok { color: #2f7a2a; }
.hh-line.warn { color: #b06a12; }
.hh-line.wait { color: #3f6f8f; }
.hh-line.mute { color: #6b5b47; }

.hh-sub {
  font-size: 11px;
  color: #8a7761;
  font-weight: 600;
}

.hh-bar {
  width: 100%;
  min-width: 92px;
  height: 4px;
  border-radius: 3px;
  background: #e8ddc8;
  overflow: hidden;
  margin-top: 1px;
}

.hh-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #8fc46a, #5aa346);
  transition: width 0.24s linear;
}

/* 手机端：同样字号够大，别缩 */
@media (max-width: 640px) {
  .headhint {
    font-size: 14px;
    padding: 6px 12px 7px;
    border-radius: 14px;
  }

  .hh-sub { font-size: 12px; }
  .hh-bar { height: 5px; min-width: 110px; }
}

/* 可买状态不再做成按钮：买地由「用」按钮发起，头顶只做提示 */


/* ---------------------------------------------------------------- 商店 */
.shop-btn {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(75, 58, 44, 0.18);
  background: rgba(255, 250, 240, 0.94);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(75, 58, 44, 0.14);
  z-index: 6;
}

.shop-btn svg { width: 22px; height: 22px; }
.shop-btn:active { transform: translateY(1px); }

.shop-dialog { width: min(560px, 92vw); max-height: 86vh; overflow: auto; position: relative; }
.shop-tabs { margin: 4px 0 12px; }
.shop-body { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(75, 58, 44, 0.14);
  background: #fffdf6;
}

.shop-main { flex: 1; min-width: 0; }
.shop-name { font-weight: 800; font-size: 14px; }
.shop-sub { font-size: 12px; color: var(--muted); }
.shop-meta { font-size: 11.5px; color: #8a7761; margin-top: 2px; }
.shop-price { font-weight: 800; color: #b06a12; white-space: nowrap; }

.shop-buy {
  padding: 7px 14px;
  border-radius: 10px;
  border: none;
  background: #5aa346;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(50, 110, 40, 0.4);
}

.shop-buy:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(50, 110, 40, 0.4); }

/* ---------------------------------------------------------------- 机器商店：图标网格 + 详情气泡 */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.shop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 6px 9px;
  border: 2px solid rgba(120, 96, 70, 0.18);
  border-radius: 16px;
  background: #fffdf6;
  font: inherit;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease, background 0.12s ease;
}

.shop-card:hover {
  background: #fffaf0;
  border-color: rgba(120, 96, 70, 0.34);
}

.shop-card:active {
  transform: scale(0.96);
}

.shop-card-icon svg {
  width: 42px;
  height: 42px;
}

.shop-card-nm {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  text-align: center;
}

.shop-card-price {
  font-size: 12px;
  font-weight: 900;
  color: #b06a12;
}

.shop-card-price::after {
  content: ' 金币';
  font-size: 9.5px;
  font-weight: 700;
  color: #b9a68a;
}

.shop-card-own {
  font-size: 9.5px;
  color: #4a8f3c;
  font-weight: 800;
}

.shop-pop {
  position: absolute;
  z-index: 8;
  width: min(250px, 84%);
  padding: 12px 14px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1.5px solid rgba(75, 58, 44, 0.16);
  box-shadow: 0 12px 26px rgba(60, 48, 36, 0.22);
  text-align: center;
  filter: drop-shadow(0 6px 12px rgba(60, 48, 36, 0.16));
}

.shop-pop[hidden] {
  display: none;
}

.shop-pop-title {
  font-size: 14.5px;
  font-weight: 900;
  color: var(--ink);
}

.shop-pop-sub {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.shop-pop-recipe {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #8a5a2b;
}

.shop-pop-meta {
  margin-top: 4px;
  font-size: 10.5px;
  line-height: 1.5;
  color: #a08b70;
}

.shop-pop .shop-buy {
  display: block;
  width: 100%;
  margin-top: 10px;
}


.gacha-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.shop-buy small {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
}

.shop-buy.ten {
  background: #c94a86;
  box-shadow: 0 3px 0 rgba(140, 40, 90, 0.4);
}

.shop-buy.ten:active {
  box-shadow: 0 2px 0 rgba(140, 40, 90, 0.4);
}

.gacha-multi {
  font-size: 13px;
  font-weight: 900;
  color: #a8436a;
  letter-spacing: 1px;
}

.gacha-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 0 6px;
}

/* 盒子容器：单抽一个大盒，十连 5×2 十个小盒 */
.gacha-boxes {
  position: relative;
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 320px;
  justify-items: center;
}

.gacha-boxes.single {
  grid-template-columns: 108px;
  justify-content: center;
}

.gacha-boxes.many {
  grid-template-columns: repeat(5, 1fr);
}

/* 整屏闪光：开盒那一刻从屏幕中心炸开一团白光，再慢慢褪掉 */
.gacha-flash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.gacha-flash i {
  width: 160vmax;
  height: 160vmax;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 248, 218, 0.95) 12%,
    rgba(255, 224, 150, 0.6) 26%,
    rgba(255, 214, 120, 0) 58%
  );
  opacity: 0;
  transform: scale(0.12);
}

/* 整屏白闪：盖满整个视口，保证任何屏幕尺寸都被闪到 */
.gacha-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.gacha-flash.play i {
  animation: gacha-burst 1.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.gacha-flash.play::after {
  animation: gacha-white 1.5s ease-out both;
}

@keyframes gacha-burst {
  0% { opacity: 0; transform: scale(0.12); }
  20% { opacity: 1; transform: scale(0.72); }
  55% { opacity: 0.85; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.45); }
}

@keyframes gacha-white {
  0% { opacity: 0; }
  16% { opacity: 0.92; }
  48% { opacity: 0.5; }
  100% { opacity: 0; }
}

/* 结果逐格淡入 */
.gacha-stage.reveal .gacha-box {
  animation: gacha-in 0.62s ease-out both;
  animation-delay: calc(var(--i, 0) * 85ms);
}

.gacha-stage.reveal .gacha-name,
.gacha-stage.reveal .gacha-sub,
.gacha-stage.reveal .shop-buy {
  animation: gacha-in 0.66s ease-out both;
  animation-delay: 0.3s;
}

@keyframes gacha-in {
  from { opacity: 0; transform: translateY(8px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.gacha-box {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  filter: drop-shadow(0 8px 12px rgba(80, 40, 60, 0.18));
  animation: gacha-shake 0.42s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 55ms);
  transform-origin: 50% 92%;
}

.gacha-box.small {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

.gacha-box.open {
  animation: gacha-pop 0.4s ease-out both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* 十连里中奖的那几个：金边 + 光晕 */
.gacha-box.got {
  filter: drop-shadow(0 0 10px rgba(255, 196, 60, 0.95));
}

.gacha-box.got .gacha-spark {
  animation: gacha-spark 1.4s ease-out 0.2s infinite;
}

.gacha-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.gacha-lid {
  transform-box: fill-box;
  transform-origin: 20% 100%;
  transition: transform 0.34s cubic-bezier(0.2, 1.3, 0.4, 1);
  transition-delay: calc(var(--i, 0) * 45ms);
}

.gacha-box.open .gacha-lid {
  transform: translate(-26px, -12px) rotate(-26deg);
}

.gacha-stage.win .gacha-box {
  filter: drop-shadow(0 0 16px rgba(240, 180, 60, 0.9));
}

.gacha-spark { opacity: 0; }
.gacha-box.open .gacha-spark { animation: gacha-spark 0.85s ease-out 0.12s both; }

@keyframes gacha-shake {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes gacha-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes gacha-spark {
  0% { opacity: 0; transform: translateY(6px) scale(0.8); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px) scale(1.15); }
}

.gacha-tip {
  font-size: 12.5px;
  color: var(--muted);
}

.gacha-name {
  font-size: 20px;
  font-weight: 900;
  color: #8a2b58;
}

.gacha-stage.lose .gacha-name {
  font-size: 17px;
  color: #8c8272;
}

.gacha-sub {
  max-width: 270px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

.gacha-stage .shop-buy { margin-top: 8px; }

@media (max-width: 640px) {
  .shop-btn { top: 120px; padding: 10px 12px; font-size: 12px; }
  .shop-btn svg { width: 26px; height: 26px; }
}

.shop-hint {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 9px;
  background: #eef6e4;
  color: #3f6f2f;
  margin-bottom: 8px;
}

.shop-hint.warn {
  background: #fdf0e0;
  color: #a05a12;
}

.shop-buy[disabled] {
  background: #cfc6b4;
  box-shadow: none;
  cursor: not-allowed;
}


/* ---------------------------------------------------------------- 出售面板 */
.sell-panel {
  position: absolute;
  display: block;
  z-index: 7;
}

.sell-panel[hidden] { display: none; }

.sell-card {
  width: 208px;
  padding: 10px 12px 10px;
  border-radius: 16px;
  background: #fff8ee;
  border: 1px solid rgba(120, 96, 70, 0.22);
  box-shadow: 0 10px 30px rgba(60, 48, 36, 0.28);
  text-align: center;
}

.sell-title { font-size: 15px; font-weight: 800; color: #6a4b2c; }
.sell-sub { font-size: 11.5px; color: #a08b70; margin-top: 2px; }

.sell-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 10px;
}

.sell-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--fruit, #e2603c);
}

.sell-icon svg { width: 38px; height: 38px; fill: var(--fruit, #e2603c); }
.sell-n { font-size: 16px; color: #6a4b2c; }

.sell-step {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  border: none;
  background: linear-gradient(180deg, #6fc24a, #4c9c33);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 #35701f;
}

.sell-step[disabled] { background: #c9c0ae; box-shadow: 0 4px 0 #a89e8b; cursor: not-allowed; }
.sell-step:active { transform: translateY(2px); box-shadow: 0 2px 0 #35701f; }

.sell-go {
  width: 100%;
  padding: 9px 0;
  font-size: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #6fc24a, #4c9c33);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #35701f;
}

.sell-go i.sell-coin {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin: 0 2px 0 6px;
  border-radius: 50%;
  background: #f2c14e;
  border: 2px solid #c08a2f;
  vertical-align: -2px;
}

.sell-go:active { transform: translateY(2px); box-shadow: 0 2px 0 #35701f; }

.sell-cancel {
  margin-top: 6px;
  width: 100%;
  padding: 6px 0;
  font-size: 12px;
  border: none;
  border-radius: 12px;
  background: #efe6d6;
  color: #7a6650;
  font-weight: 700;
  cursor: pointer;
}


/* ---------------------------------------------------------------- 电网营业厅 */
.power-dialog { width: min(340px, 92vw); }

.pw-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 2px;
  font-size: 13.5px;
  color: #6a5a45;
  border-bottom: 1px dashed rgba(120, 96, 70, 0.18);
}

.pw-row b { color: #4b3a2c; font-size: 15px; }
.pw-row b.pw-owe { color: #b84a2a; }
.pw-row.pw-quiet b { color: #9c9080; font-weight: 700; }
.pw-hint {
  margin: -2px 0 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #a08b70;
}

.pw-main {
  width: 100%;
  margin: 12px 0 22px;
  padding: 11px 0;
  border: none;
  border-radius: 13px;
  background: linear-gradient(180deg, #6fc24a, #4c9c33);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #35701f;
}

.pw-main[disabled] { background: #c9c0ae; box-shadow: 0 4px 0 #a89e8b; cursor: not-allowed; }

.pw-main:active:not([disabled]) { transform: translateY(2px); box-shadow: 0 2px 0 #35701f; }

.pw-promo {
  position: relative;
  margin-top: 12px;
  padding: 14px 12px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, #fff5d8, #ffe8b0);
  border: 1.5px dashed #e0a83c;
  text-align: center;
}

.pw-promo-tag {
  position: absolute;
  top: -9px;
  left: 12px;
  padding: 2px 9px;
  border-radius: 8px;
  background: #e2662f;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.pw-promo-main { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 4px; }
.pw-old { font-size: 12.5px; color: #a08b70; text-decoration: line-through; }
.pw-new { font-size: 22px; font-weight: 900; color: #d2521f; }

.pw-promo-sub { font-size: 12px; color: #96682a; margin: 3px 0 10px; }

.pw-buy {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffb340, #f08c1d);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #c06a10;
}

.pw-buy:active { transform: translateY(2px); box-shadow: 0 2px 0 #c06a10; }


/* 出售气泡的小三角与食用按钮 */
.sell-card {
  position: relative;
  box-shadow: none;                     /* 阴影交给整个气泡，尾巴才带得上 */
}

/* 用 drop-shadow 让阴影跟着"卡片+尾巴"的轮廓走 */
.sell-panel {
  filter: drop-shadow(0 8px 18px rgba(60, 48, 36, 0.26));
}

.sell-tail {
  position: absolute;
  left: var(--tail-x, 50%);
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  background: #fff8ee;
  border-right: 1px solid rgba(120, 96, 70, 0.22);
  border-bottom: 1px solid rgba(120, 96, 70, 0.22);
  border-radius: 0 0 3px 0;
}

/* 气泡在格子上方：尾巴朝下，压在卡片底边上 */
.sell-panel.above .sell-tail {
  bottom: -7px;
  transform: rotate(45deg);
}

/* 气泡在格子下方：尾巴朝上 */
.sell-panel.below .sell-tail {
  top: -7px;
  transform: rotate(225deg);
  border-right-color: rgba(120, 96, 70, 0.22);
  border-bottom-color: rgba(120, 96, 70, 0.22);
}

.sell-eat {
  margin-top: 6px;
  width: 100%;
  padding: 7px 0;
  border: none;
  border-radius: 12px;
  background: #eaf5e0;
  color: #3f7a2c;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.sell-eat span { color: #6a8f52; font-weight: 700; }
.sell-eat:active { transform: translateY(1px); }


/* 食用按钮：与出售同款，只是图标换成体力 */
.sell-go.eat { margin-top: 6px; }

.sell-go i.sell-energy {
  display: inline-block;
  width: 13px;
  height: 15px;
  margin: 0 2px 0 6px;
  vertical-align: -2px;
  background: #ffe066;
  border: 2px solid #d9a51f;
  border-radius: 3px 3px 6px 6px;
  clip-path: polygon(58% 0, 20% 52%, 48% 52%, 38% 100%, 82% 44%, 54% 44%);
}


/* ---------------------------------------------------------------- 金币飞行动画 */
.fly-coin {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: 15px;
  font-weight: 900;
  color: #c98a1f;
  text-shadow: 0 1px 0 #fff, 0 0 8px rgba(242, 193, 78, 0.8);
  transition: transform 0.62s cubic-bezier(0.35, 0.85, 0.35, 1), opacity 0.62s ease-in;
}

.fly-coin.energy { color: #3f8a2c; text-shadow: 0 1px 0 #fff, 0 0 8px rgba(143, 196, 106, 0.85); }

/* 余额数字被"加钱"时轻微跳动 */
@keyframes coin-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); color: #c98a1f; }
  100% { transform: scale(1); }
}

#stat-coins.bump, #stat-energy.bump {
  display: inline-block;
  animation: coin-bump 0.42s ease-out;
}


/* 背包：固定 2 行 × 5 列 */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  justify-items: stretch;
}

.bag-grid .bag-slot { width: 100%; }

.bag-slot.empty {
  border: 1.5px dashed rgba(120, 96, 70, 0.28);
  background: rgba(255, 253, 246, 0.5);
  box-shadow: none;
  cursor: default;
}

@media (max-width: 640px) {
  .bag-grid { gap: 6px; }
}


/* 不可堆叠物品（机器）：只显示图标，不显示数量选择 */
.sell-row.solo { justify-content: center; gap: 0; }


/* 背包第一行：快捷栏 */
.bag-hotbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1.5px dashed rgba(120, 96, 70, 0.22);
}

.bag-hotbar .slot {
  position: relative;
  width: 100%;
  height: 74px;
  border-radius: 14px;
  border: 2px solid rgba(120, 96, 70, 0.22);
  background: #fffdf6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: grab;
}

.bag-hotbar .slot.on { border-color: #4b3a2c; box-shadow: 0 0 0 2px rgba(75, 58, 44, 0.12); }
.bag-hotbar .slot svg { width: 30px; height: 30px; }
.bag-hotbar .slot .nm { font-size: 11px; font-weight: 800; color: #6a5a45; }
.bag-hotbar .slot .key {
  position: absolute; top: 3px; left: 5px;
  font-size: 10px; color: #a89e8b; font-weight: 700;
}
/* 快捷栏里的数量：和背包格子同一套样式（格子底部 ×N），
   这里空间小，就不压名字，直接排成一行小药丸 */
.bag-hotbar .slot .cnt {
  position: static;
  margin-top: 1px;
  padding: 0 6px;
  border-radius: 7px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(120, 96, 70, 0.18);
  font-size: 10.5px;
  font-weight: 900;
  color: #6a4b2c;
  line-height: 1.55;
}

/* 有数量时把内容整体上移一点，给底部的 ×N 腾位置 */
.bag-hotbar .slot.has-n {
  padding-bottom: 6px;
}

/* 拖拽：被拖的格子淡出、落点高亮、跟着指针的残影 */
.slot.dragging,
.bag-slot.dragging { opacity: 0.32; }

.slot.drag-over,
.bag-slot.drag-over {
  outline: 3px dashed #f2c14e;
  outline-offset: -3px;
  background: #fff8e2;
}

body.slot-dragging { cursor: grabbing; }
body.slot-dragging * { cursor: grabbing !important; }

body .slot-ghost {
  position: fixed;
  z-index: 9999;
  margin: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.06);
  opacity: 0.94;
  filter: drop-shadow(0 8px 14px rgba(60, 40, 20, 0.28));
}
