/* ============================================================
 *  style.css —— 界面与视觉
 * ============================================================ */
:root {
  --ink: #eaf2fa;
  --ink-dim: #9fb2c6;
  --panel: rgba(15, 22, 31, 0.86);
  --panel-2: rgba(24, 33, 45, 0.9);
  --line: rgba(255, 255, 255, 0.11);
  --green: #58c04a;
  --green-2: #3d9b34;
  --danger: #d9534f;
  --sky-top: #6ba8e0;
  --sky-mid: #8ec1e9;
  --sky-bottom: #cfe4f4;
  --radius: 16px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 44%, var(--sky-bottom) 100%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hidden { display: none !important; }
.muted { color: var(--ink-dim); font-size: 13px; line-height: 1.7; margin: 10px 0; }

/* ---------------- 通用面板 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(120, 190, 240, 0.28), transparent 70%),
    rgba(6, 11, 17, 0.62);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 22px;
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.panel.wide { width: min(560px, 100%); }

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 19px;
  letter-spacing: 0.5px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
}

.btn small { font-size: 11px; color: var(--ink-dim); font-weight: normal; }
.btn:hover { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: translateY(1px) scale(0.995); }

.btn.primary {
  background: linear-gradient(180deg, var(--green) 0%, var(--green-2) 100%);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  box-shadow: 0 6px 18px rgba(70, 160, 60, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: #ffb9b6; border-color: rgba(217, 83, 79, 0.35); }
.btn.danger:hover { background: rgba(217, 83, 79, 0.18); }
.btn.small { width: auto; padding: 10px 16px; margin: 0; flex-shrink: 0; font-size: 14px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 10px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------------- 主菜单 ---------------- */
#menu {
  background: linear-gradient(180deg, #4f92d4 0%, #7fb9e6 42%, #b8dcf3 72%, #dcefFA 100%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: hidden;
}

.menu-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 1500px;
  perspective-origin: 50% 45%;
}

.sun {
  position: absolute;
  top: -110px;
  right: 8%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 252, 226, 0.95) 0%, rgba(255, 244, 190, 0.5) 35%, rgba(255, 240, 180, 0) 70%);
  filter: blur(4px);
}

.cloud-b {
  position: absolute;
  height: 46px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(6px);
  box-shadow: 26px 10px 0 -6px rgba(255, 255, 255, 0.6), -30px 12px 0 -10px rgba(255, 255, 255, 0.5);
}
.cl1 { width: 170px; top: 16%; left: -60px; animation: drift 46s linear infinite; }
.cl2 { width: 240px; top: 27%; left: 62%; opacity: 0.8; animation: drift 62s linear infinite reverse; }
.cl3 { width: 130px; top: 9%; left: 38%; opacity: 0.65; animation: drift 54s linear infinite; }

@keyframes drift {
  from { transform: translateX(-30vw); }
  to { transform: translateX(120vw); }
}

.ground-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22vh;
  background: linear-gradient(180deg, rgba(96, 165, 88, 0) 0%, rgba(96, 165, 88, 0.55) 55%, #74b05f 100%);
  clip-path: polygon(0 34%, 12% 22%, 26% 38%, 41% 18%, 58% 34%, 72% 16%, 88% 32%, 100% 20%, 100% 100%, 0 100%);
}

/* CSS 3D 方块 */
.mcube {
  position: absolute;
  width: 64px;
  height: 64px;
  transform-style: preserve-3d;
  transform: rotateX(-22deg) rotateY(30deg);
  animation: bob 6s ease-in-out infinite;
  filter: drop-shadow(0 24px 26px rgba(20, 45, 70, 0.28));
}

.mcube .face {
  position: absolute;
  inset: 0;
  background-size: cover;
  image-rendering: pixelated;
  background-color: #7bb35c;
  outline: 1px solid rgba(0, 0, 0, 0.08);
}
.mcube .front { transform: translateZ(32px); filter: brightness(0.9); }
.mcube .left { transform: rotateY(-90deg) translateZ(32px); filter: brightness(0.62); }
.mcube .top { transform: rotateX(90deg) translateZ(32px); }

.m1 { left: 13%; top: 56%; }
.m2 { right: 14%; top: 22%; width: 44px; height: 44px; animation-delay: -2s; }
.m2 .front { transform: translateZ(22px); }
.m2 .left { transform: rotateY(-90deg) translateZ(22px); }
.m2 .top { transform: rotateX(90deg) translateZ(22px); }
.m3 { right: 20%; bottom: 12%; width: 92px; height: 92px; animation-delay: -4s; }
.m3 .front { transform: translateZ(46px); filter: brightness(0.9); }
.m3 .left { transform: rotateY(-90deg) translateZ(46px); filter: brightness(0.62); }
.m3 .top { transform: rotateX(90deg) translateZ(46px); }

@keyframes bob {
  0%, 100% { transform: rotateX(-22deg) rotateY(30deg) translateY(0); }
  50% { transform: rotateX(-18deg) rotateY(40deg) translateY(-14px); }
}

.menu-wrap {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#menu .brand h1 { text-shadow: 0 2px 0 rgba(31, 70, 110, 0.35), 0 12px 26px rgba(15, 45, 75, 0.3); }
#menu .brand-sub { color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 3px rgba(20, 50, 80, 0.35); }
#menu .menu-foot { color: rgba(255, 255, 255, 0.88); text-shadow: 0 1px 3px rgba(20, 50, 80, 0.3); }

@media (max-width: 760px) {
  .mcube.m1, .mcube.m2 { display: none; }
  .m3 { right: -22px; bottom: 4%; opacity: 0.9; }
}

.brand { text-align: center; position: relative; }

.brand-mark {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
  perspective: 300px;
}

.cube {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-block;
  animation: floaty 3.2s ease-in-out infinite;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.18), inset 3px 3px 0 rgba(255, 255, 255, 0.24);
}

