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

:root {
  --bg: #0d1220;
  --card: rgba(15, 21, 38, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --txt: #e9ecef;
  --dim: #868e96;
  --a1: #4dabf7;
  --a2: #38d9a9;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--txt);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#cv { position: fixed; inset: 0; cursor: crosshair; display: block; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.gold { color: #ffd43b; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(8px);
}

#score {
  position: absolute; top: 14px; left: 14px;
  display: flex; gap: 18px; align-items: center;
  padding: 10px 16px;
}
#score .stat label { display: block; font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
#score .stat b { font-size: 21px; }
#score .stat#aliveChip { font-size: 14px; color: #ffa94d; font-weight: 700; align-self: center; }
#mute {
  pointer-events: auto; cursor: pointer;
  background: none; border: none; font-size: 18px; opacity: 0.7;
}
#mute:hover { opacity: 1; }

#lb { position: absolute; top: 14px; right: 14px; width: 190px; padding: 10px 12px; }
#lb h3 { font-size: 12px; letter-spacing: 1px; color: #adb5bd; margin-bottom: 6px; }
#lbList .row {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 2px 4px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#lbList .row .pos { width: 22px; color: var(--dim); font-size: 11px; }
#lbList .row .m { margin-left: auto; color: var(--dim); font-size: 12px; }
#lbList .row.me { background: rgba(255, 212, 59, 0.12); color: #ffd43b; }

#kfeed {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
#kfeed .kfitem {
  background: rgba(13, 18, 32, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 12px;
  font-size: 12.5px; color: #ced4da;
  animation: kfin .2s ease-out;
}
@keyframes kfin { from { opacity: 0; transform: translateY(-6px); } }

#chatlog {
  position: absolute; bottom: 170px; left: 14px;
  display: flex; flex-direction: column; gap: 3px; max-width: 340px;
}
#chatlog .msg {
  background: rgba(13, 18, 32, 0.65);
  border-radius: 8px; padding: 3px 10px;
  font-size: 13px; transition: opacity 3s; width: fit-content;
}
#chatbox {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  width: min(420px, 80vw); padding: 10px 16px;
  background: rgba(13, 18, 32, 0.92); color: var(--txt);
  border: 1px solid var(--a1); border-radius: 12px;
  font-size: 14px; outline: none; pointer-events: auto;
}

#minimap {
  position: absolute; bottom: 14px; left: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

#pwbar {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
#pwbar .pw {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid; border-radius: 10px;
  padding: 5px 10px; font-size: 15px;
}
#pwbar .pw.boost { border-color: #ffd43b; }
#pwbar .pw .bar { width: 70px; height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
#pwbar .pw .bar i { display: block; height: 100%; }
#pwbar .pw b { font-size: 12px; color: #adb5bd; min-width: 24px; text-align: right; }

#banner {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%) scale(0.9);
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  opacity: 0; transition: opacity .3s, transform .3s;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6); white-space: nowrap;
}
#banner.on { opacity: 1; transform: translateX(-50%) scale(1); }
#banner.fire { color: #ffd43b; animation: pulse 0.8s infinite alternate; }
@keyframes pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.07); } }

#roundToast, #toast {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 15px; font-weight: 700;
  background: rgba(13, 18, 32, 0.78); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 16px;
  opacity: 0; transition: opacity .3s; white-space: nowrap;
}
#roundToast { top: 58px; color: #ffd43b; }
#toast { top: 100px; color: #d3f9d8; font-size: 13.5px; z-index: 9; }
#roundToast.on, #toast.on { opacity: 1; }

#hint {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(13, 18, 32, 0.7); border-radius: 10px;
  padding: 8px 16px; font-size: 13px; color: #adb5bd;
  transition: opacity 2s; white-space: nowrap;
}
#hint.fade { opacity: 0; }
#hint b { color: var(--txt); }

#specChip {
  position: absolute; top: 58px; left: 50%; transform: translateX(-50%);
  padding: 8px 14px; font-size: 14px;
  display: flex; gap: 10px; align-items: center; white-space: nowrap;
}
#specChip b { color: #ffd43b; }
#specChip button {
  pointer-events: auto; cursor: pointer;
  background: none; border: 1px solid rgba(255,255,255,0.25);
  color: #adb5bd; border-radius: 8px;
  padding: 3px 12px; font-size: 12px; font-weight: 600;
}
#specChip button:hover { color: #fff; border-color: rgba(255,255,255,0.5); }
#specChip button { min-width: 30px; text-align: center; }

