:root{
    --dark-purple:#1a0b2e;
    --wine:#4a1942;
    --gold:#f3c623;
    --purple-btn:#7b2fbe;
    --red-error:#e74c3c;
    --red-soft:#c96a78;
    --green-success:#2ecc71;
    --text-light:#ffffff;
  }

  *{ box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }

  html, body{ height:100%; }
  html{ -webkit-text-size-adjust:100%; }

  body{
    font-family:'Quicksand', sans-serif;
    min-height:100vh;
    min-height:100dvh;
    overflow-x:hidden;
    color:var(--text-light);
    position:relative;
    background: linear-gradient(-45deg, #1a0b2e, #4a1942, #7b2fbe, #2d1150);
    background-size: 400% 400%;
    animation: gradientShift 16s ease infinite;
    touch-action: manipulation;
  }

  @keyframes gradientShift{
    0%{ background-position:0% 50%; }
    50%{ background-position:100% 50%; }
    100%{ background-position:0% 50%; }
  }

  /* Textura sutil de pergamino / estrellas mágicas */
  body::before{
    content:"";
    position:fixed;
    inset:0;
    z-index:0;
    pointer-events:none;
    background-image:
      radial-gradient(circle at 10% 20%, rgba(243,198,35,0.08) 0, transparent 40%),
      radial-gradient(circle at 80% 10%, rgba(243,198,35,0.06) 0, transparent 35%),
      radial-gradient(circle at 50% 80%, rgba(123,47,190,0.15) 0, transparent 45%),
      repeating-radial-gradient(circle at 30% 60%, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 40px);
  }

  #confetti-canvas{
    position:fixed;
    inset:0;
    z-index:50;
    pointer-events:none;
  }

  #sparkles{
    position:fixed;
    inset:0;
    z-index:1;
    pointer-events:none;
    overflow:hidden;
  }

  .sparkle{
    position:absolute;
    color:var(--gold);
    opacity:0.7;
    animation: floatUp linear infinite;
    text-shadow: 0 0 6px rgba(243,198,35,0.8);
  }

  @keyframes floatUp{
    0%{ transform:translateY(110vh) scale(0.6) rotate(0deg); opacity:0; }
    10%{ opacity:0.8; }
    90%{ opacity:0.6; }
    100%{ transform:translateY(-10vh) scale(1.1) rotate(360deg); opacity:0; }
  }

  .screen{
    display:none;
    min-height:100vh;
    width:100%;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    padding:2rem 1.2rem;
    text-align:center;
    position:relative;
    z-index:2;
  }

  .screen.active{ display:flex; }

  /* ---------- PANTALLA INICIO ---------- */
  .banner{
    font-family:'Poppins', sans-serif;
    font-weight:800;
    font-size: clamp(1.8rem, 6vw, 3rem);
    background: linear-gradient(90deg, var(--gold), #fff8dc, var(--gold));
    -webkit-background-clip:text;
    background-clip:text;
    color:transparent;
    text-shadow: 0 0 25px rgba(243,198,35,0.4);
    margin-bottom:1rem;
    animation: pulseGlow 2.5s ease-in-out infinite;
  }

  @keyframes pulseGlow{
    0%,100%{ filter:drop-shadow(0 0 6px rgba(243,198,35,0.5)); }
    50%{ filter:drop-shadow(0 0 18px rgba(243,198,35,0.9)); }
  }

  .icon-central{
    font-size: clamp(4rem, 16vw, 7rem);
    margin: 1rem 0;
    animation: bounce 3s ease-in-out infinite;
  }

  @keyframes bounce{
    0%,100%{ transform:translateY(0) rotate(-3deg); }
    50%{ transform:translateY(-18px) rotate(3deg); }
  }

  .subtitle{
    font-family:'Poppins', sans-serif;
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: var(--gold);
    margin-bottom:2.2rem;
    letter-spacing:1px;
  }

  .rules{
    max-width:480px;
    background:rgba(255,255,255,0.07);
    border:1px solid rgba(243,198,35,0.3);
    border-radius:18px;
    padding:1.2rem 1.5rem;
    margin-bottom:2rem;
    font-size:0.95rem;
    line-height:1.6;
  }

  .btn-primary{
    font-family:'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--gold), #d99b1e);
    color:#2b1206;
    border:none;
    padding: 0.9rem 2.2rem;
    font-size:1.1rem;
    font-weight:700;
    border-radius:50px;
    cursor:pointer;
    box-shadow: 0 6px 20px rgba(243,198,35,0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .btn-primary:hover{
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 28px rgba(243,198,35,0.55);
  }

  .btn-primary:active{ transform: translateY(0) scale(0.98); }

  .btn-primary, .btn-secondary, .option-btn{ min-height:48px; }

  .btn-secondary{
    font-family:'Poppins', sans-serif;
    background: rgba(255,255,255,0.08);
    color: var(--text-light);
    border: 1px solid rgba(243,198,35,0.35);
    padding: 0.7rem 1.6rem;
    font-size:0.9rem;
    font-weight:600;
    border-radius:50px;
    cursor:pointer;
    margin-top:1rem;
    transition: transform 0.2s ease, background 0.2s ease;
  }

  .btn-secondary:hover{
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
  }

  .reset-icon{
    flex: 0 0 auto;
    padding:0.35rem 0.6rem;
    font-size:0.95rem;
    line-height:1;
    min-height:auto;
    margin-top:0;
  }

  /* ---------- PANTALLA JUEGO ---------- */
  #screen-game{ justify-content:flex-start; padding-top:0; }

  .header-game{
    position:sticky;
    top:0;
    width:100%;
    display:flex;
    flex-wrap:nowrap;
    align-items:flex-start;
    justify-content:space-between;
    gap:0.4rem;
    padding: 0.55rem 0.7rem;
    background: rgba(26, 11, 46, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(243,198,35,0.25);
    z-index:5;
  }

  .candles{
    display:flex;
    flex-wrap:wrap;
    align-content:flex-start;
    gap:0.1rem;
    flex:1 1 auto;
    min-width:0;
    padding-top:0.2rem;
  }

  .candle{
    position:relative;
    font-size: clamp(0.6rem, 2.4vw, 1.05rem);
    filter: grayscale(1) opacity(0.4);
    transition: filter 0.4s ease, transform 0.4s ease;
  }

  .candle.lit{
    filter: grayscale(0) opacity(1) drop-shadow(0 0 6px var(--gold));
    transform: scale(1.15);
    animation: candleLight 0.5s ease;
  }

  @keyframes candleLight{
    0%{ transform: scale(0.9); }
    50%{ transform: scale(1.3); }
    100%{ transform: scale(1.15); }
  }

  .candle.out{
    animation: candleSnuff 0.9s ease forwards;
  }

  @keyframes candleSnuff{
    0%{ filter: grayscale(0) opacity(1) drop-shadow(0 0 6px #ffb347); transform: scale(1.05); }
    35%{ filter: grayscale(0.4) opacity(0.65) drop-shadow(0 0 2px #ffb347); transform: scale(0.92) rotate(-5deg); }
    100%{ filter: grayscale(1) opacity(0.3); transform: scale(0.85) rotate(0deg); }
  }

  .candle.out::after{
    content:'💨';
    position:absolute;
    top:-4px;
    left:50%;
    font-size:0.75em;
    opacity:0;
    transform:translateX(-50%);
    animation: candleSmoke 1s ease forwards;
    animation-delay:0.2s;
  }

  @keyframes candleSmoke{
    0%{ opacity:0; transform:translate(-50%,0) scale(0.6); }
    40%{ opacity:0.55; }
    100%{ opacity:0; transform:translate(-50%,-16px) scale(1.1); }
  }

  .money{
    flex: 0 0 auto;
    font-family:'Poppins', sans-serif;
    font-weight:700;
    font-size: clamp(0.75rem, 3vw, 1.3rem);
    background: rgba(243,198,35,0.12);
    border: 1px solid rgba(243,198,35,0.4);
    padding: 0.3rem 0.6rem;
    border-radius: 50px;
    white-space:nowrap;
  }

  .money.negative{ color: #ff8a8a; }

  .game-body{
    width:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    flex:1;
    padding: 1.5rem 1rem 3rem;
  }

  .question-card{
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(243,198,35,0.3);
    border-radius: 22px;
    padding: 2rem 1.6rem;
    max-width: 620px;
    width: 100%;
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  }

  .question-image-wrap{
    width:100%;
    max-width:280px;
    margin:0 auto 1rem;
    border-radius:18px;
    overflow:hidden;
    border:3px solid rgba(243,198,35,0.5);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    aspect-ratio: 4 / 3;
  }

  /* ---------- PANTALLA DE BLOQUEO (espera entre preguntas) ---------- */
  .lock-card{
    text-align:center;
  }

  .lock-emoji{
    font-size: clamp(3rem, 12vw, 4.5rem);
    margin-bottom:0.6rem;
    animation: lockPulse 2.4s ease-in-out infinite;
  }

  @keyframes lockPulse{
    0%,100%{ transform: scale(1); opacity:1; }
    50%{ transform: scale(1.08); opacity:0.85; }
  }

  .lock-title{
    font-family:'Poppins', sans-serif;
    font-weight:700;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: var(--gold);
    margin-bottom:0.6rem;
  }

  .lock-text{
    font-size:1rem;
    margin-bottom:0.8rem;
  }

  .lock-countdown{
    font-family:'Poppins', sans-serif;
    font-weight:800;
    font-size: clamp(2.2rem, 10vw, 3.4rem);
    color: var(--gold);
    text-shadow: 0 0 20px rgba(243,198,35,0.5);
    letter-spacing:2px;
    margin-bottom:1.2rem;
    font-variant-numeric: tabular-nums;
  }

  .lock-hint{
    font-size:0.9rem;
    color: rgba(255,255,255,0.7);
    line-height:1.5;
    max-width:420px;
    margin:0 auto;
  }

  .question-image-wrap img{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
  }

  .category-emoji{
    font-size: 2.6rem;
    margin-bottom: 0.4rem;
    animation: wiggle 2s ease-in-out infinite;
  }

  @keyframes wiggle{
    0%,100%{ transform: rotate(-6deg); }
    50%{ transform: rotate(6deg); }
  }

  .q-counter{
    font-size:0.85rem;
    color: var(--gold);
    text-transform:uppercase;
    letter-spacing:1.5px;
    margin-bottom:0.8rem;
  }

  .question-text{
    font-family:'Poppins', sans-serif;
    font-size: clamp(1.15rem, 3.4vw, 1.6rem);
    margin-bottom:1.6rem;
    line-height:1.4;
  }

  .options{
    display:grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  @media (min-width:600px){
    .options{ grid-template-columns: 1fr 1fr; }
  }

  .option-btn{
    font-family:'Quicksand', sans-serif;
    font-weight:600;
    font-size:1rem;
    background: rgba(123,47,190,0.35);
    border: 2px solid rgba(243,198,35,0.25);
    color: var(--text-light);
    padding: 0.9rem 1rem;
    border-radius: 16px;
    cursor:pointer;
    text-align:left;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  }

  .option-btn:not(:disabled):hover{
    background: rgba(123,47,190,0.6);
    border-color: var(--gold);
    transform: translateY(-2px);
  }

  .option-btn:disabled{ cursor:default; }

  .option-btn.correct{
    background: var(--green-success) !important;
    border-color: #1b9e50 !important;
    color:#06210f;
    animation: correctPulse 0.5s ease;
  }

  .option-btn.incorrect{
    background: var(--red-soft) !important;
    border-color: #9c4a56 !important;
    animation: droop 0.6s ease;
  }

  @keyframes correctPulse{
    0%{ transform: scale(1); }
    40%{ transform: scale(1.06); }
    100%{ transform: scale(1); }
  }

  @keyframes droop{
    0%{ transform: translateY(0) rotate(0deg); opacity:1; }
    45%{ transform: translateY(4px) rotate(-1.5deg); opacity:0.85; }
    100%{ transform: translateY(0) rotate(0deg); opacity:1; }
  }

  .hidden-message{
    margin-top:2rem;
    font-size:0.75rem;
    color: rgba(255,255,255,0.25);
    letter-spacing:0.5px;
    transition: color 0.3s ease;
  }

  .hidden-message:hover{ color: rgba(243,198,35,0.7); }

  /* ---------- MODAL ---------- */
  .modal-overlay{
    position:fixed;
    inset:0;
    background: rgba(10,4,20,0.75);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:40;
    opacity:0;
    pointer-events:none;
    transition: opacity 0.25s ease;
    padding:1rem;
  }

  .modal-overlay.open{ opacity:1; pointer-events:all; }

  .modal{
    background: linear-gradient(160deg, var(--wine), var(--dark-purple));
    border: 2px solid var(--gold);
    border-radius: 24px;
    padding: 2.2rem 1.8rem;
    max-width: 400px;
    width:100%;
    text-align:center;
    transform: scale(0.8);
    transition: transform 0.25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }

  .modal-overlay.open .modal{ transform: scale(1); }

  .modal-emoji{
    font-size: 3.2rem;
    margin-bottom: 0.8rem;
  }

  .modal-message{
    font-family:'Poppins', sans-serif;
    font-weight:700;
    font-size:1.2rem;
    margin-bottom:1.6rem;
    line-height:1.4;
  }

  /* ---------- PANTALLA FINAL ---------- */
  .trophy{
    font-size: clamp(4rem, 16vw, 6rem);
    animation: bounce 2.2s ease-in-out infinite;
    margin-bottom:0.5rem;
  }

  .end-title{
    font-family:'Poppins', sans-serif;
    font-weight:800;
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    color: var(--gold);
    margin-bottom:1.2rem;
  }

  .final-message{
    max-width:560px;
    font-size: clamp(0.95rem, 2.6vw, 1.15rem);
    line-height:1.7;
    font-style:italic;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(243,198,35,0.3);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    margin-bottom:1.6rem;
  }

  .choice-emoji{
    font-size: clamp(3rem, 12vw, 4.5rem);
    margin-bottom:0.6rem;
  }

  .choice-balance{
    font-family:'Poppins', sans-serif;
    font-weight:800;
    font-size: clamp(1.8rem, 7vw, 2.8rem);
    color: var(--gold);
    margin-bottom:1.2rem;
  }

  .choice-balance.negative{ color:#ff9aa4; }

  #screen-choice .btn-primary{ margin-bottom:0.6rem; }

  .prize-label{
    font-size:0.95rem;
    text-transform:uppercase;
    letter-spacing:2px;
    color: var(--gold);
    margin-bottom:0.3rem;
  }

  .final-amount{
    font-family:'Poppins', sans-serif;
    font-weight:800;
    font-size: clamp(2rem, 8vw, 3.2rem);
    color: var(--gold);
    text-shadow: 0 0 20px rgba(243,198,35,0.6);
    margin-bottom:1.2rem;
  }

  .claim-message{
    margin-top:1.4rem;
    max-width:520px;
    font-size:1.05rem;
    color: var(--gold);
    font-weight:600;
    min-height:1.5rem;
  }

  .screenshot-hint{
    max-width:480px;
    background: rgba(243,198,35,0.12);
    border: 1px dashed rgba(243,198,35,0.5);
    border-radius: 16px;
    padding: 1rem 1.3rem;
    font-size:0.95rem;
    line-height:1.5;
    margin-bottom:1.4rem;
  }

  /* ---------- FOTO DE FONDO PANTALLA FINAL ---------- */
  #screen-end{
    position:relative;
    background-image: url("../img/bg-family.jpg");
    background-size:cover;
    background-position:center;
    overflow:hidden;
  }

  #screen-end::after{
    content:"";
    position:absolute;
    inset:0;
    background: linear-gradient(180deg, rgba(26,11,46,0.88), rgba(74,25,66,0.82) 45%, rgba(26,11,46,0.92));
    z-index:0;
  }

  #screen-end > *{ position:relative; z-index:1; }

  @media (max-width:380px){
    .question-card{ padding:1.5rem 1.1rem; }
    .option-btn{ padding:0.8rem 0.9rem; font-size:0.95rem; }
  }

  @media (hover:none) and (pointer:coarse){
    .option-btn:not(:disabled):hover{
      background: rgba(123,47,190,0.35);
      border-color: rgba(243,198,35,0.25);
      transform:none;
    }
    .btn-primary:hover{ transform:none; box-shadow: 0 6px 20px rgba(243,198,35,0.4); }
  }

  /* ---------- REPRODUCTOR DE MÚSICA (oculto) ---------- */
  .yt-music-player{
    position:fixed;
    width:1px;
    height:1px;
    overflow:hidden;
    opacity:0;
    pointer-events:none;
    top:0;
    left:0;
  }

  /* ---------- BOTÓN DE MÚSICA ---------- */
  .mute-btn{
    position:fixed;
    bottom:0.8rem;
    right:0.8rem;
    z-index:60;
    width:2.6rem;
    height:2.6rem;
    border-radius:50%;
    background: rgba(26,11,46,0.75);
    border: 1px solid rgba(243,198,35,0.4);
    color:#fff;
    font-size:1.15rem;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    transition: transform 0.2s ease;
  }

  .mute-btn:active{ transform: scale(0.92); }
