:root {
  --panel-bg: rgba(18, 22, 32, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #7ecb4f;
  --text: #e8eef4;
  --muted: #9aa7b5;
  --slot: rgba(0, 0, 0, 0.45);
  --slot-active: rgba(126, 203, 79, 0.28);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e1f;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  /* 抑制浏览器原生手势：滚动链 / 橡皮筋 / 触控手势导致的页面跳动 */
  overscroll-behavior: none;
  touch-action: none;
}

/* 禁止图片被拖拽 */
img {
  -webkit-user-drag: none;
  user-drag: none;
}

/* 输入框保留文本选择能力 */
input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

#app,
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
}
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
#crosshair::before {
  left: 10px;
  top: 0;
  width: 2px;
  height: 22px;
}
#crosshair::after {
  left: 0;
  top: 10px;
  width: 22px;
  height: 2px;
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  pointer-events: auto;
}

.hotbar-slot {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 7px;
  background: var(--slot);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.08s, background 0.08s;
}
.hotbar-slot:hover {
  border-color: rgba(255, 255, 255, 0.35);
}
.hotbar-slot.active {
  border-color: var(--accent);
  background: var(--slot-active);
}
.hotbar-slot img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  pointer-events: none;
}
.hotbar-slot .num {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
}
.hotbar-slot .name {
  font-size: 10px;
  color: #d7dfe8;
  line-height: 1;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

#info-panel {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 13px;
  line-height: 1.7;
  background: rgba(0, 0, 0, 0.32);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
}
#info-panel .k {
  color: var(--muted);
  margin-right: 8px;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  white-space: nowrap;
}

#toast {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font-size: 15px;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 20, 40, 0.82), rgba(5, 8, 16, 0.94));
  z-index: 20;
}

.panel {
  width: min(420px, 92vw);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 28px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 88vh;
  overflow-y: auto;
}

h1 {
  font-size: 34px;
  letter-spacing: 2px;
  text-align: center;
  color: #fff;
}
h1::before {
  content: "⛏ ";
}
h2 {
  text-align: center;
  font-size: 22px;
}
.subtitle {
  text-align: center;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  color: var(--muted);
}
.field input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.range-hint {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.btn {
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c1a06;
  font-weight: 600;
}
.btn.primary:hover {
  background: #93d96b;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-style: dashed;
}

.saves {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.save-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}
.save-item .meta {
  color: var(--muted);
  font-size: 11px;
}
.save-item .btn {
  padding: 6px 10px;
  font-size: 13px;
}

.tip {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}

/* ---------- 启动错误提示 ---------- */
#boot-error {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: min(92vw, 640px);
  background: rgba(120, 28, 28, 0.94);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.7;
  z-index: 100;
  display: none;
  white-space: pre-wrap;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- Loading ---------- */
.bar {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
#loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7ecb4f, #a6e27a);
  transition: width 0.12s;
}
#loading-text {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