/* ---------- MISIONES ---------- */
#pfMissions { padding: 12px 14px; text-align: left; margin-bottom: 12px; }
#pfMissions h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: #ffd43b; margin-bottom: 10px; }
#pfMisList .mission { margin-bottom: 12px; }
#pfMisList .mission:last-child { margin-bottom: 0; }
#pfMisList .mrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
#pfMisList .mrow b { color: #ffd43b; font-size: 12px; white-space: nowrap; }
#pfMisList .mission.done .mrow span { color: #38d9a9; }
#pfMisList .mbar { height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
#pfMisList .mbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--a1), var(--a2)); transition: width .4s; }

/* ---------- TÁCTIL ---------- */
#joy {
  position: fixed; width: 110px; height: 110px; z-index: 6;
  border: 2px solid rgba(255,255,255,0.25); border-radius: 50%;
  background: rgba(255,255,255,0.05); pointer-events: none;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; background: rgba(255,255,255,0.35);
}
#touchBtns { display: none; }
body.touch #touchBtns {
  display: flex; flex-direction: column; gap: 14px;
  position: fixed; right: 20px; bottom: 90px; z-index: 6;
}
.tbtn {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(13,18,32,0.8); border: 2px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; pointer-events: auto;
}
body.touch #hint { display: none; }

/* ---------- OVERLAYS ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(13,18,32,0.55), rgba(5,8,15,0.9));
}
.panel {
  background: linear-gradient(180deg, rgba(20,27,47,0.97), rgba(15,21,38,0.97));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 40px 24px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  width: 460px; max-width: 94vw;
  max-height: 92vh; overflow-y: auto;
}
.panel.small { width: 360px; padding: 26px 34px; }
.panel.small input { margin-bottom: 10px; }

h1 { font-size: 40px; font-weight: 900; letter-spacing: 2px; margin-top: 14px; }
h1 span {
  background: linear-gradient(90deg, var(--a1), var(--a2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h1.skull { font-size: 52px; }
.sub { color: var(--dim); margin: 4px 0 18px; font-size: 14px; line-height: 1.45; }
.sub b { color: #ff8787; }
.sub.gold b { color: #ffd43b; font-size: 18px; }
.stats { color: #adb5bd; margin-bottom: 10px; font-size: 14px; }
.stats.pos { color: #ffa94d; font-weight: 700; margin-bottom: 18px; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: rgba(13, 18, 32, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 12px;
  text-align: left;
}
#avatar { border-radius: 50%; background: #0d1220; flex-shrink: 0; }
.tb-info { flex: 1; min-width: 0; }
.tb-info b { font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xpbar { height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin: 4px 0 3px; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--a1), var(--a2)); border-radius: 3px; transition: width .4s; }
.xpbar.big { height: 9px; margin-top: 8px; }
#tbLevel { font-size: 11px; }
.tb-coins { font-size: 16px; font-weight: 700; color: #ffd43b; white-space: nowrap; }

/* ---------- BOTONES ---------- */
button {
  pointer-events: auto; cursor: pointer;
  background: linear-gradient(90deg, var(--a1), var(--a2));
  color: #08111c; font-weight: 800; font-size: 16px;
  border: none; border-radius: 12px;
  padding: 12px 34px; letter-spacing: 0.4px;
  transition: transform .12s, box-shadow .12s, background .15s;
}
button:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(56, 217, 169, 0.35); }
button:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: none; }
button.mini { font-size: 12.5px; padding: 7px 14px; border-radius: 9px; }
button.ghostbtn, button.ghost {
  background: rgba(255, 255, 255, 0.08); color: var(--txt);
}
button.ghostbtn:hover, button.ghost:hover { box-shadow: none; background: rgba(255, 255, 255, 0.15); }
.linkbtn {
  background: none; color: var(--dim); font-weight: 600; font-size: 12px;
  padding: 8px; text-decoration: underline;
}
.linkbtn:hover { box-shadow: none; transform: none; color: var(--txt); background: none; }
.btnrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.big-emoji { font-size: 40px; margin-bottom: 4px; }

