/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', serif;
    line-height: 1.6;
    color: #2c1810;
    overflow-x: hidden;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d1b0e 50%, #1a1a1a 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Il velo di avvio (#loader) vive in main/css/boot_loader.css: stesse regole
   per homepage e gioco, e animazioni di sola opacita'/trasformazione perche'
   girino sul compositor mentre la pagina si carica. */

/* Usata anche dall'intestazione dell'hero: resta qui. */
@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    100% {
        opacity: 0.9;
        transform: translate3d(0, 0, 0);
    }
}

/* Altezza reale dell'header fisso: e' l'hero ad appoggiarcisi sotto, quindi
   deve stare in un solo posto. Qui c'e' il valore di riserva (padding +
   logo + notch); homepage.js lo riscrive con la misura vera a pagina carica,
   cosi' nemmeno una lingua piu' lunga o un font in ritardo puo' far finire il
   titolo sotto la barra. */
:root {
    --home-header-h: calc(2rem + 40px + env(safe-area-inset-top, 0px));
}

/* Header moderno */
.modern-header {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    font-family: 'MY_MEDIEVAL', serif;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.logo-text {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffd700;
    text-decoration: none;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 40px;
    height: 40px;
    padding: 0 0.6rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 20px;
    color: #ffd700;
    font-size: 0.85rem;
    font-family: 'MY_MEDIEVAL', serif;
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-links a i:only-child {
    margin: 0;
}

.social-links a:hover {
    background: #ffd700;
    color: #1a1a1a;
    transform: translateY(-2px);
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}

.login-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.forgot-pass-link {
    color: rgba(255, 215, 0, 0.7);
    font-size: 0.75rem;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.3s;
}

.forgot-pass-link:hover {
    color: #ffd700;
    text-decoration: underline;
}

.login-inline-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background-color: rgba(220, 53, 69, 0.12);
    border: 1px solid rgba(220, 53, 69, 0.5);
    border-left: 4px solid #dc3545;
    color: #ff8a8a;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    animation: fadeInDown 0.3s ease-out;
}

.login-inline-error[hidden] { display: none; }

.login-inline-error i {
    margin-top: 2px;
    flex-shrink: 0;
    color: #dc3545;
}

.login-inline-error span { flex: 1; }

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

.mobile-login-form .login-inline-error {
    color: #ff8a8a;
    margin-top: 0.5rem;
}

.login-error-tooltip {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 10000;
    background-color: rgba(220, 53, 69, 0.95);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideInRight 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-width: 450px;
    width: max-content;
    backdrop-filter: blur(5px);
    border-left: 5px solid #a71d2a;
    pointer-events: auto;
    line-height: 1.4;
}

/* Gestione responsive per schermi piccoli */
@media (max-width: 480px) {
    .login-error-tooltip {
        top: 90px;
        max-width: 90vw;
        right: 5vw;
        left: 5vw;
        width: auto;
    }
}

.login-error-tooltip span {
    flex: 1;
    word-break: break-word;
}

.login-error-tooltip i {
    margin-top: 3px; /* Allinea icona col testo su più righe */
    flex-shrink: 0;
}

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.login-form input {
    padding: 0.5rem;
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
    width: 120px;
    font-family: 'serif';
}

.login-form input::placeholder {
    color: rgba(255, 255, 255, 0.85);
}

.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a1a1a;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.btn-secondary {
    background: transparent;
    color: #ffd700;
    border: 2px solid #ffd700;
}

.btn-secondary:hover {
    background: #ffd700;
    color: #1a1a1a;
}

.btn-outline {
    background: transparent;
    color: rgba(255, 215, 0, 0.8);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.btn-outline:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border-color: #ffd700;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.6)), url('imgs/medieval_background_optimized.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    position: relative;
}

.hero-content {
    max-width: 800px;
    padding: 2rem;
    animation: fadeInUp 1s ease-out;
}

.hero h1 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 2rem;
    opacity: 0.9;
    font-style: italic;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

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

/* Story Section */
.story-section {
    padding: 5rem 0;
    background: linear-gradient(135deg, #f4e4bc 0%, #e6d3a3 100%);
    position: relative;
    overflow: hidden;
}

.story-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="%23000" opacity="0.02"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.story-header {
    text-align: center;
    margin-bottom: 4rem;
}

.story-header h2 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #8b4513;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.story-subtitle {
    font-size: 1.3rem;
    color: #5d4037;
    font-style: italic;
    opacity: 0.8;
}

.story-timeline {
    position: relative;
    margin: 4rem 0;
}

.story-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #8b4513, #a0522d, #8b4513);
    transform: translateX(-50%);
}

.timeline-item {
    display: flex;
    align-items: center;
    margin: 3rem 0;
    position: relative;
}

.timeline-item:nth-child(odd) {
    flex-direction: row;
}

.timeline-item:nth-child(even) {
    flex-direction: row-reverse;
}

.timeline-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(45deg, #8b4513, #a0522d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(139, 69, 19, 0.3);
    z-index: 2;
    position: relative;
}

.timeline-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 15px;
    margin: 0 2rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 69, 19, 0.1);
}

.timeline-content h3 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.4rem;
    /* Rete di sicurezza: sotto i 360px una parola sola ("L'Impero") supera la
       colonna e viene tagliata dall'overflow:hidden della sezione. */
    overflow-wrap: break-word;
    color: #8b4513;
    margin-bottom: 0.5rem;
}

.timeline-content p {
    color: #2c1810;
    line-height: 1.6;
    margin: 0;
}

.story-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    align-items: center;
    margin-top: 4rem;
    background: rgba(255, 255, 255, 0.7);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.story-cta > * {
    flex: 1;
    min-width: 300px;
}

.story-image {
    text-align: center;
}

.story-image img {
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

.story-image img:hover {
    transform: scale(1.05);
}

.story-action h3 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 2rem;
    /* Come sopra: a 320px "Leggenda" non entra nella colonna. Non cambia nulla
       alle larghezze in cui la parola ci sta. */
    overflow-wrap: break-word;
    color: #8b4513;
    margin-bottom: 1rem;
}

.story-action p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #2c1810;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .story-timeline::before {
        left: 40px;
    }
    
    .timeline-item {
        flex-direction: row !important;
        padding-left: 100px;
    }
    
    .timeline-icon {
        position: absolute;
        left: 0;
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
    
    .timeline-content {
        margin: 0;
        /* Flex item senza min-width: 0 = non scende sotto il proprio
           min-content e sborda dalla colonna sui display stretti. */
        min-width: 0;
    }

    .story-cta {
        flex-direction: column;
        text-align: center;
    }

    /* In colonna il min-width di .story-cta > * governa l'asse trasversale:
       i 300px pensati per la soglia di wrap in riga diventano una larghezza
       imposta, più larga del container, e sbordano. */
    .story-cta > * {
        min-width: 0;
        width: 100%;
    }
}

/* Features Section */
.features {
    padding: 5rem 0;
    background: #1a1a1a;
    color: white;
}

.features h2 {
    font-family: 'MY_MEDIEVAL', serif;
    /* Una singola parola lunga (IT "Caratteristiche", ES "Características") a
       2.5rem fisse supera la larghezza del container e fa scorrere la pagina
       di lato su mobile: la dimensione scala, e break-word resta come rete. */
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    overflow-wrap: break-word;
    text-align: center;
    margin-bottom: 3rem;
    color: #ffd700;
}

.features-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}

.feature-card {
    flex: 1 1 250px;
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid rgba(255, 215, 0, 0.1);
    min-height: 280px;
}

.feature-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0.2;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 0;
}

.feature-content {
    position: relative;
    z-index: 1;
    padding: 2rem;
    background: linear-gradient(180deg, rgba(26,26,26,0.6) 0%, rgba(26,26,26,0.9) 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card:hover .feature-bg {
    opacity: 0.35;
    transform: scale(1.05);
}

.feature-icon {
    font-size: 3rem;
    color: #ffd700;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #ffd700;
}


/* Main content wrapper */
.main-content {
    flex: 1;
}

/* ══════════════════════════════════════════════════════════════
   REALM MODALS — Unified Medieval Theme (Login + Registration)
   ══════════════════════════════════════════════════════════════ */
.realm-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10000;
    justify-content: center;
    align-items: center;
    /* Lo stemma sporge di 38px sopra la cornice: senza questa fascia il bordo
       dello schermo lo taglierebbe come lo tagliava prima l overflow. */
    padding: 46px 0 14px;
    animation: modalFadeIn 0.3s ease-out;
}

.realm-modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.realm-modal-content {
    position: relative;
    background: linear-gradient(160deg, #1a0f08 0%, #2d1b0e 50%, #1a0f08 100%);
    border: 2px solid rgba(212, 175, 55, 0.35);
    border-radius: 16px;
    width: 92%;
    /* 60px = la fascia di .realm-modal (46 sopra per lo stemma, 14 sotto).
       Va sottratta a mano: un `max-height: 92dvh` non sa che il genitore si e'
       preso quello spazio, e il modale sfora sotto di quanto ha guadagnato
       sopra. */
    max-height: calc(100dvh - 60px);
    /* Colonna: intestazione ferma in alto, corpo che scorre, niente overflow
       sulla cornice — era lui a tagliare a meta lo stemma. */
    display: flex;
    flex-direction: column;
    overflow: visible;
    animation: modalSlideIn 0.4s ease-out;
    box-shadow:
        0 0 80px rgba(212, 175, 55, 0.12),
        0 25px 50px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 215, 0, 0.08);
}

.realm-modal-sm { max-width: 440px; }
.realm-modal-lg { max-width: 680px; }

/* Crest decoration */
.realm-modal-crest {
    position: absolute;
    top: -38px;
    pointer-events: none;
    left: 50%;
    transform: translateX(-50%);
    width: 76px; height: 76px;
    border-radius: 50%;
    border: 3px solid #d4af37;
    background: linear-gradient(160deg, #1a0f08, #2d1b0e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3), 0 4px 15px rgba(0, 0, 0, 0.5);
}

.realm-crest-img {
    width: 48px; height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Close button */
.realm-close {
    position: absolute;
    top: 12px; right: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: rgba(244, 228, 188, 0.6);
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 6;
    font-size: 0.9rem;
}

.realm-close:hover {
    background: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.4);
    color: #ff6b6b;
    transform: rotate(90deg);
}

/* Header */
.realm-modal-header {
    flex: 0 0 auto;
    text-align: center;
    /* Lo stemma sta ora tutto sopra la cornice: qui dentro non serve piu
       lasciargli 2.8rem di cielo. */
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.realm-modal-header h2 {
    font-family: 'MY_MEDIEVAL', serif;
    color: #ffd700;
    font-size: 1.5rem;
    margin: 0 0 0.4rem;
    text-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    letter-spacing: 1px;
}

.realm-modal-header h2 i {
    margin-right: 8px;
    opacity: 0.8;
}

.realm-subtitle {
    color: rgba(244, 228, 188, 0.55);
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    font-style: italic;
    margin: 0;
}

/* Body — l unico pezzo che scorre. min-height:0 o in flex non si stringe. */
.realm-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.4rem 2rem 2rem;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
}

/* Nel modulo d iscrizione il fondo lo tiene la barra dei passi, che e
   appiccicata in basso: qui sotto ci sarebbe solo aria sprecata. */
.realm-modal-body:has(#registrationForm) {
    padding-bottom: 0;
}

/* ── Realm Fields (unified input style) ── */
.realm-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.2rem;
}

/* Il modale e largo 680px: sopra i 700px di finestra i campi stanno a due per
   riga, e un passo intero si legge senza scorrere. Lo scarto fra le righe
   cresce perche la riga di aiuto vive SOTTO al campo, fuori dal suo riquadro. */
@media (min-width: 700px) {
    .realm-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 1.1rem;
        row-gap: 1.7rem;
    }

    /* Campi larghi tutta la riga: portano una riga di aiuto lunga (il tag), o
       chiudono il passo da soli (lingua, citta). */
    .realm-field-wide { grid-column: 1 / -1; }
}

