@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cormorant Garamond', serif;
    background: linear-gradient(135deg, #0a0a15 0%, #1a1a2e 50%, #0a0a15 100%);
    color: #e8dcc4;
    overflow-x: hidden;
    min-height: 100vh;
    cursor: none;
    transition: background 0.8s ease, color 0.8s ease;
}

body.day-mode {
    background: linear-gradient(135deg, #87ceeb 0%, #e0f6ff 50%, #87ceeb 100%);
    color: #2d2419;
}

/* ===== CURSOR PERSONALIZADO ===== */
.custom-cursor {
    position: fixed;
    width: 20px;
    height: 20px;
    border: 2px solid #d4af7a;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.15s ease, width 0.2s ease, height 0.2s ease;
    mix-blend-mode: difference;
}

.cursor-trail {
    position: fixed;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, rgba(212, 175, 122, 0.8), transparent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    animation: trailFade 0.8s ease-out forwards;
}

@keyframes trailFade {
    to {
        transform: scale(3);
        opacity: 0;
    }
}

.cursor-sparkle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #d4af7a;
    pointer-events: none;
    z-index: 9997;
    animation: sparkleFade 1s ease-out forwards;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

@keyframes sparkleFade {
    to {
        transform: translateY(-30px) scale(0);
        opacity: 0;
    }
}

.mouse-particle {
    position: fixed;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #d4af7a, transparent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9996;
    animation: mouseParticleFade 1.5s ease-out forwards;
}

@keyframes mouseParticleFade {
    to {
        transform: scale(4) translateY(-40px);
        opacity: 0;
    }
}

/* ===== CONTROLES ===== */
.mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(58, 47, 37, 0.8);
    border: 2px solid #d4af7a;
    border-radius: 30px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
    color: #d4af7a;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.mode-toggle:hover {
    box-shadow: 0 0 20px rgba(212, 175, 122, 0.5);
    transform: scale(1.05);
}

.day-mode .mode-toggle {
    background: rgba(255, 255, 255, 0.8);
    border-color: #6b4f3a;
    color: #6b4f3a;
}

.sound-toggle {
    position: fixed;
    top: 20px;
    right: 180px;
    z-index: 1000;
    background: rgba(58, 47, 37, 0.8);
    border: 2px solid #d4af7a;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
}

.sound-toggle:hover {
    box-shadow: 0 0 20px rgba(212, 175, 122, 0.5);
    transform: scale(1.1) rotate(15deg);
}

.day-mode .sound-toggle {
    background: rgba(255, 255, 255, 0.8);
    border-color: #6b4f3a;
}

/* ===== ESTRELLAS Y NUBES ===== */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.8s ease;
}

.day-mode .stars {
    opacity: 0;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { 
        opacity: 0.2; 
        transform: scale(1); 
    }
    50% { 
        opacity: 1; 
        transform: scale(1.5); 
    }
}

.clouds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.day-mode .clouds {
    opacity: 1;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 100px;
    animation: cloudFloat 60s infinite linear;
}

@keyframes cloudFloat {
    from { 
        transform: translateX(-200px); 
    }
    to { 
        transform: translateX(calc(100vw + 200px)); 
    }
}

/* ===== PARTÍCULAS MÁGICAS ===== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle, rgba(255, 215, 130, 0.8), transparent);
    border-radius: 50%;
    animation: float 12s infinite ease-in-out;
    box-shadow: 0 0 10px rgba(255, 215, 130, 0.6);
}

.day-mode .particle {
    background: radial-gradient(circle, rgba(255, 215, 0, 0.6), transparent);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0) translateX(0) scale(0.5);
        opacity: 0;
    }
    10% { 
        opacity: 1; 
    }
    50% { 
        transform: translateY(-100vh) translateX(50px) scale(1);
        opacity: 0.8;
    }
    90% { 
        opacity: 0.3; 
    }
}

/* ===== PANTALLA DE ENTRADA ===== */
.entrance-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a15 70%);
    opacity: 1;
    transition: opacity 2s ease;
    padding: 20px;
}

