:root {
  --bg: #0b0e14;
  --bg2: #11151f;
  --panel: rgba(17, 21, 31, 0.94);
  --border: #2a3350;
  --gold: #e8c86a;
  --gold2: #b08d3c;
  --text: #d8dbe6;
  --text-dim: #8b91a5;
  --green: #58c16a;
  --red: #d45757;
  --blue: #5b8fe0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- Экраны ---------- */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #131a2a 0%, var(--bg) 70%);
  z-index: 30; text-align: center; gap: 14px; padding: 20px;
}
.game-title {
  font-size: 72px; font-weight: 800; letter-spacing: 6px;
  background: linear-gradient(180deg, #f6e27a, var(--gold) 45%, #8a6a22);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(232, 200, 106, 0.25);
  margin-top: -40px;
}
.subtitle { font-size: 20px; letter-spacing: 12px; color: var(--text-dim); text-transform: uppercase; }
#menutree { position: absolute; inset: 0; opacity: 0.18; pointer-events: none; z-index: -1; }

.btn {
  min-width: 260px; padding: 12px 24px; font-size: 17px; cursor: pointer;
  background: rgba(255,255,255,0.04); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; transition: all .15s; font-family: inherit;
}
.btn:hover { background: rgba(255,255,255,0.09); border-color: #3d4a75; transform: translateY(-1px); }
.btn-gold {
  background: linear-gradient(180deg, #f0d37e, var(--gold)); color: #2a2008; border: none; font-weight: 700;
  box-shadow: 0 4px 18px rgba(232,200,106,0.25);
}
.btn-gold:hover { box-shadow: 0 6px 26px rgba(232,200,106,0.4); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; z-index: 2; margin-top: 10px; }
.meta-line { color: var(--gold); font-size: 15px; z-index: 2; }
#joinbox { display: flex; flex-direction: column; gap: 8px; z-index: 2; width: 300px; margin-top: 6px; }
#joinbox input { padding: 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); font-size: 14px; }
#net-status { color: var(--text-dim); font-size: 13px; z-index: 2; min-height: 18px; }

.death-title { font-size: 40px; color: var(--red); letter-spacing: 2px; }
#death-stats { font-size: 16px; color: var(--text-dim); line-height: 1.7; }
#death-loot { font-size: 15px; color: var(--gold); line-height: 1.6; max-width: 500px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hpbar, #xpbar { position: absolute; left: 50%; transform: translateX(-50%); width: 340px; height: 20px; background: rgba(0,0,0,0.55); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
#hpbar { top: 14px; }
#xpbar { top: 38px; width: 220px; height: 9px; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(180deg, #e06a6a, #a63a3a); transition: width .12s; }
#xpfill { height: 100%; width: 0%; background: linear-gradient(180deg, #7fa8f0, #3f6bc0); transition: width .2s; }
#hpbar span, #xpbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; text-shadow: 0 1px 2px #000; }
#gold { position: absolute; top: 14px; right: 16px; font-size: 18px; color: var(--gold); background: rgba(0,0,0,0.5); padding: 6px 12px; border-radius: 8px; }
#waveinfo { position: absolute; top: 14px; left: 16px; font-size: 15px; background: rgba(0,0,0,0.5); padding: 6px 12px; border-radius: 8px; color: var(--text-dim); }
#floorinfo { position: absolute; top: 52px; left: 16px; font-size: 13px; color: var(--gold2); }
#petbar { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.pet-chip { width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--border); background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; font-size: 24px; position: relative; }
.pet-chip .cd { position: absolute; inset: 0; border-radius: 8px; background: rgba(0,0,0,0.6); }
.pet-chip .cd.fill { background: rgba(0,0,0,0); }
#keyshelp { position: absolute; bottom: 10px; left: 10px; font-size: 12px; color: rgba(255,255,255,0.35); }
#minimap { position: absolute; bottom: 10px; right: 10px; width: 130px; height: 130px; border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,0.4); }

#banner {
  position: absolute; top: 26%; left: 50%; transform: translate(-50%, -50%);
  font-size: 42px; letter-spacing: 3px; color: var(--gold); text-shadow: 0 0 30px rgba(232,200,106,0.5);
  animation: bannerIn .4s ease-out;
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -30%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ---------- Панели ---------- */
.panel {
  position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 17px; color: var(--gold); }
.btn-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }
.btn-close:hover { color: var(--text); }

#inv-panel { right: 24px; top: 80px; width: 420px; max-height: 80vh; }
#inv-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 14px; }
.inv-slot {
  aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,0.03);
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; font-size: 26px;
}
.inv-slot:hover { border-color: var(--gold); }
.inv-slot .slot-name { position: absolute; bottom: 2px; font-size: 8px; color: var(--text-dim); text-align: center; line-height: 1; padding: 0 2px; overflow: hidden; max-width: 100%; }
.inv-slot.equipped { box-shadow: inset 0 0 0 2px rgba(232,200,106,0.6); }
.slot-type { font-size: 10px; position: absolute; top: 2px; left: 4px; color: var(--text-dim); }

.rarity-common { border-color: #7a808f; }
.rarity-uncommon { border-color: #5fbf6f; }
.rarity-rare { border-color: #4f8ef0; }
.rarity-epic { border-color: #b45ae8; }
.rarity-legendary { border-color: #e8a23c; }
.rarity-mythic { border-color: #ff5a5a; box-shadow: 0 0 14px rgba(255,90,90,0.5); }

.tooltip {
  position: fixed; z-index: 60; background: rgba(10, 12, 18, 0.97); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; max-width: 300px; pointer-events: none; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.tooltip .tt-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-type { color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }

/* ---------- Дерево ---------- */
.tree-panel { inset: 40px; }
#tree-canvas-wrap { flex: 1; overflow: hidden; position: relative; }
#tree-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#tree-points { color: var(--green); }

/* ---------- Сеть ---------- */
#net-box { position: fixed; left: 16px; bottom: 16px; z-index: 20; pointer-events: none; }
#net-players { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-dim); }
.net-player { background: rgba(0,0,0,0.5); padding: 4px 10px; border-radius: 6px; }

/* ---------- Тосты ---------- */
#toast {
  position: fixed; top: 90px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(10,12,18,0.9); border: 1px solid var(--gold); color: var(--gold);
  padding: 10px 22px; border-radius: 10px; font-size: 15px; transition: opacity .3s;
}

/* ---------- Ковчег ---------- */
#meta-perks { display: flex; flex-direction: column; gap: 10px; width: 560px; max-height: 40vh; overflow-y: auto; }
.perk {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: rgba(255,255,255,0.03); text-align: left;
}
.perk .pk-name { font-weight: 700; color: var(--gold); }
.perk .pk-desc { color: var(--text-dim); font-size: 13px; }
.perk .pk-cost { color: #b45ae8; font-weight: 700; white-space: nowrap; }
.perk .pk-rank { color: var(--text-dim); font-size: 12px; }
#meta-species { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; }
.sp-badge { padding: 5px 10px; border-radius: 20px; border: 1px solid var(--border); font-size: 13px; background: rgba(255,255,255,0.03); }
.sp-badge.locked { opacity: 0.35; filter: grayscale(1); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