.c1 { background: #6fb851; animation-delay: 0s; }
.c2 { background: #a97b4d; animation-delay: 0.35s; }
.c3 { background: #8d949c; animation-delay: 0.7s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-7px) rotate(4deg); }
}

.brand h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: 2px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.35);
}

.brand h1 .dot { color: var(--green); margin: 0 4px; }

.brand-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.menu-panel { padding: 18px; }

.seed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

.seed-row input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
}

.seed-row input::placeholder { color: rgba(255, 255, 255, 0.28); }

.menu-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.7);
  padding: 0 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.cloud-state.ok { color: #a9e79f; }

/* ---------------- 版权 ---------------- */
.menu-copy {
  width: fit-content;
  margin: 12px auto 0;
  padding: 5px 15px;
  border-radius: 999px;
  background: rgba(14, 30, 46, 0.34);
  backdrop-filter: blur(4px);
  text-align: center;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.copy-line {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: var(--ink-dim);
  user-select: none;
}

/* ---------------- 加载 ---------------- */
.loading-box {
  width: min(360px, 100%);
  text-align: center;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.logo-mini {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 14px;
}
.logo-mini span { color: var(--green); }

.load-text { font-size: 13.5px; color: var(--ink-dim); margin-bottom: 12px; }

.bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6fd35f, #3d9b34);
  transition: width 0.2s ease;
}

.load-tip { margin-top: 12px; font-size: 11.5px; color: rgba(255, 255, 255, 0.45); line-height: 1.6; }

/* ---------------- 存档 ---------------- */
.save-top { display: flex; gap: 10px; margin-bottom: 14px; }

.save-top input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}
.save-top input:focus { border-color: rgba(120, 210, 110, 0.6); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }

.tab {
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 13.5px;
  cursor: pointer;
}
.tab.active { color: #fff; border-bottom-color: var(--green); }

.save-body { min-height: 190px; max-height: 46vh; overflow-y: auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.empty { color: var(--ink-dim); font-size: 13px; text-align: center; padding: 40px 0; }

.save-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.save-item .thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #6fb851, #a97b4d 60%, #8d949c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.save-item .meta { flex: 1; min-width: 0; }
.save-item .meta b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-item .meta span { font-size: 11.5px; color: var(--ink-dim); }

.save-item .acts { display: flex; gap: 6px; flex-shrink: 0; }

.mini-btn {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.16); }
.mini-btn.go { background: rgba(88, 192, 74, 0.9); border-color: transparent; color: #fff; }
.mini-btn.del { color: #ffb3b0; }

.hint-line { font-size: 11.5px; color: var(--ink-dim); margin: 12px 0 0; line-height: 1.6; }

/* ---------------- 设置 ---------------- */
.range-row { display: block; margin: 14px 0; font-size: 13.5px; }
.range-row > span { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-dim); }
.range-row em { color: #fff; font-style: normal; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6fd35f;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.check-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-dim); margin: 16px 0 6px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--green); }

/* ---------------- 操作说明 ---------------- */
.keys { display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.keys > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.keys span { color: var(--ink-dim); margin-left: 6px; }

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 3px 7px;
  text-align: center;
  font-size: 11.5px;
  font-family: var(--font);
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* ---------------- 物品栏 ---------------- */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.inv-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s;
}
.inv-cell:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-2px); }
.inv-cell img { width: 34px; height: 34px; image-rendering: pixelated; border-radius: 4px; }
.inv-cell span { font-size: 11px; color: var(--ink-dim); }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; }

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
}

.badge {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.75);
}

.badge b { color: #fff; font-size: 12.5px; letter-spacing: 0.5px; }

.hud-right { display: flex; align-items: center; gap: 8px; }

#hudFps {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 16, 24, 0.5);
  padding: 6px 9px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.hud-btn {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 16, 24, 0.55);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.hud-btn:hover { background: rgba(30, 42, 58, 0.8); }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  opacity: 0.9;
}
#crosshair::before, #crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
}
#crosshair::before { left: 50%; top: 3px; width: 2px; height: 14px; margin-left: -1px; }
#crosshair::after { top: 50%; left: 3px; height: 2px; width: 14px; margin-top: -1px; }

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100vw;
}

.hud-info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 16, 24, 0.5);
  padding: 4px 10px;
  border-radius: 99px;
  backdrop-filter: blur(4px);
}

.hotbar {
  display: flex;
  gap: 5px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.slot {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.12s;
}

.slot img { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }

.slot .num {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

.slot.blank { opacity: 0.55; }

.slot.active {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.hud-tip {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -8px);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(12, 18, 26, 0.85);
  border: 1px solid var(--line);
  font-size: 13px;
  opacity: 0;
  transition: 0.22s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 触屏 ---------------- */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; }

#joystick {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  touch-action: none;
}

#joystickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.touch-btns {
  position: absolute;
  right: 16px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(2, 62px);
  gap: 10px;
  pointer-events: none;
}

.touch-btns button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 22, 31, 0.55);
  color: #fff;
  font-size: 16px;
  font-family: var(--font);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  touch-action: none;
}
.touch-btns button:active { background: rgba(88, 192, 74, 0.55); }
.touch-btns .big { font-size: 17px; font-weight: 600; }
#tJump { background: rgba(88, 192, 74, 0.35); }

/* 飞行时出现的下降键，浮在按钮组左上方，不占网格 */
#tDown {
  position: absolute;
  right: 82px;
  bottom: 78px;
  width: 54px;
  height: 54px;
  font-size: 15px;
  background: rgba(30, 60, 90, 0.6);
}

