/* ================================================
   Un Altar - Estilos CSS
   ================================================ */

/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.altar-page {
    font-family: 'Inter', sans-serif;
    background: #000000;
    color: #ffffff;
    overflow-x: hidden;
    position: relative;
}

/* Tipografías */
h1, h2, h3, .altar-title {
    font-family: 'Playfair Display', serif;
}

/* ================================================
   PANTALLA DE BIENVENIDA
   ================================================ */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.welcome-screen.active {
    opacity: 1;
    pointer-events: all;
}

.welcome-content {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
}

.notes-count {
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: #fff;
    margin-bottom: 3rem;
    font-weight: 300;
}

.altar-title {
    font-size: 4rem;
    font-weight: 400;
    margin-bottom: 2rem;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
}

.welcome-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ccc;
    margin-bottom: 3rem;
    font-weight: 300;
}

.enter-button {
    background: transparent;
    border: 1px solid #ffffff;
    color: #ffffff;
    padding: 15px 50px;
    font-size: 1rem;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}

.enter-button:hover,
.enter-button:focus {
    background: #ffffff;
    color: #000000;
    transform: scale(1.05);
}

.welcome-footer {
    margin-top: 4rem;
}

.welcome-footer a {
    color: #fff !important;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.welcome-footer a:hover {
    color: #fff;
}

/* ================================================
   PANTALLA PRINCIPAL
   ================================================ */
.main-screen {
    min-height: 100vh;
    display: none;
    flex-direction: column;
    position: relative;
}

.main-screen.active {
    display: flex;
}

/* Header */
.altar-header {
    padding: 2rem;
    text-align: center;
    position: relative;
    z-index: 10;
}

.site-title {
    font-size: 2.5rem;
    letter-spacing: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.site-title span {
    display: inline-block;
    animation: fadeInLetter 0.5s ease forwards;
    opacity: 0;
}

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

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

.notes-counter {
    font-size: 0.75rem;
    color: #fff;
    letter-spacing: 2px;
}

/* Navegación de pestañas */
.altar-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    position: relative;
    z-index: 10;
}

.tab-button {
    background: transparent;
    border: 1px solid #444;
    color: #999;
    padding: 10px 30px;
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.tab-button.active {
    border-color: #ffffff;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.tab-button:hover:not(.active),
.tab-button:focus:not(.active) {
    background-color: #B69425;
    color: #000;
}

/* ================================================
   ÁREA DE VELAS
   ================================================ */
.candles-container {
    flex: 1;
    position: relative;
    min-height: 600px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    height: auto;
}

/* ============================ VELA COMPLETA ============================ */
.candle {
    position: absolute;
    width: 60px;
    cursor: pointer;
    animation: floatCandle 3s ease-in-out infinite;
    opacity: 0;
    animation: fadeInCandle 0.8s ease forwards, floatCandle 3s ease-in-out infinite;
}

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

.candle:hover {
    transform: scale(1.1);
}

.candle:nth-child(odd) {
    animation-delay: -1s;
}

.candle:nth-child(even) {
    animation-delay: -2s;
}

/* Difuminado del cuerpo */
.candle-body {
    width: 40px;
    height: 26px;
    margin: 0 auto;
    position: relative;
    background: linear-gradient(to bottom, rgba(255, 245, 220, 1) 0%, rgba(255, 235, 190, 0.8) 40%, rgba(255, 220, 150, 0.4) 70%, rgba(255, 200, 120, 0) 100%);
    border-radius: 10px 10px 4px 4px;
    box-shadow: inset -4px 0 10px rgba(0, 0, 0, 0.3), inset 4px 0 10px rgba(255, 255, 255, 0.2);
}
}

/* Mecha */
.candle-wick {
    width: 3px;
    height: 12px;
    background: linear-gradient(to top, #1a1a1a, #4a3f35);
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2px;
}

/* Llama */
.candle-flame {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 35px;
    background: radial-gradient(
        ellipse at center bottom,
        #fff8dc 0%,
        #ffeb3b 20%,
        #ff9800 40%,
        #ff5722 60%,
        rgba(255, 87, 34, 0.4) 80%,
        transparent 100%
    );
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 1.5s ease-in-out infinite;
    filter: blur(0.5px);
}

/* Núcleo brillante */
.candle-flame::before {
    content: '';
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 15px;
    background: radial-gradient(circle, #ffffff 0%, #ffeb3b 40%, transparent 80%);
    border-radius: 50%;
    animation: flameCore 1s ease-in-out infinite;
}

/* Halo de luz */
.candle-glow {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 72px;
    background: radial-gradient(circle, rgba(255, 220, 150, 0.6) 0%, rgba(255, 180, 80, 0.25) 30%, transparent 70%);
    border-radius: 50%;
    animation: glow 2.2s ease-in-out infinite;
    filter: blur(6px);
    pointer-events: none;
}

/* Partículas individuales */
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 240, 200, 0.7), rgba(255, 200, 100, 0.3), transparent);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

/* ============================ ANIMACIONES ============================ */
@keyframes floatCandle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes flicker {
    0%, 100% {
        transform: translateX(-50%) scaleY(1);
        opacity: 1;
    }
    50% {
        transform: translateX(-48%) scaleY(0.95);
        opacity: 0.9;
    }
}

@keyframes flameCore {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.7;
        transform: translate(-50%, -52%) scale(0.9);
    }
}