/* ---------- PESTAÑAS ---------- */
#tabs { display: flex; gap: 6px; margin: 16px 0 18px; background: rgba(13,18,32,0.6); border-radius: 12px; padding: 4px; }
.tab {
  flex: 1; background: none; color: #adb5bd; font-weight: 700; font-size: 13.5px;
  padding: 9px 6px; border-radius: 9px;
}
.tab:hover { transform: none; box-shadow: none; color: var(--txt); }
.tab.sel { background: linear-gradient(90deg, var(--a1), var(--a2)); color: #08111c; }

/* ---------- JUGAR ---------- */
#modes { display: flex; gap: 10px; margin-bottom: 14px; }
.mode {
  flex: 1; padding: 12px 8px; cursor: pointer;
  background: #0d1220; border: 2px solid rgba(255,255,255,0.1);
  border-radius: 14px; transition: border-color .15s, transform .12s;
}
.mode:hover { transform: translateY(-2px); }
.mode.sel { border-color: var(--a2); }
.mode h3 { font-size: 15px; margin-bottom: 3px; }
.mode p { font-size: 11px; color: var(--dim); }

#name {
  width: 100%; padding: 11px 16px;
  background: #0d1220; color: var(--txt);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 12px;
  font-size: 16px; text-align: center; outline: none;
}
#name:focus { border-color: var(--a1); }

#swatches { display: flex; gap: 9px; justify-content: center; margin: 13px 0 14px; }
.sw {
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform .12s, border-color .12s;
}
.sw:hover { transform: scale(1.15); }
.sw.sel { border-color: #fff; transform: scale(1.15); }

#boostToggles { margin-bottom: 14px; text-align: left; }
.boost-lbl { font-size: 11.5px; color: var(--dim); margin-bottom: 6px; }
.boost-item {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 9px; padding: 5px 10px; margin: 0 6px 6px 0;
  font-size: 13px; cursor: pointer; transition: border-color .15s;
}
.boost-item.on { border-color: #ffd43b; color: #ffd43b; }
.boost-item input { accent-color: #ffd43b; }

#hofWrap { margin-top: 18px; padding: 12px 14px; text-align: left; }
#hofWrap h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: #ffd43b; margin-bottom: 6px; }
#hofWrap .row { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
#hofWrap .row .pos { width: 20px; color: var(--dim); font-size: 11px; }
#hofWrap .row .m { margin-left: auto; color: var(--dim); font-size: 12px; }
#hofWrap .row.me { background: rgba(255, 212, 59, 0.12); color: #ffd43b; }
#hofWrap .row.dim { color: #495057; font-size: 12px; }

.help { margin-top: 14px; }
.help p { font-size: 12.5px; color: #adb5bd; line-height: 1.5; }
.foot { margin-top: 16px; font-size: 11px; color: #495057; }

/* ---------- TIENDA ---------- */
#shopTabs { display: flex; gap: 6px; margin-bottom: 14px; }
.stab {
  flex: 1; background: rgba(255,255,255,0.06); color: #adb5bd;
  font-weight: 700; font-size: 13px; padding: 8px; border-radius: 10px;
}
.stab:hover { transform: none; box-shadow: none; color: var(--txt); }
.stab.sel { background: rgba(77, 171, 247, 0.18); color: var(--a1); }
#shopGrid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-height: 44vh; overflow-y: auto; padding: 2px;
}
.shop-card {
  background: rgba(13,18,32,0.6); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: border-color .15s;
}
.shop-card:hover { border-color: rgba(77, 171, 247, 0.5); }
.shop-card.equipped { border-color: var(--a2); }
.shop-card.booster { justify-content: center; }
.shop-info { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.shop-info.wide { align-items: flex-start; text-align: left; gap: 4px; }
.shop-info b { font-size: 13px; }
.shop-info span { font-size: 11px; color: var(--dim); }
.shop-info .own { color: #38d9a9; }
.shop-note { margin-top: 12px; font-size: 11.5px; color: #495057; }

/* ---------- PERFIL ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stats-grid > div { background: rgba(13,18,32,0.6); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; }
.stats-grid label { display: block; font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.stats-grid b { font-size: 19px; }
.level-card { padding: 14px 16px; text-align: left; margin-bottom: 12px; font-size: 14px; }
#pfAuth { text-align: left; font-size: 13px; color: #adb5bd; background: rgba(13,18,32,0.6); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
#pfAuth p { margin-bottom: 10px; line-height: 1.45; }

/* ---------- INPUTS de auth ---------- */
#authModal input {
  width: 100%; padding: 11px 14px; margin-bottom: 8px;
  background: #0d1220; color: var(--txt);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 11px;
  font-size: 14px; outline: none;
}
#authModal input:focus { border-color: var(--a1); }
#authMsg { min-height: 20px; font-size: 13px; margin-bottom: 8px; color: #ffd43b; }

.spinner {
  width: 28px; height: 28px; margin: 14px auto 0;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--a2); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#connTxt { color: #adb5bd; font-size: 14px; }