/* ---------------- 适配 ---------------- */
@media (max-width: 560px) {
  .slot { width: 38px; height: 38px; border-radius: 7px; }
  .slot img { width: 27px; height: 27px; }
  .hotbar { gap: 3px; padding: 5px; }
  .hud-tip { display: none; }
  .panel { padding: 16px; }
  .brand h1 { letter-spacing: 1px; }
  .menu-copy { font-size: 10.5px; letter-spacing: 0.2px; }
  .copy-line { margin-top: 12px; padding-top: 10px; font-size: 10.5px; }
}

@media (max-width: 430px) {
  .slot { width: 31px; height: 31px; border-radius: 6px; }
  .slot img { width: 22px; height: 22px; }
  .slot .num { display: none; }
  .hotbar { gap: 2px; padding: 4px; }
  /* 窄屏：账号小标签让位给坐标/FPS，避免顶部信息挤成两行 */
  .user-chip { display: none; }
  .badge { max-width: 52vw; gap: 7px; padding: 5px 9px; }
  .badge b { font-size: 11.5px; }
}

/* 触屏设备：把快捷栏抬到摇杆上方，避免遮挡 */
body.touch-mode .hud-bottom { bottom: 152px; }
body.touch-mode .hud-info { display: none; }

@media (max-height: 460px) {
  .hud-bottom { bottom: 6px; }
  .slot { width: 34px; height: 34px; }
  .slot img { width: 24px; height: 24px; }
  #joystick { width: 96px; height: 96px; }
  .touch-btns { grid-template-columns: repeat(2, 52px); }
  .touch-btns button { width: 52px; height: 52px; font-size: 14px; }
}


/* ================= 生存模式 ================= */

/* 模式选择 */
.mode-pick { display: flex; gap: 8px; margin-bottom: 12px; }

.mode-btn {
  flex: 1;
  text-align: left;
  padding: 10px 10px 9px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font);
  transition: 0.15s;
}
.mode-btn b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.mode-btn span { display: block; font-size: 10.5px; line-height: 1.5; color: var(--ink-dim); }
.mode-btn:hover { background: rgba(255, 255, 255, 0.12); }
.mode-btn.active {
  border-color: rgba(111, 211, 95, 0.7);
  background: rgba(88, 192, 74, 0.16);
  box-shadow: inset 0 0 0 1px rgba(111, 211, 95, 0.35);
}
.mode-btn.active b { color: #d9f7cf; }

/* 血量 / 饱食度 */
.stats {
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  pointer-events: none;
}
.hearts, .hunger { display: flex; gap: 2px; }
.hearts img, .hunger img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

/* 受伤红屏 */
#damage {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(160, 0, 0, 0) 30%, rgba(150, 8, 8, 0.62) 100%);
  transition: opacity 0.18s ease;
}