@keyframes glow {
    0%, 100% {
        opacity: 0.7;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
}

@keyframes floatParticles {
    0% {
        transform: translate(var(--offset-x, 0px), 0) scale(0.3);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    50% {
        transform: translate(var(--offset-x, 0px), -60px) scale(1);
        opacity: 0.9;
    }
    100% {
        transform: translate(var(--offset-x, 0px), -100px) scale(0.2);
        opacity: 0;
    }
}

@keyframes floatParticles2 {
    0% {
        transform: translate(var(--offset-x, 0px), 0) scale(0.4);
        opacity: 0;
    }
    8% {
        opacity: 0.8;
    }
    55% {
        transform: translate(var(--offset-x, 0px), -70px) scale(0.9);
        opacity: 0.7;
    }
    100% {
        transform: translate(var(--offset-x, 0px), -110px) scale(0.1);
        opacity: 0;
    }
}

@keyframes floatParticles3 {
    0% {
        transform: translate(var(--offset-x, 0px), 0) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 0.95;
    }
    60% {
        transform: translate(var(--offset-x, 0px), -80px) scale(0.8);
        opacity: 0.6;
    }
    100% {
        transform: translate(var(--offset-x, 0px), -120px) scale(0.15);
        opacity: 0;
    }
}

/* ================================================
   INSTRUCCIONES Y BOTONES
   ================================================ */
.instructions {
    text-align: center;
    padding: 1rem;
    color: #999;
    font-size: 0.9rem;
    position: relative;
    z-index: 10;
    margin: 0 auto;
    max-width: 90%;
}

#instruction-text {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.release-button {
    display: block;
    margin: 0 auto;
    background: transparent;
    border: 1px solid #ffffff;
    color: #ffffff;
    padding: 15px 40px;
    font-size: 0.9rem;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    position: relative;
    z-index: 10;
    max-width: calc(100% - 2rem);
    box-sizing: border-box;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

.release-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.release-button:focus {
    background-color: #B69425;
    color: #000;
}

/* Footer */
.altar-footer {
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

.altar-footer a {
    color: #fff !important;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.altar-footer a:hover {
    color: #999;
}

/* ================================================
   MODALES
   ================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 3rem;
    max-width: 600px;
    width: 90%;
    position: relative;
    animation: slideUp 0.4s ease;
}

/* Estilo de nota de papel para el modal de creación */
#create-modal .modal-content.note-paper {
    background: linear-gradient(135deg, #f9e79f 0%, #f7dc6f 50%, #f4d03f 100%);
    border: none;
    border-radius: 0;
    padding: 3rem 2.5rem 2rem 2.5rem;
    max-width: 500px;
    width: calc(100% - 2rem);
    box-sizing: border-box;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset -2px -2px 5px rgba(0, 0, 0, 0.1),
        inset 2px 2px 5px rgba(255, 255, 255, 0.3);
    transform: rotate(-2deg);
    animation: paperFloat 0.6s ease forwards;
}

#create-modal .modal-content.note-paper-back {
    background: linear-gradient(135deg, #f9e79f 0%, #f7dc6f 50%, #f4d03f 100%);
    border: none;
    position: absolute;
    z-index: -1;
    height: 525px;
    border-radius: 0;
    padding: 3rem 2.5rem 2rem 2.5rem;
    max-width: 500px;
    width: calc(100% - 2rem);
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset -2px -2px 5px rgba(0, 0, 0, 0.1), inset 2px 2px 5px rgba(255, 255, 255, 0.3);
    transform: rotate(-13deg) !important;
    animation: paperFloat 0.6s ease forwards;
}

@keyframes paperFloat {
    0% {
        transform: translateY(-100px) rotate(-5deg) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateY(10px) rotate(-1deg) scale(1.02);
    }
    100% {
        transform: translateY(0) rotate(-2deg) scale(1);
        opacity: 1;
    }
}

/* Clip de papel - estilo redondeado más realista */
.paper-clip {
    position: absolute;
    top: -70px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 60px;
    z-index: 10;
}

/* Forma del clip usando border */
.paper-clip::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    transform: rotate(-25deg);
    width: 35px;
    height: 100px;
    border: 3.5px solid #ff700b;
    border-radius: 20px 20px 20px 20px;
    background: transparent;
    box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.2), inset 2px 2px 3px rgba(255, 255, 255, 0.3), -3px 3px 6px rgba(0, 0, 0, 0.3);
}

/* Clip de papel trasero - no se usa, ocultar */
.paper-clip-back {
    display: none;
}

#create-modal .note-paper h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: #2c2c2c;
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: 3px;
    font-weight: 400;
    text-transform: uppercase;
}

