/* =========================
   PALETA FARMAAZUL (Cruz Azul)
   ========================= */
:root {
  --fa-navy: #0b2d62;
  --fa-blue: #0057b8;
  --fa-blue-2: #0f4aa2;
  --fa-sky: #6bb6ff;
  --fa-red: #e2231a;
  --fa-white: #ffffff;

  --bg-deep: #00246a;
  --text: #f6f8ff;
  --muted: #b9c7e6;

  --card: rgba(10, 28, 72, 0.55);
  --stroke: rgba(255, 255, 255, 0.12);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);

  --radius-xl: 24px;
  --radius-lg: 18px;
}
html {
  -webkit-text-size-adjust: 100%;
}

/* Reset básico */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}
.app {
  overflow-x: hidden;
}
img,
canvas {
  max-width: 100%;
  display: block;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial;
  color: var(--text);

  /* Fondo sobrio: #00246a con leve degradado vertical y viñetas suaves */
  background: radial-gradient(
      120% 120% at 50% 0%,
      rgba(255, 255, 255, 0.05) 0%,
      rgba(255, 255, 255, 0) 45%
    ),
    radial-gradient(
      140% 140% at 50% 120%,
      rgba(0, 0, 0, 0.35) 0%,
      rgba(0, 0, 0, 0) 55%
    ),
    linear-gradient(180deg, #001a4f 0%, #002e86 40%, #00246a 100%);
  background-attachment: fixed;
}

/* Estado por defecto: SIEMPRE oculta (gana la cascada con !important) */
.promo-mobile {
  display: none !important;
}

/* Solo en móvil la mostramos */
@media (max-width: 640px) {
  .promo-mobile {
    display: block !important;
    margin-top: 0.9rem;
  }
}

/* Layout */
.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.brand-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* Logo: responsive con clamp (sin duplicados) */
.brand-logo {
  height: clamp(26px, 6vw, 42px);
  width: auto;
}

/* Título */
.topbar h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: clamp(1.3rem, 2.2vw, 2rem);
}

/* Botones */
button {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-lg);
  font-weight: 800;
  letter-spacing: 0.2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--fa-blue), var(--fa-sky));
  color: #071a3b;
  padding: 0.9rem 1.2rem;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* No uses visibility:hidden porque deja hueco: lo controlamos con media query abajo */
.btn-ghost {
  background: transparent;
  visibility: hidden;
  color: var(--fa-white);
  padding: 0.9rem 1.2rem;
  border: 2px solid var(--fa-blue);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  max-width: 100%;
}
.controls > * {
  min-width: 0;
}

/* Zona ruleta */
.wheel-zone {
  display: grid;
  grid-template-columns: 1fr min(28rem, 35vw);
  gap: 1.25rem;
  align-items: center;
  width: 100%;
}
.wheel-zone.panel-hidden {
  grid-template-columns: 1fr !important;
}
.wheel-zone.panel-hidden .panel {
  display: none;
}

/* Fallback amplio (navegadores sin dv*): */
.wheel-wrapper {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: min(92vmin, 1100px);
  margin-inline: auto;
  padding: clamp(0.6rem, 1.2vw, 1rem);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--stroke);
}

/* Si el navegador soporta dvh/dvw → más estable */
@supports (height: 1dvh) {
  .wheel-wrapper {
    max-width: min(92dvw, 92dvh, 1100px); /* cuadrada y estable */
  }
}

/* Móvil muy estrecho: un pelín más contenida */
@media (max-width: 640px) {
  .wheel-wrapper {
    padding: 0.5rem;
  }
}

#wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Puntero tipo “pastilla” rojo + cruz blanca */
.pointer-tip {
  --w: 60px;
  --h: 28px;
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  height: var(--h);
  border-radius: 999px;
  background: var(--fa-red);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.pointer-tip::before,
.pointer-tip::after {
  content: "";
  position: absolute;
  background: var(--fa-white);
}
.pointer-tip::before {
  width: 8px;
  height: 18px;
  left: calc(50% - 4px);
  top: 5px;
  border-radius: 2px;
}
.pointer-tip::after {
  width: 18px;
  height: 8px;
  left: calc(50% - 9px);
  top: 10px;
  border-radius: 2px;
}

/* Panel lateral */
.panel {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--stroke);
  min-height: min(80vmin, 980px);
}
.panel h2 {
  margin: 0.2rem 0 1rem;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  font-weight: 800;
}

.prize-list {
  display: grid;
  gap: 0.6rem;
}
.prize {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--stroke);
}
.prize .meta {
  font-size: 0.9rem;
  color: var(--muted);
}
.swatch {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25) inset;
}
.badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  color: var(--fa-white);
}
.badge.ok {
  background: rgba(0, 196, 108, 0.15);
  border-color: rgba(0, 196, 108, 0.35);
  color: #9af0c7;
}
.badge.out {
  background: rgba(226, 35, 26, 0.18);
  border-color: rgba(226, 35, 26, 0.45);
  color: #ffb3ad;
}

/* Pie */
.footnote {
  margin-top: 1.1rem;
  color: var(--muted);
}

/* Modal FarmaAZUL */
.fa-dialog {
  border: 0;
  border-radius: var(--radius-xl);
  padding: 0;
  background: transparent;
}
.fa-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.fa-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: linear-gradient(180deg, var(--fa-navy), #071b3e);
  color: var(--fa-white);
  padding: 0.9rem 1rem 0.7rem;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}
.dialog-title {
  font-weight: 900;
  letter-spacing: 0.3px;
}
.dialog-badge {
  font-weight: 900;
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--fa-red);
  color: var(--fa-white);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.fa-dialog .dialog-body {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  padding: 1rem 1rem 0.5rem;
  color: var(--text);
}
.fa-dialog .dialog-actions {
  background: transparent;
  padding: 0.8rem 1rem 1.1rem;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.fa-dialog .btn-primary {
  width: 100%;
}

/* A11y / toques finales */
.topbar.brand {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.6rem;
}

/* Canvas de efectos (confetti, etc.) */
.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  border-radius: 50%;
}

/* Promo solo móvil */
.promo-mobile {
  display: none;
}
.promo-mobile img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--stroke);
  object-fit: cover;
}
.promo-mobile figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.45rem;
}

/* Activa en móvil y evita cualquier overflow */
@media (max-width: 640px) {
  .promo-mobile {
    display: block;
    margin-top: 0.9rem;
  }
  .wheel-zone {
    grid-template-columns: 1fr;
  }
  .panel {
    display: none;
  } /* si no quieres panel en móvil */
}

/* ====== Breakpoints ====== */
@media (max-width: 1080px) {
  .wheel-zone {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 1rem 0.8rem 1.8rem;
  }

  .topbar h1 {
    font-size: clamp(1rem, 4.2vw, 1.4rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62vw; /* evita que el título empuje a los botones */
  }
  .brand-left {
    gap: 0.6rem;
  }

  /* Botones a ancho completo si es necesario */
  .controls .btn-primary,
  .controls .btn-ghost {
    flex: 1 1 100%;
  }

  /* Si no quieres el reset visible en móvil, ocúltalo sin ocupar espacio */
  .btn-ghost {
    display: none;
  }

  /* Aún más contenida la ruleta en móvil estrecho */
  .wheel-wrapper {
    max-width: min(88vmin, 1100px);
    padding: 0.5rem;
  }
}
