/* ============================================================
   生存战争 · 界面样式
   ============================================================ */

:root {
  --slot: 46px;
  --panel-bg: rgba(18, 18, 22, 0.94);
  --panel-border: #5c5c66;
  --slot-bg: rgba(139, 139, 148, 0.42);
  --slot-border: #3a3a42;
  --text: #e8e8ec;
  --text-dim: #a0a0aa;
  --accent: #7fc45a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0d14;
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

img { image-rendering: pixelated; -ms-interpolation-mode: nearest-neighbor; }

/* ---------------- HUD ---------------- */

.hud { position: absolute; inset: 0; pointer-events: none; }

.crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  mix-blend-mode: exclusion;
}
.crosshair::before, .crosshair::after {
  content: '';
  position: absolute;
  background: #fff;
}
.crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }

.damage-flash {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(180, 20, 12, 0.05) 30%, rgba(190, 24, 16, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.1s linear;
}

.water-overlay {
  position: absolute; inset: 0;
  background: rgba(28, 90, 150, 0.34);
  opacity: 0;
  transition: opacity 0.22s ease;
}

/* 生命 / 饥饿 / 氧气 */
.bars {
  position: absolute;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  width: 420px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.icon-row { display: flex; gap: 1px; }
.icon-row.hunger { justify-content: flex-end; margin-top: -22px; }
.icon-row.air { justify-content: flex-end; }
.icon { width: 20px; height: 20px; }
.icon.beat { animation: beat 0.5s ease-in-out infinite; }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

/* 快捷栏 */
.hotbar {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(10, 10, 14, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.6);
  border-radius: 4px;
}

.slot {
  position: relative;
  width: var(--slot); height: var(--slot);
  background: var(--slot-bg);
  border: 2px solid var(--slot-border);
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.slot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55), inset 0 0 12px rgba(255, 255, 255, 0.18);
  transform: scale(1.06);
}
.slot-icon { width: 78%; height: 78%; pointer-events: none; }
.slot-count {
  position: absolute; right: 3px; bottom: 1px;
  font-size: 13px; font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}
.slot-key {
  position: absolute; left: 3px; top: 1px;
  font-size: 10px; color: rgba(255, 255, 255, 0.42);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

.item-name {
  position: absolute;
  left: 50%; bottom: 118px;
  transform: translateX(-50%);
  font-size: 16px;
  text-shadow: 2px 2px 0 #000;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

/* 挖掘进度条 */
.break-bar {
  position: absolute;
  left: 50%; top: calc(50% + 24px);
  transform: translateX(-50%);
  width: 88px; height: 5px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.12s linear;
  overflow: hidden;
}
.break-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #cfcfcf, #fff); }

/* 调试 */
.debug {
  position: absolute;
  left: 8px; top: 8px;
  display: none;
  font-family: Consolas, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e8f0e8;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 10px;
  border-radius: 4px;
  white-space: pre;
  text-shadow: 1px 1px 0 #000;
}

/* 提示条 */
.toasts {
  position: absolute;
  left: 50%; top: 64px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.toast {
  background: rgba(0, 0, 0, 0.62);
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 14px;
  transition: opacity 0.35s ease;
  white-space: nowrap;
}

/* ---------------- 模态界面 ---------------- */

.overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  z-index: 20;
}
.panel-host { display: flex; }

.panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
  max-height: 92vh;
  overflow-y: auto;
}
.panel.narrow { width: 400px; text-align: center; }
.panel h1, .panel h2 { margin-bottom: 14px; font-weight: 600; }
.panel h2 { font-size: 20px; }

.section-title { font-size: 12px; color: var(--text-dim); margin: 10px 0 5px; }

.slot-grid { display: grid; gap: 3px; }
.slot-grid .slot { cursor: pointer; }
.slot-grid .slot:hover { background: rgba(200, 200, 210, 0.55); border-color: #8f8f9a; }
.main-inv { margin-bottom: 10px; }
.hotbar-inv { padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.12); }

.craft-row { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.arrow { font-size: 26px; color: var(--text-dim); padding-bottom: 12px; }
.out-grid .slot { width: 56px; height: 56px; background: rgba(120, 160, 110, 0.35); }

.furnace-row { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.furnace-col { display: flex; flex-direction: column; align-items: center; }

.fire-bar {
  width: 24px; height: 30px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #444;
  display: flex; align-items: flex-end;
  margin-bottom: 6px;
}
.fire-fill { width: 100%; background: linear-gradient(0deg, #f0a020, #ffd868); height: 0%; }

.cook-bar {
  width: 74px; height: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #444;
  margin-bottom: 30px;
}
.cook-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #cfcfcf, #fff); }

.hover-label { min-height: 20px; font-size: 14px; color: var(--accent); margin-top: 8px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 10px; line-height: 1.7; }

.cursor-item {
  position: fixed;
  width: 42px; height: 42px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 40;
}
.cursor-item img { width: 100%; height: 100%; }

/* 按钮 / 表单 */
.btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 11px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #3a3a44;
  border: 2px solid #55555f;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}
.btn:hover { background: #4a4a56; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #4a7a3a; border-color: #6aa254; }
.btn.primary:hover { background: #588f45; }
.btn.danger { background: #6a2f2a; border-color: #8f4038; }
.btn.danger:hover { background: #7d3832; }

.row { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 14px; }
.row span { flex: 0 0 108px; text-align: left; color: var(--text-dim); }
.row input[type="range"] { flex: 1; }
.seed-input {
  flex: 1;
  padding: 8px 10px;
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: #22222a;
  border: 2px solid #44444e;
  border-radius: 4px;
}
.seed-input:focus { outline: none; border-color: var(--accent); }

.stats { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.8; }
.title { font-size: 34px; letter-spacing: 3px; margin-bottom: 2px; }
.subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 22px; letter-spacing: 1px; }
.help { font-size: 12px; color: var(--text-dim); margin-top: 18px; line-height: 1.9; text-align: left; }
.panel.death h2 { color: #e05a4a; font-size: 30px; }

/* ---------------- 加载 ---------------- */

#loading {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: #0d1018;
  z-index: 50;
}
#loading[style*="display: none"] { display: none !important; }
.loading-box { text-align: center; }
.spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: var(--text-dim); }

#nowebgl {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0d1018; z-index: 60;
}
#nowebgl[hidden] { display: none; }
#nowebgl p { font-size: 14px; line-height: 1.8; color: var(--text-dim); text-align: left; }