#create-modal .note-paper .modal-close {
    color: #000;
    font-size: 1.5rem;
    top: -4.5rem;
    left: 88%;
    opacity: 0.6;

    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: #999;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

#create-modal .note-paper .modal-close:hover {
    color: #333;
    opacity: 1;
}

#create-modal .note-paper #nota-textarea {
    width: 100%;
    min-height: 250px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0;
    color: #2c2c2c;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.8;
    resize: none;
    margin: 0;
    box-sizing: border-box;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

#create-modal .note-paper #nota-textarea::placeholder {
    color: rgba(44, 44, 44, 0.4);
    font-style: italic;
}

#create-modal .note-paper #nota-textarea:focus {
    outline: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

/* Footer de la nota con fecha y botón */
.note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

#create-modal .note-paper .modal-date {
    text-align: left;
    color: #000;
    font-size: 0.85rem;
    font-style: italic;
    margin: 0;
}

/* Botón de enviar */
.submit-note-button {
    background: rgba(44, 44, 44, 0.1);
    border: 1px solid rgba(44, 44, 44, 0.3);
    color: #2c2c2c;
    padding: 8px 24px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.submit-note-button:hover,
.submit-note-button:focus {
    background: rgba(44, 44, 44, 0.15);
    border-color: rgba(44, 44, 44, 0.4);
    transform: translateY(-1px);
}

.submit-note-button:active {
    transform: translateY(0);
}

.submit-note-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mensaje de validación */
.validation-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    animation: slideDown 0.3s ease;
}

.validation-message.error {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #c0392b;
}

.validation-message.success {
    background-color: rgba(39, 174, 96, 0.1);
    border: 1px solid rgba(39, 174, 96, 0.3);
    color: #27ae60;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error en textarea */
#nota-textarea.input-error {
    border-bottom: 1px solid rgba(231, 76, 60, 0.5) !important;
    animation: shake 0.5s;
}

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

/* Textura de papel */
#create-modal .note-paper::after,
#nota-modal .note-paper-read::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 29px,
            rgba(0, 0, 0, 0.02) 29px,
            rgba(0, 0, 0, 0.02) 30px
        );
    pointer-events: none;
    z-index: 1;
}

/* Asegurar que el contenido esté por encima de la textura */
#create-modal .note-paper > *,
#nota-modal .note-paper-read > * {
    position: relative;
    z-index: 2;
}

/* ================================================
   MODAL DE LECTURA (NOTA-MODAL)
   ================================================ */

/* Aplicar estilos de papel a modal de lectura */
#nota-modal .note-paper-read {
    background: linear-gradient(135deg, #f9e79f 0%, #f7dc6f 50%, #f4d03f 100%);
    border: none;
    border-radius: 0;
    padding: 3rem 2.5rem 2rem 2.5rem;
    max-width: 500px;
    width: calc(100% - 2rem);
    box-sizing: border-box;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset -2px -2px 5px rgba(0, 0, 0, 0.1),
        inset 2px 2px 5px rgba(255, 255, 255, 0.3);
    transform: rotate(-2deg);
    animation: paperFloat 0.6s ease forwards;
}

