:root {
  --bg: #07090f;
  --ink: #f2efe6;
  --dim: #a9a49a;
  --blood: #d8322b;
  --toxic: #8be04e;
  --gold: #ffcf4a;
  --panel: rgba(8, 10, 16, 0.72);
  --edge: rgba(255, 255, 255, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: Nunito, system-ui, sans-serif; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- menú ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; }
#menu { background: radial-gradient(ellipse at 50% 30%, rgba(60, 10, 10, 0.55), rgba(0, 0, 0, 0.92)); overflow-y: auto; padding: 16px; }
.menu-box { width: min(720px, 100%); text-align: center; }
h1 { font-family: Creepster, cursive; font-weight: 400; font-size: clamp(44px, 9vw, 92px); line-height: 0.9; margin: 0 0 10px; color: var(--toxic); text-shadow: 0 0 24px rgba(139, 224, 78, 0.45), 0 4px 0 #1b3b0b; letter-spacing: 2px; }
h1 span { display: block; color: var(--blood); text-shadow: 0 0 24px rgba(216, 50, 43, 0.5), 0 4px 0 #3b0b0b; }
.tagline { color: var(--dim); font-size: 17px; max-width: 560px; margin: 0 auto 18px; }
.field { display: block; font-weight: 800; margin: 12px 0; font-size: 15px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--dim); }
.field input { display: block; margin: 6px auto 0; width: min(320px, 100%); padding: 12px 14px; font: inherit; font-size: 20px; text-transform: none; color: var(--ink); background: #10131c; border: 2px solid var(--edge); border-radius: 12px; text-align: center; outline: none; }
.field input:focus { border-color: var(--toxic); }
.skins { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.skin { position: relative; width: 104px; height: 120px; border-radius: 14px; border: 3px solid transparent; background: #121622 center 30%/115% no-repeat; cursor: pointer; transition: transform 0.12s, border-color 0.12s; color: var(--ink); font: inherit; }
.skin span { position: absolute; left: 0; right: 0; bottom: 4px; font-weight: 900; font-size: 14px; text-shadow: 0 1px 3px #000; }
.skin:hover { transform: translateY(-3px); }
.skin.sel { border-color: var(--toxic); box-shadow: 0 0 18px rgba(139, 224, 78, 0.5); }
button.big { margin-top: 14px; font: inherit; font-weight: 900; font-size: 24px; padding: 14px 40px; border-radius: 16px; border: 0; color: #10200a; background: var(--toxic); cursor: pointer; box-shadow: 0 6px 0 #4c8a22; }
button.big:disabled { background: #555; color: #bbb; box-shadow: 0 6px 0 #333; cursor: wait; }
button.big:not(:disabled):hover { filter: brightness(1.1); }
.status { min-height: 22px; color: var(--gold); }
.controls { margin: 8px auto; max-width: 600px; text-align: left; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 8px 14px; }
.controls summary { cursor: pointer; font-weight: 800; }
.controls table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
.controls td, .controls th { padding: 4px 6px; border-top: 1px solid var(--edge); text-align: left; }
.controls th { color: var(--dim); font-weight: 800; }
.credits { color: #6d6a63; font-size: 12px; margin-top: 14px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.panel { position: absolute; background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(3px); }
.small { font-size: 12px; padding: 4px 8px; color: var(--dim); }
#me { left: 14px; bottom: 14px; width: 290px; }
.me-row { display: flex; justify-content: space-between; align-items: center; font-weight: 900; font-size: 18px; margin-bottom: 6px; }
.zone { font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #222; }
.bar { position: relative; height: 18px; border-radius: 9px; background: #2a0f0f; overflow: hidden; }
.bar > div { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#ef4a3c, #b3221b); transition: width 0.15s; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; font-weight: 900; line-height: 18px; text-shadow: 0 1px 2px #000; }
.bar.stamina { height: 6px; margin-top: 5px; background: #13240c; }
.bar.stamina > div { background: var(--toxic); transition: none; }
.inv { display: flex; gap: 12px; margin-top: 8px; font-weight: 900; font-size: 17px; }
#team { left: 14px; top: 14px; min-width: 210px; font-size: 14px; font-weight: 800; }
#team:empty { display: none; }
.mate { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.mate .dot { width: 10px; height: 10px; border-radius: 50%; }
.mate .mini { flex: 1; height: 6px; background: #2a0f0f; border-radius: 3px; overflow: hidden; min-width: 60px; }
.mate .mini div { height: 100%; background: #ef4a3c; }
.mate.caido { color: var(--gold); }
.mate.muerto { color: #777; text-decoration: line-through; }
#mission { left: 50%; top: 14px; transform: translateX(-50%); max-width: min(620px, 60vw); text-align: center; }
#objective { font-weight: 900; font-size: 16px; }
#mission-row { display: flex; justify-content: center; gap: 16px; margin-top: 4px; font-weight: 800; color: var(--dim); font-size: 14px; }
#timer { color: var(--gold); font-size: 18px; }
#feed { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.msg { background: rgba(0, 0, 0, 0.6); padding: 5px 12px; border-radius: 10px; font-weight: 800; font-size: 15px; animation: fadeout 6s forwards; }
.msg.bad { color: #ff8a80; }
.msg.good { color: #b9f6ca; }
.msg.big { color: var(--gold); font-size: 17px; }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#mapbox { right: 14px; top: 14px; padding: 6px; }
#minimap { display: block; border-radius: 10px; }
#hint { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); font-weight: 900; font-size: 18px; color: var(--gold); text-shadow: 0 2px 4px #000; }
#action { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); width: 260px; text-align: center; font-weight: 900; display: none; }
#action.on { display: block; }
#action .bar { margin-top: 4px; background: #222; }
#action .bar > div { background: var(--gold); transition: none; }
#banner { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font-family: Creepster, cursive; font-size: clamp(36px, 7vw, 80px); color: var(--gold); text-shadow: 0 0 30px rgba(0, 0, 0, 0.9), 0 4px 0 #000; opacity: 0; transition: opacity 0.4s; padding: 0 20px; }
#banner.on { opacity: 1; }
#downed { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, transparent 30%, rgba(120, 0, 0, 0.55)); font-weight: 900; font-size: 26px; text-align: center; text-shadow: 0 2px 6px #000; padding: 20px; }
#hurt { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 0, 0, 0.6)); opacity: 0; transition: opacity 0.25s; }
#net { right: 14px; bottom: 14px; }
#labels { position: absolute; inset: 0; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -100%); font-weight: 900; font-size: 14px; white-space: nowrap; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.label .hb { width: 44px; height: 5px; margin: 2px auto 0; background: #400; border-radius: 3px; overflow: hidden; }
.label .hb div { height: 100%; background: #ef4a3c; }
.label.help { color: var(--gold); animation: pulse 0.8s infinite alternate; }
.float { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 18px; color: var(--gold); text-shadow: 0 2px 4px #000; animation: floatup 1.6s forwards; white-space: nowrap; }
@keyframes floatup { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -60px; } }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

#bigmap { background: rgba(0, 0, 0, 0.85); z-index: 15; flex-direction: column; }
#bigmap canvas { max-width: 96vw; max-height: 88vh; border-radius: 12px; }
.bigmap-help { text-align: center; color: var(--dim); font-weight: 800; }

@media (max-width: 700px) {
  #me { width: auto; right: 14px; }
  #mapbox canvas { width: 140px; height: 140px; }
  #team { display: none; }
  #mission { max-width: 90vw; top: 170px; }
}

/* ---------- parties y ranking ---------- */
.party-row { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.party-row input { margin: 0; }
.field .party-row input { display: block; width: min(280px, 70vw); padding: 12px 14px; font: inherit; font-size: 20px; text-transform: none; color: var(--ink); background: #10131c; border: 2px solid var(--edge); border-radius: 12px; text-align: center; outline: none; }
.field .party-row input:focus { border-color: var(--gold); }
#party-dice { font-size: 24px; width: 52px; border-radius: 12px; border: 2px solid var(--edge); background: #10131c; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; text-transform: none; }
.chip { font: inherit; font-size: 13px; font-weight: 800; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--edge); background: #181d2a; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--gold); }
.ranking { margin: 14px auto 6px; max-width: 640px; text-align: left; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 8px 14px; }
.ranking:empty { display: none; }
.ranking h3 { margin: 6px 0; font-size: 16px; color: var(--gold); }
.ranking table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ranking td, .ranking th { padding: 4px 6px; border-top: 1px solid var(--edge); }
.ranking th { color: var(--dim); font-weight: 800; text-align: left; }
.ranking tr.me td { background: rgba(255, 207, 74, 0.12); }
.ranking .live { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 2px solid; background: rgba(0, 0, 0, 0.35); }
.pill.me { background: rgba(255, 207, 74, 0.15); }
.dim { color: var(--dim); }
p.small, .dim.small { font-size: 12px; }
.pt-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 900; margin-top: 4px; }
.pt-head:first-child { margin-top: 0; }
.pt-head span { color: var(--gold); }
.label.home { font-size: 15px; text-align: center; }
.label.home small { color: var(--dim); font-size: 11px; }
.bigmap-row { display: flex; gap: 12px; align-items: flex-start; justify-content: center; }
#bigmap-rank { margin: 0; width: 340px; max-height: 86vh; overflow-y: auto; font-size: 13px; }
#bigmap-rank .wide { display: none; }

/* ---------- cofre ---------- */
#stash { position: fixed; z-index: 12; right: 14px; top: 50%; transform: translateY(-50%); width: 270px; pointer-events: auto; }
.stash-title { font-weight: 900; font-size: 17px; margin-bottom: 6px; color: var(--gold); }
.stash-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin: 4px 0; padding: 9px 10px; font: inherit; font-weight: 800; font-size: 15px; text-align: left; color: var(--ink); background: #181d2a; border: 2px solid var(--edge); border-radius: 10px; cursor: pointer; }
.stash-btn:hover, .stash-btn.sel { border-color: var(--gold); background: #262d3f; }
.stash-btn kbd { font: inherit; font-size: 11px; color: var(--dim); border: 1px solid var(--edge); border-radius: 4px; padding: 0 5px; }
#stash p { margin: 6px 0 0; }

/* ---------- pantalla táctil ---------- */
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#touch { position: fixed; inset: 0; z-index: 11; touch-action: none; }
.stick { position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.05); pointer-events: none; opacity: 0.55; transition: opacity 0.15s; }
.stick.on { opacity: 1; border-color: rgba(255, 255, 255, 0.4); }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); box-shadow: 0 0 12px rgba(0, 0, 0, 0.4); }
.stick.aim { border-color: rgba(255, 90, 70, 0.35); }
.stick.aim .knob { background: rgba(255, 90, 70, 0.5); }
.tbtn { position: absolute; width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.28); background: rgba(10, 12, 20, 0.55); font-size: 28px; line-height: 1; padding: 0; color: #fff; touch-action: none; }
.tbtn.xl { width: 78px; height: 78px; font-size: 36px; }
.tbtn.small { width: 44px; height: 44px; font-size: 20px; }
.tbtn.down { transform: scale(0.9); background: rgba(255, 207, 74, 0.45); }
.tbtn.on { background: rgba(139, 224, 78, 0.5); border-color: var(--toxic); }
#rotate { z-index: 30; background: rgba(0, 0, 0, 0.88); text-align: center; font-weight: 900; font-size: 24px; padding: 20px; }
body.touch #hud #me { left: 10px; top: 10px; bottom: auto; width: 230px; padding: 6px 9px; }
body.touch #hud .me-row { font-size: 15px; margin-bottom: 4px; }
body.touch #hud .inv { font-size: 14px; gap: 8px; margin-top: 5px; }
body.touch #hud #team { left: 10px; top: 112px; min-width: 0; font-size: 12px; padding: 6px 9px; }
body.touch #hud .mate .mini { min-width: 30px; }
body.touch #hud #mission { top: 8px; max-width: min(46vw, 460px); padding: 6px 10px; }
body.touch #hud #objective { font-size: 13px; }
body.touch #hud #objective div { font-size: 17px !important; }
body.touch #hud #mission-row { font-size: 12px; gap: 10px; }
body.touch #hud #mapbox { top: 8px; right: 8px; padding: 4px; }
body.touch #hud #minimap { width: 132px; height: 132px; }
body.touch #hud #net { display: none; }
body.touch #hud #feed { top: 84px; }
body.touch #hud .msg { font-size: 13px; }
body.touch #hud #hint { bottom: 150px; font-size: 15px; max-width: 46vw; text-align: center; }
body.touch #hud #action { bottom: 120px; }
body.touch #stash { right: 150px; top: 46%; width: 240px; }
body.touch .stash-btn { padding: 11px 10px; }
body.touch .stash-btn kbd { display: none; }
@media (max-height: 500px) {
  body.touch #hud #team { display: none; }
  body.touch #hud #me { width: 200px; }
}
@media (max-width: 1000px) {
  body.touch #bigmap-rank { display: none; }
}
@media (max-width: 900px) {
  #bigmap-rank { display: none; }
}

/* ---------- clave del party e instalar la app ---------- */
.key-row input { font-size: 17px !important; }
.key-help { margin: 6px auto 0; max-width: 420px; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; color: #8b877e; }
button.install { margin-top: 4px; font: inherit; font-weight: 900; font-size: 16px; padding: 9px 20px; border-radius: 12px; border: 2px solid var(--gold); color: var(--gold); background: transparent; cursor: pointer; }
.install-help { max-width: 420px; margin: 8px auto; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 12px; }
