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

:root {
  --bg: #10141c;
  --panel: #1a2130;
  --panel2: #222b3f;
  --text: #e8ecf4;
  --muted: #8b96ab;
  --accent: #4da3ff;
  --accent2: #2ecc71;
  --danger: #e74c3c;
  --radius: 12px;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.15); }
button:active { transform: scale(.97); }
button.secondary { background: var(--panel2); color: var(--text); }
button.danger { background: var(--danger); }
button:disabled { opacity: .45; cursor: default; }

input, select {
  font-family: inherit;
  background: #131926;
  color: var(--text);
  border: 1px solid #303c55;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

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

/* ---------------- menu overlay ---------------- */
#menu {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 50% 30%, #1c2740 0%, var(--bg) 70%);
  z-index: 20;
}
#menu.hidden, .hidden { display: none !important; }

.menu-card {
  width: 420px; max-width: 94vw;
  background: var(--panel);
  border: 1px solid #2c3852;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.menu-card h1 {
  font-size: 42px; text-align: center; letter-spacing: 2px;
  background: linear-gradient(90deg, #4da3ff, #2ecc71);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 4px;
}
.menu-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.menu-card .motd {
  text-align: center; font-size: 13px; color: #ffd166;
  margin-bottom: 12px; white-space: pre-wrap;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.account-bar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
  background: var(--panel2); border-radius: 8px; padding: 8px 12px;
}
.account-bar b { color: var(--text); }
.account-bar a { color: var(--accent); cursor: pointer; text-decoration: none; }

.error-msg { color: #ff7b6b; font-size: 13px; min-height: 17px; }
.ok-msg { color: var(--accent2); font-size: 13px; min-height: 17px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button {
  flex: 1; background: var(--panel2); color: var(--muted); font-size: 14px; padding: 8px;
}
.tabs button.active { background: var(--accent); color: #fff; }

/* skins */
#skinGrid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 6px 0 2px;
}
.skin-tile {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel2); cursor: pointer; position: relative;
}
.skin-tile.selected { border-color: var(--accent); }
.skin-tile.locked { opacity: .38; cursor: default; }
.skin-tile canvas { width: 80%; height: 80%; }
.skin-tile .lock {
  position: absolute; bottom: 2px; right: 4px; font-size: 10px; color: var(--muted);
}
.skin-name { font-size: 12px; color: var(--muted); text-align: center; min-height: 15px; }

/* ---------------- HUD ---------------- */
.hud { position: fixed; z-index: 10; pointer-events: none; user-select: none; }

#hudTop {
  top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bar-wrap {
  width: 340px; height: 16px; background: rgba(0,0,0,.5);
  border-radius: 9px; overflow: hidden; border: 1px solid rgba(255,255,255,.12);
}
.bar-wrap.xp { height: 10px; width: 300px; }
.bar-fill { height: 100%; width: 50%; transition: width .2s; }
#hpFill { background: linear-gradient(90deg, #2ecc71, #a3e635); }
#xpFill { background: linear-gradient(90deg, #4da3ff, #9b59b6); }
#hudStats { font-size: 13px; color: #cfd8ea; text-shadow: 0 1px 3px #000; }

#leaderboard {
  top: 10px; right: 10px; width: 220px;
  background: rgba(10,14,22,.72); border-radius: 10px; padding: 10px 12px;
  font-size: 13px; border: 1px solid rgba(255,255,255,.08);
}
#leaderboard h3 { font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: 1px; }
#leaderboard .lb-row { display: flex; justify-content: space-between; padding: 1px 0; }
#leaderboard .lb-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
#leaderboard .lb-row.me { color: #ffd166; font-weight: 700; }

#minimapWrap {
  bottom: 10px; right: 10px;
  background: rgba(10,14,22,.72); border-radius: 10px; padding: 6px;
  border: 1px solid rgba(255,255,255,.08);
}
#minimap { display: block; border-radius: 6px; }

#upgradePanel {
  display: flex; gap: 8px; pointer-events: auto; justify-content: center;
  flex-wrap: wrap; max-width: 92vw;
}
.up-btn {
  background: rgba(10,14,22,.8); border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; padding: 7px 8px; font-size: 11.5px; color: var(--text);
  text-align: center; min-width: 76px;
}
.up-btn b { display: block; font-size: 11px; color: var(--muted); }
.up-btn .lvl-pips { color: var(--accent); font-size: 10px; letter-spacing: 1px; }
.up-btn.can { border-color: var(--accent2); box-shadow: 0 0 12px rgba(46,204,113,.35); cursor: pointer; }
#upgradeHint { font-size: 12px; color: #ffd166; text-align: center; margin-bottom: 4px; text-shadow: 0 1px 3px #000; }

#hudLeft { bottom: 12px; left: 12px; font-size: 12px; color: #cfd8ea; text-shadow: 0 1px 3px #000; }
#hudLeft .cd { color: var(--muted); }
#hudLeft .ready { color: var(--accent2); }

#buffBar { top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.buff {
  background: rgba(10,14,22,.8); border-radius: 8px; padding: 3px 8px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.15);
}

#killMsg {
  top: 30%; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 800; color: #ffd166; text-shadow: 0 2px 8px #000;
  opacity: 0; transition: opacity .3s;
}

/* death screen */
#deathScreen {
  position: fixed; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,9,14,.78);
}
#deathScreen .menu-card { text-align: center; }
#deathScreen h2 { color: var(--danger); font-size: 30px; margin-bottom: 12px; }
#deathStats { font-size: 15px; color: var(--muted); margin-bottom: 18px; line-height: 1.7; }
#deathStats b { color: var(--text); }

/* spectator */
#specBar {
  top: 10px; left: 10px; display: flex; gap: 8px; align-items: center; pointer-events: auto;
  background: rgba(10,14,22,.72); border-radius: 10px; padding: 8px 12px; font-size: 13px;
  border: 1px solid rgba(255,255,255,.08);
}

.ability-card {
  flex: 1; background: var(--panel2); border: 2px solid #303c55; border-radius: 12px;
  padding: 16px 12px; cursor: pointer; font-size: 12.5px; color: var(--muted);
  transition: border-color .15s, transform .1s;
}
.ability-card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--text); }
.ability-card b { display: block; color: var(--text); margin: 6px 0 4px; font-size: 15px; }
.ability-card .ability-icon { font-size: 30px; }

#connStatus {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,9,14,.85); font-size: 18px; color: var(--muted);
}
