@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;800&family=Roboto:wght@300;400&display=swap');

:root {
    --font-primary: 'Cinzel', serif;
    --font-secondary: 'Roboto', sans-serif;
    --color-gold: #FFD700;
    --color-gold-darker: #DAA520;
    --color-gold-darkest: #B8860B;
    --color-text-light: #e0e0e0;
    --color-text-medium: #cccccc;
    --color-text-dark: #333333;
    --color-bg-dark: #0a0806;
    --color-panel-bg: rgba(15, 10, 5, 0.85);
    --color-panel-border: rgba(87, 69, 51, 0.7);
    --color-input-bg: rgba(0, 0, 0, 0.4);
    --color-input-border: #443322;
    --color-button-bg: #3a2c1e;
    --color-button-hover-bg: #574533;
    --color-button-play-bg: #800000; /* Rojo oscuro para "Jugar" */
    --color-button-play-hover-bg: #a02020; /* Rojo más brillante al pasar el mouse */
    --color-error: #ff6b6b;
    --color-success: #6bcb77;

    --particle-color-bright: rgba(255, 230, 180, 0.98);
    --particle-color-medium: rgba(255, 200, 100, 0.9);
    --particle-color-faint: rgba(220, 170, 90, 0.8);
}

body {
    font-family: var(--font-secondary);
    background-color: var(--color-bg-dark);
    background-image: url('../images/medieval_bg.jpg'); /* << ACTUALIZA ESTA RUTA >> */
    background-size: cover;
    background-attachment: fixed;
    background-position: center center;
    color: var(--color-text-light);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

.game-main-title {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: clamp(2.8em, 7vw, 5em);
    color: var(--color-gold);
    text-shadow: 
        1px 1px 2px rgba(0,0,0,0.6),
        0 0 7px var(--color-gold-darker),
        0 0 12px var(--color-gold-darkest);
    margin: 30px 0 40px 0;
    text-align: center;
    letter-spacing: 2px;
    position: relative;
    padding: 20px 25px; 
    -webkit-text-stroke: 0.5px var(--color-gold-darkest);
}

.game-main-title span.title-text-wrapper {
    position: relative;
    display: inline-block; 
}

.game-main-title::before,
.game-main-title::after,
.game-main-title span.title-text-wrapper::before,
.game-main-title span.title-text-wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    background-repeat: no-repeat;
    opacity: 0;
}

.game-main-title::before {
    left: 0;
    width: 25%;
    background-image:
        radial-gradient(circle 3px at 20% 70%, var(--particle-color-bright), transparent 100%),
        radial-gradient(circle 2px at 50% 40%, var(--particle-color-medium), transparent 100%),
        radial-gradient(circle 3.5px at 80% 60%, var(--particle-color-faint), transparent 100%);
    animation: simpleParticleFloat 7s infinite linear 0s;
}

.game-main-title span.title-text-wrapper::before {
    left: 25%;
    width: 25%;
    background-image:
        radial-gradient(circle 3.5px at 20% 60%, var(--particle-color-medium), transparent 100%),
        radial-gradient(circle 2.5px at 50% 30%, var(--particle-color-faint), transparent 100%),
        radial-gradient(circle 3px at 70% 75%, var(--particle-color-bright), transparent 100%);
    animation: simpleParticleFloat 7s infinite linear -1.75s;
}

.game-main-title span.title-text-wrapper::after {
    left: 50%;
    width: 25%;
    background-image:
        radial-gradient(circle 3px at 30% 70%, var(--particle-color-faint), transparent 100%),
        radial-gradient(circle 4px at 60% 40%, var(--particle-color-bright), transparent 100%),
        radial-gradient(circle 2.5px at 80% 65%, var(--particle-color-medium), transparent 100%);
    animation: simpleParticleFloat 7s infinite linear -3.5s;
}

.game-main-title::after {
    left: 75%;
    width: 25%;
    background-image:
        radial-gradient(circle 3.5px at 20% 50%, var(--particle-color-bright), transparent 100%),
        radial-gradient(circle 2px at 50% 80%, var(--particle-color-medium), transparent 100%),
        radial-gradient(circle 3px at 70% 35%, var(--particle-color-faint), transparent 100%);
    animation: simpleParticleFloat 7s infinite linear -5.25s;
}