.realm-field {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(244, 228, 188, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.18);
    border-radius: 10px;
    transition: all 0.3s ease;
    margin-bottom: 0.2rem;
}

.realm-field:hover {
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(244, 228, 188, 0.06);
}

.realm-field:focus-within {
    border-color: #d4af37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.12), 0 0 40px rgba(212, 175, 55, 0.05);
    background: rgba(244, 228, 188, 0.07);
}

.realm-field-icon {
    width: 46px;
    min-width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(212, 175, 55, 0.5);
    font-size: 1rem;
    transition: color 0.3s ease;
    border-right: 1px solid rgba(212, 175, 55, 0.1);
    align-self: stretch;
}

.realm-field:focus-within .realm-field-icon {
    color: #d4af37;
}

.realm-field-input {
    flex: 1;
    position: relative;
    min-width: 0;
}

.realm-field-input input,
.realm-field-input select {
    width: 100%;
    padding: 14px 15px;
    background: transparent;
    border: none;
    outline: none;
    color: #f4e4bc;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    letter-spacing: 0.3px;
}

.realm-field-input input::placeholder {
    color: rgba(244, 228, 188, 0.3);
    font-style: italic;
}

.realm-field-input input:focus::placeholder {
    color: rgba(212, 175, 55, 0.4);
}

/* Floating label inside realm-field */
.realm-field-input label {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: rgba(244, 228, 188, 0.5);
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 4px;
    background: transparent;
}

.realm-field-input input:focus ~ label,
.realm-field-input input:not(:placeholder-shown) ~ label,
.realm-field-input input[placeholder]:not([placeholder=" "]) ~ label {
    top: -1px;
    transform: translateY(-50%) scale(0.8);
    color: #d4af37;
    background: linear-gradient(180deg, transparent 45%, #1a0f08 45%, #1a0f08 55%, transparent 55%);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Select styling */
.realm-field-select .realm-field-input select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23d4af37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
    padding-right: 35px;
}

.realm-field-select .realm-field-input select option {
    background: #1a0f08;
    color: #f4e4bc;
    font-family: 'Crimson Text', serif;
    padding: 8px;
}

.realm-field-select .realm-field-input select option:checked {
    background: #8b4513;
    color: #fff;
}

/* Select floating label — always floated up */
.realm-field-select .realm-field-input label {
    top: -1px;
    left: 15px;
    transform: translateY(-50%) scale(0.8);
    color: #d4af37;
    background: linear-gradient(180deg, transparent 45%, #1a0f08 45%, #1a0f08 55%, transparent 55%);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Helper & feedback text */
.realm-field-helper {
    position: absolute;
    bottom: -18px;
    left: 48px;
    font-size: 0.72rem;
    color: rgba(212, 175, 55, 0.4);
    font-family: 'Crimson Text', serif;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 60px);
}

.realm-field:focus-within .realm-field-helper {
    opacity: 1;
}

/* Campi con le regole di identità (nome, cognome, tag, username): la riga di
   aiuto porta anche cosa si può scrivere, quindi non sta più su una riga sola.
   Diventa un pannellino che compare mentre si scrive — sopra al campo
   successivo, con un fondo suo, invece di sovrapporvisi in trasparenza.
   Compare al focus, non all'hover: sul touch l'hover non esiste. */
.realm-field-helper.has-identity-rules {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    top: calc(100% + 6px);
    bottom: auto;
    right: 12px;
    max-width: none;
    z-index: 5;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(20, 14, 8, 0.97);
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    line-height: 1.35;
}

.realm-field-helper .identity-rules-line {
    display: block;
    margin-top: 3px;
    color: rgba(240, 224, 187, 0.72);
    font-style: normal;
}

/* Il campo si è riscritto da solo: username in minuscolo, tag con l'iniziale
   maiuscola (includes/identity_rules.js). La riscrittura DEVE vedersi — un
   valore che cambia mentre guardi altrove sembra un errore di battitura tuo —
   quindi il testo si accende d'oro e si riposa sul suo colore. Il lampo è sulle
   lettere perché sono le lettere ad essere cambiate. */
.realm-field-input input.identity-canonicalized {
    animation: identityCanonicalized 620ms ease-out;
}

@keyframes identityCanonicalized {
    0%   { color: #ffd86b; text-shadow: 0 0 10px rgba(212, 175, 55, 0.75); }
    100% { color: #f4e4bc; text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
    .realm-field-helper { transition: none; }
    /* Non `animation: none`: senza animationend la classe non verrebbe mai
       tolta e la correzione dopo non si riaccenderebbe. Dura un istante. */
    .realm-field-input input.identity-canonicalized { animation-duration: 1ms; }
}

/* Esito di un campo. Il colore lo decide l ESITO, non il posto in cui
   compare: prima era rosso fisso, e «le password corrispondono» — una buona
   notizia — arrivava del colore di un errore. Il segno di spunta e un icona
   Font Awesome messa qui: nel JS era un carattere scritto a mano. */
.realm-field .email-feedback,
.realm-field .password-feedback,
.realm-field .realm-field-error {
    position: absolute;
    bottom: -18px;
    left: 48px;
    right: 12px;
    font-size: 0.72rem;
    font-family: 'Crimson Text', serif;
    font-style: italic;
    line-height: 1.3;
    color: #ff6b6b;
}

.realm-field .email-feedback.is-ok,
.realm-field .password-feedback.is-ok,
.realm-field .realm-field-error.is-ok {
    color: #8fd694;
}

.realm-field .email-feedback.is-ok::before,
.realm-field .password-feedback.is-ok::before,
.realm-field .realm-field-error.is-ok::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-style: normal;
    margin-right: 5px;
}

/* Un errore e una riga di aiuto occupano lo stesso rigo: quando c e un errore
   parla l errore, o si sovrappongono l uno all altra. */
.realm-field:has(input.invalid) .realm-field-helper,
.realm-field:has(select.invalid) .realm-field-helper {
    opacity: 0;
}

/* Validation states */
.realm-field.invalid,
.realm-field:has(input.invalid),
.realm-field:has(select.invalid) {
    border-color: rgba(220, 53, 69, 0.5) !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.15) !important;
    animation: realmShake 0.4s ease;
}

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

.realm-field.valid,
.realm-field:has(input.valid) {
    border-color: rgba(40, 167, 69, 0.4);
}

/* Chrome/Safari Autofill Override */
.realm-field-input input:-webkit-autofill,
.realm-field-input input:-webkit-autofill:hover,
.realm-field-input input:-webkit-autofill:focus,
.realm-field-input input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 50px #1a0f08 inset !important;
    -webkit-text-fill-color: #f4e4bc !important;
    background-color: transparent !important;
    background-clip: text !important;
    caret-color: #f4e4bc;
    transition: background-color 5000s ease-in-out 0s;
}

.realm-field-input input:-webkit-autofill ~ label {
    top: -1px;
    transform: translateY(-50%) scale(0.8);
    color: #d4af37;
    background: linear-gradient(180deg, transparent 45%, #1a0f08 45%, #1a0f08 55%, transparent 55%);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Toggle password */
.realm-toggle-pass {
    background: none;
    border: none;
    color: rgba(212, 175, 55, 0.4);
    cursor: pointer;
    padding: 0 14px;
    font-size: 0.9rem;
    transition: color 0.3s;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.realm-toggle-pass:hover {
    color: #d4af37;
}

/* ── Realm Buttons ── */
.realm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.35s ease;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
}

/* Passo non ancora completo. Il bottone NON viene spento: spento era muto —
   si premeva, non accadeva nulla e nessuno diceva che cosa mancasse. Ora si
   smorza per dire «non ancora», ma il clic passa e la validazione accende i
   campi che mancano. */
.realm-btn.is-incomplete {
    filter: saturate(0.45) brightness(0.78);
    box-shadow: none;
}

.realm-btn.is-incomplete:hover {
    transform: none;
}

/* Spento davvero: solo durante l invio, quando premere di nuovo
   raddoppierebbe l iscrizione. */
.realm-btn:disabled {
    cursor: progress;
    opacity: 0.65;
}

.realm-btn:disabled:hover {
    transform: none;
}

.realm-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    transition: left 0.5s ease;
}

.realm-btn:hover::before {
    left: 100%;
}

.realm-btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #8b4513, #a0522d, #8b4513);
    color: #f8ddb2;
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 4px 20px rgba(139, 69, 19, 0.3);
    font-size: 1rem;
    letter-spacing: 2px;
}

.realm-btn-primary:hover {
    background: linear-gradient(135deg, #a0522d, #cd853f, #a0522d);
    box-shadow: 0 6px 30px rgba(212, 175, 55, 0.25);
    transform: translateY(-2px);
}

.realm-btn-next {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.25);
    flex: 1;
}

.realm-btn-next:hover {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}

.realm-btn-prev {
    background: transparent;
    color: rgba(244, 228, 188, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    flex: 0.5;
}

.realm-btn-prev:hover {
    background: rgba(212, 175, 55, 0.08);
    color: #f4e4bc;
    border-color: rgba(212, 175, 55, 0.4);
}

.realm-btn-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #8b4513, #a0522d, #cd853f);
    color: #f8ddb2;
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 4px 20px rgba(139, 69, 19, 0.3);
    font-size: 1rem;
    letter-spacing: 2px;
    flex: 1;
}

.realm-btn-submit:hover {
    background: linear-gradient(135deg, #a0522d, #cd853f, #daa520);
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.3), 0 0 20px rgba(212, 175, 55, 0.15);
    transform: translateY(-2px);
}

/* ── Realm Divider ── */
.realm-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.2rem 0;
    color: rgba(212, 175, 55, 0.35);
    font-size: 0.7rem;
}

