/* Justito: la escena ocupa todo; los carteles flotan encima, con el estilo de Mauspi (botones redondeados con borde
   oscuro) y los colores de la etiqueta (azul profundo, amarillo del sello y blanco). */
:root {
  --azul: #071f4d;
  --azul-2: #0f57c2;
  --amarillo: #f2b705;
  --blanco: #ffffff;
  --vidrio: rgba(6, 26, 66, 0.8);
  --display: "Arial Black", "Arial Rounded MT Bold", "Segoe UI Black", Impact, system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--azul);
  color: var(--blanco);
  font-family: Verdana, Tahoma, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; }

.escena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.zona { position: fixed; inset: 0; z-index: 1; cursor: pointer; }
.capa-marcas { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }

/* ---------- Arriba ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 7;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-der { display: flex; align-items: center; gap: 6px; }
.redondo {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--azul); background: var(--blanco);
  font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 3px 0 var(--azul);
  display: grid; place-items: center; padding: 0; color: var(--azul);
}
.redondo:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--azul); }

/* ---------- Abajo: la ayuda, centrada ---------- */
.ayuda {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100vw - 24px);
  z-index: 3; pointer-events: none; text-align: center; white-space: nowrap;
  bottom: max(18px, env(safe-area-inset-bottom));
  padding: 10px 18px; border-radius: 16px; background: var(--vidrio); border: 2px solid rgba(0, 0, 0, 0.35);
  font-size: 15px; font-weight: bold; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: respira 1.6s ease-in-out infinite;
}
@keyframes respira { 50% { opacity: 0.7; } }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--vidrio); border: 3px solid rgba(0, 0, 0, 0.45); border-radius: 22px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tarjeta h2 { margin: 0 0 6px; font-family: var(--display); font-size: 22px; }
.tarjeta p { margin: 0 0 12px; line-height: 1.45; }

.boton {
  display: block; width: 100%; padding: 13px 16px; border-radius: 16px; border: 3px solid var(--azul);
  background: var(--amarillo); color: var(--azul); font-family: var(--display); font-size: 17px; cursor: pointer;
  box-shadow: 0 4px 0 var(--azul); text-align: center;
}
.boton small { font-family: Verdana, sans-serif; font-weight: bold; font-size: 12px; opacity: 0.75; margin-left: 4px; }
.boton.secundario { background: var(--blanco); }
.boton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--azul); }
.boton:disabled { opacity: 0.55; cursor: default; }
.botones { display: grid; gap: 10px; }
.botones.fila { grid-template-columns: 1fr 1fr; }