/* 死亡 */
.death-panel { border-color: rgba(217, 83, 79, 0.5); }
.death-title { color: #ff8b85; font-size: 22px; letter-spacing: 2px; }

/* 背包 */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 6px;
}
.bag-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.12s;
}
.bag-cell:hover { background: rgba(255, 255, 255, 0.12); }
.bag-cell img { width: 74%; height: 74%; image-rendering: pixelated; object-fit: contain; }
.bag-cell .cnt {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}
.bag-cell.sel { border-color: #fff; background: rgba(255, 255, 255, 0.2); }
.bag-cell.empty { cursor: default; }
.bag-cell.empty:hover { background: rgba(255, 255, 255, 0.05); }

.inv-head {
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

/* 快捷栏数量角标 */
.slot .cnt {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}
.slot .num { left: 3px; right: auto; }

@media (max-width: 560px) {
  .bag-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .hearts img, .hunger img { width: 16px; height: 16px; }
  .hearts, .hunger { gap: 0; }
  .stats { padding: 0 2px; }
}

/* ================= 账号 / 登录 ================= */
.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 22px 18px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.auth-head { text-align: center; margin-bottom: 16px; }
.auth-logo { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.auth-logo .cube { width: 22px; height: 22px; }
.auth-head h1 { margin: 0; font-size: 21px; letter-spacing: 1px; }
.auth-head p { margin: 6px 0 0; font-size: 12px; color: var(--ink-dim); line-height: 1.6; }

.auth-tabs {
  display: flex; gap: 6px; padding: 4px;
  background: rgba(0, 0, 0, 0.26); border-radius: 11px; margin-bottom: 14px;
}
.auth-tab {
  flex: 1; padding: 9px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim);
  font-family: var(--font); font-size: 13px; cursor: pointer; transition: 0.15s;
}
.auth-tab.active { background: rgba(255, 255, 255, 0.1); color: #fff; }

.auth-field { display: block; margin-bottom: 12px; }
.auth-field > span { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; }
.auth-field input {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.28);
  color: var(--ink); font-family: var(--font); font-size: 14px; outline: none;
}
.auth-field input:focus { border-color: rgba(111, 211, 95, 0.65); }
.auth-err { min-height: 18px; font-size: 12.5px; color: #ffb3ae; margin: 2px 0 6px; }
.auth-guest {
  width: 100%; margin-top: 10px; padding: 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-dim); font-family: var(--font);
  font-size: 12.5px; text-decoration: underline; cursor: pointer;
}
.auth-guest:hover { color: #fff; }
.auth-note { text-align: center; font-size: 10.5px; color: rgba(255, 255, 255, 0.32); margin: 14px 0 0; }

.user-chip {
  font-size: 11.5px; color: #dff0ff;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 8px;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.menu-account {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-dim);
}
.link-btn { background: none; border: 0; color: #8fd0ff; font-family: var(--font); font-size: 12px; cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }
.small-line { margin: 6px 0 0 !important; font-size: 12px; }

.acct-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.acct-line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 10px; }
.acct-line b { color: #fff; }
.acct-pw summary { font-size: 12.5px; color: #8fd0ff; cursor: pointer; padding: 4px 0; }
.acct-pw input {
  width: 100%; margin-top: 8px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.28);
  color: var(--ink); font-family: var(--font); font-size: 13px; outline: none;
}
.acct-pw .btn { margin-top: 8px; }
@media (max-width: 560px) {
  .auth-card { padding: 18px 16px 14px; }
}

/* ================= 工作台 / 熔炉 ================= */
.panel.station {
  width: min(680px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
}

.station-tabs { display: flex; gap: 6px; margin: 2px 0 12px; flex-wrap: wrap; }
.ctab {
  padding: 6px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  transition: 0.14s;
}
.ctab:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ctab.active {
  background: rgba(88, 192, 74, 0.18);
  border-color: rgba(111, 211, 95, 0.62);
  color: #e8ffe0;
}

.recipe-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 4px 6px 0;
}

.rc {
  display: grid;
  grid-template-columns: 92px 108px 1fr 76px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  transition: 0.14s;
}
.rc.can { background: rgba(88, 192, 74, 0.09); border-color: rgba(111, 211, 95, 0.34); }
.rc.cant { opacity: 0.62; }

.rc-grid { display: grid; grid-template-columns: repeat(3, 26px); grid-auto-rows: 26px; gap: 2px; }
.rc-cell {
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px; background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.045);
}
.rc-cell img { width: 19px; height: 19px; image-rendering: pixelated; }
.rc-cell.empty { background: rgba(0, 0, 0, 0.06); border-color: transparent; }

.rc-out { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rc-out img { width: 36px; height: 36px; image-rendering: pixelated; flex-shrink: 0; }
.rc-out em { display: block; font-style: normal; font-size: 12.5px; line-height: 1.35; }
.rc-out i { display: block; font-style: normal; font-size: 10.5px; color: var(--ink-dim); }

.rc-need { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: 11.5px; color: var(--ink-dim); min-width: 0; }
.need { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.need img { width: 16px; height: 16px; image-rendering: pixelated; }
.need.lack { color: #ff9f97; }

.rc .mini-btn { width: 100%; padding: 8px 6px; font-size: 12.5px; }

.fuel-bar {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-dim);
  margin: 0 0 10px; padding: 9px 11px;
  border-radius: 10px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line);
}
.fuel-bar b { color: #ffd479; font-size: 14px; }

@media (max-width: 560px) {
  /* 手机：配方卡片改成两行，材料说明占满整行，不会被挤掉 */
  .rc {
    grid-template-columns: 64px 1fr 62px;
    grid-template-areas: "grid out btn" "need need need";
    gap: 6px 8px;
    padding: 8px 10px;
  }
  .rc-grid { grid-area: grid; grid-template-columns: repeat(3, 19px); grid-auto-rows: 19px; }
  .rc-cell img { width: 13px; height: 13px; }
  .rc-out { grid-area: out; }
  .rc-out img { width: 28px; height: 28px; }
  .rc-out em { font-size: 12px; }
  .rc-need { grid-area: need; font-size: 11px; gap: 4px 8px; }
  .rc .mini-btn { grid-area: btn; }
  .panel.station { padding: 16px 14px; }
}

/* 合成 / 冶炼按钮的禁用态 */
.mini-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.55);
}
.mini-btn.go:disabled {
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink-dim);
  border-color: var(--line);
}

/* 配方卡片更紧凑一点，一屏能多放几条 */
.rc { padding: 7px 10px; }
.rc-grid { grid-template-columns: repeat(3, 23px); grid-auto-rows: 23px; }
.rc-cell img { width: 17px; height: 17px; }
.recipe-list::-webkit-scrollbar { width: 8px; }
.recipe-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 8px; }

/* 加载页的「取消」按钮 */
#loadCancel { margin-top: 14px; }

/* 背包里的 2x2 随身合成 */
.hand-box {
  margin: 4px 0 12px;
  padding: 10px 12px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}
.hand-title { font-size: 12.5px; color: var(--ink); margin-bottom: 8px; }
.hand-title span { font-size: 10.5px; color: var(--ink-dim); margin-left: 6px; }
.hand-list { max-height: none; gap: 6px; }
.hand-note { font-size: 11px; color: var(--ink-dim); margin-top: 6px; line-height: 1.6; }
@media (max-width: 560px) {
  .hand-box { padding: 8px 9px 6px; }
}

/* 背包面板内容高，超出屏幕时整体滚动 */
#inventory .panel { max-height: 88vh; overflow-y: auto; }
#inventory .panel::-webkit-scrollbar { width: 8px; }
#inventory .panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 8px; }

/* 挖掘进度条（准星下方） */
#mineBar {
  position: absolute;
  left: 50%;
  top: calc(50% + 20px);
  transform: translateX(-50%);
  width: 80px;
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}
#mineBar.show { opacity: 1; }
#mineBar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7fd35f, #d8e8a4);
  transition: width 0.06s linear;
}

/* ============================================================
 *  模组：极寒生存
 * ============================================================ */

/* 暴风雪白幕：盖在画面上，天色发白 */
#storm {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(180deg, rgba(240, 246, 252, 0.95) 0%, rgba(224, 235, 247, 0.62) 45%, rgba(204, 222, 240, 0.32) 100%);
}

/* 寒冷蓝晕：屏幕四周 */
#cold {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 50%, rgba(64, 128, 214, 0.3) 78%, rgba(14, 62, 150, 0.82) 100%);
  box-shadow: inset 0 0 88px 8px rgba(34, 100, 196, 0.42);
}