.realm-divider::before,
.realm-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.25), transparent);
}

/* ── Realm Links ── */
.realm-links {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.realm-links a {
    color: rgba(244, 228, 188, 0.5);
    text-decoration: none;
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.realm-links a:hover {
    color: #d4af37;
}

.realm-links a strong {
    color: #d4af37;
    font-weight: 700;
}

/* ── Realm Stepper (Registration) ── */
.realm-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.1rem;
    padding: 0 0.5rem;
}

.realm-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 2;
    min-width: 70px;
}

.realm-step-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(212, 175, 55, 0.25);
    background: rgba(26, 15, 8, 0.9);
    color: rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.4s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.realm-step-label {
    font-size: 0.72rem;
    color: rgba(244, 228, 188, 0.35);
    font-family: 'Crimson Text', serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.realm-step-connector {
    flex: 1;
    height: 2px;
    background: rgba(212, 175, 55, 0.15);
    margin-top: -20px;
    position: relative;
    min-width: 30px;
    max-width: 80px;
}

.realm-step-connector::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 100%;
    background: linear-gradient(90deg, #d4af37, #ffd700);
    transition: width 0.5s ease;
}

.realm-step-connector.active::after {
    width: 100%;
}

/* Active step */
.realm-step.active .realm-step-icon {
    border-color: #d4af37;
    color: #ffd700;
    background: rgba(45, 27, 14, 0.95);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3), 0 0 40px rgba(212, 175, 55, 0.1);
    transform: scale(1.1);
}

.realm-step.active .realm-step-label {
    color: #d4af37;
}

/* Completed step */
.realm-step.completed .realm-step-icon {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #1a0f08;
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.realm-step.completed .realm-step-label {
    color: rgba(212, 175, 55, 0.7);
}

/* ── Realm Step Title ── */
.realm-step-title {
    color: #ffd700;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.9rem;
    padding-bottom: 8px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    position: relative;
}

.realm-step-title::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 60px; height: 2px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
}

.realm-step-title i {
    margin-right: 8px;
    opacity: 0.7;
    font-size: 0.95rem;
}

/* ── Realm Step Navigation ── */
.realm-step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 1.4rem;
}

/* Nel modale web la barra resta incollata in fondo al corpo che scorre: il
   terzo passo e lungo per forza (regole e consensi) e il sigillo non deve
   andarsi a cercare. Nel pannello dell app la cornice e un altra: la si lascia
   in fondo al contenuto, dove sta gia. */
.realm-modal:not(.al-embedded-modal) .realm-step-nav {
    position: sticky;
    bottom: 0;
    z-index: 6;
    padding: 0.9rem 0 1.3rem;
    margin-top: 1rem;
    background: linear-gradient(180deg, rgba(26, 15, 8, 0) 0%, #1a0f08 45%, #1a0f08 100%);
}

/* ── Realm Summary (Step 3) ── */
@media (min-width: 700px) {
    /* Il riepilogo e' fatto di righe corte: affiancare le due sezioni toglie
       mezzo schermo di scorrimento al passo piu' lungo. */
    .realm-summary {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 1.6rem;
        align-items: start;
    }

    .realm-summary .realm-divider { display: none; }
}
.realm-summary {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.2rem;
}

.realm-summary-section h4 {
    font-family: 'MY_MEDIEVAL', serif;
    color: #d4af37;
    font-size: 0.95rem;
    margin: 0 0 0.8rem;
    letter-spacing: 0.5px;
}

.realm-summary-section h4 i {
    margin-right: 6px;
    opacity: 0.7;
}

.realm-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.08);
}

.realm-summary-row:last-child {
    border-bottom: none;
}

.realm-summary-label {
    color: rgba(244, 228, 188, 0.5);
    font-family: 'Crimson Text', serif;
    font-size: 0.85rem;
}

.realm-summary-label i {
    margin-right: 6px;
    width: 16px;
    text-align: center;
    opacity: 0.6;
}

.realm-summary-val {
    color: #f4e4bc;
    font-family: 'Crimson Text', serif;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
}

/* ── Realm Game Rules ── */
.realm-rules-section {
    margin: 1.1rem 0 0.4rem;
}

.realm-rules-heading {
    color: #d4af37;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.realm-rules-heading i {
    margin-right: 6px;
    opacity: 0.8;
}

.realm-rules-intro {
    color: rgba(244, 228, 188, 0.6);
    font-family: 'Crimson Text', serif;
    font-size: 0.88rem;
    margin-bottom: 10px;
}

.realm-rule {
    border: 1px solid rgba(212, 175, 55, 0.12);
    border-radius: 8px;
    margin-bottom: 6px;
    overflow: hidden;
    transition: border-color 0.3s;
    cursor: pointer;
}

.realm-rule:hover {
    border-color: rgba(212, 175, 55, 0.3);
}

.realm-rule-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(212, 175, 55, 0.06);
    color: rgba(244, 228, 188, 0.85);
    font-family: 'Crimson Text', serif;
    font-size: 0.92rem;
    font-weight: 600;
    /* E' un <button>, non piu' un <div> con l'onclick: la regola si apre anche
       da tastiera. Senza questi azzeramenti arriverebbe col grigio di sistema. */
    text-align: left;
    border: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.realm-rule-header:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.7);
    outline-offset: -2px;
}

.realm-rule-header i:first-child {
    color: rgba(212, 175, 55, 0.6);
    font-size: 0.85rem;
    width: 18px;
    text-align: center;
}

.realm-rule-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    color: rgba(212, 175, 55, 0.4);
    transition: transform 0.3s;
}

.realm-rule.open .realm-rule-arrow {
    transform: rotate(180deg);
}

.realm-rule-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 14px;
    color: rgba(244, 228, 188, 0.55);
    font-family: 'Crimson Text', serif;
    font-size: 0.84rem;
    line-height: 1.5;
}

.realm-rule.open .realm-rule-body {
    max-height: 300px;
    padding: 8px 14px 12px;
}

/* ── Realm Checkbox ── */
.realm-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Sono quattro di fila: 1.2rem di margine l'una faceva del terzo passo una
       colonna d'aria. */
    margin: 0.7rem 0;
    padding: 11px 14px;
    background: rgba(212, 175, 55, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.12);
    border-radius: 10px;
    transition: border-color 0.3s;
}

.realm-checkbox:hover {
    border-color: rgba(212, 175, 55, 0.25);
}

.realm-checkbox input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: #d4af37;
    cursor: pointer;
}

.realm-checkbox label {
    color: rgba(244, 228, 188, 0.7);
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    cursor: pointer;
}

.realm-checkbox label i {
    margin-right: 4px;
    color: rgba(212, 175, 55, 0.5);
}

.realm-checkbox a {
    color: #d4af37;
    text-decoration: none;
    font-weight: 600;
}

.realm-checkbox a:hover {
    color: #ffd700;
    text-decoration: underline;
}

/* L'informativa in breve sopra le caselle (parere legale del 12-10-2026): chi tratta i dati e perché, col link */
.realm-privacy-notice {
    color: rgba(244, 228, 188, 0.6);
    font-family: 'Crimson Text', serif;
    font-size: 0.88rem;
    line-height: 1.4;
    margin: 1rem 0 0.2rem;
}

.realm-privacy-notice a {
    color: #d4af37;
    font-weight: 600;
}

/* ── Realm Modal Scrollbar ── */
.realm-modal-content::-webkit-scrollbar {
    width: 6px;
}

.realm-modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.realm-modal-content::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.realm-modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}


