/* Todo en rem: así el zoom y el tamaño de letra del navegador agrandan el juego
   en vez de no hacer nada. Los colores son los de aidaasistente.com. */
:root {
  --fondo: #f2fafa;
  --tinta: #14343e;
  --petroleo: #196f77;
  --turq: #3bb7b4;
  --texto: #22363c;
  --suave: #55696f;
  --borde-suave: #dce7e8;
  --ambar: #9a6400;
  --papel: #fdf2dc;
  --dorado: #f2b84d;
  --coral: #b94a30;
  --verde: #2c7a53;
  --titulos: Poppins, "Segoe UI", system-ui, sans-serif;
}

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

html { font-size: calc(100% + .75vmin); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: var(--fondo) url("fondo.svg");
  font-family: Nunito, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--tinta); outline-offset: 2px; }

.boton {
  background: var(--color, var(--turq));
  color: #fff;
  border-radius: .9rem;
  font-weight: 800;
  font-size: 1.2rem;
  padding: .7rem .9rem;
  min-height: 3.4rem;
}
.boton:active { filter: brightness(.85); }
.boton.turquesa { color: var(--tinta); }
@media (hover: hover) {
  .boton:hover, .parte:hover, #cabecera:hover { filter: brightness(1.07); }
}

/* ── Barra de arriba ── */
#barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .4rem .75rem;
  background: #fff;
  border-bottom: 1px solid var(--borde-suave);
}
#volver {
  font-weight: 700;
  font-size: .85rem;
  color: var(--petroleo);
  text-decoration: none;
  border: 2px solid var(--borde-suave);
  border-radius: 99px;
  padding: .35rem .75rem;
  white-space: nowrap;
}
#volver:hover { border-color: var(--turq); }
#marcador { display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 1.2rem; font-weight: 800; font-size: .9rem; text-align: right; }
#lbl-mensaje { color: var(--ambar); }
@media (max-width: 599px) {
  #marcador { flex-direction: column; font-size: .75rem; white-space: nowrap; }
  #volver { font-size: .75rem; padding: .3rem .55rem; }
  #botones .boton { white-space: nowrap; font-size: 1.1rem; padding: .5rem .3rem; }
}

/* ── La mesa: en angosto, todo apilado ── */
#mesa {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: .6rem .6rem 0;
}
#zona-telefono { position: relative; flex: 1 1 0; min-height: 15rem; display: flex; }
#telefono {
  flex: 1;
  min-width: 0;
  display: flex;
  background: #1b2b33;
  border: 2px solid #3a5560;
  border-radius: 1.9rem;
  padding: .45rem;
}
#pantalla {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 1.45rem;
  overflow: hidden;
  background: var(--pantalla);
}

