/* General styles */
body {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-image: url(../Imagenes/fondo.png);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    user-select: none;
    padding: 20px;
    box-sizing: border-box;
    position: relative; /* Needed for absolute positioning of nav and images on desktop */
}

/* Helper classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Main container */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 900px;
    gap: 20px;
}

/* Header */
.header {
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: rgb(255, 255, 255);
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.897);
    box-shadow: 0 0 10px rgb(255, 255, 255);
    border-radius: 20px;
    width: 95%;
    position: static;
    margin-bottom: 20px; /* Add margin for spacing */
}

/* Game board */
.game-board {
    display: flex;
    flex-direction: column; /* Default to column for small screens */
    width: 100%;
    max-width: 900px;
    gap: 20px;
    align-items: center;
}

/* Letters container */
.letters-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
}

.letters {
    width: 100%;
    min-height: 200px;
    border-radius: 10px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    background-color: rgba(0, 0, 0, 0.897);
    box-shadow: 0 0 10px rgb(255, 255, 255);
}

/* General button styling */
button {
    background-color: rgba(0, 0, 0, 0.897);
    box-shadow: 0 0 10px rgb(255, 255, 255);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    font-size: clamp(1rem, 2vw, 1.5rem);
    transition: background-color 0.5s, transform 0.3s;
    cursor: pointer;
    padding: 10px;
}

button:hover {
    background-color: #383838c4;
    transform: scale(1.1);
}

/* Specific buttons container */
.buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Adjusted for better mobile layout */
    gap: 10px;
    width: 100%;
    margin-top: 10px;
    order: 3;
}

.buttons button {
    width: 100%;
    font-size: clamp(0.8rem, 2vw, 1rem);
    padding: 10px;
}

/* Word builder */
.word-builder {
    width: 100%;
    min-height: 150px;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.897);
    box-shadow: 0 0 10px rgb(255, 255, 255);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: static;
    color: white;
    font-size: 25px;
    font-weight: bold;
    order: 2;
}

.word-builder p {
    font-weight: bold;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: #ffffff;
    margin: 0;
}

/* Scoreboard and word list */
.scoreboard, .word-list {
    font-size: clamp(1rem, 3vw, 1.5rem);
    position: static;
    text-align: center;
    color: white;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.897);
    box-shadow: 0 0 10px rgb(255, 255, 255);
    border-radius: 10px;
    width: 100%;
    padding: 15px;
    margin-top: 10px;
}

.scoreboard p {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: bold;
}

/* Informative text boxes (Mobile) */
.xx, .xx1 {
    display: block; /* Make visible on mobile too */
    width: 90%; /* Take most of the width */
    margin: 10px auto; /* Center with margin */
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7); /* Semitransparent dark background */
    color: white;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5); /* Subtle white glow */
    font-size: clamp(0.9rem, 2.5vw, 1.2rem); /* Responsive font size */
    position: static; /* Position statically in the flow */
}

/* Navigation */
nav {
   background-color: rgba(0, 0, 0, 0.897);
    position: absolute;
    top: 40px;
    left: 20px;
    width: 50px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgb(255, 255, 255);
    z-index: 10;
}

nav a {
      text-decoration: none;
    color: white;
    font-size: 30px;
}

/* New article for image gallery */
.image-row-container {
    width: 100%;
    max-width: 900px; /* Match main container max-width */
    margin-top: 30px; /* Spacing from elements above */
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-gallery {
    display: flex;
    flex-wrap: wrap; /* Allows images to wrap on smaller screens */
    justify-content: center; /* Center images within the row */
    gap: 15px; /* Spacing between images */
    width: 100%;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.7); /* Optional: add a background for the row */
    border-radius: 15px;
    box-shadow: 0 0 10px rgb(255, 255, 255);
}

.image-gallery img {
    width: clamp(60px, 12vw, 100px); /* Smaller size for images */
    height: auto;
    filter: drop-shadow(5px 5px 5px rgba(0, 0, 0, 0.5));
    animation: breathing 2s ease-in-out infinite;
    -webkit-user-drag: none;
    cursor: pointer;
    transition: transform 0.3s;
}

.image-gallery img:hover {
    transform: scale(1.15); /* Slightly smaller hover effect */
}

/* Animations */
@keyframes breathing {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); } /* Slightly smaller breathing effect */
}

/* --- Media Queries for Desktop --- */
@media (min-width: 768px) {
    body {
        justify-content: center;
    }

    .container {
        flex-direction: column; /* Keep container column on desktop, game-board handles row layout */
        max-width: 1000px; /* Slightly wider for better image display */
    }

    .header {
        position: absolute;
        top: 0.5%;
        width: 98%;
        margin: 0 10px;
        font-size: 30px;
    }
    
    .game-board {
        flex-direction: row;
        width: 100%;
        margin-top: 100px;
        align-items: flex-start;
        justify-content: center; /* Center game board elements */
        gap: 40px; /* Increase gap for desktop */
    }

    .letters-container {
        flex-direction: row;
        align-items: flex-start;
        width: 45%; /* Adjust width for desktop */
        position: relative;
    }

    .letters {
        width: calc(100% - 150px);
        min-height: 200px;
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px;
    }

    .buttons {
        flex-direction: column;
        justify-content: flex-start;
        margin-left: 10px;
        gap: 10px;
        width: auto;
        order: 1;
    }

    .buttons button {
        width: 120px; /* Adjust button width for desktop */
        font-size: 20px;
    }

    .word-builder {
        width: 35%; /* Adjust width for desktop */
        min-height: 200px;
        order: 1;
    }

    .word-builder p {
        font-size: 40px;
    }
    
    .scoreboard {
        position: absolute;
        top: 40%;
        left: 8%;
        width: 180px; /* Fixed width for scoreboard on desktop */
        padding: 10px;
    }

    .scoreboard p {
        font-size: 40px;
    }

    .word-list {
        position: absolute;
        top: 35%;
        right: 8%;
        width: 250px;
        height: 45%;
    }

    /* Informative text boxes (Desktop) */
    .xx, .xx1 {
        display: block; /* Ensure visibility on desktop */
        position: absolute; /* Revert to absolute positioning for desktop */
        padding: 20px;
        background-color: rgba(0, 0, 0, 0.7); /* Keep background */
        color: white;
        text-align: center;
        border-radius: 10px;
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
        font-size: 30px; /* Fixed size for desktop */
        width: auto; /* Allow width to adjust based on content */
        max-width: 500px; /* Limit max width to prevent stretching too much */
        margin: 0; /* Remove auto margin */
    }

    .xx {
        top: 13%; /* Adjust top positioning */
        left: 20%; /* Adjust right positioning */
    }

    .xx1 {
        top: 13%; /* Adjust top positioning */
        right: 21%; /* Adjust right positioning */
    }

    /* Image gallery on desktop */
    .image-row-container {
        position: absolute;
        bottom: 20px;
        width: 95%;
        max-width: none;
    }

    .image-gallery {
        flex-wrap: nowrap;
        justify-content: space-around;
        background-color: rgba(0, 0, 0, 0.7);
        padding: 15px 20px;
    }

    .image-gallery img {
        width: 80px;
        height: auto;
        animation: breathing 2s ease-in-out infinite;
        position: static !important;
    }
}