@keyframes simpleParticleFloat {
    0% {
        background-size: 0 0, 0 0, 0 0;
        opacity: 0;
        background-position: 20% 100%, 50% 100%, 80% 100%;
    }
    15% {
        background-size: 6px 6px, 5px 5px, 7px 7px;
        opacity: 0.95;
    }
    25% {
        background-position: 25% 70%, 45% 75%, 75% 65%;
        opacity: 0.9;
    }
    50% {
        background-position: 15% 40%, 55% 35%, 85% 45%;
        opacity: 0.7;
    }
    75% {
        background-size: 5px 5px, 4px 4px, 6px 6px;
        background-position: 30% 10%, 40% 5%, 70% 15%;
        opacity: 0.3;
    }
    100% {
        background-size: 0 0, 0 0, 0 0;
        opacity: 0;
        background-position: 20% -20%, 50% -25%, 80% -15%;
    }
}

.content-wrapper {
    background-color: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    border-radius: 8px;
    padding: 30px 40px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    width: 100%;
    max-width: 550px; /* Default max-width */
    box-sizing: border-box;
    position: relative;
}

.form-container h2 {
    font-family: var(--font-primary);
    font-weight: 700;
    color: var(--color-gold-darker);
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    font-size: clamp(1.5em, 5vw, 2em);
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.5);
}

.form-container .form-group {
    margin-bottom: 20px;
}

.form-container label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text-medium);
    font-size: 0.95em;
    font-weight: 300;
}

