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

:root {
  --gold: #caa45a;
  --panel: rgba(13, 17, 12, 0.86);
  --panel-border: rgba(202, 164, 90, 0.35);
  --text: #f4efe2;
  --muted: #a89f8c;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0c0f0b;
  color: var(--text);
  user-select: none;
}

#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

/* --- Overlays ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12, 15, 11, 0.55), rgba(8, 10, 8, 0.92));
  z-index: 40;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

.panel h1 {
  font-size: 30px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.loading-panel { width: 380px; text-align: center; }
.loading-panel p { color: var(--muted); margin: 14px 0; }
.load-bar {
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
#loadProgress {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #8a6f38, var(--gold));
  transition: width 0.2s;
}

/* --- Login --------------------------------------------------------------- */
.login-panel { width: min(620px, 92vw); max-height: 90vh; overflow-y: auto; }
.login-panel .subtitle { color: var(--muted); margin-bottom: 18px; }
.login-panel label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login-panel input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}
.login-panel h3 { color: var(--gold); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 8px; }

.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.choices button:hover { border-color: var(--gold); }
.choices button.selected { background: var(--gold); color: #17130a; border-color: var(--gold); font-weight: 600; }
.choices button.preferred:not(.selected) { border-color: rgba(202, 164, 90, 0.55); }
.choice-info { color: var(--muted); font-size: 13px; min-height: 34px; margin-top: 8px; }

#enter {
  margin-top: 18px;
  width: 100%;
  padding: 13px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #17130a;
  background: linear-gradient(180deg, #dcb86d, #a9822f);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#enter:hover { filter: brightness(1.1); }

/* --- Frames -------------------------------------------------------------- */
.frame {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 230px;
  z-index: 10;
}
#playerFrame { top: 14px; left: 14px; }
#targetFrame { top: 14px; left: 270px; }
#playerName, #targetName { font-weight: 700; font-size: 15px; }
.meta { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }

.bar {
  position: relative;
  height: 16px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  margin-top: 5px;
}
.bar div { height: 100%; width: 100%; transition: width 0.18s; }
.bar.hp div { background: linear-gradient(180deg, #6fbc8a, #3f7d57); }
.bar.xp div { background: linear-gradient(180deg, #7a9fd6, #46618f); }
.bar span {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

#zoneBadge {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--gold);
  z-index: 10;
}
#zoneBadge.pvp { color: #e07a6a; border-color: rgba(224, 122, 106, 0.5); }

#connection {
  position: fixed;
  top: 166px;
  right: 14px;
  font-size: 11px;
  color: #c05a4a;
  z-index: 10;
}
#connection.online { color: #5fa97a; }

#minimap {
  position: fixed;
  top: 14px;
  right: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  z-index: 10;
}

/* --- Side panels ---------------------------------------------------------- */
.side-panel {
  position: fixed;
  right: 14px;
  width: 250px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  z-index: 10;
  max-height: 34vh;
  overflow-y: auto;
}
#questPanel { top: 190px; }
#inventoryPanel { top: calc(190px + 36vh); }
.side-panel h3 {
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.quest {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.quest.ready { border-color: var(--gold); }
.quest-title { font-weight: 700; font-size: 13px; }
.quest-giver { color: var(--muted); font-size: 11px; margin: 2px 0 4px; }
.quest-text { color: var(--muted); margin-bottom: 6px; }
.quest-progress { color: var(--gold); margin-bottom: 4px; }
.quest button {
  width: 100%;
  padding: 5px;
  border-radius: 5px;
  border: 1px solid var(--panel-border);
  background: rgba(202, 164, 90, 0.15);
  color: var(--gold);
  cursor: pointer;
  font-size: 12px;
}
.quest button:hover { background: rgba(202, 164, 90, 0.3); }

.inv-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.rarity-rare { color: #7a9fd6; }
.rarity-epic { color: #b07ad6; }
.rarity-legendary { color: #e0a75a; }

/* --- Skillbar -------------------------------------------------------------- */
#skillbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}
.skill {
  position: relative;
  width: 86px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  font-size: 11px;
}
.skill:hover:not(:disabled) { border-color: var(--gold); }
.skill:disabled { cursor: default; filter: grayscale(0.4) brightness(0.8); }
.skill .key {
  position: absolute;
  top: 3px;
  left: 6px;
  color: var(--gold);
  font-weight: 700;
  font-size: 12px;
}
.skill .skill-name {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skill .cd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(0, 0, 0, 0.72);
  color: var(--gold);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Log ------------------------------------------------------------------- */
#logPanel {
  position: fixed;
  bottom: 16px;
  left: 14px;
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  z-index: 10;
}
#logTabs { display: flex; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
#logTabs button {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
#logTabs button.active { color: var(--gold); }
.log {
  display: none;
  height: 120px;
  overflow-y: auto;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #d9d2c0;
}
.log.active { display: block; }
#chatForm { border-top: 1px solid rgba(255, 255, 255, 0.08); }
#chatInput {
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

/* --- Death ------------------------------------------------------------------ */
.death-panel { text-align: center; }
.death-panel h2 { color: #e07a6a; margin-bottom: 8px; }
.death-panel p { color: var(--muted); }

/* --- Scrollbars -------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(202, 164, 90, 0.3); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .side-panel { width: 200px; }
  #logPanel { width: 300px; }
}