#cabecera {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .8rem;
  text-align: left;
  background: var(--cab);
  color: var(--cab-letra);
  border-radius: 1.45rem 1.45rem 0 0;
}
#cabecera.mirada { box-shadow: inset 0 0 0 5px var(--borde); }
#avatar { width: 3rem; height: 3rem; object-fit: contain; flex: none; }
.nombres { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
#nombre { font-size: 1.15rem; font-weight: 800; }
#numero { font-size: .9rem; opacity: .85; }
#icono { font-size: 1.3rem; }

#cuerpo {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: .7rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.parte {
  display: block;
  width: 100%;
  flex: none;
  text-align: left;
  background: var(--burbuja);
  color: var(--letra);
  border: 4px solid transparent;
  border-radius: .8rem;
  padding: .45rem .55rem;
  font-size: 1.15rem;
}
.parte.mirada { border-color: var(--borde); }
.parte.titulo { font-size: 1.25rem; font-weight: 800; background: transparent; padding: .2rem; }
.parte.titulo.mirada { background: #fff8e6; }
.parte.enlace { color: #1d6fd1; text-decoration: underline; overflow-wrap: anywhere; }
.parte .rotulo { display: block; font-size: .85rem; font-weight: 800; opacity: .75; }
.parte img { display: block; width: 100%; height: 8rem; object-fit: contain; }
.parte img.comprobante { height: 11rem; }
.parte img.qr_trampa { height: 9rem; }

/* ── La app del banco ── */
#menu-banco { display: none; }
#pantalla.banco #cabecera { background: #14457a; color: #fff; border-radius: 1.45rem 1.45rem 0 0; }
#pantalla.banco { background: #e9eef5; }
.banco #avatar { background: #fff; border-radius: .7rem; padding: .2rem; }
.banco #cuerpo { gap: 0; }
.banco #cuerpo::before { content: ""; flex: none; height: 2.4rem; margin: -.7rem -.7rem -1.4rem; background: #14457a; border-radius: 0 0 1.2rem 1.2rem; }
.banco .parte { position: relative; background: #fff; text-align: center; box-shadow: 0 .2rem .8rem rgba(20, 69, 122, .16); }
.banco .parte.titulo { border-radius: 1rem 1rem 0 0; background: #fff; padding: .9rem .6rem .5rem; font-size: 1.45rem; color: #14457a; }
.banco .parte.titulo::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin: 0 auto .5rem;
  border-radius: 50%;
  background: var(--verde);
  color: #fff;
  font-size: 1.7rem;
}
.banco .parte.titulo ~ .parte { border-radius: 0 0 1rem 1rem; border-top-color: #e3e9f0; color: var(--suave); padding: .7rem; }
.banco .parte.titulo ~ .parte.mirada { border-color: var(--borde); }
.banco .parte.titulo.mirada { background: #fff8e6; }
.banco #menu-banco { display: flex; justify-content: space-around; padding: .55rem; background: #fff; border-top: 1px solid #d5dee8; }
#menu-banco svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: #8795a8; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#menu-banco svg.activo { stroke: #14457a; }

/* ── AIDA y su globo ── */
#globo {
  position: relative;
  flex: 0 1 auto;
  display: flex;
  min-height: 3rem;
  max-height: 11rem;
  background: #fff;
  border: 3px solid var(--turq);
  border-radius: 1.1rem;
  padding: .6rem .8rem;
}
#globo::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 1.4rem;
  border: .7rem solid transparent;
  border-top-color: var(--turq);
  border-bottom: 0;
}
#globo-texto { flex: 1; min-height: 0; overflow-y: auto; font-size: 1.1rem; white-space: pre-line; }
#globo-texto .bien { color: var(--verde); }
#globo-texto .casi { color: var(--coral); }

#acciones { display: flex; align-items: center; gap: .6rem; flex: none; padding-top: .3rem; }
#aida { width: 4.5rem; height: 4rem; object-fit: contain; transform-origin: 50% 100%; flex: none; }
#btn-ayuda { flex: 1; --color: var(--petroleo); }

#botones {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: .6rem;
  flex: none;
  padding: .1rem 0 .7rem;
  background: var(--fondo);
}
#botones .boton { flex: 1; min-height: 4.2rem; }
#btn-seguro { --color: var(--verde); }
#btn-trampa { --color: var(--coral); }

#sello {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  translate: -50% 0;
  padding: .3rem 1.8rem;
  border: .3rem solid currentColor;
  border-radius: .7rem;
  background: rgba(255, 255, 255, .85);
  font-size: 2.2rem;
  font-weight: 800;
  pointer-events: none;
}
#escua-asoma {
  position: fixed;
  z-index: 4;
  right: 1rem;
  bottom: 5.5rem;
  width: 7rem;
  height: 10rem;
  object-fit: contain;
  transform-origin: 50% 100%;
  pointer-events: none;
}

/* ── Pantalla ancha: teléfono a un lado, AIDA y los botones al otro ── */
@media (min-width: 600px) and (orientation: landscape) {
  #mesa {
    flex: 1 0 0;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas: "tel globo" "tel acciones" "tel botones";
    gap: .8rem 1.2rem;
    max-width: 64rem;
    min-height: 20rem;
    max-height: 46rem;
    padding: .8rem;
  }
  #zona-telefono { grid-area: tel; min-height: 0; }
  #globo { grid-area: globo; align-self: end; max-height: 100%; min-height: 0; }
  #globo-texto { font-size: 1.2rem; }
  #acciones { grid-area: acciones; }
  #aida { width: 6rem; height: 5.5rem; }
  #botones { grid-area: botones; position: static; padding: 0; background: none; }
  #escua-asoma { right: auto; left: 42%; bottom: 0; }
}

