* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a0a;
    background-image: radial-gradient(#ff69b4 0.5px, transparent 0.5px);
    background-size: 30px 30px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Inconsolata', monospace;
    padding: 10px;
}

:root {
    --pink: #ff69b4;
    --pink-dark: #ff1493;
    --pink-light: #ffb6c1;
    --purple: #9400d3;
    --dorado: #ffd700;
    --pergamino: #f1e3c6;
    --pergamino-oscuro: #d8c9a8;
    --tinta: #4a2c1a;
    --madera: #8b4513;
}

#out-all {
    max-width: 900px;
    width: 100%;
    min-height: 600px;
    background: #000000;
    border: 3px solid var(--pink);
    border-radius: 30px;
    padding: 20px;
    color: #ffffff;
    box-shadow: 0 0 30px var(--pink),
                inset 0 0 20px rgba(255, 105, 180, 0.3);
    position: relative;
    overflow: hidden;
}

#out-all::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255, 105, 180, 0.05) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    animation: scanline 6s linear infinite;
}

@keyframes scanline {
    0% { background-position: 0 0; }
    100% { background-position: 0 10px; }
}

.escena {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 15px;
    background: #000;
    border-radius: 30px;
}

.escena.activa {
    display: flex;
}

.subescena {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.subescena.activa {
    display: flex;
}

h1 {
    font-family: 'VT323', monospace;
    font-size: clamp(24px, 7vw, 48px);
    color: var(--pink);
    text-align: center;
    margin-bottom: 12px;
    text-shadow: 0 0 10px var(--pink);
    overflow: hidden;
    border-right: 2px solid var(--pink);
    white-space: nowrap;
    animation: typing 3s steps(40, end),
               blink-caret 0.75s step-end infinite;
    max-width: 100%;
}

h2 {
    font-family: 'VT323', monospace;
    font-size: clamp(20px, 5.5vw, 36px);
    color: var(--pink-light);
    text-align: center;
    margin-bottom: 12px;
    animation: fadeIn 2s ease-in forwards;
    animation-delay: 3s;
    opacity: 0;
    padding: 0 8px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

h3 {
    font-family: 'VT323', monospace;
    font-size: clamp(18px, 5vw, 32px);
    color: #ffffff;
    text-align: center;
    margin-bottom: 8px;
    padding: 0 8px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--pink); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes aparecer {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes flotar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.opciones {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
    width: 100%;
    padding: 0 8px;
}

.btn {
    font-family: 'VT323', monospace;
    font-size: clamp(18px, 4.5vw, 28px);
    padding: 10px 20px;
    background: transparent;
    border: 2px solid var(--pink);
    color: var(--pink);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    animation: aparecer 1s ease forwards;
    animation-delay: 2.5s;
    opacity: 0;
    text-decoration: none;
    display: inline-block;
    width: auto;
    min-width: 160px;
    max-width: 100%;
    word-break: break-word;
}

.btn:hover {
    background: var(--pink);
    color: #000;
    box-shadow: 0 0 20px var(--pink);
    transform: scale(1.05);
}

.princesa-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    width: 100%;
    padding: 0 8px;
}

.princesa-img {
    width: auto;
    height: clamp(130px, 35vw, 220px);
    max-width: 100%;
    object-fit: contain;
    animation: flotar 3s ease-in-out infinite;
    margin-bottom: 10px;
    position: relative;
    top: -10px;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.princesa-container h3 {
    color: var(--pink);
    text-shadow: 0 0 10px var(--pink);
    font-size: clamp(18px, 4.5vw, 28px);
    margin-top: -8px;
}

.cofres-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
    flex-wrap: wrap;
    padding: 0 8px;
}

.cofre-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 80px;
    max-width: 130px;
}

.cofre {
    width: 100%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cofre-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.3s ease;
}

.cofre.activo .cofre-img.cerrado {
    filter: drop-shadow(0 0 15px gold);
    animation: brilloCofre 1.5s infinite;
    cursor: pointer;
}

@keyframes brilloCofre {
    0%, 100% { filter: drop-shadow(0 0 8px gold); }
    50% { filter: drop-shadow(0 0 20px gold) drop-shadow(0 0 10px pink); }
}

.cofre.inactivo {
    cursor: not-allowed;
}

.cofre.inactivo .cofre-img.cerrado {
    filter: grayscale(0.9) brightness(0.4) drop-shadow(0 0 5px #333);
    opacity: 0.6;
}

.cofre.abierto {
    cursor: default;
}

.cofre.abierto .cofre-img.cerrado {
    display: none;
}

.cofre.abierto .cofre-img.abierto {
    display: block !important;
    filter: drop-shadow(0 0 15px gold);
}

.numero-cofre {
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 4vw, 28px);
    color: var(--pink);
    background: rgba(0,0,0,0.6);
    padding: 3px 12px;
    border-radius: 30px;
    border: 1px solid var(--pink);
}

.pergamino-escena {
    background: #1a0f1a;
    padding: 8px;
}

.pergamino-elegante {
    background: var(--pergamino);
    background-image: linear-gradient(145deg, #f1e3c6 0%, #e8d9b5 50%, #d8c9a8 100%);
    width: 95%;
    max-width: 750px;
    max-height: 80vh;
    border-radius: 15px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
    padding: 12px;
    position: relative;
    border: 2px solid #b89a7a;
    display: flex;
    flex-direction: column;
}

.pergamino-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    border-bottom: 2px solid #b89a7a;
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.pergamino-icono {
    font-size: clamp(20px, 5vw, 40px);
}

.pergamino-titulo {
    font-family: 'VT323', monospace;
    font-size: clamp(24px, 5vw, 42px);
    color: #4a2c1a;
    text-align: center;
    margin: 0;
}

.pergamino-contenido {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    margin: 8px 0;
    background: rgba(210, 180, 140, 0.2);
    border-radius: 12px;
    max-height: 50vh;
    -webkit-overflow-scrolling: touch;
}

.pergamino-contenido::-webkit-scrollbar {
    width: 5px;
}

.pergamino-contenido::-webkit-scrollbar-track {
    background: #e8d9b5;
    border-radius: 10px;
}

.pergamino-contenido::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 10px;
}

.pergamino-parrafo {
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 3.5vw, 24px);
    line-height: 1.4;
    color: #3d2b1a;
    margin-bottom: 12px;
    text-align: left;
    padding: 0 5px;
}

