:root {
    --bg-color: #050505;
    --card-bg: #0d0d0e;
    --text-color: #d1d1d1;
    --text-dim: #777;
    --accent-color: #ff2a2a;
    --accent-dark: #8b0000;
    --accent-glow: rgba(255, 42, 42, 0.6);
    --sigil-color: #ff2a2a;
    --border-color: #222;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
}

.hidden {
    display: none !important;
}

/* Contador Minimalista */
.contador-container {
    position: absolute;
    top: 30px;
    right: 30px;
    text-align: right;
    font-size: 0.8rem;
    opacity: 0.5;
    letter-spacing: 1px;
}
.contador-numero {
    color: var(--accent-color);
    font-weight: bold;
    display: block;
    font-size: 1.1rem;
    margin-top: 5px;
    text-shadow: 0 0 5px rgba(255, 42, 42, 0.3);
}

/* Contenedor del Juego */
.game-container {
    width: 100%;
    max-width: 750px;
    padding: 20px;
    z-index: 10;
    margin-bottom: 40px;
}

/* Control de Flujo de Pasos */
.step {
    display: none;
    text-align: center;
    animation: fadeIn 0.6s ease forwards;
}
.step.active {
    display: block;
}

h1, h2 {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 30px;
    text-transform: uppercase;
}

/* Pantalla de Inicio */
.intro-box {
    max-width: 550px;
    margin: 0 auto;
}
.leyenda-misterio {
    font-size: 1.15rem;
    font-style: italic;
    color: var(--text-dim);
    margin-bottom: 50px;
    line-height: 1.7;
}
.advertencia-inicio {
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 4px;
    margin-bottom: 35px;
    text-transform: uppercase;
    animation: pulse 2s infinite alternate;
}

/* Botones y Controles Minimalistas */
.btn-action, .btn-option, .btn-secondary {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-color);
    padding: 15px 35px;
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.4s ease;
    text-transform: uppercase;
}
.btn-action.primary {
    border-color: var(--accent-color);
    color: #fff;
    background: rgba(255, 42, 42, 0.15);
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.3);
}
.btn-action:hover:not(:disabled), .btn-option:hover, .btn-secondary:hover {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: #000;
    box-shadow: 0 0 20px var(--accent-glow);
}
.btn-secondary {
    padding: 12px 24px;
    font-size: 0.75rem;
    border-color: #333;
}
.btn-ghost {
    background: transparent;
    border: none;
    color: #666;
    font-family: inherit;
    font-size: 0.75rem;
    letter-spacing: 1px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s;
}
.btn-ghost:hover {
    color: var(--accent-color);
}
.btn-action:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* FORMULARIO Y ESCENARIO DEL SIGILO */
.sigilo-box {
    max-width: 600px;
    margin: 0 auto;
}
.sigilo-titulo {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #fff;
}
.sigilo-subtexto {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 30px;
    line-height: 1.5;
}
.input-group-sigilo {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 400px;
    margin: 0 auto 30px auto;
}
.field-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.field-container label {
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    color: #999;
    text-transform: uppercase;
}
.field-container input {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px 15px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.field-container input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 42, 42, 0.2);
}

