/* =============================================================
   EL REGALO DE SER SU HIJO - JUEGO
   Estilos generales - Inspirado en el forro del libro
   ============================================================= */

   :root {
    /* Paleta oficial extraída del forro del libro */
    --frambuesa: #D60D47;
    --frambuesa-claro: #E6396B;
    --frambuesa-suave: #FCE8EE;
  
    --azul-rey: #4054A1;
    --azul-claro: #5A6FC2;
    --azul-suave: #EBF0FA;
  
    --verde-hoja: #52AE32;
    --verde-claro: #5CB838;
    --verde-suave: #EAF6E7;
  
    --amarillo-sol: #FBB900;
  
    --blanco: #FFFFFF;
    --crema: #FFFDF7;
    --gris-texto: #333333;
  
    --azul: var(--azul-rey);
    --verde: var(--verde-hoja);
    --verde-claro: var(--verde-titulo);
    --amarillo: var(--amarillo-sol);
    --amarillo-suave: #FFF7D6;
    --celeste: var(--crema);
  
    --sombra: 0 8px 20px rgba(64, 84, 161, 0.20);
    --sombra-suave: 0 12px 30px rgba(214, 13, 71, 0.16);
    --radio: 24px;
  }
  
  * {
    box-sizing: border-box;
  }
  
  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Baloo 2', 'Comic Sans MS', sans-serif;
    background: var(--crema);
    color: var(--gris-texto);
    -webkit-user-select: none;
    user-select: none;
  }
  
  #app {
    position: relative;
    width: 100%;
    height: 100%;
  }
  
  button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
  }
  
  img {
    -webkit-user-drag: none;
    user-drag: none;
  }
  
  /* =============================================================
     PANTALLAS
     ============================================================= */
  
  .screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: auto;
  }
  
  .screen.active {
    display: block;
  }
  
  .oculto {
    display: none !important;
  }
  
  /* =============================================================
     PORTADA
     ============================================================= */
  
  .portada-bg {
    width: 100%;
    height: 100vh;
    min-height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    box-sizing: border-box;
    background: var(--frambuesa);
  }
  
  .portada-bg::before,
  .portada-bg::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    pointer-events: none;
  }
  
  .portada-bg::before {
    width: 46vmax;
    height: 46vmax;
    top: -18vmax;
    left: -14vmax;
  }
  
  .portada-bg::after {
    width: 38vmax;
    height: 38vmax;
    bottom: -16vmax;
    right: -12vmax;
    background: rgba(255, 255, 255, 0.08);
  }
  
  .portada-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
  }
  
  .portada-card {
    width: min(920px, 92vw);
    height: min(850px, 94vh);
    background: var(--blanco);
    border-radius: 28px;
    padding: 20px 34px 15px;
    box-shadow: 0 24px 50px rgba(20, 40, 10, 0.28);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    overflow: hidden;
  }
  
  .portada-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: linear-gradient(90deg, var(--frambuesa) 0%, var(--azul-rey) 50%, var(--verde-hoja) 100%);
  }
  
  .portada-card::after {
    content: "";
    position: absolute;
    inset: 14px 10px 10px;
    border-radius: 18px;
    pointer-events: none;
    box-shadow: inset 0 0 0 3px rgba(64, 84, 161, 0.05);
  }
  
  .titulo {
    width: min(800px, 95%);
    max-height: 45%;
    height: auto;
    object-fit: contain;
    display: block;
    margin-top: 0;
    margin-bottom: -15px;
    filter: drop-shadow(0 6px 3px rgba(0, 0, 0, 0.12));
    position: relative;
    z-index: 2;
  }
  
  .portada-media {
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    min-height: 0;
    margin-top: -15px;
  }
  
  .portada-imagen {
    max-width: 750px;
    width: auto;
    max-height: 100%;
    height: auto;
    border-radius: 16px;
    border: 8px solid var(--blanco);
    outline: 3px solid var(--verde-hoja);
    box-shadow: var(--sombra);
    background: var(--blanco);
    display: block;
    object-fit: contain;
  }
  
  .portada-botones {
    flex: 0 0 auto;
    display: flex;
    gap: 18px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: -10px;
    margin-bottom: 5px;
    position: relative;
    z-index: 2;
  }
  
  .portada-footer {
    flex: 0 0 auto;
    width: 100%;
    margin-top: 4px;
    text-align: center;
    color: var(--azul-rey);
    opacity: 0.75;
    font-size: 13px;
    padding-top: 8px;
    border-top: 1px solid rgba(64, 84, 161, 0.12);
    box-sizing: border-box;
  }
  
  .portada-logo-peq {
    position: absolute;
    right: 18px;
    bottom: 14px;
    width: 40px;
    height: auto;
    opacity: 0.95;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.12));
  }
  
  @media (max-width: 920px) {
    .portada-card {
      width: 94vw;
      height: min(800px, 92vh);
      padding: 20px 20px 16px;
    }
    .titulo { width: min(650px, 95%); max-height: 40%; margin-bottom: -10px; }
    .portada-imagen { max-width: 600px; }
    .portada-media { margin-top: -10px; }
  }
  
  @media (max-width: 540px) {
    .portada-card {
      width: 94vw;
      height: min(700px, 90vh);
      padding: 16px 16px 14px;
      gap: 2px;
    }
    .titulo { width: 95%; max-height: 35%; margin-bottom: -10px; }
    .portada-imagen { max-width: 420px; border-width: 6px; border-radius: 12px; }
    .portada-media { margin-top: -10px; }
    .btn-grande { font-size: 15px; padding: 10px 16px; }
    .portada-footer { font-size: 11px; padding-top: 6px; }
    .portada-logo-peq { width: 32px; right: 12px; bottom: 10px; }
  }
  
  @media (max-height: 480px) and (orientation: landscape) {
    .portada-card { height: 94vh; padding: 16px 20px 10px; gap: 2px; }
    .titulo { width: 50%; max-height: 30%; margin-bottom: -5px; }
    .portada-imagen { max-height: 100%; }
    .portada-media { margin-top: -5px; }
    .portada-footer { display: none; }
  }
  
  /* =============================================================
     BOTONES
     ============================================================= */
  
  .btn {
    font-weight: 700;
    font-size: 18px;
    padding: 14px 28px;
    border-radius: 999px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--sombra);
    color: var(--blanco);
    border: 3px solid transparent;
  }
  
  .btn:active {
    transform: scale(0.94);
  }
  
  .btn-primary {
    background: var(--verde-hoja);
    box-shadow: 0 8px 0 rgba(82, 174, 50, 0.4);
  }
  
  .btn-secundario {
    background: var(--azul-rey);
    box-shadow: 0 8px 0 rgba(64, 84, 161, 0.4);
  }
  
  .btn-grande {
    font-size: 20px;
    padding: 16px 34px;
  }
  
  .btn-icon {
    margin-right: 6px;
  }
  
  /* =============================================================
     PANELES CENTRADOS / TARJETAS
     ============================================================= */
  
  .panel-centrado {
    width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--crema);
  }
  
  .fondo-nivel1 {
    background: var(--azul-suave);
  }
  
  .fondo-nivel2 {
    background: var(--amarillo-suave);
  }
  
  .fondo-nivel3 {
    background: var(--verde-suave);
  }
  
  .fondo-final {
    background: var(--frambuesa-suave);
  }
  
  .tarjeta {
    background: var(--blanco);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 32px 28px;
    max-width: 520px;
    width: 100%;
    text-align: center;
    border: 4px solid var(--azul-rey);
  }
  
  .tarjeta-logo {
    width: 56px;
    margin-bottom: 8px;
  }
  
  .titulo-marca {
    color: var(--verde-hoja);
    font-weight: 800;
    font-size: 26px;
    margin: 6px 0 16px;
  }
  
  .emoji-grande {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 6px;
  }
  
  .texto-mensaje {
    font-size: 18px;
    line-height: 1.5;
    color: var(--gris-texto);
    margin-bottom: 20px;
  }
  
  .instruccion-bloque {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    background: var(--azul-suave);
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 14px;
  }
  
  .instruccion-bloque h3 {
    margin: 0 0 4px;
    color: var(--azul-rey);
    font-size: 17px;
  }
  
  .instruccion-bloque p {
    margin: 0;
    font-size: 15px;
    line-height: 1.4;
  }
  
  .instruccion-icono {
    font-size: 30px;
    flex-shrink: 0;
  }
  
  .nota-adulto {
    font-size: 13px;
    color: #8a8397;
    margin: 12px 0 20px;
  }
  
  /* =============================================================
     CONTENEDOR DE JUEGO (niveles)
     ============================================================= */
  
  .juego-contenedor {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--crema);
    padding: 14px;
    gap: 10px;
  }
  
  .juego-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .etiqueta-nivel {
    background: var(--azul-rey);
    color: var(--blanco);
    font-weight: 700;
    font-size: 15px;
    padding: 8px 16px;
    border-radius: 999px;
  }
  
  .etiqueta-progreso {
    background: var(--verde-hoja);
    color: var(--blanco);
    font-weight: 700;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 999px;
  }
  
  /* =============================================================
     NIVEL 1 - LA FILA DE NÚMEROS
     ============================================================= */
  
  .n1-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 0;
    padding: 10px;
  }
  
  .n1-linea-wrap {
    width: 100%;
    max-width: 1100px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .n1-papa-dios,
  .n1-regalo {
    height: min(18vh, 130px);
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
  }
  
  .n1-pista {
    position: relative;
    flex: 1;
    min-width: 0;
    padding-bottom: 46px;
  }
  
  .n1-linea {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
    background: var(--blanco);
    border-radius: 18px;
    border: 4px solid var(--azul-rey);
  }
  
  .n1-slot {
    flex-shrink: 0;
    width: 68px;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blanco);
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.10);
  }
  
  .n1-slot img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
  }
  
  .n1-slot-vacio {
    background: var(--amarillo-suave);
    border: 3px dashed var(--amarillo);
    position: relative;
  }
  
  .n1-slot-vacio::after {
    content: "?";
    position: absolute;
    font-size: 28px;
    font-weight: 800;
    color: var(--amarillo);
  }
  
  .n1-slot-colocado {
    animation: popIn 0.35s ease;
  }
  
  @keyframes popIn {
    0% { transform: scale(0.4); opacity: 0; }
    70% { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
  }
  
  /* --------- HUELLA ---------
     Animación con `left` (compatible con el JS).
     La imagen interior se voltea con scaleX(-1) para apuntar al regalo. */
  
  .n1-huella {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 44px;
    transition: left 0.5s ease;
  }
  
  .n1-huella img {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    transform: scaleX(-1);   /* ← Voltea la huella horizontalmente */
  }
  
  .n1-bandeja {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 14px;
    background: var(--azul-suave);
    border-radius: 18px;
    min-height: 96px;
    border: 3px solid var(--azul-rey);
  }
  
  .n1-ficha {
    width: 64px;
    height: 86px;
    background: var(--blanco);
    border-radius: 12px;
    box-shadow: var(--sombra);
    padding: 6px;
    touch-action: manipulation;
    transition: transform 0.15s ease;
    border: 2px solid var(--verde-hoja);
  }
  
  .n1-ficha img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
  }
  
  .n1-ficha:active {
    transform: scale(0.9);
  }
  
  /* =============================================================
     NIVEL 2 - ¿ESTÁ BIEN O ESTÁ MAL?
     ============================================================= */
  
  .n2-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    min-height: 0;
    padding: 10px;
  }
  
  .n2-tarjeta {
    position: relative;
    width: min(420px, 80vw);
    height: min(50vh, 420px);
    background: var(--blanco);
    border-radius: 24px;
    box-shadow: var(--sombra);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
    border: 5px solid var(--frambuesa);
  }
  
  .n2-imagen {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .n2-imagen img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  
  .n2-emoji {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    animation: popIn 0.3s ease;
  }
  
  .n2-emoji img {
    width: 60%;
    max-width: 220px;
    height: auto;
  }
  
  .n2-botones {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .btn-n2 {
    font-size: 19px;
    padding: 18px 30px;
    touch-action: manipulation;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
  }
  
  .btn-n2-bien {
    background: var(--verde-hoja);
  }
  
  .btn-n2-mal {
    background: var(--frambuesa);
  }
  
  .btn-n2:disabled {
    opacity: 0.6;
    pointer-events: none;
  }
  
  /* =============================================================
     NIVEL 3 - CUENTA LOS REGALOS
     ============================================================= */
  
  .n3-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 0;
    padding: 6px;
  }
  
  .n3-prompt {
    font-size: 19px;
    font-weight: 700;
    color: var(--azul-rey);
    text-align: center;
    margin: 0;
    max-width: 700px;
  }
  
  .n3-contador {
    font-size: 15px;
    font-weight: 700;
    color: var(--verde-hoja);
    margin: 0;
  }
  
  .n3-escena-wrap {
    position: relative;
    width: 100%;
    max-width: 1100px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--sombra);
    flex-shrink: 1;
    min-height: 0;
    border: 6px solid var(--amarillo-sol);
    box-sizing: border-box;
  }
  
  .n3-escena-img {
    width: 100%;
    height: auto;
    display: block;
    background: var(--blanco);
  }
  
  .n3-capa-puntos {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  
  .n3-punto {
    position: absolute;
    width: var(--radio-punto, 60px);
    height: var(--radio-punto, 60px);
    border-radius: 50%;
    background: transparent;
    border: none;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    box-sizing: border-box;
    pointer-events: auto;
  }
  
  .n3-punto::after {
    content: "";
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%) scale(0.6);
    font-weight: 800;
    font-size: 20px;
    color: var(--blanco);
    background: var(--verde-hoja);
    border: 2px solid var(--blanco);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-sizing: border-box;
  }
  
  .n3-punto-tocado::after {
    content: attr(data-numero);
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  
  .n3-punto-tocado:not([data-numero])::after {
    content: "";
    opacity: 0;
  }
  
  .n3-punto:hover {
    background: rgba(82, 174, 50, 0.10);
  }
  
  .n3-zona {
    position: absolute;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    border-radius: 20px;
    pointer-events: auto;
  }
  
  .n3-marca-clic {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(82, 174, 50, 0.6);
    border: 2px solid var(--verde-hoja);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: destello 0.6s ease forwards;
  }
  
  @keyframes destello {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  }
  
  .n3-panel-numeros {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    max-width: 900px;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--blanco);
    border: 3px dashed var(--verde-hoja);
    border-radius: 14px;
    min-height: 48px;
    box-shadow: var(--sombra-suave);
    box-sizing: border-box;
  }
  
  .n3-panel-numero {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--verde-hoja);
    color: var(--blanco);
    font-weight: 800;
    font-size: 14px;
    border: 2px solid var(--blanco);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: popIn 0.3s ease;
    box-sizing: border-box;
  }
  
  .n3-opciones {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .n3-opcion-numero {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--blanco);
    border: 4px solid var(--azul-rey);
    color: var(--azul-rey);
    font-size: 24px;
    font-weight: 800;
    box-shadow: var(--sombra);
    touch-action: manipulation;
    transition: transform 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
  }
  
  .n3-opcion-numero:active {
    transform: scale(0.9);
  }
  
  .n3-opcion-correcta {
    background: var(--verde-hoja);
    border-color: var(--verde-hoja);
    color: var(--blanco);
  }
  
  .n3-opcion-incorrecta {
    animation: sacudir 0.4s ease;
    border-color: var(--frambuesa);
    color: var(--frambuesa);
  }
  
  @keyframes sacudir {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
  }
  
  @media (max-width: 600px) {
    .n3-punto {
      width: var(--radio-punto, 45px);
      height: var(--radio-punto, 45px);
    }
    .n3-punto::after {
      width: 22px;
      height: 22px;
      font-size: 16px;
      top: -12px;
    }
    .n3-panel-numeros {
      gap: 4px;
      padding: 6px 8px;
      min-height: 40px;
    }
    .n3-panel-numero {
      width: 22px;
      height: 22px;
      font-size: 12px;
    }
  }
  
  /* =============================================================
     EFECTOS DE ERROR
     ============================================================= */
  
  .n1-ficha-error {
    animation: sacudir 0.4s ease;
    border-color: var(--frambuesa) !important;
    background: var(--frambuesa-suave) !important;
  }
  
  /* =============================================================
     CONFETI
     ============================================================= */
  
  .confeti {
    position: fixed;
    top: -20px;
    font-size: 22px;
    animation: caer 2.2s linear forwards;
    z-index: 999;
    pointer-events: none;
  }
  
  @keyframes caer {
    to {
      transform: translateY(110vh) rotate(360deg);
      opacity: 0.3;
    }
  }
  
  /* =============================================================
     RESPONSIVE GENERAL
     ============================================================= */
  
  @media (max-width: 600px) {
    .titulo-marca { font-size: 21px; }
    .texto-mensaje { font-size: 16px; }
    .tarjeta { padding: 24px 18px; }
    .btn-grande { font-size: 17px; padding: 14px 24px; }
    .etiqueta-nivel, .etiqueta-progreso { font-size: 13px; padding: 7px 12px; }
  
    .n1-papa-dios, .n1-regalo { height: 80px; }
    .n1-slot { width: 52px; height: 72px; }
    .n1-slot-vacio::after { font-size: 22px; }
    .n1-huella { width: 34px; }
    .n1-ficha { width: 52px; height: 70px; }
  
    .n2-tarjeta { width: 88vw; height: 42vh; }
    .btn-n2 { font-size: 16px; padding: 14px 22px; }
  
    .n3-prompt { font-size: 16px; }
    .n3-punto { width: 32px; height: 32px; font-size: 15px; }
    .n3-opcion-numero { width: 50px; height: 50px; font-size: 20px; }
  }
  
  @media (max-width: 380px) {
    .n1-slot { width: 44px; height: 62px; }
    .n1-ficha { width: 44px; height: 60px; }
  }
  
  @media (max-height: 480px) and (orientation: landscape) {
    .juego-contenedor { padding: 8px; gap: 6px; }
    .tarjeta { padding: 18px 16px; }
    .emoji-grande { font-size: 40px; }
    .titulo-marca { font-size: 19px; margin: 4px 0 10px; }
    .texto-mensaje { font-size: 15px; margin-bottom: 14px; }
  
    .n1-papa-dios, .n1-regalo { height: 56px; }
    .n1-slot { width: 42px; height: 58px; }
    .n1-bandeja { padding: 8px; min-height: 70px; }
    .n1-ficha { width: 42px; height: 58px; }
  
    .n2-tarjeta { height: 60vh; }
    .n3-escena-wrap { max-width: 60vh; }
  }