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

/* ---------------------------------------------------------------- 金币 */

.coins {
  position: absolute;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px 6px 12px;
  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;
  z-index: 5;
}

.coins svg {
  width: 20px;
  height: 20px;
}

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

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

.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;
  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;
}

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

.slot .cnt {
  position: absolute;
  top: 1px;
  right: 3px;
  min-width: 14px;
  padding: 0 3px;
  border-radius: 6px;
  background: #eef3e2;
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 800;
  line-height: 13px;
}

.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;
}

/* 体力：用按钮外圈的那道环表示，满了就是一圈绿 */
.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;
  }
}