.day-mode .entrance-screen {
    background: radial-gradient(ellipse at center, #e0f6ff 0%, #87ceeb 70%);
}

.entrance-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.entrance-text {
    font-size: clamp(1.3rem, 4vw, 2rem);
    line-height: 1.8;
    text-align: center;
    max-width: 600px;
    margin-bottom: 50px;
    color: #d4af7a;
    font-style: italic;
    text-shadow: 0 0 20px rgba(212, 175, 122, 0.3);
    animation: fadeInUp 2s ease;
    position: relative;
    z-index: 2;
}

.day-mode .entrance-text {
    color: #6b4f3a;
    text-shadow: 0 2px 10px rgba(107, 79, 58, 0.2);
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.entrance-button {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    padding: 15px 40px;
    background: linear-gradient(135deg, #4a3728 0%, #6b4f3a 100%);
    border: 2px solid #d4af7a;
    color: #e8dcc4;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.4s ease;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(212, 175, 122, 0.2);
    position: relative;
    z-index: 2;
    animation: fadeInUp 2s ease 0.5s backwards;
    overflow: hidden;
}

.day-mode .entrance-button {
    background: linear-gradient(135deg, #8b6f4a 0%, #b89968 100%);
    color: #2d2419;
}

.entrance-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 122, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.entrance-button:hover::before {
    width: 300px;
    height: 300px;
}

.entrance-button:hover {
    background: linear-gradient(135deg, #6b4f3a 0%, #8b6f4a 100%);
    box-shadow: 0 0 40px rgba(212, 175, 122, 0.6), 0 8px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-3px) scale(1.05);
}

.entrance-button span {
    position: relative;
    z-index: 1;
}

/* ===== GABINETE PRINCIPAL ===== */
.cabinet-screen {
    opacity: 0;
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 2s ease 0.5s;
    position: relative;
    z-index: 10;
}

.cabinet-screen.visible {
    opacity: 1;
}

.cabinet-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    margin-bottom: 20px;
    text-align: center;
    color: #d4af7a;
    text-shadow: 0 0 30px rgba(212, 175, 122, 0.5);
    animation: titleGlow 3s infinite ease-in-out;
}

.day-mode .cabinet-title {
    color: #6b4f3a;
    text-shadow: 0 2px 20px rgba(107, 79, 58, 0.3);
}

@keyframes titleGlow {
    0%, 100% { 
        text-shadow: 0 0 20px rgba(212, 175, 122, 0.4); 
    }
    50% { 
        text-shadow: 0 0 40px rgba(212, 175, 122, 0.7), 0 0 60px rgba(212, 175, 122, 0.4); 
    }
}

.cabinet-subtitle {
    font-size: 1.1rem;
    color: #b89968;
    text-align: center;
    margin-bottom: 50px;
    font-style: italic;
    opacity: 0.8;
}

.day-mode .cabinet-subtitle {
    color: #8b6f4a;
}

.envelopes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 35px;
    width: 100%;
    max-width: 950px;
}

/* ===== SOBRES ===== */
.envelope {
    background: linear-gradient(145deg, #3a2f25 0%, #2d2419 100%);
    border: 2px solid #6b5947;
    border-radius: 12px;
    padding: 30px 25px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(212, 175, 122, 0.1);
    position: relative;
    overflow: hidden;
    animation: envelopeAppear 0.8s ease backwards;
}

.day-mode .envelope {
    background: linear-gradient(145deg, #f5f5dc 0%, #e8dcc4 100%);
    border-color: #b89968;
    box-shadow: 0 8px 20px rgba(107, 79, 58, 0.2);
}

@keyframes envelopeAppear {
    from {
        opacity: 0;
        transform: translateY(30px) rotateX(-15deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.envelope:nth-child(1) { animation-delay: 0.1s; }
.envelope:nth-child(2) { animation-delay: 0.2s; }
.envelope:nth-child(3) { animation-delay: 0.3s; }
.envelope:nth-child(4) { animation-delay: 0.4s; }
.envelope:nth-child(5) { animation-delay: 0.5s; }
.envelope:nth-child(6) { animation-delay: 0.6s; }
.envelope:nth-child(7) { animation-delay: 0.7s; }
.envelope:nth-child(8) { animation-delay: 0.8s; }

.envelope::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(212, 175, 122, 0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: scale(0.5);
}

.envelope::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 122, 0.2), transparent);
    transition: left 0.8s ease;
}

.envelope:hover::after {
    left: 100%;
}

.envelope:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(212, 175, 122, 0.3), 0 0 50px rgba(212, 175, 122, 0.2);
    border-color: #d4af7a;
}

.day-mode .envelope:hover {
    box-shadow: 0 15px 40px rgba(107, 79, 58, 0.3);
}

.envelope:hover::before {
    opacity: 1;
    transform: scale(1);
}

.envelope-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 15px rgba(212, 175, 122, 0.4));
    animation: iconFloat 3s infinite ease-in-out;
    display: block;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.envelope:hover .envelope-icon {
    animation: iconSpin 1s ease;
}

@keyframes iconSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

.envelope-opening {
    animation: envelopeOpen 0.8s ease;
}

@keyframes envelopeOpen {
    0% { transform: scale(1); }
    50% { transform: scale(1.1) rotateY(10deg); }
    100% { transform: scale(1); }
}

.envelope-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    text-align: center;
    color: #d4af7a;
    margin-bottom: 10px;
    transition: color 0.3s ease;
    position: relative;
}

.day-mode .envelope-title {
    color: #6b4f3a;
}

.envelope:hover .envelope-title {
    color: #e8c48a;
}

.envelope-subtitle {
    font-size: 1rem;
    text-align: center;
    color: #b89968;
    font-style: italic;
    transition: color 0.3s ease;
}

.day-mode .envelope-subtitle {
    color: #8b6f4a;
}

.envelope:hover .envelope-subtitle {
    color: #d4af7a;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.5s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(145deg, #3a2f25 0%, #2d2419 100%);
    border: 3px solid #d4af7a;
    border-radius: 15px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 80px rgba(212, 175, 122, 0.5), inset 0 0 50px rgba(212, 175, 122, 0.1);
    animation: modalSlideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.day-mode .modal-content {
    background: linear-gradient(145deg, #f5f5dc 0%, #e8dcc4 100%);
    border-color: #6b4f3a;
}

@keyframes modalSlideUp {
    from { 
        transform: translateY(100px) scale(0.9);
        opacity: 0;
    }
    to { 
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: #d4af7a;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 0 0 20px rgba(212, 175, 122, 0.5);
    animation: titleShimmer 2s infinite ease-in-out;
}

.day-mode .modal-title {
    color: #6b4f3a;
    text-shadow: 0 2px 10px rgba(107, 79, 58, 0.2);
}

@keyframes titleShimmer {
    0%, 100% { text-shadow: 0 0 15px rgba(212, 175, 122, 0.4); }
    50% { text-shadow: 0 0 30px rgba(212, 175, 122, 0.8); }
}

.riddle-section, .message-section {
    margin-bottom: 25px;
    position: relative;
}

.riddle-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #e8dcc4;
    margin-bottom: 25px;
    text-align: center;
    font-style: italic;
    padding: 20px;
    background: rgba(26, 26, 46, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 122, 0.2);
    animation: riddleGlow 3s infinite ease-in-out;
}

.day-mode .riddle-text {
    background: rgba(255, 255, 255, 0.3);
    color: #2d2419;
}

@keyframes riddleGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(212, 175, 122, 0.2); }
    50% { box-shadow: 0 0 25px rgba(212, 175, 122, 0.4); }
}

.riddle-input {
    width: 100%;
    padding: 15px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid #6b5947;
    border-radius: 8px;
    color: #e8dcc4;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.4s ease;
}

.day-mode .riddle-input {
    background: rgba(255, 255, 255, 0.6);
    color: #2d2419;
    border-color: #b89968;
}

.riddle-input:focus {
    outline: none;
    border-color: #d4af7a;
    box-shadow: 0 0 25px rgba(212, 175, 122, 0.4), inset 0 0 15px rgba(212, 175, 122, 0.1);
    transform: scale(1.02);
}

.modal-button {
    font-family: 'Cinzel', serif;
    padding: 12px 35px;
    background: linear-gradient(135deg, #4a3728 0%, #6b4f3a 100%);
    border: 2px solid #d4af7a;
    color: #e8dcc4;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.day-mode .modal-button {
    background: linear-gradient(135deg, #8b6f4a 0%, #b89968 100%);
    color: #2d2419;
}

.modal-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 122, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.modal-button:hover::before {
    width: 300px;
    height: 300px;
}

.modal-button:hover {
    background: linear-gradient(135deg, #6b4f3a 0%, #8b6f4a 100%);
    box-shadow: 0 0 30px rgba(212, 175, 122, 0.5);
    transform: translateY(-2px) scale(1.05);
}

.modal-button span {
    position: relative;
    z-index: 1;
}

.error-message {
    color: #c97676;
    text-align: center;
    margin-top: 15px;
    font-style: italic;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.message-text {
    font-size: 1.2rem;
    line-height: 1.9;
    color: #e8dcc4;
    margin-bottom: 25px;
    text-align: justify;
    animation: messageAppear 1s ease;
}

.day-mode .message-text {
    color: #2d2419;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-text p {
    margin-bottom: 20px;
    opacity: 0;
    animation: paragraphAppear 0.8s ease forwards;
}

.message-text p:nth-child(1) { animation-delay: 0.2s; }
.message-text p:nth-child(2) { animation-delay: 0.5s; }
.message-text p:nth-child(3) { animation-delay: 0.8s; }

@keyframes paragraphAppear {
    to {
        opacity: 1;
    }
}

.close-message {
    font-size: 0.95rem;
    color: #b89968;
    text-align: center;
    font-style: italic;
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid rgba(107, 89, 71, 0.5);
    animation: fadeIn 1s ease 1.2s backwards;
}

.day-mode .close-message {
    color: #8b6f4a;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #d4af7a;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    z-index: 10;
}

.day-mode .close-button {
    color: #6b4f3a;
}

.close-button:hover {
    transform: rotate(90deg) scale(1.2);
    color: #e8dcc4;
    text-shadow: 0 0 15px rgba(212, 175, 122, 0.8);
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(26, 26, 46, 0.3);
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #6b5947;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #d4af7a;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .envelopes-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .entrance-text {
        font-size: 1.2rem;
    }
    
    .envelope-icon {
        font-size: 2.5rem;
    }
    
    .mode-toggle {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .sound-toggle {
        top: 10px;
        right: 140px;
        width: 45px;
        height: 45px;
    }
    
    body {
        cursor: auto;
    }
    
    .custom-cursor {
        display: none;
    }
}