/* ── Tarjetas: portada, días y final ── */
#capa { flex: 1; display: flex; flex-direction: column; text-align: center; overflow: hidden; }
.tarjeta {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  padding: 1rem;
  font-weight: 800;
  color: var(--tinta);
}
.tarjeta > * { max-width: 100%; }
.tarjeta .ambar { color: var(--ambar); }
.tarjeta .turq { color: var(--petroleo); }
.tarjeta .boton { width: min(100%, 17rem); flex: none; }
.figura { object-fit: contain; transform-origin: 50% 100%; pointer-events: none; }
.figuras { display: flex; justify-content: center; gap: 2rem; }

.t-titulo, .d-titulo, .f-titulo, .z-titulo, .f-puntos, .z-puntos { font-family: var(--titulos); line-height: 1.15; }
.t-titulo { font-size: 2.7rem; color: var(--petroleo); }
.t-de { font-size: 1rem; color: var(--suave); margin-bottom: -.4rem; }
.marca { display: flex; align-items: center; gap: .6rem; text-align: left; }
.marca img { width: 4.6rem; height: 4.6rem; object-fit: contain; }
.marca-textos { display: flex; flex-direction: column; line-height: 1.05; font-family: var(--titulos); }
.marca-nombre { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; color: var(--petroleo); }
.marca-lema { font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--suave); }
.t-ayuda { font-size: 1.15rem; max-width: 22rem; }
.portada .escua { display: none; }

.d-numero { font-size: 1.1rem; }
.d-titulo { font-size: 2.2rem; }
.consejo {
  background: var(--papel);
  border: 3px solid var(--dorado);
  border-radius: 1.1rem;
  padding: 1.3rem;
  font-size: 1.4rem;
  width: min(100%, 31rem);
}
.inicio .escua { width: 8rem; height: min(10rem, 20vh); }

.f-titulo { font-size: 1.8rem; }
.f-puntos { font-size: 3rem; }
.f-aciertos { font-size: 1.35rem; }
.fin-dia .figura { width: 8rem; height: min(10rem, 22vh); }

.final .figura { width: 9rem; height: min(10rem, 20vh); }
.z-titulo { font-size: 1.8rem; }
.z-puntos { font-size: 2.2rem; }
.z-aciertos { font-size: 1.2rem; }
.promo {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(100%, 32rem);
  background: #fff;
  color: var(--texto);
  border: 3px solid var(--turq);
  border-radius: 1.2rem;
  padding: 1.1rem;
  font-weight: 400;
}
.promo strong { color: var(--petroleo); font-size: 1.35rem; font-family: var(--titulos); }

@media (min-width: 600px) and (orientation: landscape) {
  .tarjeta { gap: .6rem; }
  .t-titulo { font-size: 3.2rem; }
  .portada .escua,
  .con-pista .inicio .escua {
    display: block;
    position: absolute;
    right: 5%;
    top: 50%;
    translate: 0 -50%;
    width: 9rem;
    height: 12rem;
  }
  /* AIDA y la Escúa a los costados, para que entre todo sin bajar. */
  .fin-dia .figuras, .final .figuras { display: contents; }
  .fin-dia .figura, .final .figura { position: absolute; top: 50%; translate: 0 -50%; width: 9rem; height: 12rem; }
  .fin-dia .figura.aida, .final .figura.aida { left: 5%; }
  .fin-dia .figura.escua, .final .figura.otra { right: 5%; }
}

/* ── El piso por donde corre AIDA ── */
.pista { position: relative; flex: none; height: calc(60px * var(--k, 1)); }
.piso {
  position: absolute;
  inset: 0;
  background: #dcf0f0;
  border-top: calc(8px * var(--k, 1)) solid #c6e8e8;
}
.pista canvas { position: absolute; left: 0; bottom: 0; width: 100%; pointer-events: none; }

.escua-hamaca { animation: hamaca 1.8s ease-in-out infinite alternate; }
@keyframes hamaca { from { rotate: -4deg; } to { rotate: 4deg; } }

@media (prefers-reduced-motion: reduce) {
  .escua-hamaca { animation: none; }
}