/* ── Realm Modal Responsive ── */
@media (max-width: 768px) {
    /* Lo stemma resta sopra la cornice anche qui: la fascia di .realm-modal
       gli fa posto, quindi al modale ne resta un po' meno di prima. */
    .realm-modal {
        padding: 42px 0 10px;
    }

    .realm-modal-content {
        width: 96%;
        max-height: calc(100dvh - 52px); /* la fascia qui e' 42 + 10 */
        border-radius: 12px;
    }

    .realm-modal-header {
        padding: 1.1rem 1.5rem 0.8rem;
    }

    .realm-modal-header h2 {
        font-size: 1.25rem;
    }

    .realm-modal-body {
        padding: 1rem 1.2rem 1.5rem;
    }

    .realm-modal:not(.al-embedded-modal) .realm-step-nav {
        padding: 0.7rem 0 1rem;
        margin-top: 0.8rem;
    }

    .realm-step-icon {
        width: 42px; height: 42px;
        font-size: 0.95rem;
    }

    .realm-step-label {
        font-size: 0.65rem;
    }

    .realm-btn {
        padding: 12px 20px;
        font-size: 0.85rem;
        letter-spacing: 1px;
    }

    .realm-btn-primary,
    .realm-btn-submit {
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .realm-modal-content {
        width: 98%;
        /* Come sopra: 42 + 10 di fascia. Un `98dvh` qui rimetteva il modale
           piu' alto dello spazio che gli resta, e lo stemma tornava tagliato. */
        max-height: calc(100dvh - 52px);
    }

    .realm-modal-crest {
        width: 64px; height: 64px;
        top: -32px;
    }

    .realm-crest-img {
        width: 40px; height: 40px;
    }

    .realm-modal-header {
        padding: 1rem 1rem 0.7rem;
    }

    .realm-modal-header h2 {
        font-size: 1.1rem;
    }

    .realm-subtitle {
        font-size: 0.82rem;
    }

    .realm-modal-body {
        padding: 0.8rem 1rem 1.2rem;
    }

    .realm-field-icon {
        width: 38px; min-width: 38px;
        font-size: 0.85rem;
    }

    .realm-field-input input,
    .realm-field-input select {
        padding: 12px;
        font-size: 0.95rem;
    }

    .realm-step-nav {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .realm-btn-prev,
    .realm-btn-next,
    .realm-btn-submit {
        width: 100%;
        flex: none;
    }

    .realm-step-icon {
        width: 36px; height: 36px;
        font-size: 0.85rem;
    }

    .realm-step-connector {
        min-width: 20px;
    }
}

@media (max-height: 700px) {
    .realm-modal-content {
        max-height: calc(100dvh - 52px);
    }

    .realm-modal-header {
        padding: 0.9rem 1.5rem 0.6rem;
    }

    .realm-form-grid {
        gap: 0.8rem;
    }

    .realm-step-title {
        font-size: 0.95rem;
        margin-bottom: 0.8rem;
    }

    .realm-stepper {
        margin-bottom: 1rem;
    }
}

/* Schermo basso — portatile piccolo, telefono coricato. Lo stemma e il motto
   sono sapore; i campi sono il modulo. Si toglie il sapore, non il modulo. */
@media (max-height: 620px) {
    .realm-modal { padding: 10px 0; }
    .realm-modal-content { max-height: calc(100dvh - 20px); }
    .realm-modal-crest { display: none; }
    .realm-subtitle { display: none; }
    .realm-modal-header { padding: 0.9rem 1.5rem 0.7rem; }
    .realm-stepper { margin-bottom: 0.7rem; }
    .realm-step-title { margin-bottom: 0.6rem; }
}

/* ── Stats Section ──────────────────────────────────────────── */
.stats-section {
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 50%, #0d0d0d 100%);
    padding: 3rem 0;
    border-top: 1px solid rgba(255, 215, 0, 0.15);
    border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}

.stats-grid {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.stat-item i {
    font-size: 1.8rem;
    color: #ffd700;
    opacity: 0.8;
}

.stat-number {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.stat-version {
    font-size: 2.2rem;
}

.stat-label {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 2px;
}

@media (max-width: 480px) {
    .stats-grid {
        gap: 1.5rem;
    }
    .stat-number {
        font-size: 2rem;
    }
    .stat-item i {
        font-size: 1.4rem;
    }
}

/* ── Testimonials Section ───────────────────────────────────── */
.testimonials-section {
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 50%, #0d0d0d 100%);
    padding: 5rem 0;
    color: white;
}

.testimonials-section h2 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    color: #ffd700;
}

.testimonials-grid {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.testimonial-card {
    flex: 1 1 280px;
    max-width: 380px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #ffd700;
    border-radius: 0 12px 12px 0;
    padding: 2rem;
    position: relative;
    transition: transform 0.3s ease, background 0.3s ease;
}

.testimonial-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.06);
}

.testimonial-quote-icon {
    font-size: 1.5rem;
    color: rgba(255, 215, 0, 0.3);
    margin-bottom: 1rem;
    display: block;
}

.testimonial-text {
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 1.5rem;
}

.testimonial-author {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #ffd700;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
}

.testimonial-author i {
    font-size: 1rem;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .testimonials-grid {
        flex-direction: column;
        align-items: center;
    }
    .testimonial-card {
        max-width: 100%;
    }
}

/* Registration Modal Styles moved to end of file */
/* Animation keyframes retained for use */

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}







/* Progress Bar Styles */
.progress-container {
    margin-bottom: 8px;
    padding: 0 10px;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    padding: 8px 12px;
    position: relative;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(139, 69, 19, 0.3);
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.2);
    width: 100%;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: calc(25px + 30px);
    left: 30px;
    right: 30px;
    height: 3px;
    background: rgba(139, 69, 19, 0.3);
    z-index: 1;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    transition: all 0.4s ease;
    padding: 10px;
    border-radius: 15px;
}

.progress-step:hover {
    background: rgba(212, 175, 55, 0.1);
    transform: translateY(-2px);
}

.step-number {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.4), rgba(160, 82, 45, 0.3));
    color: #8b4513;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
    border: 2px solid #8b4513;
    transition: all 0.4s ease;
    font-family: 'MY_MEDIEVAL', serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.step-number::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.step-number:hover::before {
    opacity: 1;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.step-label {
    color: #a0522d;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    font-family: 'Crimson Text', serif;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.progress-step.active .step-number {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6), 0 0 50px rgba(255, 215, 0, 0.3);
    transform: scale(1.15);
    animation: activeGlow 2s ease-in-out infinite alternate;
}

@keyframes activeGlow {
    0% { box-shadow: 0 0 25px rgba(212, 175, 55, 0.6), 0 0 50px rgba(255, 215, 0, 0.3); }
    100% { box-shadow: 0 0 35px rgba(212, 175, 55, 0.8), 0 0 70px rgba(255, 215, 0, 0.5); }
}

.progress-step.active .step-label {
    color: #d4af37;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
}

.progress-step.completed .step-number {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border-color: #28a745;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.5);
    position: relative;
}

.progress-step.completed .step-number::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-step.completed .step-label {
    color: #28a745;
}

/* Form Steps */
.form-step {
    display: none;
    animation: fadeInSlide 0.5s ease-out;
}

.form-step.active {
    display: block;
}

.step-title {
    color: #ffd700;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 5px;
    font-family: 'MY_MEDIEVAL', serif;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
    position: relative;
    padding-bottom: 3px;
}

.step-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #d4af37, #ffd700, #d4af37);
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
}

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



.form-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 3px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.form-group:hover {
    background: rgba(212, 175, 55, 0.05);
    transform: translateY(-1px);
}

.form-group label {
    color: #ffd700;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.95rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label::before {
    content: '◆';
    color: #8b4513;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.form-group:focus-within label::before {
    color: #ffd700;
    transform: scale(1.2);
}



.form-group input::placeholder,
.form-group select::placeholder {
    color: rgba(244, 228, 188, 0.78) !important;
    font-style: italic;
    font-weight: 500;
}

.form-group input:focus::placeholder,
.form-group select:focus::placeholder {
    color: rgba(255, 215, 0, 0.8) !important;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), inset 0 0 10px rgba(255, 215, 0, 0.3);
    background: #2d1b0e !important;
    transform: translateY(-2px);
    color: #f4e4bc !important;
}



.form-group select option {
    background-color: #1a0f08 !important;
    color: #ffffff !important;
    padding: 8px 12px;
    font-family: 'Crimson Text', serif !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
}

.form-group select option:hover {
    background-color: #2d1b0e !important;
    color: #ffd700 !important;
}

.form-group select option:checked,
.form-group select option:selected {
    background-color: #8b4513 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
}

.form-group select option[value=""] {
    color: rgba(255, 215, 0, 0.7) !important;
    font-style: italic !important;
}



/* Additional cross-browser select styling */
.form-group select::-ms-expand {
    display: none;
}

.form-group select::-webkit-scrollbar {
    width: 8px;
}

.form-group select::-webkit-scrollbar-track {
    background: #1a0f08;
}

.form-group select::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 4px;
}

.form-group select::-webkit-scrollbar-thumb:hover {
    background: #d4af37;
}

.form-group input.invalid,
.form-group select.invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.4) !important;
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(255, 107, 107, 0.15)) !important;
    animation: invalidShake 0.5s ease-in-out;
}

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


.form-group:focus-within::after {
    width: 100%;
}

.form-group:focus-within label {
    color: #ffffff;
    transform: translateY(-2px);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

.error-text {
    font-size: 0.9rem;
    color: #ff6b6b;
    margin-top: 10px;
    font-style: italic;
    font-weight: 600;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(220, 53, 69, 0.1));
    border-left: 4px solid #ff6b6b;
    border-radius: 8px;
    animation: errorPulse 2s ease-in-out infinite;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.2);
    position: relative;
    overflow: hidden;
}

.error-text::before {
    content: '⚠';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: #ff6b6b;
}

.error-text {
    padding-left: 40px;
}

@keyframes errorPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Utility Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 2rem;
}

.mt-4 {
    margin-top: 2rem;
}
/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection Styling */
::selection {
    background: #d4af37;
    color: #1a1a1a;
}

::-moz-selection {
    background: #d4af37;
    color: #1a1a1a;
}