/* HUD 角标 */
.mod-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  line-height: 1.5;
  color: #d7ebff;
  background: rgba(96, 160, 226, 0.22);
  border: 1px solid rgba(150, 200, 255, 0.34);
  white-space: nowrap;
}
.mod-chip i { font-style: normal; }
.mod-chip i.ok { color: #ffd08a; }
.mod-chip i.bad { color: #a8d4ff; }
.mod-chip.warm {
  color: #ffe1b0;
  background: rgba(214, 132, 48, 0.26);
  border-color: rgba(255, 186, 108, 0.45);
}
.mod-chip.freezing { animation: chillPulse 2.6s ease-in-out infinite; }
@keyframes chillPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(120, 180, 255, 0); }
  50% { box-shadow: 0 0 12px rgba(130, 190, 255, 0.55); }
}

/* 主菜单：已开启模组提示 */
.mod-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: #a9cdf0;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(96, 160, 226, 0.14);
  border: 1px solid rgba(150, 200, 255, 0.22);
}

/* 模组面板 */
.mod-list { display: grid; gap: 10px; margin: 12px 0 0; }
.mod-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  transition: 0.16s;
}
.mod-card.on {
  background: rgba(90, 162, 232, 0.13);
  border-color: rgba(140, 200, 255, 0.42);
}
.mod-icon {
  width: 46px; height: 46px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: 13px;
  background: rgba(120, 180, 240, 0.16);
  border: 1px solid rgba(160, 210, 255, 0.28);
  color: #cfe9ff;
}
.mod-body { flex: 1; min-width: 0; }
.mod-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-title b { font-size: 14.5px; letter-spacing: 0.3px; }
.mod-tag {
  font-style: normal;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  color: #9fd0f6;
  background: rgba(120, 180, 240, 0.16);
  border: 1px solid rgba(150, 200, 255, 0.24);
}
.mod-tag.ghost { color: var(--ink-dim); background: rgba(255, 255, 255, 0.06); border-color: var(--line); }
.mod-desc { margin: 6px 0 0; font-size: 12.5px; line-height: 1.65; color: var(--ink-dim); }
.mod-tips { margin: 8px 0 0; padding-left: 18px; font-size: 11.5px; line-height: 1.75; color: rgba(200, 218, 235, 0.82); }
.mod-tips li { margin: 2px 0; }
.mod-switch {
  flex-shrink: 0;
  min-width: 72px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-family: var(--font);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: 0.15s;
}
.mod-switch:hover { background: rgba(255, 255, 255, 0.15); }
.mod-switch.on {
  color: #072033;
  background: linear-gradient(180deg, #a9dcff, #6fb6e8);
  border-color: rgba(180, 224, 255, 0.7);
  font-weight: 600;
}

/* 火堆面板 */
.warm-tag { color: #ffbe74; font-size: 12.5px; }
.need.warm { color: #ffbe74; }

@media (max-width: 640px) {
  .badge { flex-wrap: wrap; max-width: 66vw; row-gap: 4px; }
  .mod-card { padding: 12px; gap: 10px; }
  .mod-icon { width: 38px; height: 38px; font-size: 19px; }
  .mod-switch { min-width: 62px; padding: 8px 9px; }
}

.mod-chip .sep {
  width: 1px;
  height: 10px;
  background: currentColor;
  opacity: 0.28;
  display: inline-block;
}

/* ============================================================
 *  工具耐久条（镐子）
 * ============================================================ */
.dura {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 4px;
  height: 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
}
.dura b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7ed957, #4ea83a);
  border-radius: 2px;
  transition: width 0.12s linear;
}
.dura.warn b { background: linear-gradient(90deg, #f0cc55, #d9a02c); }
.dura.low b { background: linear-gradient(90deg, #f07c72, #c93c34); }

.bag-cell .dura { left: 12%; right: 12%; bottom: 6px; height: 3px; }
/* 快捷栏右下角有数量时，耐久条别被压住 */
.slot .dura { bottom: 5px; }

/* 抗寒 buff 角标 */
.mod-chip.buffed {
  color: #ffe7c6;
  background: rgba(212, 128, 42, 0.32);
  border-color: rgba(255, 190, 112, 0.55);
  animation: warmPulse 1.6s ease-in-out infinite;
}
.mod-chip i.buff { color: #ffd28a; font-weight: 600; letter-spacing: 0.2px; }
@keyframes warmPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 170, 80, 0); }
  50% { box-shadow: 0 0 10px rgba(255, 178, 96, 0.5); }
}

/* ============================================================
 *  夜空：星星 + 月亮（在 canvas 之下，被地形遮住）
 * ============================================================ */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background-repeat: repeat;
  background-size: 520px 520px;
  transition: opacity 1.2s linear;
}
body.night-up #stars { opacity: 0.92; }

#moon {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  width: 74px;
  height: 74px;
  margin: -37px 0 0 -37px;
  border-radius: 50%;
  opacity: 0;
  background:
    radial-gradient(circle at 40% 36%, #fffdf6 0%, #f2f5fb 52%, #d6e2f2 78%, #c3d3e8 100%);
  box-shadow:
    0 0 34px 10px rgba(206, 226, 255, 0.34),
    0 0 110px 42px rgba(150, 184, 245, 0.16);
  transition: opacity 1s linear;
}
body.night-up #moon { opacity: 1; }
#moon::before,
#moon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(186, 202, 224, 0.55);
}
#moon::before { width: 15px; height: 15px; left: 24%; top: 30%; }
#moon::after { width: 9px; height: 9px; left: 56%; top: 55%; background: rgba(196, 212, 232, 0.45); }

/* 星星越靠地平线越淡，别在低空显得突兀 */
#stars {
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.35) 74%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.35) 74%, transparent 92%);
}