#nota-modal .note-paper-read-back {
    position: absolute;
    z-index: -1;
    background: linear-gradient(135deg, #f9e79f 0%, #f7dc6f 50%, #f4d03f 100%);
    border: none;
    border-radius: 0;
    padding: 3rem 2.5rem 2rem 2.5rem;
    max-width: 500px;
    width: calc(100% - 2rem);
    min-height: 220px;
    box-sizing: border-box;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset -2px -2px 5px rgba(0, 0, 0, 0.1),
        inset 2px 2px 5px rgba(255, 255, 255, 0.3);

    transform: rotate(-10deg) !important;
    animation: paperFloat 0.6s ease forwards;
}

#nota-modal .note-paper-read h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: #2c2c2c;
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: 3px;
    font-weight: 400;
    text-transform: uppercase;
}

#nota-modal .note-paper-read .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: #999;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

#nota-modal .note-paper-read .modal-close:hover {
    color: #333;
    opacity: 1;
}

#nota-modal .note-paper-read .modal-text .model-text2 {
    font-size: 1rem;
    line-height: 1.8;
    color: #2c2c2c;
    margin: 2rem 0 1.5rem 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    background: transparent;
    border: none;
    padding: 0;
}

#nota-modal .note-paper-read .modal-date-read {
    text-align: left;
    color: #000;
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 1.5rem;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: #999;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-content h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #000;
}

.modal-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #000;
    margin: 2rem 0;
    white-space: pre-wrap;
}

.modal-date {
    font-size: 0.85rem;
    color: #000;
    margin-top: 2rem;
    text-align: right;
}


#nota-textarea:focus {
    outline: none;
    border-color: #555;
}

.char-counter {
    text-align: right;
    color: #fff;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.submit-button {
    width: 100%;
    background: #ffffff;
    border: none;
    color: #000000;
    padding: 15px;
    font-size: 1rem;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    font-weight: 600;
}

.submit-button:hover,
.submit-button:focus {
    background: #e0e0e0;
    color: black;
    transform: scale(1.02);
}

.submit-button:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

#create-modal-subtitle {
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

/* Desktop Large (1920px+) */
@media (min-width: 1920px) {
    .candles-container {
        max-width: 1600px;
    }

    .altar-title {
        font-size: 5rem;
    }

    .site-title {
        font-size: 3rem;
    }
}

/* Desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    .candles-container {
        max-width: 1400px;
    }
}

/* Laptop/Tablet Landscape (992px - 1199px) */
@media (max-width: 1199px) {
    .candles-container {
        max-width: 1000px;
        padding: 2rem 1.5rem;
    }

    .altar-title {
        font-size: 3.5rem;
        letter-spacing: 0.4rem;
    }

    .site-title {
        font-size: 2.2rem;
        letter-spacing: 0.8rem;
    }

    .modal-content {
        max-width: 550px;
    }

    #nota-modal .note-paper-read,
    #nota-modal .note-paper-read-back {
        max-width: 450px;
    }
}

/* Tablet Portrait (768px - 991px) */
@media (max-width: 991px) {
    .altar-title {
        font-size: 3rem;
        letter-spacing: 0.35rem;
    }

    .site-title {
        font-size: 2rem;
        letter-spacing: 0.6rem;
    }

    .welcome-text {
        font-size: 1.05rem;
        padding: 0 1rem;
    }

    .notes-count {
        font-size: 0.7rem;
        letter-spacing: 2px;
    }

    .tabs {
        gap: 1rem;
        padding: 0 1rem;
    }

    .tab-button {
        padding: 10px 24px;
        font-size: 0.85rem;
        letter-spacing: 1.5px;
    }

    .candles-container {
        max-width: 100%;
        padding: 2rem 1rem;
        min-height: 700px;
    }

    .candle {
        width: 55px;
    }

    .candle-body {
        width: 38px;
        height: 24px;
    }

    .modal-content {
        max-width: 90%;
        padding: 2.5rem 2rem;
        margin: 0 1rem;
    }

    #create-modal .note-paper,
    #create-modal .note-paper-back {
        max-width: 90%;
        width: calc(100% - 2rem);
        padding: 2.5rem 2rem 2rem 2rem;
    }

    #create-modal .note-paper-back {
        transform: rotate(-13deg) !important;
    }

    .instructions {
        padding: 0 2rem;
    }

    #instruction-text {
        font-size: 0.95rem;
    }

    #release-button {
        font-size: 0.9rem;
        padding: 12px 30px;
        letter-spacing: 1.5px;
        max-width: calc(100% - 4rem);
    }
}