/* ---------- La entrada ---------- */
.portada {
  position: fixed; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: flex-start;
  padding: 70px max(16px, 6vw) 24px;
  background: linear-gradient(90deg, rgba(4, 18, 48, 0.72), rgba(4, 18, 48, 0.25) 45%, rgba(4, 18, 48, 0) 60%);
}
.portada-tarjeta { width: min(400px, 100%); }
.marca-juego { position: relative; display: flex; align-items: center; justify-content: center; gap: 4px; margin: 2px 0 10px; }
.logo {
  margin: 0; font-family: var(--display); font-weight: 900; font-size: clamp(46px, 11vw, 70px); line-height: 1;
  color: var(--blanco); -webkit-text-stroke: 10px var(--azul); paint-order: stroke fill; transform: rotate(-3deg);
  text-shadow: 3px 5px 0 rgba(0, 10, 40, 0.45);
}
.sello {
  flex: none; width: 74px; height: 74px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, #fff3a0, var(--amarillo)); border: 4px solid var(--azul);
  color: var(--azul); transform: rotate(8deg); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
.sello b { font-family: var(--display); font-size: 25px; line-height: 0.9; }
.sello small { font-family: var(--display); font-size: 12px; }
.bajada { font-size: 14px; }
.bajada b { color: #ffe27a; }
.p-stats { min-height: 1em; margin: 12px 0 0 !important; font-size: 13px; color: #cfe8ff; text-align: center; }
.invitado { margin: 10px 0 0 !important; font-size: 12px; color: #cfe8ff; text-align: center; }
.creditos { margin: 12px 0 0 !important; font-size: 11px; opacity: 0.65; text-align: center; }
.creditos a { color: inherit; margin-left: 6px; }

/* ---------- El cartel del final: flota entre la canilla y la botella, sin caja (main.js lo ubica) ---------- */
.resultado {
  position: fixed; z-index: 6; left: 50%; top: 30%; transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 24px)); text-align: center;
  text-shadow: 0 1px 3px rgba(0, 10, 30, 0.95), 0 0 10px rgba(0, 10, 30, 0.6);
  animation: entra 0.35s ease-out;
}
@keyframes entra { from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }
.resultado p { margin: 0 0 5px; }
.r-ml, .r-titulo { -webkit-text-stroke: 7px var(--azul); paint-order: stroke fill; text-shadow: 0 4px 0 rgba(0, 10, 30, 0.35); }
.r-ml { font-family: var(--display); font-size: 58px; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.r-titulo { font-family: var(--display); font-size: 26px; color: var(--amarillo); min-height: 1.1em; -webkit-text-stroke-width: 6px; }
.r-texto { font-size: 15px; font-weight: bold; }
.r-gotitas, .r-datos { font-size: 12px; font-weight: bold; color: #e3f2ff; }
.r-record { font-size: 14px; font-weight: bold; color: #59ffa0; }
.r-record:empty { display: none; }
.lista-ranking .t-emoji { font-family: var(--display); font-size: 18px; }
.r-datos { margin-bottom: 10px !important; }
.resultado .boton { text-shadow: none; padding: 10px 14px; }
.resultado.exacto .r-titulo { font-size: 32px; animation: late 0.9s ease-in-out infinite; }
.resultado.rebalse .r-titulo, .resultado.lejos .r-titulo { color: #ff8a7a; }
@keyframes late { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.12); } 30% { transform: scale(1.04); } }

/* ---------- Los números que saltan cuando late ---------- */
.marca {
  position: absolute; transform: translate(-50%, -50%); font-family: var(--display); font-size: 52px; line-height: 1;
  color: var(--blanco); -webkit-text-stroke: 8px var(--azul); paint-order: stroke fill; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); animation: salta 1.25s ease-out forwards;
}
.marca.centena { font-size: 66px; }
.marca.seiscientos { font-size: 88px; color: var(--amarillo); }
@keyframes salta {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  24% { transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(0.95); }
}
.regla {
  position: absolute; left: 0; top: 0; font-weight: bold; font-size: 12px; color: var(--blanco); opacity: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums;
}
.regla.seis { color: var(--amarillo); font-size: 14px; }
.regla.final { color: #59ffa0; font-size: 15px; }

.papelito {
  position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px;
  animation: papel 2.4s cubic-bezier(0.25, 0.6, 0.5, 1) forwards;
}
@keyframes papel { to { transform: translateY(110vh) rotate(var(--giro)); } }

/* ---------- Trofeos ---------- */
.velo {
  position: fixed; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(2, 10, 28, 0.55);
}
.velo .tarjeta { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.lista-trofeos { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.lista-trofeos li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.06); opacity: 0.7;
}
.lista-trofeos li.ganado { background: rgba(242, 183, 5, 0.16); opacity: 1; }
.lista-trofeos b { display: block; font-family: var(--display); font-size: 14px; }
.lista-trofeos small { font-size: 12px; color: #cfe8ff; }
.t-emoji { font-size: 22px; text-align: center; }
.t-xp { font-size: 12px; font-weight: bold; color: var(--amarillo); }

.aviso-trofeo {
  position: fixed; z-index: 10; top: max(64px, calc(env(safe-area-inset-top) + 56px)); left: 50%;
  transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-radius: 16px; background: var(--amarillo); color: var(--azul); border: 3px solid var(--azul);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); pointer-events: none;
}
.aviso-trofeo.entra { animation: baja 0.4s ease-out; }
@keyframes baja { from { opacity: 0; transform: translate(-50%, -14px); } }
.at-emoji { font-size: 28px; }
.aviso-trofeo b { display: block; font-family: var(--display); }
.aviso-trofeo small { font-size: 12px; font-weight: bold; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .portada { align-items: flex-end; justify-content: center; padding: 70px 12px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(4, 18, 48, 0.75), rgba(4, 18, 48, 0) 70%); }
  .r-ml { font-size: 44px; }
  .r-titulo { font-size: 20px; }
  .resultado.exacto .r-titulo { font-size: 26px; }
  .marca { font-size: 40px; }
  .marca.centena { font-size: 50px; }
  .marca.seiscientos { font-size: 66px; }
  .ayuda { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .ayuda, .resultado.exacto .r-titulo { animation: none; }
  .papelito { display: none; }
}