/*!--- Footer Moderno ---->*/
#modern-footer {
    background: linear-gradient(135deg, #2d1b0e 0%, #1a1a1a 50%, #2d1b0e 100%);
    color: #f8ddb2;
    font-family: 'Crimson Text', serif;
    margin-top: auto;
    border-top: 3px solid #8b4513;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 10;
}

.footer-main {
    padding: 3rem 0 2rem;
    background: rgba(139, 69, 19, 0.1);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 50px;
    align-items: start;
}

.footer-container > *:first-child {
    flex: 2;
    min-width: 300px;
}

.footer-container > *:not(:first-child) {
    flex: 1.5;
    min-width: 200px;
}

.footer-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 0;
}

.footer-column h3 {
    color: #d4af37;
    font-size: 1.3rem;
    margin-bottom: 25px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 12px;
    position: relative;
}

.footer-column h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 30px;
    height: 2px;
    background: #d4af37;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.footer-logo-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.footer-logo h3 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
}

.footer-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #d4af8c;
    margin-bottom: 1rem;
}

.footer-info p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.footer-column h4 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffd700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #8b4513;
    padding-bottom: 0.5rem;
}

.footer-column h5 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.1rem;
    color: #ffd700;
    margin: 1rem 0 0.5rem;
}

.footer-column h6 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1rem;
    color: #ffd700;
    margin: 1rem 0 0.5rem;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 12px;
    padding-left: 0;
    position: relative;
    transition: all 0.3s ease;
}

.footer-links li:hover {
    transform: translateX(5px);
}

.footer-links a {
    color: #d4af8c;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
}

.footer-links a:hover {
    color: #ffd700;
    transform: translateX(3px);
}

.footer-links a::before {
    content: '▸';
    position: absolute;
    left: -15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #d4af37;
}

.footer-links a:hover::before {
    opacity: 1;
}

