/* ==========================================================
   Juegos de Salón — estilos base compartidos por todos los juegos
   Tono: fiesta nocturna, neón, distendido. Mobile-first.
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Nunito:wght@400;700;900&display=swap');

:root {
  --bg1: #150726;
  --bg2: #2a0a4a;
  --bg3: #0b1e3f;
  --pink: #ff2e88;
  --pink-deep: #c2185b;
  --yellow: #ffd23f;
  --cyan: #2ee6d6;
  --lime: #9dff3a;
  --orange: #ff7a1a;
  --purple: #8a4dff;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --card: #fffdf7;
  --card-ink: #1a1a1a;
  --red: #e0243c;
  --radius: 22px;
  --font-display: 'Bangers', 'Impact', 'Arial Black', sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
  /* Cifras que el jugador lee o compara: en Bangers el 1 y el 7 son casi el mismo trazo */
  --font-num: 'Nunito', system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg1);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 46, 136, 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(46, 230, 214, 0.22), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(138, 77, 255, 0.35), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Partículas / confeti de fondo animado */
.bg-sparkles {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-sparkles span {
  position: absolute; display: block; border-radius: 50%;
  background: var(--yellow); opacity: 0.35;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  from { transform: translateY(110vh) rotate(0deg); }
  to   { transform: translateY(-10vh) rotate(720deg); }
}

.app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto; padding: 16px 18px 32px;
  min-height: 100dvh; display: flex; flex-direction: column;
}

/* --- Tipografía --- */
.display {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  line-height: 0.95;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 46, 136, 0.45);
}
.display--xl { font-size: clamp(2.6rem, 12vw, 4.4rem); }
.display--lg { font-size: clamp(2rem, 9vw, 3.2rem); }
.display--md { font-size: clamp(1.5rem, 6.5vw, 2.2rem); }
.display--sm { font-size: clamp(1.2rem, 5vw, 1.6rem); }
.rainbow {
  background: linear-gradient(90deg, var(--yellow), var(--pink), var(--cyan), var(--lime), var(--yellow));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite;
  text-shadow: none;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}
@keyframes shimmer { to { background-position: 300% 0; } }