/* Canvas y Escenario de Revelación del Sigilo */
.sigil-stage {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sigil-canvas {
    width: 320px;
    height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(20,0,0,0.4) 0%, rgba(5,5,5,0) 70%);
    border: 1px solid rgba(255, 42, 42, 0.15);
    border-radius: 50%;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8), 0 0 25px rgba(255,42,42,0.1);
    position: relative;
}
.sigil-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.sigil-svg.watermark {
    opacity: 0.15;
    position: absolute;
    pointer-events: none;
}
.sigil-status-msg {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 15px 0;
    letter-spacing: 1px;
}
.sigil-actions-bar {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

/* ANIMACIONES VECTORIALES DEL SIGILO */
.sigil-element {
    transition: opacity 0.5s ease;
}

.sigil-animating .sigil-ring {
    stroke-dasharray: 2500;
    stroke-dashoffset: 2500;
    animation: sigilDraw 1.5s ease forwards 0.1s;
}

.sigil-animating .sigil-line {
    stroke-dasharray: 2500;
    stroke-dashoffset: 2500;
    animation: sigilDraw 1.8s ease forwards 1.0s;
}

.sigil-animating .sigil-node {
    opacity: 0;
    animation: sigilNodeFade 0.8s ease forwards 2.2s;
}

.sigil-animating .sigil-glyph {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: sigilDraw 1.2s ease forwards 2.8s;
}

@keyframes sigilDraw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes sigilNodeFade {
    0% { opacity: 0; transform: scale(0.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* Menú de Opciones */
.menu-opciones {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 320px;
    margin: 0 auto;
}

/* Área de Texto */
.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}
textarea {
    width: 100%;
    height: 120px;
    background: #0d0d0d;
    border: 1px solid #222;
    color: #fff;
    padding: 15px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: border 0.3s;
}
textarea:focus {
    border-color: var(--accent-color);
}

/* Elementos de los Rituales */
#canvas-ritual {
    width: 100%;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}
.instruccion-ritual {
    font-size: 0.9rem;
    color: #666;
    letter-spacing: 1px;
}

.espejo-objeto {
    width: 160px;
    height: 220px;
    background: linear-gradient(135deg, #111, #000);
    border: 4px solid #222;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.9), 0 0 15px rgba(0,0,0,0.5);
    cursor: pointer;
    position: relative;
    transition: transform 0.05s, border-color 0.2s;
}
.espejo-objeto:active {
    transform: scale(0.98);
}

.veladora-objeto {
    width: 60px;
    height: 120px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    position: relative;
    border-radius: 4px;
    cursor: pointer;
}
.flama {
    width: 16px;
    height: 26px;
    background: radial-gradient(circle, #ffaa44, #ff3300);
    border-radius: 50% 50% 20% 20%;
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 20px #ff5500;
    animation: flicker 0.1s infinite alternate;
    transition: transform 2s ease, opacity 2s ease;
}
.veladora-objeto.extinguiendo .flama {
    transform: translateX(-50%) scale(0.2);
    opacity: 0.2;
}

.contenedor-hilo {
    width: 100%;
    height: 60px;
    position: relative;
    cursor: ew-resize;
    display: flex;
    align-items: center;
}
.hilo-linea {
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
    transition: width 0.4s ease, opacity 0.4s ease;
}
.hilo-linea.cortado {
    width: 0%;
    opacity: 0;
}

/* --- REFINAMIENTO DE LA PANTALLA FINAL (#step-resultado) --- */
.resultado-box {
    max-width: 620px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.resultado-titulo {
    font-size: 1.6rem;
    font-weight: 300;
    color: #fff;
    letter-spacing: 3px;
    margin-bottom: 12px;
    text-transform: uppercase;
}
.resultado-mensaje {
    font-size: 0.95rem;
    color: #aaa;
    line-height: 1.7;
    margin-bottom: 30px;
    letter-spacing: 0.5px;
}
.resultado-reflexion {
    display: block;
    margin-top: 10px;
    font-style: italic;
    color: var(--accent-color);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* SELLO FINAL ILUMINADO CON RESPIRACIÓN LEVE */
.resultado-sigilo-wrapper {
    width: 240px;
    height: 240px;
    margin: 10px 0 30px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 42, 42, 0.08) 0%, rgba(5, 5, 5, 0) 70%);
    box-shadow: 0 0 35px rgba(255, 42, 42, 0.15);
    animation: sealBreathing 4s ease-in-out infinite alternate;
}

@keyframes sealBreathing {
    0% {
        transform: scale(0.98);
        box-shadow: 0 0 25px rgba(255, 42, 42, 0.12);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.02);
        box-shadow: 0 0 45px rgba(255, 42, 42, 0.28);
        opacity: 1;
    }
}

/* METADATA DEL RITUAL */
.resultado-metadata {
    background: #0a0a0c;
    border: 1px solid #1c0808;
    border-radius: 4px;
    padding: 12px 24px;
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 35px;
}
.meta-item {
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 1px;
}
.meta-label {
    color: #555;
    margin-right: 5px;
}

/* BOTONES PRINCIPALES DE ACCIÓN */
.resultado-acciones {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 50px;
}

/* SECCIÓN DISCRETA DE OFRENDA NARRATIVA */
.ofrenda-narrativa {
    border-top: 1px solid #18181c;
    padding-top: 30px;
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}
.ofrenda-texto {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 18px;
    font-style: italic;
    letter-spacing: 0.5px;
}
.btn-ofrenda {
    display: inline-block;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.75rem;
    letter-spacing: 2px;
    border: 1px solid #333;
    padding: 10px 24px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border-radius: 2px;
}
.btn-ofrenda:hover {
    border-color: var(--accent-dark);
    color: #fff;
    background: rgba(139, 0, 0, 0.2);
    box-shadow: 0 0 15px rgba(139, 0, 0, 0.3);
}

/* CONTROL DE AUDIO FLOTANTE (ESQUINA INFERIOR DERECHA) */
.audio-control-floating {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 999;
}
.btn-audio-toggle {
    background: rgba(10, 10, 12, 0.85);
    border: 1px solid #2a1212;
    color: #bbb;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}
.btn-audio-toggle:hover {
    border-color: var(--accent-color);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.25);
}

/* GALERÍA DE VALIDACIÓN VISUAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 20px;
}
.modal-content {
    background: #0a0a0c;
    border: 1px solid #222;
    width: 100%;
    max-width: 1100px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0,0,0,0.95);
    border-radius: 8px;
}
.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #1a1a1c;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 1rem;
    margin-bottom: 0;
    color: #ddd;
    letter-spacing: 1.5px;
}
.modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.3s;
}
.modal-close:hover {
    color: var(--accent-color);
}
.modal-body {
    padding: 30px;
    overflow-y: auto;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 36px;
    justify-content: center;
}
.gallery-card {
    background: #09090b;
    border: 1px solid #1a0808;
    border-radius: 6px;
    padding: 24px 16px 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 310px;
    box-sizing: border-box;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.gallery-card:hover {
    border-color: #8b0000;
    box-shadow: 0 10px 30px rgba(139, 0, 0, 0.3);
    transform: translateY(-5px);
}
.gallery-svg-container {
    width: 175px;
    height: 175px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}
.gallery-svg-container svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}
.gallery-info {
    width: 100%;
    text-align: center;
    margin-top: 15px;
}
.gallery-name {
    display: block;
    font-size: 0.85rem;
    color: #ffffff;
    font-weight: bold;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-date {
    display: block;
    font-size: 0.75rem;
    color: #8b0000;
    font-weight: bold;
    margin-top: 4px;
    letter-spacing: 1px;
}
.gallery-meta {
    display: block;
    font-size: 0.65rem;
    color: #555555;
    margin-top: 3px;
    letter-spacing: 1px;
}

/* Animaciones de Entrada */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0% { opacity: 0.4; text-shadow: 0 0 5px rgba(255,42,42,0.1); }
    100% { opacity: 1; text-shadow: 0 0 15px var(--accent-glow); }
}
@keyframes flicker {
    0% { transform: translateX(-50%) skewX(-2deg) scale(1); }
    100% { transform: translateX(-50%) skewX(2deg) scale(1.05); }
}
.pantalla-sacudida {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}