/* Mobile Landscape / Small Tablet (576px - 767px) */
@media (max-width: 767px) {
    .altar-header {
        padding: 1.5rem 1rem;
    }

    .altar-title {
        font-size: 2.5rem;
        letter-spacing: 0.3rem;
    }

    .site-title {
        font-size: 1.8rem;
        letter-spacing: 0.5rem;
    }

    .welcome-content {
        padding: 1.5rem;
    }

    .welcome-text {
        font-size: 1rem;
        line-height: 1.6;
    }

    .enter-button {
        padding: 14px 45px;
        font-size: 0.95rem;
        letter-spacing: 1.5px;
    }

    .tab-button {
        width: 100%;
        max-width: 300px;
        padding: 12px 20px;
        font-size: 0.8rem;
    }

    .candles-container {
        min-height: 800px;
        padding: 1.5rem 0.75rem;
    }

    .candle {
        width: 50px;
    }

    .candle-body {
        width: 35px;
        height: 22px;
    }

    .candle-flame {
        width: 18px;
        height: 30px;
        top: -32px;
    }

    .candle-glow {
        width: 80px;
        height: 80px;
        top: -50px;
    }

    .modal {
        padding: 1rem;
    }

    .modal-content {
        max-width: 95%;
        padding: 2rem 1.5rem;
    }

    .modal-content h3 {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }

    #nota-modal .note-paper-read h3 {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    #nota-modal .note-paper-read-back {
        transform: rotate(-10deg) !important;
    }

    #create-modal .note-paper,
    #create-modal .note-paper-back {
        max-width: 95%;
        width: calc(100% - 1rem);
        padding: 2rem 1.5rem 1.5rem 1.5rem;
    }

    #create-modal .note-paper-back {
        transform: rotate(-13deg) !important;
    }

    #create-modal .note-paper #nota-textarea {
        min-height: 200px;
        font-size: 0.95rem;
    }

    .instructions {
        padding: 0 1rem;
        margin: 2rem 0 1.5rem 0;
    }

    #instruction-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    #release-button {
        font-size: 0.85rem;
        padding: 10px 25px;
        letter-spacing: 1.5px;
        max-width: calc(100% - 2rem);
    }

    .altar-footer {
        padding: 1.5rem;
        font-size: 0.8rem;
    }

    .note-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .submit-note-button {
        width: 100%;
        padding: 10px 20px;
    }

    .paper-clip::before {
        top: 5px;
    }

    #create-modal .note-paper .modal-close {
        left: 75%;
    }
}