p { line-height: 1.5; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.lead { font-size: 1.1rem; font-weight: 700; }

/* --- Botones --- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font-family: var(--font-display); font-size: 1.45rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: #fff;
  padding: 16px 24px; border-radius: 999px;
  background: linear-gradient(180deg, var(--pink), var(--pink-deep));
  box-shadow: 0 6px 0 #7a0f3a, 0 12px 24px rgba(255, 46, 136, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s;
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none; user-select: none; min-height: 60px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a0f3a, 0 6px 12px rgba(255, 46, 136, 0.35); }
.btn:disabled { filter: grayscale(0.6) brightness(0.7); cursor: not-allowed; box-shadow: none; transform: none; }
.btn--yellow { background: linear-gradient(180deg, var(--yellow), var(--orange)); color: #3a1200; box-shadow: 0 6px 0 #9a4a00, 0 12px 24px rgba(255, 210, 63, 0.35); }
.btn--yellow:active { box-shadow: 0 2px 0 #9a4a00, 0 6px 12px rgba(255, 210, 63, 0.35); }
.btn--cyan { background: linear-gradient(180deg, var(--cyan), #14a89b); color: #03302c; box-shadow: 0 6px 0 #0b5f57, 0 12px 24px rgba(46, 230, 214, 0.35); }
.btn--cyan:active { box-shadow: 0 2px 0 #0b5f57, 0 6px 12px rgba(46, 230, 214, 0.35); }
.btn--ghost {
  background: var(--glass); border: 2px solid var(--glass-border); box-shadow: none; color: var(--ink);
  font-size: 1.15rem; min-height: 50px; padding: 12px 18px;
}
.btn--ghost:active { transform: translateY(2px); box-shadow: none; }
.btn--sm { font-size: 1.05rem; min-height: 44px; padding: 10px 16px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* --- Tarjetas de vidrio --- */
.panel {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 18px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.12); border: 1px solid var(--glass-border);
}
.chip--hot { background: var(--pink); border-color: transparent; }
.chip--gold { background: var(--yellow); color: #3a1200; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Panel desplegable --- */
details.panel summary { cursor: pointer; font-weight: 900; font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.panel summary::after { content: '▾'; font-size: 1.3rem; transition: transform 0.2s; }
details.panel[open] summary::after { transform: rotate(180deg); }
details.panel[open] summary { margin-bottom: 12px; }
details.panel summary::-webkit-details-marker { display: none; }

/* --- Cabecera compartida --- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.topbar .back {
  color: var(--ink); text-decoration: none; font-weight: 900; font-size: 1rem;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 999px; padding: 8px 14px;
}

/* --- Animaciones reutilizables --- */
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
.pop { animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.wiggle { animation: wiggle 1.2s ease-in-out infinite; display: inline-block; }
.bounce { animation: bounce 1.4s ease-in-out infinite; display: inline-block; }
.slide-up { animation: slideUp 0.35s ease-out both; }
.shake { animation: shake 0.6s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Confeti (canvas) */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* --- Toggle de idioma --- */
.lang-toggle {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border);
}
.lang-toggle button {
  border: 0; cursor: pointer; border-radius: 999px; padding: 7px 12px;
  font: 900 0.9rem var(--font-body); color: var(--muted); background: transparent;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.lang-toggle button.on { background: var(--yellow); color: #3a1200; transform: scale(1.04); }
.lang-toggle button:active { transform: scale(0.96); }

/* --- Botón de sonido --- */
.sound-toggle {
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--ink);
  width: 44px; height: 44px; border-radius: 999px; font-size: 1.25rem; cursor: pointer; display: grid; place-items: center;
  transition: transform 0.1s;
}
.sound-toggle:active { transform: scale(0.92); }
.topbar .tools { display: flex; gap: 8px; align-items: center; }

/* --- Transición entre turnos (overlay compartido: salud / pásale el celular) --- */
.handoff {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(700px 500px at 50% 20%, rgba(255, 46, 136, 0.45), transparent 65%),
    radial-gradient(600px 500px at 50% 110%, rgba(46, 230, 214, 0.35), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 60%, var(--bg3));
  animation: fadeIn 0.25s ease-out both; text-align: center;
}
.handoff.leaving { animation: fadeOut 0.3s ease-in both; pointer-events: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
.handoff .stage { width: 100%; max-width: 480px; display: grid; gap: 14px; justify-items: center; }
.handoff .stage.pop { animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.cheers { font-size: 5.5rem; line-height: 1; display: flex; gap: 0; }
.cheers span { display: inline-block; }
.cheers .l { animation: clinkL 0.9s cubic-bezier(0.3, 1.4, 0.5, 1) infinite; transform-origin: bottom right; }
.cheers .r { animation: clinkR 0.9s cubic-bezier(0.3, 1.4, 0.5, 1) infinite; transform-origin: bottom left; }
@keyframes clinkL { 0%, 100% { transform: rotate(-18deg) translateX(-6px); } 45% { transform: rotate(10deg) translateX(6px); } }
@keyframes clinkR { 0%, 100% { transform: rotate(18deg) translateX(6px) scaleX(-1); } 45% { transform: rotate(-10deg) translateX(-6px) scaleX(-1); } }
.handoff .title { font-family: var(--font-display); font-size: clamp(2.6rem, 14vw, 4.2rem); letter-spacing: 0.04em; text-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 30px rgba(255, 210, 63, 0.6); line-height: 0.95; }
.handoff .title.gold { color: var(--yellow); }
.handoff .drinkers { margin: 0; }
.handoff .drinkers .chip { font-size: 1.2rem; padding: 10px 18px; }
.handoff .hint { color: var(--muted); font-weight: 800; font-size: 0.9rem; }
.handoff .phone { font-size: 4.5rem; line-height: 1; animation: passPhone 1.4s ease-in-out infinite; }
@keyframes passPhone { 0%, 100% { transform: translateX(-14px) rotate(-8deg); } 50% { transform: translateX(14px) rotate(8deg); } }
.handoff .next-name { font-family: var(--font-display); font-size: clamp(3rem, 16vw, 4.8rem); color: var(--cyan); letter-spacing: 0.04em; text-shadow: 0 5px 0 rgba(0,0,0,0.4), 0 0 36px rgba(46, 230, 214, 0.7); line-height: 0.95; }
.handoff .btn { max-width: 420px; }

/* --- Pantalla opaca compartida: "pásale el celular", toca para ver (modo un celular) --- */
.cover {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; text-align: center; padding: 24px;
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%, var(--bg3)); animation: fadeIn 0.2s both;
}
.cover .big { font-family: var(--font-display); font-size: clamp(2.2rem, 12vw, 3.6rem); color: var(--cyan); letter-spacing: 0.04em; text-shadow: 0 5px 0 rgba(0,0,0,0.4); }
.cover .eye { font-size: 4rem; animation: bounce 1.6s infinite; }


/* --- Chat de sala compartido (canon C-15): burbuja + hoja inferior --- */
/* Vive fuera de las pantallas del juego y por debajo de .handoff (z-index 30),
   así el veredicto de una jugada siempre lo tapa. */
.chat { position: fixed; inset: 0; z-index: 20; pointer-events: none; --kb: 0px; }
.chat > * { pointer-events: auto; }

.chat-fab {
  position: absolute; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--glass-border);
  background: linear-gradient(180deg, rgba(138, 77, 255, 0.95), rgba(42, 10, 74, 0.95));
  color: var(--ink); font-size: 1.5rem; cursor: pointer; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  display: grid; place-items: center; animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
.chat-fab:active { transform: scale(0.94); }
.chat-fab.has-unread { border-color: var(--pink); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 46, 136, 0.6); }
.chat-badge {
  position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px; background: var(--pink); color: #fff; font: 900 0.72rem var(--font-body);
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Etiqueta que se asoma al lado de la burbuja con el mensaje recién llegado */
.chat-peek {
  position: absolute; right: 74px; bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  max-width: min(64vw, 260px); min-height: 54px;
  display: flex; flex-direction: column; justify-content: center; gap: 1px; text-align: left;
  padding: 8px 12px; border-radius: 16px 16px 4px 16px;
  background: linear-gradient(180deg, rgba(42, 10, 74, 0.97), rgba(21, 7, 38, 0.97));
  border: 2px solid var(--glass-border); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  color: var(--ink); font-family: var(--font-body); cursor: pointer;
}
.chat-peek .who { font-size: 0.66rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.07em; }
/* Un mensaje largo se corta en dos líneas: la etiqueta es un aviso, no el chat */
.chat-peek .txt { font-size: 0.85rem; font-weight: 700; line-height: 1.25; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-peek.in { animation: peekIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
.chat-peek.leaving { animation: peekOut 0.28s ease-in both; }
@keyframes peekIn { from { opacity: 0; transform: translateX(16px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes peekOut { to { opacity: 0; transform: translateX(10px) scale(0.96); } }

.chat-sheet { position: absolute; inset: 0; display: grid; align-items: end; }
.chat-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); animation: fadeIn 0.2s both; }
.chat-panel {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  height: min(62dvh, 520px); display: grid; grid-template-rows: auto 1fr auto;
  border-radius: 22px 22px 0 0; border: 2px solid var(--glass-border); border-bottom: 0;
  background: linear-gradient(180deg, rgba(42, 10, 74, 0.985), rgba(21, 7, 38, 0.99));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(calc(-1 * var(--kb))); transition: transform 0.15s ease-out;
  animation: slideUp 0.25s ease-out both;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 6px; border-bottom: 1px solid var(--glass-border); }
.chat-head b { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: 0.05em; }
.chat-x { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; width: 44px; height: 44px; cursor: pointer; }
.chat-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
/* Los mensajes se apoyan abajo, pegados al campo de texto, como en cualquier chat */
.chat-list > :first-child { margin-top: auto; }
.chat-empty { color: var(--muted); font-weight: 800; text-align: center; margin: auto 0; font-size: 0.9rem; }
.chat-msg {
  max-width: 84%; align-self: flex-start; padding: 7px 11px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-border); animation: pop 0.2s ease-out both;
}
.chat-msg.mine { align-self: flex-end; background: rgba(46, 230, 214, 0.16); border-color: rgba(46, 230, 214, 0.4); }
.chat-msg.grouped { margin-top: -4px; }
.chat-msg .who { display: block; font-size: 0.68rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 1px; }
.chat-msg .txt { font-size: 0.92rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--glass-border); }
/* 16px exactos: con menos, iOS hace zoom al enfocar el campo */
.chat-form input { width: 100%; font: 700 16px var(--font-body); color: var(--ink); background: rgba(0, 0, 0, 0.35); border: 2px solid transparent; border-radius: 999px; padding: 11px 16px; outline: none; }
.chat-form input:focus { border-color: var(--cyan); }
.chat-form input::placeholder { color: rgba(255, 255, 255, 0.35); }
.chat-send { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--cyan); color: #03302c; font-size: 1.2rem; cursor: pointer; }
.chat-send:active { transform: scale(0.94); }