.contact-info {
    margin-bottom: 1.5rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

.contact-item i {
    color: #8b4513;
    font-size: 1.1rem;
    width: 20px;
}

.social-icons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: #d4af8c;
    text-decoration: none;
    padding: 0.8rem;
    border-radius: 8px;
    background: rgba(139, 69, 19, 0.2);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.social-link:hover {
    background: rgba(139, 69, 19, 0.4);
    border-color: #8b4513;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.social-link.telegram:hover {
    color: #0088cc;
}

.social-link.discord:hover {
    color: #5865f2;
}

.social-link i {
    font-size: 1.2rem;
    width: 24px;
}

.credits-column {
    position: relative;
}

.credits-toggle {
    margin-bottom: 1rem;
}

.credits-btn {
    background: linear-gradient(45deg, #8b4513, #a0522d);
    color: #f8ddb2;
    border: none;
    padding: 14px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.credits-btn:hover {
    background: linear-gradient(45deg, #a0522d, #cd853f);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.credits-content {
    display: none;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 25px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #8b4513;
    border-left: 5px solid #d4af37;
    backdrop-filter: blur(5px);
}

.credits-content.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Floating Labels */
.form-group.floating-label {
    position: relative;
    margin-bottom: 2.2rem;
}

.form-group.floating-label input,
.form-group.floating-label select {
    width: 100%;
    padding: 14px 15px 10px; /* Slightly more top padding for the label */
    font-size: 1rem;
    background: rgba(244, 228, 188, 0.96);
    border: 1px solid rgba(139, 69, 19, 0.35);
    border-radius: 6px;
    outline: none;
    transition: all 0.3s ease;
    height: 52px; /* Increased height slightly */
    color: #2a1810;
    font-family: 'Crimson Text', serif;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.form-group.floating-label input::placeholder {
    color: rgba(42, 24, 16, 0.55);
}

.form-group.floating-label input:focus,
.form-group.floating-label select:focus {
    border-color: #8b4513;
    box-shadow: 0 0 8px rgba(139, 69, 19, 0.18);
    background: rgba(248, 240, 216, 0.98);
}

.form-group.floating-label label {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    background: transparent;
    padding: 0 5px;
    color: rgba(42, 24, 16, 0.75);
    opacity: 0.85;
    font-size: 1rem;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Crimson Text', serif;
    z-index: 1;
}

/* Float the label when input has focus or value */
.form-group.floating-label input:focus ~ label,
.form-group.floating-label input:not(:placeholder-shown) ~ label,
.form-group.floating-label select:focus ~ label,
.form-group.floating-label select:not([value=""]) ~ label,
.form-group.floating-label select:valid ~ label {
    top: 0;
    transform: translateY(-50%) scale(0.85);
    color: #8b4513;
    background: rgba(244, 228, 188, 0.98);
    opacity: 1;
    font-weight: 700;
    padding: 0 8px;
}

/* Adjust for select specifically since it might always have a value */
.form-group.floating-label select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%238b4513%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
}

.form-group.floating-label .error-text,
.form-group.floating-label .helper-text,
.form-group.floating-label .email-feedback,
.form-group.floating-label .password-feedback {
    position: absolute;
    bottom: -22px;
    left: 5px;
    font-size: 0.75rem;
    font-family: 'Crimson Text', serif;
    font-style: italic;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: normal;
    line-height: 1.2;
    width: 100%;
}

.form-group.floating-label .helper-text {
    color: #5d4037;
    opacity: 0.7;
}

.form-group.floating-label .error-text,
.form-group.floating-label .email-feedback,
.form-group.floating-label .password-feedback {
    color: #b22222;
}

.form-group.floating-label input:focus ~ .helper-text,
.form-group.floating-label select:focus ~ .helper-text {
    opacity: 1;
    bottom: -20px;
}

.form-group.floating-label .email-feedback:not(:empty),
.form-group.floating-label .password-feedback:not(:empty),
.form-group.floating-label input.invalid ~ .error-text,
.form-group.floating-label input.error ~ .error-text,
.form-group.floating-label select.error ~ .error-text {
    opacity: 1;
    bottom: -20px;
}

.form-group.floating-label input.invalid ~ .helper-text,
.form-group.floating-label input.error ~ .helper-text {
    opacity: 0 !important;
}
 
.credits-content::-webkit-scrollbar {
    width: 6px;
}

.credits-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.credits-content::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 3px;
}

.credits-section {
    margin-bottom: 1.5rem;
}

.credits-section ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.credits-section li {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.credits-section a {
    color: #d4af8c;
    text-decoration: none;
    transition: color 0.3s ease;
}

.credits-section a:hover {
    color: #ffd700;
}

.footer-bottom {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.6), rgba(45, 27, 14, 0.4), rgba(0, 0, 0, 0.6));
    padding: 25px 0;
    text-align: center;
    border-top: 2px solid #8b4513;
    margin-top: 40px;
    position: relative;
}

.footer-bottom::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 2px;
    background: #d4af37;
}

.footer-bottom-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.copyright p {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 500;
}

.footer-bottom-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-bottom-links a {
    color: #d4af37;
    text-decoration: none;
    margin: 0 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.footer-bottom-links a:hover {
    color: #ffd700;
    transform: translateY(-1px);
}

.footer-bottom-links a::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background: #ffd700;
    transition: width 0.3s ease;
}

.footer-bottom-links a:hover::after {
    width: 100%;
}

.separator {
    color: #8b4513;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .footer-container {
        grid-template-columns: 1fr;
        gap: 35px;
        text-align: center;
        padding: 0 20px;
    }
    
    .footer-column h3 {
        font-size: 1.2rem;
        margin-bottom: 20px;
    }
    
    .footer-column p {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }
    
    .footer-main {
        padding: 2rem 0 1.5rem;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
        padding: 0 1rem;
    }
    
    .footer-bottom {
        padding: 20px 0;
        margin-top: 30px;
    }
    
    .footer-bottom a {
        display: inline-block;
        margin: 8px 10px;
        font-size: 0.85rem;
    }
    
    .footer-logo {
        justify-content: center;
    }
    
    .social-icons {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }
    
    .credits-toggle {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .credits-content {
        max-height: 250px;
        padding: 20px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .footer-main {
        padding: 30px 0;
    }
    
    .footer-container {
        padding: 0 15px;
        gap: 25px;
    }
    
    .footer-column h3 {
        font-size: 1.1rem;
    }
    
    .footer-bottom a {
        display: block;
        margin: 10px 0;
    }
    
    .footer-logo h3 {
        font-size: 1.5rem;
    }
    
    .footer-logo p {
        font-size: 0.8rem;
    }
    
    .social-icons a {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .credits-content {
        max-height: 200px;
        font-size: 0.8rem;
    }
    
    .footer-column h4 {
        font-size: 1.1rem;
    }
    
    .footer-description {
        font-size: 0.9rem;
    }
    
    .social-icons {
        flex-direction: column;
    }
}

/* Registration Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    background: linear-gradient(135deg, #f4e4bc 0%, #e6d3a3 100%);
    margin: 0;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    max-width: 800px;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(139, 69, 19, 0.4);
    position: relative;
    animation: modalSlideIn 0.4s ease-out;
}

.modal-header {
    background: linear-gradient(to right, #8b4513, #a0522d);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #5d4037;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h2 {
    font-family: 'MY_MEDIEVAL', serif;
    margin: 0;
    font-size: 1.5rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    color: #ffd700;
    background: none;
    -webkit-text-fill-color: initial;
}

.close {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.8rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    /* Riga unica: impilando logo, lingua e hamburger l'header arrivava a 185px
       e copriva il titolo dell'hero. */
    :root {
        --home-header-h: calc(1.6rem + 44px + env(safe-area-inset-top, 0px));
    }

    .header-content {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0 1rem;
        min-height: 44px;
    }

    .header-content .logo {
        flex: 1 1 auto;
        min-width: 0;
        gap: 0.6rem;
    }

    .header-content .logo-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-content .language-selector,
    .header-content .mobile-menu-btn {
        flex: 0 0 auto;
    }

    /* Bersaglio da dito anche per la lingua: da sola sarebbe alta 33px. */
    .header-content .lang-btn {
        min-height: 40px;
    }

    /* Bersaglio da dito, senza far crescere l'header oltre il logo. */
    .header-content .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .auth-section {
        flex-direction: column;
        width: 100%;
    }
    
    .login-form {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .hero {
        padding: 0 1rem;
    }
    
    .hero-cta {
        flex-direction: column;
        align-items: center;
    }
    
    .modal {
        padding: 0;
        align-items: center; /* Center on mobile too for visibility */
    }
    
    .modal-content {
        width: 95%;
        height: auto;
        max-height: 98dvh; /* Maximized height for mobile */
        margin: 0;
        border-radius: 12px;
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        height: 100%;
    }
}

@media (max-width: 480px) {
    .social-links {
        display: none;
    }

    /* Telefoni stretti: logo e selettore lingua rimpiccioliscono quel tanto che
       basta perche' "Feudera" non finisca nei puntini. L'altezza dell'header non
       cambia, la regge il min-height della riga. */
    .header-content .logo img {
        width: 34px;
        height: 34px;
    }

    .header-content .logo-text {
        font-size: 1.15rem;
    }

    .header-content .lang-btn {
        padding: 8px 10px;
        gap: 6px;
    }

    .login-form input {
        width: 100px;
    }
    
    .modal-header {
        padding: 0.8rem 1rem;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }
}

/* Landscape Mode Optimization */
@media (max-height: 600px) {
    .modal-content {
        height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 0.5rem 1rem;
    }
    
    .modal-body {
        padding: 0.8rem;
    }
}

/* Language Selector Styles */
.language-selector {
    position: relative;
    display: inline-block;
}

.dropdown {
    position: relative;
}

.lang-btn {
    background: linear-gradient(135deg, #8B4513, #A0522D);
    border: 2px solid #D4AF37;
    color: #F5F5DC;
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.lang-btn:hover {
    background: linear-gradient(135deg, #A0522D, #CD853F);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.lang-btn i.fa-globe {
    color: #D4AF37;
}

.lang-btn i.fa-chevron-down {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.dropdown.active .lang-btn i.fa-chevron-down {
    transform: rotate(180deg);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #2C1810;
    border: 2px solid #D4AF37;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 160px;
    margin-top: 5px;
    overflow: hidden;
}

.dropdown.active .dropdown-content {
    display: block;
    animation: slideDown 0.3s ease;
}

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

.dropdown-content a {
    color: #F5F5DC;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: #D4AF37;
}

.dropdown-content a.active {
    background: linear-gradient(135deg, #D4AF37, #FFD700);
    color: #2C1810;
    font-weight: 700;
}

.dropdown-content a img {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Hero Section Redesign */
.hero-section {
    position: relative;
    padding: calc(var(--home-header-h) + 3.5rem) 0 4rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: url('imgs/medieval_background_optimized.jpg') no-repeat center center/cover;
    overflow: hidden;
}

.hero-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(26, 26, 26, 0.9) 0%, rgba(26, 26, 26, 0.7) 50%, rgba(26, 26, 26, 0.95) 100%);
    z-index: 1;
}

.hero-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.hero-header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fade-in-up 1s ease-out;
}

.hero-header h1 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: #ffd700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
    font-family: 'Crimson Text', serif;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #e0e0e0;
    max-width: 800px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap; /* senza wrap i tre bottoni sbordano dal container su mobile */
    gap: 1.5rem;
    justify-content: center;
}

/* Hero Grid Layout */
.hero-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
}

@media (max-width: 992px) {
    .hero-content-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
}

/* Section Titles */
.hero-gallery-wrapper h3,
.hero-news-wrapper h3 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.8rem;
    color: #ffd700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 0.5rem;
}

/* Gallery Styles */
.hero-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 215, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    transition: transform 0.5s ease;
    background: rgba(255, 255, 255, 0.05);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay i {
    color: #ffd700;
    font-size: 1.5rem;
}

/* News Styles */
.hero-news-wrapper {
    background: linear-gradient(160deg, rgba(26, 15, 8, 0.9) 0%, rgba(45, 27, 14, 0.8) 50%, rgba(26, 15, 8, 0.9) 100%);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 215, 0, 0.05);
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar for News */
.news-list::-webkit-scrollbar {
    width: 5px;
}

.news-list::-webkit-scrollbar-track {
    background: rgba(212, 175, 55, 0.05);
    border-radius: 3px;
}

.news-list::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.news-list::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

.news-card {
    background: rgba(244, 228, 188, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.12);
    border-left: 3px solid rgba(212, 175, 55, 0.35);
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.news-card:hover {
    background: rgba(244, 228, 188, 0.08);
    border-left-color: #ffd700;
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.12);
    transform: translateX(4px);
}

.news-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
    font-family: 'Crimson Text', serif;
}

.news-card-badge i {
    font-size: 0.7rem;
}

.news-title {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.05rem;
    color: #f4e4bc;
    margin-bottom: 6px;
    line-height: 1.3;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.news-card:hover .news-title {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
}

.news-excerpt {
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    color: rgba(244, 228, 188, 0.55);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-read-more {
    font-size: 0.82rem;
    color: #d4af37;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-family: 'Crimson Text', serif;
}

.news-read-more i {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.news-card:hover .news-read-more {
    color: #ffd700;
}

.news-card:hover .news-read-more i {
    transform: translateX(4px);
}

.no-news-message {
    color: rgba(244, 228, 188, 0.4);
    font-style: italic;
    text-align: center;
    padding: 2rem 0;
    font-family: 'Crimson Text', serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-modal.show {
    opacity: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    border: 2px solid #ffd700;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox-modal.show .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.lightbox-close:hover {
    color: #ffd700;
}

/* News Modal — Realm Style */
.realm-modal-news .realm-modal-content {
    max-width: 750px;
}

.news-modal-date {
    color: #d4af37;
    font-size: 0.9rem;
    font-family: 'Crimson Text', serif;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.news-modal-date i {
    font-size: 0.8rem;
}

.news-modal-body-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

.news-modal-body-scroll::-webkit-scrollbar {
    width: 5px;
}

.news-modal-body-scroll::-webkit-scrollbar-track {
    background: rgba(212, 175, 55, 0.05);
    border-radius: 3px;
}

.news-modal-body-scroll::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.news-body-content {
    font-family: 'Crimson Text', serif;
    line-height: 1.8;
    font-size: 1.1rem;
    color: #f4e4bc;
}

.news-body-content a {
    color: #d4af37;
    text-decoration: underline;
    text-decoration-color: rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
}

.news-body-content a:hover {
    color: #ffd700;
    text-decoration-color: #ffd700;
}

.news-body-content strong,
.news-body-content b {
    color: #ffd700;
}

.news-body-content ul,
.news-body-content ol {
    padding-left: 1.5rem;
    margin: 0.8rem 0;
}

.news-body-content li {
    margin-bottom: 0.4rem;
}

.news-body-content img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    margin: 1rem 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-header h1 {
        font-size: 2rem;
    }
    
    .hero-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hero-section {
        padding-top: calc(var(--home-header-h) + 2rem);
    }
}

/* Scroll Reveal Animation */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Medieval Dividers */
.section-divider {
    height: 60px;
    width: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    margin: 2rem 0;
    opacity: 0.8;
}

.divider-gold {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" fill="%23ffd700"><path d="M0,50 Q250,100 500,50 T1000,50" stroke="%23ffd700" stroke-width="2" fill="none"/><circle cx="500" cy="50" r="10"/></svg>');
}

/* Card Hover Shine Effect */
.feature-card, .news-card {
    position: relative;
    overflow: hidden;
}

.feature-card::after, .news-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg) translate(-100%, -100%);
    transition: transform 0.6s;
    pointer-events: none;
}

.feature-card:hover::after, .news-card:hover::after {
    transform: rotate(30deg) translate(0%, 0%);
    transition: transform 0.6s;
}

/* Pulsing CTA */
@keyframes pulse-gold {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

#playNowBtn {
    animation: pulse-gold 2s infinite;
}

/* Hero Particles Container */
#hero-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}
EOF~
/* --- Modern Header Redesign --- */

/* Glassmorphism & Depth */
.modern-header {
    background: rgba(15, 10, 8, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.modern-header.scrolled {
    background: rgba(10, 5, 3, 0.95);
    padding: 0.7rem 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
}

/* Logo Animation */
.logo {
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.logo img {
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.logo-text {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to right, #ffd700, #f0e68c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Styled Inputs */
.login-form input {
    border: none;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 4px 4px 0 0;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-bottom-color: #ffd700;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Primary CTA Button (Register) */
#registerBtn {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%);
    color: #1a1a1a;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

#registerBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: 0.5s;
}

#registerBtn:hover::before {
    left: 100%;
}

#registerBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

/* Language Dropdown */
.lang-btn {
    background: transparent;
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'MY_MEDIEVAL', serif;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: #ffd700;
}

.dropdown-content {
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    margin-top: 0.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.dropdown-content a {
    color: #e0e0e0;
    padding: 0.8rem 1rem;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

/* Mobile Responsive Header */
@media (max-width: 992px) {
    .header-content {
        padding: 0 1rem;
    }

    .auth-section {
        display: none; /* Hide login on mobile initially (can be toggled in future) */
    }

    /* Show only Register button on mobile if needed, or hamburger menu */
    .mobile-menu-toggle {
        display: block; /* If we add a toggle */
    }
}

@media (max-width: 768px) {
    .modern-header {
        padding: 0.8rem 0;
    }
    
    .logo-text {
        font-size: 1.4rem;
    }
    
    .social-links {
        display: none; /* Hide social on very small screens to save space */
    }
    
    .auth-section {
        display: none; /* Keep hidden on mobile for now */
    }
    
    /* We should add a mobile menu icon instead */
}

/* --- Mobile Menu Styles --- */
.mobile-menu-btn {
    display: none;
    font-size: 1.5rem;
    color: #ffd700;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(10, 5, 3, 0.98);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.show {
    opacity: 1;
}

.mobile-menu-content {
    width: 80%;
    max-width: 300px;
    text-align: center;
}

.mobile-login-form h3 {
    color: #ffd700;
    margin-bottom: 1.5rem;
    font-family: 'MY_MEDIEVAL', serif;
}

.mobile-login-form input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 4px;
    color: #fff;
}

.mobile-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.5), transparent);
    margin: 2rem 0;
}

.mobile-social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.mobile-social-links a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    color: #ffd700;
    text-decoration: none;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.mobile-social-links a:hover {
    background: #ffd700;
    color: #1a1a1a;
}

.close-mobile {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
}

.btn-block {
    width: 100%;
    display: block;
    margin-bottom: 1rem;
}

@media (max-width: 992px) {
    .mobile-menu-btn {
        display: block;
    }
}

/* --- Link Colors Fix --- */
.forgot-pass-link, .forgot-pass-link-mobile {
    color: #ffd700;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.forgot-pass-link:hover, .forgot-pass-link-mobile:hover {
    opacity: 1;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    text-decoration: underline;
}

.forgot-pass-link-mobile {
    display: inline-block;
    margin-top: 1rem;
    color: #e0e0e0;
}

.forgot-pass-link-mobile:hover {
    color: #ffd700;
}

/* --- Link Colors Fix --- */
.forgot-pass-link, .forgot-pass-link-mobile {
    color: #ffd700;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.forgot-pass-link:hover, .forgot-pass-link-mobile:hover {
    opacity: 1;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    text-decoration: underline;
}

.forgot-pass-link-mobile {
    display: inline-block;
    margin-top: 1rem;
    color: #e0e0e0;
}

.forgot-pass-link-mobile:hover {
    color: #ffd700;
}

/* --------------------------------------------------------------- consensi legali
   Le checkbox aggiunte in registrazione (conferma dell'età, opt-in facoltativo sui
   contenuti) hanno etichette lunghe su più righe: allineano il quadratino in alto
   invece che al centro, altrimenti "galleggia" a metà del paragrafo.
   La variante --optional è tratteggiata per distinguere a colpo d'occhio ciò che
   è facoltativo da ciò che è obbligatorio. */
.realm-checkbox--multiline,
#ageconfirm ~ label,
.realm-checkbox:has(#ageconfirm),
.realm-checkbox:has(#ugccommercial),
.realm-checkbox:has(#terms) {
    align-items: flex-start;
}

.realm-checkbox:has(#ageconfirm) input[type="checkbox"],
.realm-checkbox:has(#ugccommercial) input[type="checkbox"],
.realm-checkbox:has(#terms) input[type="checkbox"] {
    margin-top: 3px;
    flex: 0 0 auto;
}

.realm-checkbox:has(#ageconfirm) label,
.realm-checkbox:has(#ugccommercial) label,
.realm-checkbox:has(#terms) label {
    line-height: 1.5;
    min-width: 0;
}

.realm-checkbox--optional {
    border-style: dashed;
    background: rgba(212, 175, 55, 0.02);
}
.realm-checkbox--optional label {
    color: rgba(244, 228, 188, 0.55);
    font-size: 0.85rem;
}

/* ── "Resta nel reame": la spunta che ricorda il dispositivo ──────────────
   Vive nel modale di accesso e nel form del menu mobile. La durata non si
   sceglie qui: è una preferenza dell'account, nella scheda Dispositivi delle
   impostazioni di gioco. */
.realm-remember {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0.85rem 0 1rem;
    cursor: pointer;
    user-select: none;
}

/* Spunta disegnata a mano: quella di sistema è un quadratino bianco, fuori
   posto su un modale di bronzo e pergamena. */
.realm-remember input[type="checkbox"] {
    flex: none;
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    display: grid;
    place-content: center;
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 4px;
    background: rgba(244, 228, 188, 0.06);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.realm-remember input[type="checkbox"]::after {
    content: '';
    width: 11px;
    height: 11px;
    transform: scale(0);
    transition: transform 0.15s ease;
    box-shadow: inset 1em 1em #ffd86b;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.realm-remember input[type="checkbox"]:checked {
    border-color: rgba(212, 175, 55, 0.9);
    background: rgba(212, 175, 55, 0.18);
}

.realm-remember input[type="checkbox"]:checked::after { transform: scale(1); }

.realm-remember input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.7);
    outline-offset: 2px;
}

.realm-remember-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.realm-remember-label {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    color: #f8ddb2;
}

.realm-remember-hint {
    font-size: 0.75rem;
    line-height: 1.35;
    color: rgba(248, 221, 178, 0.6);
}

.realm-remember:hover .realm-remember-label { color: #ffd86b; }

.mobile-login-form .realm-remember { margin: 0.25rem 0 0.75rem; }

@media (max-width: 768px) {
    /* Bersaglio più generoso al tocco. */
    .realm-remember input[type="checkbox"] { width: 24px; height: 24px; }
    .realm-remember input[type="checkbox"]::after { width: 13px; height: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .realm-remember input[type="checkbox"],
    .realm-remember input[type="checkbox"]::after { transition: none; }
}

/* La card della news e' un <a> verso la pagina dell'annuncio (vedi news.php):
   serve a farla seguire dai crawler e ad aprirla in una scheda nuova. Il clic
   normale resta la modale, quindi visivamente non deve cambiare niente. */
.news-card {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Dalla modale all'annuncio intero: l'indirizzo da copiare e condividere. */
.news-modal-full-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0.7rem 1.2rem;
    min-height: 44px;
    border-radius: 8px;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
    text-decoration: none;
    color: #ffd86b;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.35);
    transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.news-modal-full-link:hover {
    color: #2a1808;
    background: linear-gradient(135deg, #e8c25a, #d4af37);
    border-color: rgba(255, 216, 107, 0.8);
}

.news-modal-full-link:active { transform: scale(0.98); }

@media (prefers-reduced-motion: reduce) {
    .news-modal-full-link { transition: none; }
}

/* ── Modale delle news: attesa, errore, srotolamento ─────────────────────────
   Il corpo dell'annuncio non viaggia piu' dentro la homepage: arriva da
   news_body.php al primo clic sulla card. Nell'attesa la modale non resta
   vuota — la pergamena si sta srotolando — e quando il testo arriva scende
   dall'alto invece di comparire di scatto. */

/* Uno stato alla volta: attesa, errore, corpo. Il JS accende la classe. */
.news-modal-body-scroll .news-body-loading,
.news-modal-body-scroll .news-body-failure {
    display: none;
}

.news-modal-body-scroll.is-loading .news-body-loading,
.news-modal-body-scroll.is-error .news-body-failure {
    display: flex;
}

/* Durante l'attesa non c'e' niente da leggere e niente da aprire; in errore il
   link all'annuncio intero resta, ed e' la via d'uscita buona. */
.news-modal-body-scroll.is-loading .news-body-content,
.news-modal-body-scroll.is-error .news-body-content,
.news-modal-body-scroll.is-loading .news-modal-full-link {
    display: none;
}

/* Pergamena in arrivo */
.news-body-loading {
    flex-direction: column;
    gap: 0.9rem;
    padding: 0.5rem 0 1rem;
    min-height: 170px;
    animation: newsStateIn 0.35s ease both;
}

.news-body-loading-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: #b89a63;
}

.news-body-loading-label i {
    color: #d4af37;
    animation: newsScrollBreathe 2.2s ease-in-out infinite;
}

.news-skeleton-line {
    display: block;
    height: 0.85rem;
    border-radius: 4px;
    background: linear-gradient(90deg,
        rgba(212, 175, 55, 0.06) 0%,
        rgba(212, 175, 55, 0.20) 45%,
        rgba(212, 175, 55, 0.06) 90%);
    background-size: 250% 100%;
    animation: newsSkeletonSweep 1.7s linear infinite;
}

.news-skeleton-line:nth-child(2) { width: 97%; }
.news-skeleton-line:nth-child(3) { width: 88%; animation-delay: 0.12s; }
.news-skeleton-line:nth-child(4) { width: 93%; animation-delay: 0.24s; }
.news-skeleton-line:nth-child(5) { width: 62%; animation-delay: 0.36s; }

/* L'araldo non ce l'ha fatta */
.news-body-failure {
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    padding: 1.8rem 1rem 1rem;
    text-align: center;
    font-family: 'Crimson Text', serif;
    color: #f4e4bc;
    animation: newsStateIn 0.35s ease both;
}

.news-body-failure > i {
    font-size: 1.6rem;
    color: #d4af37;
}

.news-body-failure p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

.news-body-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.6rem 1.3rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
    color: #ffd86b;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.35);
    transition: color 0.25s ease, background 0.25s ease,
                border-color 0.25s ease, transform 0.15s ease;
}

.news-body-retry:hover {
    color: #2a1808;
    background: linear-gradient(135deg, #e8c25a, #d4af37);
    border-color: rgba(255, 216, 107, 0.8);
}

.news-body-retry:active { transform: scale(0.97); }

/* Il corpo arrivato si srotola: la classe la mette il JS sull'elemento appena
   cambiato e se la toglie a fine corsa, cosi' l'annuncio dopo riparte da capo. */
.news-body-content.is-unfurling {
    transform-origin: top center;
    animation: newsBodyUnfurl 0.42s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

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

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

@keyframes newsSkeletonSweep {
    from { background-position: 120% 0; }
    to   { background-position: -40% 0; }
}

@keyframes newsScrollBreathe {
    0%, 100% { opacity: 0.55; transform: translateY(0); }
    50%      { opacity: 1;    transform: translateY(-2px); }
}

@media (max-width: 768px) {
    .news-body-loading { min-height: 150px; gap: 0.8rem; }
    .news-body-failure { padding: 1.4rem 0.5rem 0.8rem; }
    .news-body-failure p { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .news-body-loading,
    .news-body-failure,
    .news-body-content.is-unfurling,
    .news-body-loading-label i {
        animation: none;
    }
    .news-skeleton-line {
        animation: none;
        background: rgba(212, 175, 55, 0.12);
    }
    .news-body-retry { transition: none; }
}

/* ============ Safe area (notch / home indicator) ============ */
/* A pagina full-bleed (PWA installata, wrapper nativo: viewport-fit=cover)
   l'header fisso finiva sotto la status bar. Il padding-top va ribadito per
   ogni stato che lo riscrive con lo shorthand (.scrolled, breakpoint 768). */
.modern-header { padding-top: calc(1rem + env(safe-area-inset-top, 0px)); }
.modern-header.scrolled { padding-top: calc(0.7rem + env(safe-area-inset-top, 0px)); }
@media (max-width: 768px) {
    .modern-header { padding-top: calc(0.8rem + env(safe-area-inset-top, 0px)); }
    .modern-header.scrolled { padding-top: calc(0.7rem + env(safe-area-inset-top, 0px)); }
}
#modern-footer { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ============ Modalità app: solo registrazione ============ */
/* Nel wrapper nativo, index.php?register=1 fa da cornice al SOLO modale di
   registrazione: una cortina bronzo copre l'intera homepage (nessun elemento
   sotto è raggiungibile) e sopra resta il modale, già aperto da homepage.js.
   Chiudere riporta ad app_login.php (handler in homepage.js). */
body.app-register-mode { overflow: hidden; }
body.app-register-mode::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 5000;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(59, 26, 8, .6), rgba(24, 10, 2, .97) 78%),
        #3B1A08;
}
body.app-register-mode #registrationModal {
    display: flex !important;
    z-index: 6000;
}
/* Dentro l'app il modale non è un popup: È la pagina. A tutto schermo, senza
   angoli né cornice — la "carta flottante col buio intorno" è il riflesso
   più da sito web che ci sia. E lo stemma, che sul web sporge sopra la carta
   (position absolute a top negativo: qui l'overflow lo taglierebbe a metà),
   rientra nel flusso normale in testa alla pagina. */
body.app-register-mode #registrationModal { animation: none; }
body.app-register-mode .realm-modal-overlay { display: none; } /* c'è già la cortina */
body.app-register-mode .realm-modal-content {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    animation: none;
    padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
}
body.app-register-mode .realm-modal-crest {
    position: static;
    transform: none;
    margin: 10px auto 0;
}

/* La croce di chiusura sta in position:absolute, quindi si misura dal BORDO
   del modale e non dal padding: con il solo padding-top di safe-area finiva
   sotto l'orologio e la tacca del telefono, irraggiungibile. Qui la safe-area
   entra nel top suo, e il bersaglio sale a 44px come vuole il tocco. */
body.app-register-mode .realm-close {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: calc(env(safe-area-inset-right, 0px) + 14px);
    width: 44px;
    height: 44px;
    font-size: 1rem;
    background: rgba(0, 0, 0, .35);
    border-color: rgba(232, 194, 90, .45);
    color: var(--app-parchment, #f0e0bb);
}
body.app-register-mode .realm-close:active { transform: scale(.92); }

/* ══════════════════════════════════════════════════════════════
   SUGGERIMENTO DI LINGUA — la barra in fondo alla radice inglese
   ══════════════════════════════════════════════════════════════
   La radice parla sempre inglese (v. index.php in testa): a chi ha il
   browser in un'altra lingua si dice che esiste la sua porta, non lo si
   sposta. Cornice bronzo come l'annuncio della prova chiusa (che sta in
   alto): questa sale dal basso, dove un telefono mette gli avvisi. La
   accende homepage.js con .is-open; .is-leaving la fa scendere.
   ══════════════════════════════════════════════════════════════ */
.lang-suggest {
    display: none;
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 9998;
    width: calc(100% - 32px);
    max-width: 560px;
    transform: translateX(-50%);
}

.lang-suggest.is-open {
    display: block;
    animation: langSuggestRise 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.lang-suggest.is-leaving {
    animation: langSuggestSink 0.3s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes langSuggestRise {
    from { opacity: 0; transform: translateX(-50%) translateY(140%); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes langSuggestSink {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(140%); }
}

.lang-suggest-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 16px;
    border: 2px solid #DAA520;
    border-radius: 12px;
    background: linear-gradient(135deg, #3B1A08 0%, #521906 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.lang-suggest-flag {
    flex-shrink: 0;
    width: 20px;
    height: 15px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.lang-suggest-text {
    flex: 1;
    min-width: 0;
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    line-height: 1.3;
    color: #e7d8b1;
}

.lang-suggest-cta {
    flex-shrink: 0;
    padding: 10px 16px;
    border-radius: 6px;
    background: linear-gradient(135deg, #DAA520, #FFD700);
    color: #521906;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lang-suggest-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(218, 165, 32, 0.4);
    color: #521906;
}

.lang-suggest-cta:active { transform: translateY(1px); }

.lang-suggest-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: none;
    color: rgba(231, 216, 177, 0.5);
    font-size: 1.05rem;
    cursor: pointer;
    transition: color 0.25s ease, transform 0.25s ease;
}

.lang-suggest-close:hover {
    color: #ff6b6b;
    transform: rotate(90deg);
}

/* Sul telefono, come l'annuncio in alto: la croce in un angolo, il tasto
   scende sotto il testo e prende tutta la riga — un bersaglio vero. */
@media (max-width: 768px) {
    .lang-suggest { width: calc(100% - 20px); }
    .lang-suggest-inner {
        flex-wrap: wrap;
        padding: 12px;
    }
    .lang-suggest-text {
        flex: 1 1 0;
        font-size: 0.9rem;
    }
    .lang-suggest-cta {
        order: 3;
        flex: 1 1 100%;
        text-align: center;
        padding: 12px 18px;
        font-size: 0.78rem;
    }
    .lang-suggest-close { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    .lang-suggest.is-open,
    .lang-suggest.is-leaving { animation: none; }
    .lang-suggest.is-leaving { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   IMPARA A GIOCARE — le pergamene ufficiali della wiki e i suoi scaffali
   ══════════════════════════════════════════════════════════════
   Una pagina di carta fra due sezioni scure, come già la Leggenda. I
   colori sono i token del design system (main/css/mobile-app.css), scritti
   qui perché la homepage non carica quel foglio: cambiano lì, cambiano qui.
   ══════════════════════════════════════════════════════════════ */
.learn-section {
    --lp-paper: #faf1d8;
    --lp-paper-deep: #f0e3c2;
    --lp-paper-bright: #fffaf0;
    --lp-ink: #3a2a18;
    --lp-ink-soft: #6b5636;
    --lp-line: rgba(58, 42, 24, .22);
    --lp-brown: #8a4a12;
    --lp-amber: #e2a94f;
    --lp-amber-deep: #c98a2e;
    --lp-amber-light: #eec687;
    --lp-leaf: #6b8c42;
    position: relative;
    padding: 4.5rem 0;
    background: linear-gradient(180deg, var(--lp-paper) 0%, var(--lp-paper-deep) 100%);
    color: var(--lp-ink);
}

.learn-section h2 {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: clamp(1.75rem, 5vw, 3rem);
    overflow-wrap: break-word;
    text-align: center;
    color: var(--lp-brown);
    margin: 0 0 0.5rem;
}

.learn-subtitle {
    text-align: center;
    max-width: 640px;
    margin: 0 auto 2.5rem;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--lp-ink-soft);
}

.learn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 1.5rem;
    align-items: start;
}

.learn-card {
    min-width: 0;
    padding: 1.5rem 1.6rem;
    border: 1px solid var(--lp-line);
    border-radius: 14px;
    background: var(--lp-paper-bright);
    box-shadow: 0 4px 10px rgba(58, 42, 24, .12);
}

.learn-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.25rem;
    color: var(--lp-brown);
}

.learn-card h3 i { color: var(--lp-amber-deep); }

.learn-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.learn-list li {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.7rem 0;
    border-top: 1px dotted var(--lp-line);
}

.learn-list li:first-child { border-top: 0; padding-top: 0; }

.learn-list a {
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 1.05rem;
    color: var(--lp-brown);
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
}

.learn-list a:hover {
    color: var(--lp-amber-deep);
    text-decoration: underline;
}

.learn-summary {
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--lp-ink-soft);
}

.learn-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.learn-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--lp-brown);
    border-radius: 999px;
    background: linear-gradient(180deg, var(--lp-amber-light), var(--lp-amber));
    color: var(--lp-ink);
    font-family: 'MY_MEDIEVAL', serif;
    font-size: 0.9rem;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(58, 42, 24, .12);
    transition: transform 0.2s cubic-bezier(.2,.9,.3,1.25), box-shadow 0.2s ease;
}

.learn-chip i { color: var(--lp-brown); }

.learn-chip small {
    font-family: 'Crimson Text', serif;
    font-size: 0.85rem;
    color: var(--lp-ink-soft);
    font-variant-numeric: tabular-nums;
}

.learn-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(58, 42, 24, .18);
    color: var(--lp-ink);
}

.learn-chip:active { transform: translateY(1px); }

.learn-actions {
    margin-top: 2.5rem;
    text-align: center;
}

.learn-actions .btn-outline {
    color: var(--lp-brown);
    border-color: var(--lp-brown);
}

.learn-actions .btn-outline:hover {
    background: rgba(138, 74, 18, 0.08);
    color: var(--lp-brown);
    border-color: var(--lp-brown);
}

@media (max-width: 768px) {
    .learn-section { padding: 3rem 0; }
    .learn-card { padding: 1.2rem 1.1rem; }
}

/* I contatori salgono da 0: cifre a larghezza fissa, così la riga non balla. */
.stat-number { font-variant-numeric: tabular-nums; }