.form-container input[type="text"],
.form-container input[type="password"],
.form-container input[type="email"] {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: 5px;
    color: var(--color-text-light);
    font-family: var(--font-secondary);
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-container input[type="text"]:focus,
.form-container input[type="password"]:focus,
.form-container input[type="email"]:focus {
    outline: none;
    border-color: var(--color-gold-darker);
    box-shadow: 0 0 10px rgba(218, 165, 32, 0.3);
}

.form-container input::placeholder {
    color: #777;
    font-weight: 300;
}

.form-container button[type="submit"] {
    width: 100%;
    padding: 12px 20px;
    background-color: var(--color-button-bg);
    color: var(--color-gold);
    border: 1px solid var(--color-gold-darkest);
    border-radius: 5px;
    font-family: var(--font-primary);
    font-size: 1.2em;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.form-container button[type="submit"]:hover {
    background-color: var(--color-button-hover-bg);
    color: #ffffff;
    box-shadow: 0 0 10px var(--color-gold-darker);
}

.form-link {
    text-align: center;
    margin-top: 20px;
}

.form-link a {
    color: var(--color-gold-darker);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 300;
}

.form-link a:hover {
    text-decoration: underline;
    color: var(--color-gold);
}

.message-area {
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    text-align: center;
    font-size: 0.95em;
    line-height: 1.5;
    border-width: 1px;
    border-style: solid;
}
.message-area p { margin: 0; }

.error-messages {
    background-color: rgba(255, 107, 107, 0.1);
    border-color: var(--color-error);
    color: var(--color-error);
}

.success-message {
    background-color: rgba(107, 203, 119, 0.1);
    border-color: var(--color-success);
    color: var(--color-success);
}

.index-page .content-wrapper { /* Specific to index page */
    max-width: 700px;
}

.online-status-indicator {
    text-align: right;
    margin-bottom: 20px;
    color: var(--color-text-medium);
    font-size: 0.9em;
    font-family: var(--font-secondary);
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #32CD32; /* Verde brillante */
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 7px #32CD32;
}

.index-main-panel {
    text-align: center;
}

.index-welcome-message h2 {
    font-family: var(--font-primary);
    font-weight: 700;
    color: var(--color-gold);
    font-size: clamp(1.8em, 5vw, 2.2em);
    margin-top: 0;
    margin-bottom: 15px;
}

.index-welcome-message p {
    font-size: 1.05em;
    line-height: 1.7;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-weight: 300;
}

.index-navigation-buttons {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.portal-button {
    display: inline-block; /* Changed from block for side-by-side in historia */
    text-align: center;
    width: 100%;
    max-width: 350px;
    padding: 12px 20px;
    background-color: var(--color-button-bg);
    color: var(--color-gold-darker);
    text-decoration: none;
    font-family: var(--font-primary);
    font-size: 1.1em;
    letter-spacing: 0.5px;
    border-radius: 5px;
    border: 1px solid var(--color-gold-darkest);
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    cursor: pointer; /* Added for button elements */
}
button.portal-button { /* Ensure button elements also look like links */
    line-height: normal; /* Reset for buttons */
}


.portal-button:hover {
    background-color: var(--color-button-hover-bg);
    color: #ffffff;
    border-color: var(--color-gold-darker);
    box-shadow: 0 0 12px var(--color-gold-darker);
}

.portal-button.play-emphasis {
    background-color: var(--color-button-play-bg);
    color: var(--color-gold);
    border-color: var(--color-gold);
    font-size: 1.3em;
    padding: 14px 20px;
    font-weight: 700;
}

.portal-button.play-emphasis:hover {
    background-color: var(--color-button-play-hover-bg);
    color: #ffffff;
    border-color: var(--color-gold-darker);
    box-shadow: 0 0 15px var(--color-gold);
}

.page-footer {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 0.85em;
    color: #888;
    font-weight: 300;
}
.page-footer p { margin: 0; }

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .game-main-title {
        font-size: clamp(2.2em, 10vw, 2.8em);
        margin: 20px 0 30px 0;
        padding: 15px 10px;
    }
    .content-wrapper {
        padding: 20px;
        max-width: 95% !important; /* Ensure it overrides specific max-widths */
    }
    .form-container h2 {
        font-size: 1.6em;
    }
    .index-welcome-message h2 {
        font-size: 1.5em;
    }
    .index-welcome-message p {
        font-size: 0.95em;
    }
    .portal-button, .form-container button[type="submit"] {
        font-size: 1em;
    }
    .portal-button.play-emphasis {
        font-size: 1.15em;
    }
}

/* --- ESTILOS ADICIONALES PARA HISTORIA.PHP --- */
.historia-page-content-wrapper { /* Para la página de historia */
    max-width: 750px; /* Más ancho para leer texto cómodamente */
}

.historia-chapter-display {
    text-align: left; /* El texto de los capítulos alineado a la izquierda */
}

#chapter-title-display {
    font-family: var(--font-primary);
    color: var(--color-gold-darker);
    font-size: clamp(1.6em, 4vw, 2em);
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 700;
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.3);
}

#chapter-text-display {
    font-size: 1.05em;
    line-height: 1.7;
    color: var(--color-text-light);
    margin-bottom: 30px;
    font-weight: 300;
}

#chapter-text-display p { /* Estilo para los párrafos generados por JS */
    margin-bottom: 1em; /* Espacio entre párrafos de la historia */
}
#chapter-text-display p:last-child {
    margin-bottom: 0;
}

.historia-navigation { /* Contenedor para los botones de navegación de la historia */
    margin-top: 30px;
    display: flex;
    flex-direction: row; /* Botones en línea */
    justify-content: space-between; /* Espacio entre Anterior/Siguiente y el Final */
    align-items: center;
    gap: 15px; /* Espacio entre botones */
}

.historia-navigation .portal-button {
    flex-grow: 1; /* Permite que los botones crezcan si hay espacio */
    max-width: 300px; /* Límite para que no sean demasiado anchos */
}
.historia-navigation #final-action-btn {
    /* Ya tiene play-emphasis, se ajusta bien */
}


@media (max-width: 700px) { /* Ajuste para pantallas medianas/pequeñas para botones de historia */
    .historia-navigation {
        flex-direction: column; /* Apilar botones */
    }
    .historia-navigation .portal-button,
    .historia-navigation #final-action-btn {
        width: 100%; /* Ancho completo al apilarse */
        max-width: 100%; /* Ancho completo al apilarse */
    }
}