/* ===================== Variables y base ===================== */
:root {
  --fondo: #170f0c; --panel: #251915; --panel2: #2f201b; --borde: #4a332b;
  --texto: #f6e9dc; --suave: #bfa490; --acento: #e8a84f; --rosa: #ff6b8a;
  --ok: #7bd88f; --peligro: #ff5a5a; --azul: #6fb3ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #3a221a 0%, #170f0c 65%) fixed;
  background-color: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
input { font: inherit; color: inherit; }
.oculto { display: none !important; }
.centro { text-align: center; }

/* ===================== Barra superior ===================== */
.barra-sup {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--borde); background: rgba(0,0,0,.25);
}
.logo { font-weight: 800; letter-spacing: .02em; }
.logo b { color: var(--acento); }
.etq18 { margin-left: 8px; font-size: .68rem; padding: 2px 6px; border-radius: 6px; background: var(--rosa); color: #1b0f0c; font-weight: 800; vertical-align: middle; }
.barra-der { display: flex; align-items: center; gap: 10px; }
.estado-red { font-size: .8rem; color: var(--peligro); }
.sala-mini { font-weight: 800; letter-spacing: .15em; color: var(--acento); font-size: .9rem; }
.btn-pildora { background: var(--panel2); border: 1px solid var(--borde); padding: 6px 14px; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
#btn-mute[aria-pressed="false"] { border-color: var(--acento); color: var(--acento); }

/* ===================== Pantallas y tarjetas ===================== */
.pantalla { display: none; padding: 16px; }
.pantalla.activa { display: block; }
.tarjeta {
  max-width: 560px; margin: 12px auto; background: var(--panel); border: 1px solid var(--borde);
  border-radius: 20px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
h1 { font-size: 2rem; line-height: 1.1; margin-bottom: 6px; }
h1 b { color: var(--acento); }
.sub { color: var(--suave); font-size: .95rem; margin-bottom: 16px; }
.tit { display: block; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); margin-bottom: 8px; }
.campo { display: block; margin-bottom: 16px; }
.campo input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--borde);
  background: var(--panel2); outline: none;
}
.campo input:focus { border-color: var(--acento); }
.in-codigo { text-transform: uppercase; letter-spacing: .4em; font-weight: 800; font-size: 1.4rem; text-align: center; }
.check18 { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--suave); margin: 4px 0 16px; }
.check18 input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--rosa); flex: none; }
.fila-botones { display: flex; gap: 10px; margin-top: 10px; }
.fila-botones > * { flex: 1; }
.btn-grande {
  display: block; width: 100%; padding: 14px; border-radius: 14px; font-weight: 800; font-size: 1.05rem;
  background: linear-gradient(180deg, #f2b860, #d18c35); color: #1b0f0c; box-shadow: 0 5px 0 #8a5a1f;
  transition: transform .08s, box-shadow .08s;
}
.btn-grande.alt { background: linear-gradient(180deg, #ff8aa3, #e0566f); box-shadow: 0 5px 0 #8c2c3e; }
.btn-grande:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #8a5a1f; }
.btn-sec { display: block; width: 100%; padding: 12px; border-radius: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--borde); margin-top: 10px; }
.error { color: var(--peligro); font-weight: 700; min-height: 1.4em; margin-top: 12px; text-align: center; }

/* ===================== Lobby ===================== */
.codigo-grande {
  font-size: clamp(3.5rem, 18vw, 6.5rem); font-weight: 900; letter-spacing: .18em; text-align: center;
  color: var(--acento); line-height: 1; margin: 4px 0 10px; text-shadow: 0 6px 0 rgba(0,0,0,.35);
}
.enlace { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.enlace code { font-size: .8rem; color: var(--suave); word-break: break-all; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--panel2); padding: 5px; border-radius: 12px; border: 1px solid var(--borde); }
.seg button { padding: 10px 6px; border-radius: 9px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--acento); color: #1b0f0c; opacity: 1; }
.lista-lobby { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.lista-lobby li { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--borde); border-radius: 10px; padding: 8px 10px; }
.lista-lobby .punto { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.lista-lobby .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etq { font-size: .65rem; font-weight: 800; padding: 2px 6px; border-radius: 5px; background: #555; color: #fff; }
.etq.host { background: var(--acento); color: #1b0f0c; }
.etq.tu { background: var(--rosa); color: #1b0f0c; }
.btn-kick { font-size: .75rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--peligro); color: var(--peligro); }

/* ===================== Partida ===================== */
.juego-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; max-width: 1240px; margin: 0 auto; align-items: start; }
@media (max-width: 900px) { .juego-grid { grid-template-columns: 1fr; } }
.escena-wrap {
  position: relative; width: min(100%, calc(100vh - 90px)); aspect-ratio: 1 / 1; margin: 0 auto;
  border-radius: 24px; overflow: hidden; border: 1px solid var(--borde); background: #1a110d;
  user-select: none; -webkit-user-select: none;
}
@media (max-width: 900px) { .escena-wrap { width: min(100%, 68vh); } }
#escena { display: block; width: 100%; height: 100%; touch-action: none; }
#escena .mio { cursor: grab; }
#escena .mio:active { cursor: grabbing; }
.etq-nombre { font: 700 22px system-ui, sans-serif; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 6px; text-anchor: middle; }
.etq-nombre.tu { fill: var(--acento); }
.pista { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: .72rem; color: rgba(255,255,255,.55); white-space: nowrap; pointer-events: none; }

/* Animación de goteo (galleta final) */
@keyframes gotear { 0% { transform: scaleY(.2); } 70% { transform: scaleY(1); } 100% { transform: scaleY(1.15); opacity: .4; } }
.goteo { transform-box: fill-box; transform-origin: top; animation: gotear 1.6s ease-in infinite; }

/* Cuenta atrás */
.cuenta { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22vmin; font-weight: 900; background: rgba(0,0,0,.45); pointer-events: none; }

/* Capa del QTE: anillo y textos junto a tu personaje */
.qte-capa {
  position: absolute; left: 50%; top: 52%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px;
  background: rgba(20,12,9,.88); border: 2px solid var(--rosa); max-width: 92%; pointer-events: none; z-index: 5;
}
.anillo { width: 54px; height: 54px; flex: none; transform: rotate(-90deg); }
.anillo-fondo { fill: none; stroke: rgba(255,255,255,.15); stroke-width: 6; }
.anillo-prog { fill: none; stroke: var(--rosa); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 163.4; stroke-dashoffset: 0; }
.qte-textos { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qte-textos strong { color: var(--rosa); font-size: 1rem; }
.qte-textos span { font-size: .82rem; color: var(--texto); }
.qte-prog { height: 5px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.qte-prog i { display: block; height: 100%; width: 0; background: var(--ok); }
.qte-alerta {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  width: 90px; height: 90px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rosa); color: #1b0f0c; font-size: 3.5rem; font-weight: 900; z-index: 6; pointer-events: none;
  animation: latir .2s ease-in-out infinite alternate;
}
@keyframes latir { from { transform: translate(-50%, -50%) scale(.9); } to { transform: translate(-50%, -50%) scale(1.1); } }

/* Imaginación: todo oscuro */
.oscuro { position: absolute; inset: 0; background: rgba(4,2,2,.95); display: grid; place-items: center; z-index: 4; pointer-events: none; }
.oscuro span { color: rgba(255,255,255,.25); font-size: 1.4rem; font-style: italic; letter-spacing: .2em; }

/* Pestaña porno: panel abstracto con silueta en bucle y barra de tempo */
.porno-panel {
  position: absolute; top: 10px; right: 10px; width: min(46%, 240px); border-radius: 12px; overflow: hidden;
  background: #111; border: 1px solid #444; z-index: 3; box-shadow: 0 10px 30px rgba(0,0,0,.6); pointer-events: none;
}
.porno-tab { display: flex; justify-content: space-between; font-size: .7rem; padding: 5px 8px; background: #2a2a2a; color: #ccc; }
.porno-cuerpo { position: relative; height: 92px; background: radial-gradient(circle at 50% 60%, #4a1426, #12060a); overflow: hidden; }
.porno-ondas { position: absolute; inset: auto 0 0 0; height: 40px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; opacity: .6; }
.porno-ondas i { width: 6px; background: var(--rosa); border-radius: 3px 3px 0 0; height: 30%; animation: onda var(--periodo, .45s) ease-in-out infinite alternate; }
.porno-ondas i:nth-child(2n) { animation-delay: calc(var(--periodo, .45s) * -.5); }
.porno-ondas i:nth-child(3n) { animation-delay: calc(var(--periodo, .45s) * -.25); }
@keyframes onda { from { height: 15%; } to { height: 95%; } }
.porno-silueta { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; gap: 2px; }
.porno-silueta b { display: block; width: 34px; height: 46px; border-radius: 50% 50% 40% 40%; background: rgba(255,160,180,.55); animation: vaiven-sil var(--periodo, .45s) ease-in-out infinite alternate; }
.porno-silueta b + b { animation-direction: alternate-reverse; }
@keyframes vaiven-sil { from { transform: translateY(-6px) scale(.95); } to { transform: translateY(6px) scale(1.05); } }
.tempo { padding: 8px; }
.tempo small { display: block; font-size: .62rem; color: #aaa; margin-top: 4px; text-align: center; }
.tempo-pista { position: relative; height: 12px; background: #2a2a2a; border-radius: 6px; }
.tempo-marca, .tempo-tu { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; }
.tempo-marca { background: var(--rosa); left: 0; animation: tempo-va var(--medio, .22s) ease-in-out infinite alternate; }
.tempo-tu { background: #fff; width: 8px; height: 8px; margin: -4px 0 0 -4px; }
@keyframes tempo-va { from { left: 4%; } to { left: 96%; } }

/* Aviso del móvil */
.movil-noti {
  position: absolute; left: 50%; top: 68%; width: 64%; transform: translate(-50%, -50%);
  background: rgba(245,245,250,.97); color: #111; border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.6); z-index: 5; touch-action: none; cursor: grab;
}
.noti-cab { font-size: .72rem; color: #666; margin-bottom: 4px; }
.noti-txt { font-weight: 700; }
.noti-pie { font-size: .68rem; color: #999; margin-top: 4px; }

/* Panel lateral */
.lado { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.caja { background: var(--panel); border: 1px solid var(--borde); border-radius: 18px; padding: 12px; }
.fila-mi { display: flex; justify-content: space-between; font-size: .85rem; color: var(--suave); margin-bottom: 6px; }
.fila-mi b { color: var(--texto); font-variant-numeric: tabular-nums; }
.tubo { height: 18px; background: rgba(0,0,0,.5); border: 1px solid var(--borde); border-radius: 9px; overflow: hidden; }
.tubo i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7bd88f, #e8a84f 60%, #ff5a5a); background-size: 100% 100%; }
.tubo i.bloq { filter: grayscale(1); }
.fila-estados { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; min-height: 34px; }
.buffs { display: flex; flex-wrap: wrap; gap: 6px; }
.buff { position: relative; display: flex; align-items: center; gap: 4px; font-size: .72rem; padding: 3px 7px 6px; border-radius: 8px; background: rgba(123,216,143,.15); border: 1px solid rgba(123,216,143,.4); overflow: hidden; }
.buff.malo { background: rgba(255,90,90,.15); border-color: rgba(255,90,90,.4); }
.buff .t { position: absolute; left: 0; bottom: 0; height: 3px; background: currentColor; opacity: .7; }
.racha { font-size: .8rem; font-weight: 800; color: var(--acento); white-space: nowrap; }
.btn-qte { padding: 10px 6px; border-radius: 12px; font-weight: 800; font-size: .85rem; background: #3a1622; border: 1px solid #7d2c43; color: #ffd0da; }
.btn-qte.azul { background: #1d3550; border-color: #2f5b88; color: #d8ecff; }
.btn-qte small { opacity: .7; font-weight: 600; }

.lista-juego { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.lista-juego li { display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 8px; align-items: center; font-size: .82rem; }
.lista-juego .punto { width: 12px; height: 12px; border-radius: 50%; }
.lista-juego .barra { grid-column: 2 / 4; height: 6px; background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden; }
.lista-juego .barra i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7bd88f, #e8a84f 60%, #ff5a5a); }
.lista-juego .est { font-size: .65rem; font-weight: 800; color: var(--suave); }
.lista-juego li.fuera { opacity: .55; }
.lista-juego li.fuera .est { color: var(--ok); }
.lista-juego li.climax .est { color: var(--rosa); }

.log { list-style: none; max-height: 200px; overflow-y: auto; font-size: .82rem; display: flex; flex-direction: column; gap: 3px; }
.log li { display: flex; gap: 8px; line-height: 1.35; }
.log .hora { color: var(--suave); font-variant-numeric: tabular-nums; flex: none; opacity: .8; }
.log .corrida { color: var(--rosa); font-weight: 700; }
.log .exito { color: var(--ok); }
.log .fallo { color: #ff9a9a; }
.log .sistema { color: var(--acento); }
.log .climax { color: #ffd166; }

/* ===================== Final ===================== */
.sello { display: inline-block; margin: 6px auto 10px; padding: 10px 22px; border: 3px solid var(--ok); color: var(--ok); border-radius: 12px; font-weight: 900; font-size: 1.6rem; letter-spacing: .12em; transform: rotate(-4deg); }
.gordo { font-size: 1.15rem; margin: 8px 0 14px; }
.final-svg { display: block; width: min(100%, 300px); margin: 0 auto 8px; }
.lista-derrotas { list-style: none; text-align: left; margin: 0 auto 16px; max-width: 320px; }
.lista-derrotas li { display: flex; justify-content: space-between; padding: 5px 2px; border-bottom: 1px dashed var(--borde); }
.lista-derrotas b { color: var(--rosa); }
h2.tit { margin-top: 18px; }

/* ===================== Avisos flotantes ===================== */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); transition: transform .25s;
  background: #2b1c17; border: 1px solid var(--acento); padding: 10px 16px; border-radius: 12px; z-index: 50;
  max-width: calc(100% - 32px); text-align: center; font-weight: 700; pointer-events: none;
}
.toast.ver { transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.mal { border-color: var(--peligro); color: #ffb3b3; }