/* Mobile Portrait (320px - 575px) */
@media (max-width: 575px) {
    .altar-title {
        font-size: 2rem;
        letter-spacing: 0.2rem;
    }

    .site-title {
        font-size: 1.5rem;
        letter-spacing: 0.4rem;
    }

    .notes-count {
        font-size: 0.65rem;
        letter-spacing: 1.5px;
        margin-bottom: 2rem;
    }

    .welcome-text {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 2rem;
    }

    .enter-button {
        padding: 12px 35px;
        font-size: 0.9rem;
        letter-spacing: 1px;
    }

    .altar-header {
        padding: 1rem;
    }

    .tab-button {
        padding: 10px 16px;
        font-size: 0.75rem;
        letter-spacing: 1px;
    }

    .candles-container {
        min-height: 1000px;
        padding: 1rem 0.5rem;
    }

    .candle {
        width: 45px;
    }

    .candle-body {
        width: 32px;
        height: 20px;
    }

    .candle-flame {
        width: 16px;
        height: 28px;
        top: -30px;
    }

    .candle-wick {
        height: 10px;
        top: -8px;
    }

    .candle-glow {
        width: 70px;
        height: 70px;
        top: -50px;
    }

    /* Reducir número de partículas en móvil (se gestiona con JS) */
    .particle {
        width: 2px;
        height: 2px;
    }

    .modal-content {
        max-width: 100%;
        padding: 1.5rem 1rem;
        margin: 0 0.5rem;
    }

    .modal-content h3 {
        font-size: 1.2rem;
        letter-spacing: 1.5px;
        margin-bottom: 1rem;
    }

    .modal-text {
        font-size: 0.9rem;
        line-height: 1.5;
        margin: 1.5rem 0;
    }

    .modal-close {
        font-size: 1.5rem;
        top: 0.5rem;
        right: 0.5rem;
    }

    #nota-modal .note-paper-read-back {
        transform: rotate(-10deg) !important;
    }

    #nota-modal .note-paper-read h3 {
        font-size: 1.1rem;
        letter-spacing: 1.5px;
    }

    #nota-modal .note-paper-read .modal-text {
        font-size: 0.9rem;
        margin: 1.5rem 0 1rem 0;
    }

    #nota-modal .note-paper-read .modal-date-read {
        font-size: 0.8rem;
        margin-top: 1rem;
    }

    #create-modal .note-paper,
    #create-modal .note-paper-back {
        max-width: calc(100% - 1rem);
        width: calc(100% - 1rem);
        padding: 1.5rem 1rem 1rem 1rem;
        margin: 0 0.5rem;
    }

    #create-modal .note-paper-back {
        transform: rotate(-13deg) !important;
    }

    #create-modal .note-paper h3 {
        font-size: 1.1rem;
        letter-spacing: 1.5px;
    }

    #create-modal .note-paper #nota-textarea {
        min-height: 180px;
        font-size: 0.9rem;
        line-height: 1.6;
    }

    #create-modal .note-paper .modal-date {
        font-size: 0.8rem;
    }

    .instructions {
        padding: 0 0.75rem;
        margin: 1.5rem 0 1rem 0;
    }

    #instruction-text {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    #release-button {
        font-size: 0.8rem;
        padding: 10px 20px;
        letter-spacing: 1px;
        max-width: calc(100% - 1rem);
    }

    .altar-footer {
        padding: 1rem;
        font-size: 0.75rem;
    }

    .note-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        margin-top: 1rem;
    }

    .submit-note-button {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .validation-message {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        margin-top: 0.75rem;
    }

    .welcome-footer {
        margin-top: 3rem;
    }

    .welcome-footer a {
        font-size: 0.8rem;
    }

    #create-modal .modal-content.note-paper-back {
        height: 490px
    }
}

/* Extra Small Devices (max 374px) */
@media (max-width: 374px) {
    .altar-title {
        font-size: 1.75rem;
        letter-spacing: 0.15rem;
    }

    .site-title {
        font-size: 1.3rem;
        letter-spacing: 0.3rem;
    }

    .enter-button {
        padding: 10px 30px;
        font-size: 0.85rem;
    }

    .tab-button {
        padding: 8px 12px;
        font-size: 0.7rem;
    }

    .candle {
        width: 40px;
    }

    .candle-body {
        width: 28px;
        height: 18px;
    }

    #instruction-text {
        font-size: 0.8rem;
    }

    #release-button {
        font-size: 0.75rem;
        padding: 8px 16px;
        max-width: calc(100% - 1rem);
        letter-spacing: 0.5px;
    }
}

/* Landscape Orientation Adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .welcome-screen {
        padding: 1rem;
    }

    .altar-title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .welcome-text {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .enter-button {
        padding: 10px 30px;
    }

    .notes-count {
        margin-bottom: 1.5rem;
    }

    .candles-container {
        min-height: 500px;
    }

    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }

    #create-modal .note-paper #nota-textarea {
        min-height: 120px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Aumentar áreas táctiles */
    .tab-button {
        min-height: 44px;
    }

    .enter-button {
        min-height: 48px;
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    .submit-note-button {
        min-height: 48px;
    }

    #release-button {
        min-height: 44px;
    }

    /* Eliminar efectos hover en dispositivos táctiles */
    .candle:hover {
        transform: none;
    }

    .tab-button:hover,
    .enter-button:hover {
        transform: none;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .candle-flame {
        filter: blur(0.3px);
    }

    .candle-glow {
        filter: blur(4px);
    }
}
