* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f2f7fc; font-family: 'Segoe UI', Ubuntu, Roboto, Arial, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#lb { position: absolute; top: 12px; right: 12px; width: 210px; background: rgba(16, 6, 159, 0.72); color: #fff; border-radius: 10px; padding: 10px 12px 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
#lb h3 { margin: 0 0 6px; text-align: center; font-size: 18px; letter-spacing: 1px; color: #FEDD00; }
#lb ol { margin: 0; padding-left: 24px; font-size: 14px; line-height: 1.55; }
#lb li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lb li.me { color: #FEDD00; font-weight: 700; }
#lb li.myrank { list-style: none; margin-left: -20px; border-top: 1px solid rgba(255,255,255,.3); margin-top: 4px; padding-top: 2px; }
#score { position: absolute; left: 12px; bottom: 12px; font-size: 22px; font-weight: 700; color: #fff; background: rgba(213, 0, 50, 0.8); padding: 6px 14px; border-radius: 8px; display: none; }
#minimap { position: absolute; right: 12px; bottom: 12px; width: 170px; height: 170px; border-radius: 8px; background: rgba(16, 6, 159, 0.18); border: 2px solid rgba(16, 6, 159, 0.6); }
#chat { position: absolute; left: 12px; bottom: 60px; width: 340px; max-width: calc(100vw - 210px); }
#chatLog { font-size: 14px; color: #111; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
#chatLog div { margin: 2px 0; transition: opacity 1s; word-wrap: break-word; }
#chatLog b { font-weight: 700; }
#chatInput { pointer-events: auto; width: 100%; margin-top: 4px; padding: 7px 10px; border-radius: 6px; border: 2px solid #10069F; font-size: 14px; outline: none; display: none; }
#status { position: absolute; top: 40%; width: 100%; text-align: center; font-size: 22px; font-weight: 700; color: #D50032; text-shadow: 0 0 4px #fff; }
#mobileBtns { position: absolute; right: 200px; bottom: 20px; display: none; gap: 14px; }
#mobileBtns button { pointer-events: auto; width: 70px; height: 70px; border-radius: 50%; border: 3px solid #fff; font-size: 26px; font-weight: 800; color: #fff; background: rgba(16, 6, 159, 0.75); }
#mobileBtns #btnSplit { background: rgba(213, 0, 50, 0.8); }
body.touch #mobileBtns { display: flex; }

body.dark { background: #0e1220; }
body.dark #chatLog { color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }

/* ---------- Menú ---------- */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 20, 50, 0.35); backdrop-filter: blur(2px); overflow-y: auto; padding: 16px; }
.panel { position: relative; background: #fff; width: 430px; max-width: 100%; border-radius: 16px; padding: 26px 26px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.35); overflow: hidden; text-align: center; margin: auto; }
.flagbar { position: absolute; top: 0; left: 0; right: 0; height: 8px; display: flex; }
.flagbar span { flex: 8; } .flagbar span:nth-child(1) { background: #10069F; } .flagbar span:nth-child(2) { background: #FEDD00; flex: 9; } .flagbar span:nth-child(3) { background: #D50032; }
h1 { margin: 6px 0 0; font-size: 46px; letter-spacing: 2px; color: #10069F; font-weight: 900; }
h1 span { color: #D50032; }
.sub { margin: 2px 0 16px; color: #556; font-size: 14px; }
#nick { width: 100%; padding: 12px 14px; font-size: 18px; border: 2px solid #cdd6e4; border-radius: 10px; outline: none; text-align: center; }
#nick:focus { border-color: #10069F; }
.label { margin: 14px 0 6px; font-size: 13px; color: #667; text-transform: uppercase; letter-spacing: 1px; }
#skins { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.skin { cursor: pointer; border-radius: 50%; border: 3px solid transparent; padding: 2px; transition: transform .1s; position: relative; }
.skin:hover { transform: scale(1.08); }
.skin.sel { border-color: #D50032; }
.skin canvas { width: 100%; display: block; border-radius: 50%; }
.skin .nm { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); font-size: 9px; background: rgba(0,0,0,.65); color: #fff; padding: 0 4px; border-radius: 4px; white-space: nowrap; pointer-events: none; }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btns button { flex: 1; padding: 13px; font-size: 20px; font-weight: 800; border: none; border-radius: 10px; cursor: pointer; color: #fff; background: #10069F; letter-spacing: 1px; transition: filter .15s; }
.btns button:hover { filter: brightness(1.2); }
.btns #play { flex: 2; background: linear-gradient(90deg, #10069F, #2b20d6); }
.btns .secondary { background: #D50032; font-size: 16px; }
.opts { display: flex; justify-content: center; gap: 18px; margin-top: 12px; font-size: 14px; color: #445; }
.opts label { cursor: pointer; }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; margin-top: 14px; font-size: 13px; color: #556; background: #f4f6fb; border-radius: 10px; padding: 10px; }
.controls b { color: #10069F; }
#online { margin-top: 10px; font-size: 13px; color: #889; }
#deathBox { background: #fff4f6; border: 2px solid #D50032; border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.deathTitle { font-size: 20px; font-weight: 800; color: #D50032; }
#deathInfo { font-size: 15px; color: #333; margin-top: 4px; }

@media (max-width: 600px) {
  #lb { width: 150px; font-size: 12px; padding: 6px 8px; }
  #lb h3 { font-size: 14px; }
  #lb ol { font-size: 12px; }
  #minimap { width: 110px; height: 110px; }
  #mobileBtns { right: 130px; }
  #chat { display: none; }
  h1 { font-size: 36px; }
  #skins { grid-template-columns: repeat(4, 1fr); }
}