.pergamino-footer {
    display: flex;
    justify-content: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 2px dashed #b89a7a;
}

.pergamino-boton {
    background: #8b4513;
    color: #f1e3c6;
    border: 2px solid #d8b56e;
    font-size: clamp(18px, 4vw, 28px);
    padding: 8px 25px;
    border-radius: 60px;
    width: 100%;
    max-width: 250px;
    text-align: center;
}

.ilustracion.anillos {
    width: clamp(80px, 25vw, 150px);
    height: clamp(80px, 25vw, 150px);
    margin: 12px auto;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="35" cy="50" r="20" fill="none" stroke="%23ffd700" stroke-width="5"/><circle cx="65" cy="50" r="20" fill="none" stroke="%23ffd700" stroke-width="5"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.ilustracion.personaje-feliz {
    width: clamp(80px, 25vw, 150px);
    height: clamp(80px, 25vw, 150px);
    margin: 12px auto;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="40" r="20" fill="%23ff69b4"/><circle cx="50" cy="80" r="30" fill="%23ff1493"/><path d="M35 30 Q50 45 65 30" stroke="white" stroke-width="5" fill="none"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.pregunta-grande {
    font-size: clamp(24px, 6vw, 64px);
    color: var(--pink);
    text-shadow: 0 0 15px var(--pink);
    animation: latido 1.5s ease-in-out infinite, typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
    text-align: center;
    padding: 0 10px;
    word-break: break-word;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid var(--pink);
    max-width: 100%;
    margin-bottom: 15px;
}

@keyframes latido {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.opciones.finales {
    margin-top: 20px;
    flex-direction: column;
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
}

.si-final, .si-rojo {
    font-size: clamp(20px, 5vw, 36px);
    padding: 12px 25px;
    width: 100%;
    max-width: 250px;
    margin: 4px 0;
}

.si-rojo {
    border-color: #ff0000;
    color: #ff0000;
}

.si-rojo:hover {
    background: #ff0000;
    color: #000;
    box-shadow: 0 0 20px #ff0000;
}

.mensaje-final {
    font-family: 'VT323', monospace;
    font-size: clamp(18px, 4.5vw, 28px);
    text-align: center;
    line-height: 1.5;
    overflow-y: auto;
    padding: 12px;
    width: 100%;
    max-height: 80vh;
}

.mensaje-final p {
    margin-bottom: 12px;
}

.libro-deseos {
    background: #1a1a1a;
    border: 2px solid var(--pink);
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    width: 100%;
    max-width: 450px;
}

.libro-deseos h3 {
    color: var(--pink);
    font-size: clamp(18px, 4.5vw, 28px);
    margin-bottom: 12px;
}

.textarea-mensaje {
    width: 100%;
    height: 100px;
    padding: 10px;
    background: #2a2a2a;
    border: 2px solid var(--pink);
    border-radius: 12px;
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 4vw, 24px);
    color: white;
    resize: vertical;
    margin-bottom: 12px;
}

.guardar-mensaje {
    width: 100%;
    background: var(--pink);
    color: black;
    border: none;
    padding: 10px;
    font-size: clamp(18px, 4.5vw, 26px);
    border-radius: 50px;
}

.control-musica {
    position: fixed;
    bottom: 12px;
    right: 12px;
    background: rgba(255, 105, 180, 0.3);
    border: 2px solid var(--pink);
    border-radius: 50px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    font-size: 20px;
    backdrop-filter: blur(5px);
}

/* ===== CARTA INICIAL TIPO SOBRE ===== */
.carta-inicial {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: #fce4e8;
    border-radius: 30px;
    z-index: 2000;
    padding: 12px;
}

.carta-inicial.activa {
    display: flex;
}

.sobre {
    width: min(350px, 85%);
    background: #fff0f5;
    border-radius: 15px 15px 30px 30px;
    position: relative;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border: 2px solid #ffb6c1;
    animation: aparecerSuave 0.5s ease;
    aspect-ratio: 4 / 3;
}

@keyframes aparecerSuave {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.solapa {
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 30px;
    background: #ffe4ec;
    border-left: 2px solid #ffb6c1;
    border-right: 2px solid #ffb6c1;
    border-top: 2px solid #ffb6c1;
    border-radius: 20px 20px 0 0;
    transform-origin: bottom;
    transition: transform 0.4s ease;
    z-index: 5;
}

.carta-inicial.abierta .solapa {
    transform: rotateX(180deg);
}

.carta-contenido {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 2px #ffc0cb;
    z-index: 10;
}

.carta-texto-inicial {
    text-align: center;
    padding: 12px;
    width: 100%;
}

.corazon-palpita {
    font-size: clamp(35px, 12vw, 60px);
    line-height: 1;
    margin-bottom: 8px;
    animation: palpitar 1.2s ease-in-out infinite;
    display: inline-block;
}

@keyframes palpitar {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    50% { transform: scale(1.05); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.nombre-merari {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(28px, 8vw, 48px);
    color: #ff1493;
    margin: 4px 0;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 105, 180, 0.3);
    word-break: break-word;
}

.abrir-carta {
    background: #ffb6c1;
    color: white;
    border: none;
    font-size: clamp(20px, 4.5vw, 28px);
    padding: 10px 20px;
    border-radius: 40px;
    margin-top: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px solid white;
    font-family: 'VT323', monospace;
    box-shadow: 0 3px 0 #ff69b4;
    width: auto;
    min-width: 130px;
}

.abrir-carta:hover {
    background: #ff69b4;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #ff1493;
}

.abrir-carta:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #ff1493;
}

/* ===== CORRECCIONES PARA PANTALLAS PEQUEÑAS ===== */
@media (max-width: 480px) {
    .escena {
        padding: 8px;
    }
    
    h1 {
        font-size: 22px !important;
        margin-bottom: 8px;
        animation: typing 2.5s steps(30, end), blink-caret 0.75s step-end infinite;
    }
    
    h2 {
        font-size: 18px !important;
        margin-bottom: 8px;
        padding: 0 5px;
    }
    
    h3 {
        font-size: 16px !important;
    }
    
    .pregunta-grande {
        font-size: 24px !important;
        white-space: nowrap;
        margin-bottom: 10px;
        animation: typing 2.5s steps(30, end), blink-caret 0.75s step-end infinite, latido 1.5s ease-in-out infinite;
    }
    
    #escena5 h1 {
        font-size: 20px !important;
    }
    
    #escena5 h2 {
        font-size: 18px !important;
    }
    
    .btn {
        min-width: 130px;
        padding: 8px 15px;
        font-size: 18px;
    }
    
    .opciones {
        gap: 8px;
        margin-top: 10px;
    }
    
    .cofre-wrapper {
        min-width: 70px;
        max-width: 100px;
    }
    
    .numero-cofre {
        font-size: 14px;
        padding: 2px 8px;
    }
    
    .princesa-img {
        height: 120px;
        top: -5px;
    }
    
    .pergamino-elegante {
        padding: 8px;
    }
    
    .pergamino-parrafo {
        font-size: 14px;
        line-height: 1.3;
        margin-bottom: 8px;
    }
    
    .pergamino-titulo {
        font-size: 20px;
    }
    
    .pergamino-boton {
        font-size: 16px;
        padding: 6px 15px;
    }
    
    .control-musica {
        width: 35px;
        height: 35px;
        font-size: 18px;
        bottom: 8px;
        right: 8px;
    }
    
    .libro-deseos {
        padding: 12px;
    }
    
    .libro-deseos h3 {
        font-size: 16px;
    }
    
    .textarea-mensaje {
        height: 80px;
        font-size: 14px;
    }
    
    .guardar-mensaje {
        font-size: 16px;
        padding: 8px;
    }
    
    .si-final, .si-rojo {
        font-size: 18px;
        padding: 10px 20px;
        max-width: 200px;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 360px) {
    h1 {
        font-size: 20px !important;
    }
    
    .btn {
        min-width: 110px;
        font-size: 16px;
        padding: 6px 12px;
    }
    
    .cofre-wrapper {
        min-width: 60px;
    }
    
    .pregunta-grande {
        font-size: 20px !important;
    }
    
    #escena5 h1 {
        font-size: 18px !important;
    }
}