/* === RESET E STILI BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
    overflow: hidden;
    line-height: 1.6;
}

/* === LAYOUT PAGINE === */
.pages-container {
    position: relative;
    height: 100vh;
    width: 100%;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    opacity: 0;
    visibility: hidden;
    transition: all 0.8s ease-in-out;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.page.active {
    opacity: 1;
    visibility: visible;
}

/* === BOTTONE PROFILO === */
.profile-btn {
    position: fixed;
    top: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: clamp(45px, 12vw, 60px);
    height: clamp(45px, 12vw, 60px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    color: white;
    z-index: 1001;
    text-decoration: none;
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
    color: white;
}

.profile-btn:active {
    transform: scale(0.95);
}

/* Animazione di entrata */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-btn {
    animation: fadeInDown 0.6s ease-out;
}

/* === RESPONSIVE BOTTONE PROFILO === */

/* Tablet */
@media (max-width: 768px) {
    .profile-btn {
        width: 50px;
        height: 50px;
        top: 1rem;
        right: 1rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .profile-btn {
        width: 45px;
        height: 45px;
        top: 0.8rem;
        right: 0.8rem;
    }
}

/* Orientamento orizzontale mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .profile-btn {
        top: 0.5rem;
        right: 0.5rem;
        width: 40px;
        height: 40px;
    }
}

/* Schermi molto piccoli */
@media (max-width: 320px) {
    .profile-btn {
        width: 40px;
        height: 40px;
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* Accessibilità */
@media (prefers-reduced-motion: reduce) {
    .profile-btn {
        animation: none;
    }

    .profile-btn:hover {
        transform: none;
    }
}

/* Alto contrasto */
@media (prefers-contrast: high) {
    .profile-btn {
        background: rgba(255, 255, 255, 0.4);
        border: 2px solid white;
    }
}

/* Focus per accessibilità */
.profile-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* === FOOTER FISSO === */
.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: clamp(0.5rem, 2vw, 1rem) 0;
    z-index: 100;
    transition: all 0.3s ease;
}

/* Footer semplificato */
.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem);
    text-align: center;
}

.footer-text {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    line-height: 1.4;
    letter-spacing: 0.5px;
}

/* Nascondi elementi non più utilizzati */
.footer-left,
.footer-right,
.footer-page-info {
    display: none !important;
}

/* Effetto hover sul footer */
.main-footer:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* === RESPONSIVE FOOTER === */

/* Tablet */
@media (max-width: 768px) {
    .main-footer {
        padding: 0.8rem 0;
    }

    .footer-content {
        padding: 0 1.5rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .main-footer {
        padding: 0.6rem 0;
    }

    .footer-content {
        padding: 0 1rem;
    }

    .footer-text {
        font-size: 0.75rem;
    }
}

/* Orientamento orizzontale mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .main-footer {
        padding: 0.4rem 0;
        background: rgba(0, 0, 0, 0.8);
    }

    .footer-text {
        font-size: 0.7rem;
    }
}

/* Schermi molto piccoli */
@media (max-width: 320px) {
    .main-footer {
        padding: 0.5rem 0;
    }

    .footer-content {
        padding: 0 0.8rem;
    }

    .footer-text {
        font-size: 0.7rem;
    }
}

/* Schermi grandi */
@media (min-width: 1440px) {
    .footer-text {
        font-size: 1rem;
    }
}

/* === ACCESSIBILITÀ FOOTER === */

@media (prefers-reduced-motion: reduce) {
    .main-footer {
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .main-footer {
        background: rgba(0, 0, 0, 0.9);
        border-top: 2px solid white;
    }

    .footer-text {
        color: white;
        font-weight: 400;
    }
}

/* === ANIMAZIONE DI ENTRATA === */
@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-footer {
    animation: slideUpIn 0.6s ease-out 0.3s both;
}

/* === CONTENUTO CON NUOVI FONT === */
.content {
    text-align: left;
    color: white;
    background-color: rgba(0, 0, 0, 0.6);
    padding: clamp(1.5rem, 5vw, 3rem);
    border-radius: 15px;
    max-width: min(600px, 90vw);
    margin-left: clamp(2%, 5vw, 8%);
    margin-right: auto;
    margin-bottom: clamp(8rem, 20vw, 15rem);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    z-index: 1000;
}

.content h1 {
    font-family: 'Keania One', cursive;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 400;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    text-transform: uppercase;
    letter-spacing: clamp(1px, 0.5vw, 2px);
    line-height: 0.9;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
}

.content p {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    line-height: clamp(1.5, 4vw, 1.7);
    margin-bottom: clamp(0.8rem, 2vw, 1rem);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.7);
    width: 100%;
}

/* Liste */
.content ul,
.content ol {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    line-height: 1.6;
    margin-left: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 1rem;
}

.content li {
    margin-bottom: 0.5rem;
}

/* Link */
.content a {
    font-family: 'Zain', sans-serif;
    font-weight: 400;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.content a:hover {
    border-bottom-color: rgba(255, 255, 255, 1);
}

/* === BOTTONE NEL CONTENUTO === */
.content-button {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: clamp(0.7rem, 1.8vw, 1rem) clamp(1.2rem, 3vw, 2rem);
    color: white;
    font-family: 'Zain', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    margin-top: clamp(1rem, 2.5vw, 1.5rem);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    width: auto;
    align-self: flex-start;
    position: relative;
    z-index: 1001;
}

.content-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* Responsive per content button */
@media (max-width: 768px) {
    .content-button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .content-button {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
        width: 100%;
        text-align: center;
        align-self: stretch;
    }
}

/* Mobile landscape */
@media (max-height: 500px) and (orientation: landscape) {
    .content-button {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        margin-top: 0.8rem;
    }
}

/* Accessibilità per content button */
.content-button:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .content-button {
        transition: none;
    }

    .content-button:hover {
        transform: none;
    }
}

@media (prefers-contrast: high) {
    .content-button {
        background: rgba(255, 255, 255, 0.4);
        border: 2px solid white;
        font-weight: 500;
    }
}

/* === NAVIGAZIONE === */
.navigation {
    position: fixed;
    right: clamp(0.5rem, 2vw, 2rem);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 2vw, 1rem);
    z-index: 1002;
    touch-action: manipulation;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: clamp(35px, 10vw, 50px);
    height: clamp(35px, 10vw, 50px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    color: white;
    touch-action: manipulation;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.nav-btn:active {
    transform: scale(0.95);
}

/* === ANIMAZIONI === */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(clamp(-30px, -5vw, -50px));
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.page.active .content {
    animation: slideInLeft 0.8s ease-out;
}

/* === OTTIMIZZAZIONI PERFORMANCE === */
.page {
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* === STILI PER SCRAMBOLGRAMS === */

/* Override per la pagina del gioco */
.scrambolgrams-page .pages-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.scrambolgrams-page .page {
    background: none !important;
    align-items: center;
    justify-content: center;
}

/* Container del gioco */
.game-container {
    width: 100%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: clamp(1rem, 3vw, 2rem);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    color: white;
    margin: 2rem auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header del gioco */
.game-header {
    text-align: center;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.game-title {
    font-family: 'Keania One', cursive;
    font-size: clamp(2rem, 6vw, 2.5rem);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-subtitle {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    opacity: 0.9;
}

/* Statistiche del gioco */
.game-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: clamp(0.5rem, 2vw, 1rem);
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.stat-box {
    background: rgba(255, 255, 255, 0.15);
    padding: clamp(0.8rem, 2vw, 1rem);
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    opacity: 0.8;
    margin-bottom: 0.3rem;
    font-family: 'Zain', sans-serif;
    font-weight: 300;
}

.stat-value {
    font-size: clamp(1.2rem, 4vw, 1.4rem);
    font-weight: bold;
    font-family: 'Zain', sans-serif;
}

.timer { color: #ffd700; }
.punteggio { color: #4cd964; }
.mescolamento { color: #5ac8fa; }

/* Griglia delle lettere */
.letter-grid-container {
    position: relative;
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    min-height: 300px;
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(0.5rem, 2vw, 0.8rem);
    max-width: 300px;
    margin: 0 auto;
}

.letter-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.3rem, 4vw, 1.5rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    font-family: 'Zain', sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.letter-cell:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.letter-cell.selected {
    background: rgba(90, 200, 250, 0.6);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.letter-cell.correct {
    background: rgba(76, 217, 100, 0.9) !important;
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.letter-cell.incorrect {
    background: rgba(255, 59, 48, 0.9) !important;
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.letter-cell.already-found {
    background: rgba(255, 204, 0, 0.9) !important;
    transform: scale(1.1);
    color: #333;
    border-color: rgba(255, 255, 255, 0.8);
}

/* Feedback visivo */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: bold;
    padding: clamp(0.8rem, 3vw, 1rem) clamp(1.5rem, 5vw, 2rem);
    border-radius: 15px;
    text-align: center;
    z-index: 1000;
    animation: popInOut 1s ease-in-out;
    font-family: 'Zain', sans-serif;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.feedback-correct {
    background: rgba(76, 217, 100, 0.95);
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

.feedback-incorrect {
    background: rgba(255, 59, 48, 0.95);
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

.feedback-already-found {
    background: rgba(255, 204, 0, 0.95);
    color: #333;
    border: 3px solid rgba(255, 255, 255, 0.8);
}

@keyframes popInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

/* Parola corrente */
.current-word {
    background: rgba(255, 255, 255, 0.15);
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 15px;
    margin-bottom: clamp(0.8rem, 2vw, 1rem);
    text-align: center;
    font-size: clamp(1.5rem, 5vw, 1.8rem);
    letter-spacing: 3px;
    font-weight: bold;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Zain', sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Messaggi del gioco */
.game-message {
    padding: clamp(0.8rem, 2vw, 1rem);
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
    margin-bottom: clamp(0.8rem, 2vw, 1rem);
    display: none;
    font-family: 'Zain', sans-serif;
}

.game-message.success {
    background: rgba(76, 217, 100, 0.3);
    display: block;
    border: 1px solid rgba(76, 217, 100, 0.5);
}

.game-message.error {
    background: rgba(255, 59, 48, 0.3);
    display: block;
    border: 1px solid rgba(255, 59, 48, 0.5);
}

.game-message.info {
    background: rgba(90, 200, 250, 0.3);
    display: block;
    border: 1px solid rgba(90, 200, 250, 0.5);
}

/* Pulsante torna indietro */
.back-button {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: clamp(0.7rem, 1.8vw, 1rem) clamp(1.2rem, 3vw, 2rem);
    color: white;
    font-family: 'Zain', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    margin-top: clamp(1rem, 2.5vw, 1.5rem);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    width: auto;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

/* === RESPONSIVE BREAKPOINTS === */

/* Tablet orizzontale e desktop piccoli */
@media (max-width: 1024px) and (min-width: 769px) {
    .content {
        max-width: 70%;
        margin-left: 5%;
    }
}

/* Tablet verticale e mobile grande */
@media (max-width: 768px) {
    .navigation {
        right: 1rem;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
    }

    .content {
        margin-left: 3%;
        margin-right: 3%;
        max-width: 90%;
        padding: 2rem;
        margin-bottom: clamp(7rem, 18vw, 14rem);
    }

    .content h1 {
        font-size: 2.5rem;
        letter-spacing: 1px;
    }

    .content p {
        font-size: 1.1rem;
    }

    /* Scrambolgrams responsive */
    .game-stats {
        grid-template-columns: 1fr 1fr;
    }

    .stat-box:nth-child(3) {
        grid-column: span 2;
    }

    .letter-grid {
        max-width: 280px;
    }
}

/* Orientamento orizzontale mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .page {
        align-items: flex-start;
        padding-top: 1rem;
    }

    .content {
        margin-top: 1rem;
        margin-bottom: 5rem;
        max-width: 85%;
        padding: 1.5rem;
    }

    .content h1 {
        font-size: 1.8rem;
        margin-bottom: 0.8rem;
    }

    .content p {
        font-size: 1rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }

    .navigation {
        top: 1rem;
        transform: none;
        flex-direction: row;
        right: 1rem;
    }

    /* Scrambolgrams landscape */
    .game-container {
        margin: 1rem auto;
        padding: 1rem;
    }

    .letter-grid-container {
        min-height: 200px;
    }
}

/* Mobile medio */
@media (max-width: 480px) {
    .navigation {
        right: 0.5rem;
    }

    .nav-btn {
        width: 35px;
        height: 35px;
    }

    .content {
        margin-left: 2%;
        margin-right: 2%;
        margin-bottom: clamp(7rem, 18vw, 14rem);
        padding: 1.5rem;
    }

    .content h1 {
        font-size: 2rem;
    }

    .content p {
        font-size: 1rem;
    }

    /* Scrambolgrams mobile */
    .game-container {
        margin: 1rem auto;
        padding: 1rem;
    }

    .letter-grid {
        max-width: 260px;
        gap: 0.5rem;
    }

    .letter-cell {
        font-size: 1.3rem;
    }

    .current-word {
        font-size: 1.5rem;
        min-height: 70px;
    }

    .feedback-overlay {
        font-size: 1.5rem;
        padding: 0.8rem 1.5rem;
    }
}

/* Mobile piccolo */
@media (max-width: 380px) {
    .content {
        padding: 1.2rem;
        max-width: 94%;
        margin-left: 1%;
        margin-right: 1%;
        margin-bottom: 6rem;
    }

    .content h1 {
        font-size: 1.7rem;
    }

    .content p {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
    }

    /* Scrambolgrams small mobile */
    .letter-grid {
        max-width: 240px;
    }

    .letter-cell {
        font-size: 1.2rem;
    }

    .current-word {
        font-size: 1.3rem;
    }
}

/* Telefoni molto piccoli */
@media (max-width: 320px) {
    .content {
        padding: 1rem;
        margin-bottom: 6rem;
    }

    .content h1 {
        font-size: 1.5rem;
    }

    .content p {
        font-size: 0.9rem;
    }

    .nav-btn {
        width: 30px;
        height: 30px;
    }
}

/* Desktop grandi */
@media (min-width: 1440px) {
    .content {
        max-width: 700px;
        margin-left: 10%;
        margin-bottom: 12rem;
    }

    .content h1 {
        font-size: 4.5rem;
    }

    .content p {
        font-size: 1.4rem;
    }
}

/* Schermi 4K e molto grandi */
@media (min-width: 2000px) {
    .content {
        max-width: 800px;
        margin-left: 15%;
        margin-bottom: 14rem;
    }

    .content h1 {
        font-size: 5rem;
    }

    .content p {
        font-size: 1.6rem;
    }
}

/* === OTTIMIZZAZIONI PER ALTA DENSITÀ PIXEL === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .page {
        background-size: cover;
    }
}

/* === MIGLIORAMENTI ACCESSIBILITÀ === */

/* Riduzione movimento */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .page.active .content {
        animation: none;
    }

    .nav-btn {
        transition: none;
    }

    .nav-btn:hover {
        transform: none;
    }

    .letter-cell {
        transition: none;
    }

    .letter-cell:hover {
        transform: none;
    }

    .feedback-overlay {
        animation: none;
    }

    .content-button:hover {
        transform: none;
    }

    .back-button:hover {
        transform: none;
    }
}

/* Alto contrasto */
@media (prefers-contrast: high) {
    .content {
        background-color: rgba(0, 0, 0, 0.8);
        border: 2px solid white;
    }

    .nav-btn {
        background: rgba(255, 255, 255, 0.4);
        border: 2px solid white;
    }

    .game-container {
        background: rgba(0, 0, 0, 0.8);
        border: 2px solid white;
    }

    .stat-box {
        background: rgba(255, 255, 255, 0.3);
        border: 1px solid white;
    }

    .letter-cell {
        background: rgba(255, 255, 255, 0.3);
        border: 1px solid white;
    }

    .current-word {
        background: rgba(255, 255, 255, 0.3);
        border: 1px solid white;
    }
}

/* Modalità scura */
@media (prefers-color-scheme: dark) {
    .content {
        background-color: rgba(0, 0, 0, 0.7);
    }
}

/* === FALLBACK PER BROWSER VECCHI === */

/* Fallback per clamp() */
@supports not (clamp(1rem, 2vw, 1.3rem)) {
    @media (max-width: 768px) {
        .content h1 {
            font-size: 2.5rem;
        }
        .content p {
            font-size: 1.1rem;
        }

        .game-title {
            font-size: 2rem;
        }
    }

    @media (max-width: 480px) {
        .content h1 {
            font-size: 2rem;
        }
        .content p {
            font-size: 1rem;
        }

        .game-title {
            font-size: 1.8rem;
        }

        .letter-cell {
            font-size: 1.3rem;
        }
    }

    @media (max-width: 320px) {
        .content h1 {
            font-size: 1.5rem;
        }
        .content p {
            font-size: 0.9rem;
        }

        .game-title {
            font-size: 1.5rem;
        }

        .letter-cell {
            font-size: 1.2rem;
        }
    }
}

/* Fallback per backdrop-filter */
@supports not (backdrop-filter: blur(10px)) {
    .content {
        background-color: rgba(0, 0, 0, 0.8);
    }

    .nav-btn {
        background: rgba(255, 255, 255, 0.3);
    }

    .game-container {
        background: rgba(0, 0, 0, 0.8);
    }

    .stat-box {
        background: rgba(255, 255, 255, 0.2);
    }

    .letter-cell {
        background: rgba(255, 255, 255, 0.25);
    }
}

/* === STATI SPECIALI === */

/* Classe per mobile landscape (gestita via JS) */
body.mobile-landscape .content {
    max-width: 80%;
    padding: 1rem;
    margin-bottom: 4.5rem;
}

body.mobile-landscape .content h1 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

body.mobile-landscape .content p {
    font-size: 0.9rem;
    line-height: 1.3;
}

/* Pulsanti disabilitati */
.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

.nav-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: none !important;
}

/* === OTTIMIZZAZIONI PER STAMPA === */
@media print {
    .navigation {
        display: none;
    }

    .page {
        position: relative;
        opacity: 1;
        visibility: visible;
        page-break-after: always;
        height: auto;
        min-height: 100vh;
    }

    .pages-container {
        height: auto;
        overflow: visible;
    }

    .content {
        background-color: white;
        color: black;
        border: 1px solid #000;
        backdrop-filter: none;
        margin-bottom: 2rem;
        z-index: auto;
    }

    body {
        overflow: visible;
    }

    /* Nascondi elementi di gioco nella stampa */
    .game-container {
        display: none;
    }
}

/* === VARIANTI DI PESO FONT === */
.text-light {
    font-family: 'Zain', sans-serif;
    font-weight: 200;
}

.text-normal {
    font-family: 'Zain', sans-serif;
    font-weight: 300;
}

.text-medium {
    font-family: 'Zain', sans-serif;
    font-weight: 400;
}

.text-bold {
    font-family: 'Zain', sans-serif;
    font-weight: 700;
}

.text-black {
    font-family: 'Zain', sans-serif;
    font-weight: 800;
}

.heading-keania {
    font-family: 'Keania One', cursive;
    font-weight: 400;
}

/* Elementi speciali */
.special-number {
    font-family: 'Keania One', cursive;
    font-size: clamp(2rem, 5vw, 3rem);
    display: block;
    margin-bottom: 0.5rem;
}

/* Focus accessibility */
.nav-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.content a:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.content-button:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.back-button:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.letter-cell:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}