/* ============================================================
 *  模组：挖矿对战
 * ============================================================ */

/* 大厅 / 结算面板 */
.battle-panel { max-width: 460px; }
.battle-panel .muted { line-height: 1.7; }

.join-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.join-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.26);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
}
.join-row input:focus { outline: none; border-color: rgba(120, 200, 255, 0.6); }
.join-row .btn { width: auto; padding: 12px 20px; margin: 0; flex-shrink: 0; }

.room-code {
  margin: 6px 0 2px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}
.room-code b {
  display: inline-block;
  margin-left: 8px;
  font-size: 30px;
  letter-spacing: 8px;
  color: #b9e3ff;
  text-shadow: 0 0 18px rgba(120, 200, 255, 0.5);
}

.wait-dots { display: flex; gap: 6px; justify-content: center; margin: 6px 0 12px; }
.wait-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7fc4f5;
  animation: waitBlink 1.2s ease-in-out infinite;
}
.wait-dots i:nth-child(2) { animation-delay: 0.18s; }
.wait-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes waitBlink {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.battle-end-title { font-size: 26px; letter-spacing: 1px; margin-bottom: 6px; }
.battle-end-title.win { color: #ffd479; }
.battle-end-title.lose { color: #8fc2e8; }

/* 交易所 */
.shop-bar { align-items: center; }
.shop-gold b { font-size: 17px; color: #ffd479; }
.stab {
  padding: 6px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 12.5px;
  cursor: pointer;
  transition: 0.14s;
}
.stab:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.stab.active {
  background: rgba(226, 176, 74, 0.2);
  border-color: rgba(255, 205, 106, 0.62);
  color: #ffeec4;
}

.shop-cat {
  font-size: 11.5px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  padding: 8px 2px 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.shop-row {
  display: grid;
  grid-template-columns: 36px 1fr auto 88px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
}
.shop-row.can { background: rgba(255, 210, 122, 0.08); border-color: rgba(255, 210, 122, 0.26); }
.shop-row.dim { opacity: 0.66; }
.shop-row > img { width: 34px; height: 34px; image-rendering: pixelated; }
.sr-main { min-width: 0; }
.sr-main em { font-style: normal; font-size: 13px; display: block; }
.sr-main i { font-style: normal; font-size: 11px; color: var(--ink-dim); display: block; line-height: 1.5; }
.sr-main i.muted { color: rgba(255, 210, 122, 0.8); }
.sr-price { font-size: 13.5px; color: #ffd479; white-space: nowrap; }
.shop-row .mini-btn { width: 100%; }

.core-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(120, 170, 230, 0.1);
  border: 1px solid rgba(150, 200, 255, 0.28);
}
.core-card img { width: 52px; height: 52px; image-rendering: pixelated; }

/* 对战 HUD */
#battleHud {
  position: fixed;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.bh-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 92vw;
}
.bh-row > span {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #dbeeff;
  background: rgba(12, 24, 38, 0.62);
  border: 1px solid rgba(150, 200, 255, 0.22);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.bh-gold b { color: #ffd479; }
.bh-core { color: #a8e6ff; }
.bh-core.enemy { color: #ffb3ae; }
.bh-dist { color: rgba(210, 226, 240, 0.8); }
.bh-net {
  font-size: 11px;
  color: #ffcf8a;
  background: rgba(60, 30, 10, 0.6);
  padding: 2px 10px;
  border-radius: 99px;
}

@media (max-width: 640px) {
  #battleHud { top: 62px; }
  .bh-row > span { font-size: 10.5px; padding: 2px 8px; }
  .shop-row { grid-template-columns: 30px 1fr 74px; grid-template-areas: "ico main btn" ". price btn"; gap: 4px 8px; padding: 7px 9px; }
  .shop-row > img { grid-area: ico; width: 28px; height: 28px; }
  .sr-main { grid-area: main; }
  .sr-price { grid-area: price; font-size: 12px; }
  .shop-row .mini-btn { grid-area: btn; }
  .core-card { grid-template-columns: 44px 1fr; }
  .core-card .btn { grid-column: 1 / -1; }
  .join-row input { font-size: 15px; }
  .room-code b { font-size: 24px; }
}

/* ============================================================
 *  挖矿对战 · PvP 血量与复活
 * ============================================================ */
.bh-hp { color: #ffd6cf; }
.bh-hp.enemy { color: #ffb8b2; }
.bh-hp.low {
  color: #ff5c4e;
  font-weight: 600;
  animation: hpLowBlink 1.05s ease-in-out infinite;
}
@keyframes hpLowBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#battleDead {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 44%, rgba(62, 10, 12, 0.72) 0%, rgba(8, 10, 16, 0.94) 78%),
    rgba(4, 6, 10, 0.9);
  backdrop-filter: blur(3px);
  animation: deadIn 0.32s ease-out;
}
#battleDead.hidden { display: none; }
@keyframes deadIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dead-card {
  text-align: center;
  padding: 0 24px;
}
.dead-title {
  font-size: 25px;
  letter-spacing: 4px;
  color: #ff9c8e;
  text-shadow: 0 0 26px rgba(255, 96, 76, 0.45);
}
.dead-count {
  font-size: 76px;
  line-height: 1.06;
  font-weight: 700;
  color: #fff;
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(255, 120, 100, 0.4);
}
.dead-text {
  font-size: 13px;
  color: #efd0ca;
}
.dead-tip {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(226, 182, 176, 0.6);
}

@media (max-width: 640px) {
  .dead-title { font-size: 21px; letter-spacing: 2px; }
  .dead-count { font-size: 62px; }
}

/* ============================================================
 *  神器模组：独立神器栏 + 钻石探测器读数
 * ============================================================ */
.relic-list { display: grid; gap: 10px; margin: 12px 0 14px; }

.relic-card {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  transition: 0.16s;
}
.relic-card.on {
  background: rgba(120, 200, 255, 0.1);
  border-color: rgba(150, 210, 255, 0.38);
}
.relic-icon {
  width: 46px;
  height: 46px;
  image-rendering: pixelated;
  background: rgba(0, 0, 0, 0.26);
  border-radius: 10px;
  padding: 3px;
}
.relic-body { min-width: 0; }
.relic-title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}
.relic-title b { font-size: 14px; letter-spacing: 0.3px; }
.relic-title em { font-style: normal; font-size: 11.5px; }
.relic-how {
  margin: 5px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-dim);
}

.relic-get {
  flex-shrink: 0;
  min-width: 76px;
  padding: 9px 14px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: 0.15s;
}
.relic-get:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.relic-get:disabled {
  cursor: default;
  color: #7fd8bd;
  background: rgba(80, 200, 160, 0.14);
  border-color: rgba(110, 220, 180, 0.34);
}

/* 钻石探测器读数：压在快捷栏上方 */
#relicFinder {
  position: fixed;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  z-index: 7;
  padding: 4px 13px;
  border-radius: 99px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  color: #bdfff5;
  background: rgba(8, 26, 32, 0.72);
  border: 1px solid rgba(92, 230, 216, 0.42);
  box-shadow: 0 0 16px rgba(92, 230, 216, 0.2);
  pointer-events: none;
}
#relicFinder.hidden { display: none; }

@media (max-width: 640px) {
  .relic-card { grid-template-columns: 40px 1fr; gap: 10px; padding: 10px 12px; }
  .relic-icon { width: 38px; height: 38px; }
  .relic-card .relic-get { grid-column: 1 / -1; width: 100%; }
  #relicFinder { bottom: 128px; font-size: 11px; }
}

/* ============================================================
   手机 / 平板 全站适配（后置覆盖，优先级最高）
   —— 目标：任何面板都不越出屏幕、内容可滚动、触控目标够大
   ============================================================ */

.panel { --pp: 22px; padding: var(--pp); }

/* 标题栏吸顶：面板内部滚动时「✕」永远点得到 */
.panel-head {
  position: sticky;
  top: calc(var(--pp) * -1);
  z-index: 6;
  margin: calc(var(--pp) * -1) calc(var(--pp) * -1) 12px;
  padding: var(--pp) var(--pp) 10px;
  background: linear-gradient(180deg, rgba(15, 22, 31, 0.98) 62%, rgba(15, 22, 31, 0.9) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* 弹层：留出安全区，内容比屏高时从顶部对齐并可滚动 */
.overlay {
  padding:
    calc(10px + env(safe-area-inset-top))
    calc(10px + env(safe-area-inset-right))
    calc(10px + env(safe-area-inset-bottom))
    calc(10px + env(safe-area-inset-left));
  align-items: center;
  align-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel,
.auth-card {
  max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 工作站（工作台 / 熔炉 / 火堆）：表头固定，列表自己滚 */
.panel.station {
  max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden;
}
.panel.station .panel-head { position: static; }
.panel.station .recipe-list { flex: 1 1 auto; min-height: 90px; overflow-y: auto; overscroll-behavior: contain; }

/* 主菜单在矮屏 / 横屏：可滚动，品牌区收缩 */
#menu { overflow-y: auto; }
#menu .menu-wrap { margin: auto; padding: 10px 0; }

/* ---------------- 触控设备：点击目标放大 ---------------- */
@media (pointer: coarse), (hover: none) {
  .icon-btn { width: 44px; height: 44px; font-size: 17px; border-radius: 12px; }
  .ctab { min-height: 40px; padding: 9px 14px; font-size: 13px; }
  .stab { min-height: 40px; padding: 9px 12px; }
  .mini-btn { min-height: 40px; padding: 9px 12px; }
  .mod-switch { min-height: 40px; padding: 10px 14px; }
  .rc .mini-btn { min-height: 40px; }
  .btn { padding: 13px 16px; }
  .check-row { min-height: 44px; }
  .range-row input[type="range"] { height: 34px; }
  .seed-row input { min-height: 34px; }
}

/* ---------------- 平板（768 ~ 1180）：留白与字号略放大 ---------------- */
@media (min-width: 700px) {
  .panel { --pp: 24px; }
  .panel.wide { width: min(620px, 100%); }
  .panel.station { width: min(720px, 100%); }
  .panel h2 { font-size: 20px; }
  .hud-tip { font-size: 11.5px; }
}

/* ---------------- 手机：结构重排 ---------------- */
@media (max-width: 700px) {
  /* 配方行：图 + 产物 + 按钮一行，材料另起一行 */
  .rc {
    grid-template-columns: 74px minmax(0, 1fr) 78px;
    grid-template-areas: "grid out btn" "need need btn";
    gap: 8px 10px;
    padding: 9px 10px;
  }
  .rc-grid { grid-area: grid; }
  .rc-out { grid-area: out; }
  .rc-need { grid-area: need; }
  .rc .mini-btn { grid-area: btn; align-self: center; }
  .panel-head { margin-bottom: 10px; }
}

@media (max-width: 560px) {
  .panel { --pp: 16px; }
  .panel { width: 100%; border-radius: 14px; }
  .panel.station { width: 100%; }
  .overlay { padding-left: 8px; padding-right: 8px; }
  .rc { grid-template-columns: 66px minmax(0, 1fr) 70px; gap: 7px 8px; padding: 8px 9px; }
  .rc-grid { grid-template-columns: repeat(3, 22px); grid-auto-rows: 22px; }
  .rc-cell img { width: 17px; height: 17px; }
  .rc-out img { width: 30px; height: 30px; }
  .rc-out em { font-size: 12px; }
  .rc-need { font-size: 11px; }
  .relic-card { grid-template-columns: 38px minmax(0, 1fr); }
  .shop-row { grid-template-columns: 28px minmax(0, 1fr) 70px; }
  .mod-card { gap: 10px; padding: 12px; }
  .mod-icon { width: 38px; height: 38px; font-size: 18px; }
  .keys { font-size: 12.5px; }
  .menu-panel { padding: 14px; }
  .menu-wrap { gap: 12px; }
  .btn-row { gap: 8px; }
}

/* 快捷栏：按屏宽自动收缩，10 格永远塞得下 */
.hotbar { max-width: calc(100vw - 12px); }
@media (max-width: 700px) {
  .hotbar { --sl: clamp(26px, calc((100vw - 34px) / 10), 44px); gap: 2px; padding: 4px; }
  .slot { width: var(--sl); height: var(--sl); border-radius: 6px; }
  .slot img { width: 72%; height: 72%; }
  .slot .num { display: none; }
}
@media (min-width: 701px) {
  .slot { width: 48px; height: 48px; }
  .slot img { width: 34px; height: 34px; }
}

/* HUD 安全区 */
.hud-top { padding-top: calc(12px + env(safe-area-inset-top)); }
.hud-bottom { bottom: calc(6px + env(safe-area-inset-bottom)); }
body.touch-mode .hud-bottom { bottom: calc(150px + env(safe-area-inset-bottom)); }
.touch-btns { right: calc(16px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); }
#joystick { left: calc(18px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom)); }

/* ---------------- 矮屏（横屏手机 / 小窗）：菜单压缩 ---------------- */
@media (max-height: 560px) {
  .panel { --pp: 14px; }
  #menu .menu-wrap { gap: 8px; padding: 8px 0; }
  .brand-mark { display: none; }
  .brand h1 { font-size: 21px; letter-spacing: 1px; }
  #menu .brand-sub { display: none; }
  .menu-panel { padding: 12px; }
  .mode-btn { padding: 8px 9px; }
  .mode-btn span { display: none; }
  .seed-row { padding: 7px 10px; }
  .btn { padding: 10px 12px; margin-top: 7px; font-size: 14px; }
  .menu-foot { display: none; }
  .menu-copy { margin-top: 6px; padding: 3px 10px; }
  .auth-card { padding: 16px 16px 12px; }
  .auth-card h2 { font-size: 18px; }
  .panel h2 { font-size: 17px; }
}

@media (max-height: 430px) {
  body.touch-mode .hud-bottom { bottom: calc(6px + env(safe-area-inset-bottom)); }
  .hotbar { --sl: 32px; }
  .slot img { width: 24px; height: 24px; }
}

/* 内部列表横向绝不溢出（2px 级误差会把面板撑出细滚动条） */
.recipe-list, .shop-list, .mod-list, .relic-list, .keys { overflow-x: hidden; }

@media (pointer: coarse), (hover: none) {
  .check-row input[type="checkbox"] { width: 22px; height: 22px; }
}

/* 快捷栏尺寸统一走变量，任何屏幕都塞得下 10 格 */
.hotbar { --sl: clamp(26px, calc((100vw - 34px) / 10), 48px); }
.slot { width: var(--sl); height: var(--sl); }

/* 横屏手机 / 矮窗口：快捷栏再收一档，别挡住视线 */
@media (max-height: 460px) {
  .hotbar { --sl: clamp(26px, calc((100vh - 150px) / 7), 38px); }
  .slot img { width: 74%; height: 74%; }
  .hud-tip { display: none; }
  .stats { margin-bottom: -2px; }
}

/* 横屏菜单再压一层，保证「开始新世界」以下的关键入口都在首屏 */
@media (max-height: 400px) {
  #menu .menu-wrap { gap: 6px; padding: 6px 0; }
  #menu .brand h1 { font-size: 17px; }
  .menu-panel { padding: 10px; }
  .mode-btn { padding: 6px 8px; font-size: 13px; }
  .seed-row { padding: 5px 8px; font-size: 12px; }
  .btn { padding: 8px 10px; margin-top: 5px; font-size: 13.5px; }
  .btn-row .btn { margin-top: 6px; }
  .menu-foot, .menu-account { display: none; }
  .menu-copy { margin-top: 4px; padding: 2px 9px; font-size: 10px; }
}

/* 触屏「背包」按钮：摆在摇杆和右侧按钮之间，拇指够得到 */
#tBag {
  position: absolute;
  right: calc(172px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 22, 31, 0.55);
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
  pointer-events: auto;
  z-index: 9;
}
#tBag:active { background: rgba(88, 192, 74, 0.55); }

@media (max-height: 460px) {
  #tBag {
    right: calc(150px + env(safe-area-inset-right));
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 48px;
    height: 48px;
  }
}

/* 工作站（工作台/熔炉/火堆）内距统一走 --pp：
   原来这里固定 16px 14px，而标题栏的负外边距按 --pp 算（16px），
   左右各多出 1px，手机上会让面板出现横向滚动条 */
.panel.station { padding: var(--pp); }

/* 背包 40 格改成自适应列数：原来固定 10 列（≤560 固定 7 列），
   竖屏转横屏的那一瞬会按旧列宽排一次，横屏下多出 5 格挤出面板。
   改成 auto-fill 后，容器多宽就排几列，永远不会横向溢出 */
.bag-grid { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }

/* 格子宽度由网格列宽决定（width:100%），避免 aspect-ratio 反过来把列撑宽 */
.bag-cell { width: 100%; min-width: 0; }
