* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel: rgba(20, 24, 34, 0.92);
  --accent: #6cc24a;
  --accent-2: #4a9e2f;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #7ec0ee;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- 准星 ---------- */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 20;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  z-index: 30;
  pointer-events: none;
}

.hud-back {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(20, 24, 34, 0.6);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}

.hud-chips { display: flex; gap: 8px; }

.hud-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(20, 24, 34, 0.6);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}
.chip-ico { font-size: 16px; }
#chip-save.saving { color: #ffd35b; }

/* ---------- 物品栏 ---------- */
#hotbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(20, 24, 34, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 30;
  backdrop-filter: blur(4px);
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.slot .swatch {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.22), inset 0 6px 0 rgba(255, 255, 255, 0.18);
}
.slot .name {
  font-size: 10px;
  color: #fff;
  margin-top: 3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.slot .key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
}
.slot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(108, 194, 74, 0.9), 0 4px 14px rgba(0, 0, 0, 0.4);
  transform: translateY(-4px);
}

@media (max-width: 640px) {
  .slot { width: 42px; height: 42px; }
  .slot .swatch { width: 24px; height: 24px; }
  .slot .name { display: none; }
}

/* ---------- 界面 (start / pause) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  background: radial-gradient(circle at 50% 30%, rgba(90, 160, 220, 0.55), rgba(10, 20, 35, 0.85));
  backdrop-filter: blur(3px);
}

.panel {
  width: min(440px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 24px 22px 26px;
  text-align: center;
  color: #eef2f7;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.title-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: 1px;
}

.game-title {
  font-size: 40px;
  margin: 12px 0 6px;
  letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.game-sub {
  color: #b9c4d2;
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.how {
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.how-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  color: #d5dde7;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.how-row:last-child { border-bottom: none; }
.how-row span {
  flex: 0 0 auto;
  min-width: 88px;
  font-weight: 700;
  color: #ffd35b;
  font-size: 13px;
}
.how-row b { color: #fff; }

.big-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 0 #35701f, 0 12px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
  letter-spacing: 2px;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #35701f; }

.over-title { font-size: 26px; margin-bottom: 18px; }

.over-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ghost-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef2f7;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.ghost-btn:active { background: rgba(255, 255, 255, 0.14); }

.mobile-tip {
  margin-top: 14px;
  font-size: 12px;
  color: #8b97a6;
  line-height: 1.5;
}

/* ---------- 魔法方块盒 ---------- */
.craft-panel {
  width: min(560px, 94vw);
  position: relative;
  text-align: center;
}
.craft-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.craft-title { font-size: 24px; margin: 10px 0 6px; }
.craft-sub { color: #b9c4d2; font-size: 14px; line-height: 1.6; margin-bottom: 14px; }
.craft-sub b { color: #ffd35b; }

.craft-search {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
#creative-search {
  flex: 1;
  padding: 13px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  outline: none;
}
#creative-search:focus { border-color: var(--accent); }
#creative-search::placeholder { color: #8b97a6; }
.craft-give {
  width: auto;
  flex: 0 0 auto;
  padding: 13px 22px;
  font-size: 16px;
  letter-spacing: 1px;
  box-shadow: 0 5px 0 #35701f;
}
.craft-give:active { box-shadow: 0 2px 0 #35701f; }

.craft-hint {
  height: 20px;
  font-size: 14px;
  color: #6cc24a;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}
.craft-hint.show { opacity: 1; }

.craft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px;
  margin-bottom: 10px;
}
.citem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  color: #eef2f7;
}
.citem:active { background: rgba(108, 194, 74, 0.25); }
.citem.custom { border-color: rgba(255, 211, 91, 0.5); }
.cswatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.22), inset 0 6px 0 rgba(255, 255, 255, 0.18);
}
.cname { font-size: 12px; }

.touch-btns .tbtn-craft { font-size: 13px; grid-column: span 2; width: auto; height: 56px; border-radius: 22px; }

/* ---------- 触屏控制 ---------- */
#touch {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

#joystick {
  position: absolute;
  left: 22px;
  bottom: 90px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: auto;
}
#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.touch-btns {
  position: absolute;
  right: 18px;
  bottom: 90px;
  display: grid;
  grid-template-columns: repeat(2, 70px);
  gap: 10px;
  pointer-events: none;
}
.tbtn {
  pointer-events: auto;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(20, 24, 34, 0.5);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.tbtn:active { background: rgba(108, 194, 74, 0.7); }
