/* Estilo flash de cyber de los 2000: degradados, botones de gomita y letras con borde. */
:root {
  --fondo: #060a24;
  --panel: #121a4a;
  --borde: #3d55c9;
  --texto: #e8ecff;
  --suave: #8fa2e8;
  --naranja: #ff8a1f;
  --amarillo: #ffd23f;
  --rojo: #ff3b3b;
  --verde: #6ee05a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--texto);
  font-family: Verdana, Tahoma, sans-serif;
  background:
    radial-gradient(ellipse at top, #1d2a7a 0%, transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0 12px, transparent 12px 24px),
    var(--fondo);
}

.cabecera {
  position: relative;
  text-align: center;
  padding: 18px 16px 6px;
}

.logo {
  margin: 0;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(36px, 8vw, 64px);
  letter-spacing: 3px;
  color: var(--amarillo);
  background: linear-gradient(#fff36b, #ffb21f 55%, #ff6a00);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 2px #4a1600;
  filter: drop-shadow(3px 4px 0 #000);
  transform: rotate(-2deg);
}

.bajada { margin: 4px 0 0; color: var(--suave); font-size: 13px; }

#mudo { position: absolute; top: 14px; right: 16px; }

main { padding: 12px 16px 16px; }

.panel {
  background: linear-gradient(#18215c, var(--panel));
  border: 2px solid var(--borde);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 0 #02040f;
  padding: 16px;
}

.boton {
  font: bold 15px Verdana, sans-serif;
  color: #3a1500;
  padding: 10px 18px;
  border: 2px solid #8a3a00;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(#ffe27a, #ffad2f 50%, #ff8a1f 51%, #ffb347);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 3px 0 #5a2400;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.boton:hover { filter: brightness(1.1); }
.boton:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 1px 0 #5a2400; }
.boton:disabled { filter: grayscale(0.8); cursor: default; }
.boton.grande { font-size: 18px; padding: 14px 22px; width: 100%; }
.boton.chico { font-size: 13px; padding: 6px 12px; }
.boton.secundario {
  color: #ffffff;
  border-color: #13207a;
  background: linear-gradient(#8fb0ff, #4a6cf0 50%, #2a46d0 51%, #4a6cf0);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #0a1150;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.boton.listo {
  color: #0b3300;
  border-color: #1f6a00;
  background: linear-gradient(#c8ff9a, #6ee05a 50%, #3cbf2a 51%, #6ee05a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 3px 0 #144a00;
}

input {
  font: bold 16px Verdana, sans-serif;
  color: var(--texto);
  background: #070b2a;
  border: 2px solid var(--borde);
  border-radius: 8px;
  padding: 9px 12px;
  min-width: 0;
}
input:focus { outline: 2px solid var(--amarillo); outline-offset: 1px; }

.menu {
  max-width: 420px;
  margin: 12px auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.campo { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--suave); }
.unirse { display: flex; gap: 8px; }
.unirse input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; }
.aviso { margin: 0; min-height: 1em; color: var(--amarillo); font-size: 13px; text-align: center; }

.trofeos summary {
  cursor: pointer;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 8px;
  background: linear-gradient(#2a3a9a, #1a2468);
  border: 1px solid var(--borde);
}
.trofeos summary b { color: var(--amarillo); float: right; }
.trofeos ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.trofeos li {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border-radius: 8px;
  background: #0b1036;
  color: var(--suave);
  font-size: 12px;
  opacity: 0.7;
}
.trofeos li b { font-size: 13px; }
.trofeos li.ganado { opacity: 1; color: var(--texto); border: 1px solid var(--amarillo); }
.trofeos li.ganado b { color: var(--amarillo); }

.avisos-trofeos {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  max-width: calc(100vw - 32px);
}
.aviso-trofeo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid #8a3a00;
  color: #3a1500;
  font-size: 12px;
  background: linear-gradient(#ffe27a, #ffad2f 50%, #ff8a1f 51%, #ffb347);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 4px 0 #5a2400;
  animation: entrar-trofeo 4.5s ease-out forwards;
}
.aviso-trofeo b { font-size: 15px; }
@keyframes entrar-trofeo {
  0% { transform: translateX(120%); }
  8%, 88% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(0); opacity: 0; }
}

.controles {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--suave);
}
.controles dt { font-weight: bold; color: var(--texto); }
.controles dd { margin: 0; }

/* ---------- Mesa: tu pozo · centro (puntos y chats) · pozo del rival, como en los cyber ---------- */
.mesa {
  display: grid;
  grid-template-columns: auto minmax(210px, 270px) auto;
  justify-content: center;
  align-items: start;
  gap: 14px;
}
.lado { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.placa {
  font-weight: bold;
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(#2a3a9a, #1a2468);
  border: 1px solid var(--borde);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.placa b { color: var(--amarillo); float: right; }
.rival .placa { background: linear-gradient(#1f8a7a, #0f4f48); border-color: #3fd0b8; }

.marco { position: relative; }
.marco canvas { display: block; margin: 0 auto; }
body.jugando .cabecera { padding-top: 6px; }
body.jugando .logo { font-size: 30px; }
body.jugando .bajada { display: none; }

.centro {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 3px solid #8a3a00;
  background: linear-gradient(#ffb347, #ff8a1f 40%, #e86a10);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 6px 0 #4a1600;
  color: #3a1500;
}
.versus {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}
.versus b { font-family: "Arial Black", Impact, sans-serif; color: #fff; -webkit-text-stroke: 1px #4a1600; font-size: 18px; }
.marcador { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.marcador td, .marcador th { padding: 6px 8px; background: #fff3d6; font-weight: bold; }
.marcador td { width: 34%; text-align: center; font: bold 17px Verdana, sans-serif; color: #3a1500; }
.marcador td:first-child { border-radius: 999px 0 0 999px; }
.marcador td:last-child { border-radius: 0 999px 999px 0; }
.marcador th { font-family: "Arial Black", Impact, sans-serif; font-size: 13px; color: #b0300a; font-style: italic; }
.marcador td[hidden] { display: table-cell !important; visibility: hidden; }

.chats { display: flex; flex-direction: column; gap: 6px; }
.pestanas { display: flex; gap: 6px; }
.pestana {
  flex: 1;
  font: bold 12px Verdana, sans-serif;
  padding: 6px 4px;
  border-radius: 999px;
  border: 2px solid #8a3a00;
  background: #ffd9a0;
  color: #8a3a00;
  cursor: pointer;
}
.pestana.activa { background: #3a1500; color: var(--amarillo); }
.pestana i { font-style: normal; color: var(--rojo); }
.pestana.activa i { color: var(--amarillo); }

.chat {
  list-style: none;
  margin: 0;
  padding: 8px;
  height: 200px;
  overflow-y: auto;
  background: #070b2a;
  color: var(--texto);
  border: 2px solid var(--borde);
  border-radius: 8px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.chat li { margin-bottom: 4px; }
.chat .quien { font-weight: bold; color: var(--naranja); }
.chat .quien.mauspi { color: var(--amarillo); }
.chat .sistema { color: var(--suave); font-style: italic; }
.centro .chat { border-color: #8a3a00; height: 170px; }
.chatear { display: flex; gap: 6px; }
.chatear input { flex: 1; font-size: 13px; padding: 6px 10px; }

/* ---------- Salón: ya están jugando · chat y retos · elegí tu oponente ---------- */
.salon {
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(0, 560px) minmax(170px, 230px);
  justify-content: center;
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  border-radius: 18px;
  border: 3px solid #8a3a00;
  background: linear-gradient(#ffb347, #ff8a1f 30%, #e86a10);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 6px 0 #4a1600;
  max-width: 1100px;
  margin: 0 auto;
}
.columna {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 3px solid #13207a;
  background: linear-gradient(#4a6cf0, #2a46d0);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
  min-height: 300px;
}
.columna.oponentes { border-color: #1f6a00; background: linear-gradient(#6ee05a, #2f9a1f); }
.cabeza-columna, .pie-columna {
  margin: 0;
  text-align: center;
  font: bold 13px Verdana, sans-serif;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.pie-columna.chico { font-size: 11px; font-weight: normal; }
.lista {
  list-style: none;
  margin: 0;
  padding: 6px;
  flex: 1;
  min-height: 160px;
  max-height: 440px;
  overflow-y: auto;
  background: #000;
  border-radius: 10px;
  border: 2px solid #fff;
  font-size: 13px;
}
.lista li { padding: 3px 4px; color: #fff; overflow-wrap: anywhere; }
.lista li b { color: var(--amarillo); }
.lista li small { color: var(--suave); }
.lista .vacio { color: #8a8a8a; font-style: italic; font-size: 12px; }
.oponente {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: 13px Verdana, sans-serif;
  text-align: left;
  cursor: pointer;
}
.oponente span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oponente small { flex: none; font-size: 11px; color: #9fe88f; }
.oponente:hover, .oponente:focus-visible { background: #1f4a10; outline: none; }
.oponente:hover small { color: var(--amarillo); }
.oponente.esperando { background: #3a3a00; }
.oponente.esperando small { color: var(--amarillo); }
.oponente.me-reta { background: #6a1a00; animation: titilar 0.8s steps(2) infinite; }

.centro-salon { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.invitacion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 64px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid #13207a;
  background: #070b2a;
  color: var(--texto);
  font-size: 14px;
}
.invitacion p { margin: 0; }
.invitacion b { color: var(--amarillo); }
.invitacion .acciones { display: flex; gap: 8px; }
.invitacion.te-retan { border-color: #1f6a00; background: linear-gradient(#3cbf2a, #1f6a00); color: #fff; animation: latir 1s ease-in-out infinite; }
.invitacion.te-retan p { font: bold 16px Verdana, sans-serif; text-shadow: 0 1px 0 #000; }
.invitacion.retando { border-color: var(--amarillo); }
@keyframes latir { 50% { box-shadow: 0 0 0 4px rgba(255, 243, 107, 0.7); } }
@keyframes titilar { 50% { background: #b03a00; } }
.yo-soy {
  margin: 0;
  align-self: flex-start;
  padding: 4px 14px;
  border-radius: 999px;
  border: 2px solid #8a3a00;
  background: #ffe9b0;
  color: #3a1500;
  font-size: 13px;
}
.chat.grande { height: auto; flex: 1; min-height: 220px; max-height: 360px; border: 3px solid #13207a; }
.botonera { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.botonera .trofeos { flex: 1 1 140px; }
.botonera .trofeos summary { font-size: 13px; }
.botonera .trofeos[open] { flex-basis: 100%; }
.nota { margin: 0; font-size: 12px; color: var(--suave); text-align: center; }
.nota a { color: var(--amarillo); }

.cartel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: rgba(4, 6, 24, 0.72);
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(28px, 6vw, 54px);
  color: var(--amarillo);
  -webkit-text-stroke: 1px #4a1600;
  text-shadow: 3px 3px 0 #000;
  padding: 16px;
}
.cartel[hidden] { display: none; }
.cartel small { font: bold 15px Verdana, sans-serif; color: var(--texto); -webkit-text-stroke: 0; text-shadow: none; }
.cartel .acciones { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.cartel .acciones .boton { font-size: 15px; -webkit-text-stroke: 0; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }

.jugadas {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  pointer-events: none;
  text-align: center;
}
.jugada {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(16px, 3.4vw, 28px);
  color: #fff36b;
  -webkit-text-stroke: 1px #4a1600;
  text-shadow: 2px 2px 0 #000;
  animation: saltar 1.1s ease-out forwards;
}
.jugada.fuerte { font-size: clamp(24px, 5.5vw, 46px); color: var(--naranja); }
@keyframes saltar {
  0% { transform: scale(0.4); opacity: 0; }
  15% { transform: scale(1.15); opacity: 1; }
  30% { transform: scale(1); }
  100% { transform: translateY(-50px); opacity: 0; }
}

.sacudon { animation: sacudir 0.25s; }
@keyframes sacudir {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ---------- Volver a la web, pausa y celular ---------- */
#volver-web { position: absolute; top: 14px; left: 16px; text-decoration: none; display: inline-block; z-index: 2; }
body.jugando #volver-web { top: 8px; }
body.jugando #mudo { top: 8px; }

html { -webkit-text-size-adjust: 100%; }
button, .boton { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body.jugando { overscroll-behavior: none; }

/* Botones en pantalla: solo en pantallas táctiles (la clase la pone main.js). */
.tactil { display: none; }
body.es-tactil.jugando .tactil {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tactil .boton { padding: 0; height: 56px; font-size: 22px; border-radius: 16px; touch-action: none; }
.tactil .boton[data-accion="guardar"], .tactil .boton[data-accion="directa"] { font-size: 14px; }
.tactil .boton.apretado { filter: brightness(0.85); transform: translateY(2px); }
body.es-tactil #pausa { display: none; }

/* ---------- Pantalla justa: todo entra en la ventana (o en el recuadro de la web), sin scroll ---------- */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
main > section { flex: 1; min-height: 0; }
main > .menu { flex: 0 0 auto; }

/* Embebido en mauspi.com la web ya tiene su menú: sin cabecera, solo el botón de sonido flotando. */
body.embebido .cabecera { position: absolute; inset: 0 0 auto auto; padding: 0; z-index: 5; }
body.embebido .logo, body.embebido .bajada { display: none; }
body.embebido #mudo { top: 6px; right: 6px; }
body.embebido main { padding-top: 8px; }
body.embebido #entrada { margin-top: 24px; }

/* Salón: las tres columnas a lo alto; las listas y el chat scrollean por dentro. */
.salon { width: 100%; grid-template-rows: minmax(0, 1fr); }
.columna { min-height: 0; }
.lista { min-height: 0; max-height: none; }
.centro-salon { min-height: 0; position: relative; }
.chat.grande { min-height: 0; max-height: none; }
/* Trofeos y controles se abren flotando, para no empujar nada. */
.botonera { position: relative; }
.botonera .trofeos[open] { flex-basis: auto; }
.botonera .trofeos[open] > :not(summary) {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 6;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--borde);
  background: #0b1036;
  box-shadow: 0 6px 0 #02040f;
}

/* Mesa: los pozos se achican con la altura disponible y mantienen su forma. */
.mesa {
  height: 100%;
  grid-template-columns: minmax(0, 107fr) minmax(200px, 260px) minmax(0, 49fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.lado { min-height: 0; }
.marco { flex: 1; min-height: 0; }
.mesa canvas { width: 100%; height: 100%; object-fit: contain; object-position: center top; }
.centro { min-height: 0; overflow: hidden; }
.chats { flex: 1; min-height: 0; }
.centro .chat { flex: 1; height: auto; min-height: 60px; }

#ver-chat { display: none; }

/* Celular (o ventana angosta): rival chiquito y marcador arriba, tu pozo y los botones abajo; el chat se abre con 💬. */
@media (max-width: 720px) {
  main { padding: 6px 6px 8px; }
  body:not(.embebido) .cabecera { padding: 6px 8px 2px; }
  body:not(.embebido) .logo { font-size: 26px; }
  .bajada { display: none; }
  #volver-web, #mudo { padding: 4px 10px; top: 6px; }
  body:not(.embebido).jugando .cabecera { display: none; }

  .salon {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.6fr);
    padding: 8px;
    gap: 8px;
  }
  .centro-salon { order: -1; }
  .jugando-ya { order: 1; }
  .columna { padding: 6px; }
  .invitacion { min-height: 0; padding: 8px 10px; }

  .mesa {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "rival centro" "propio propio";
    gap: 6px;
  }
  .lado.propio { grid-area: propio; }
  .lado.rival { grid-area: rival; }
  .centro { grid-area: centro; padding: 6px; gap: 4px; }
  .lado.propio .placa, .lado.rival .placa { display: none; }
  .lado.rival .marco { flex: none; }
  .mesa .rival canvas { height: 150px; width: auto; }
  .versus { font-size: 12px; }
  .versus b { font-size: 14px; }
  .marcador { border-spacing: 0 3px; }
  .marcador td, .marcador th { padding: 2px 6px; }
  .marcador td { font-size: 13px; }
  .marcador th { font-size: 11px; }
  #revancha { display: none !important; }
  #ver-chat:not([hidden]) { display: block; }
  .centro > .boton.chico { padding: 3px 10px; font-size: 12px; }
  /* El chat de la partida, flotando arriba del pozo cuando lo abrís. */
  .chats { display: none; }
  body.chat-abierto .chats:not([hidden]) {
    display: flex;
    position: fixed;
    left: 8px;
    right: 8px;
    top: 140px;
    height: min(45%, 320px);
    z-index: 8;
    padding: 8px;
    border-radius: 14px;
    border: 3px solid #8a3a00;
    background: linear-gradient(#ffb347, #ff8a1f);
    box-shadow: 0 6px 0 #4a1600;
  }
  .tactil .boton { height: 50px; }
}
.tactil .boton.hay-mensaje, #ver-chat.hay-mensaje { animation: titilar-boton 0.8s steps(2) infinite; }
@keyframes titilar-boton { 50% { filter: brightness(1.6); } }
