body {
    font-family: sans-serif;
    margin: 0;
    background-color: black;
    color: #333;
}

h1 {
    text-align: center;
    padding: 20px;
    color: #333;
}

/* Error Message Styling */
#error-message {
    background-color: #ffdddd;
    border: 1px solid #ffaaaa;
    color: #d8000c;
    padding: 15px;
    margin: 10px 20px;
    border-radius: 5px;
    text-align: center;
    display: none; /* Hidden by default */
}

/* Thumbnail Grid Styling */
#thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 20px;
    padding-top: 100px;
    max-width: 1200px;
    margin: 0 auto;
}

.thumbnail-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    display: flex; /* For centering placeholder text if image fails */
    align-items: center; /* For centering placeholder text if image fails */
    justify-content: center; /* For centering placeholder text if image fails */
    min-height: 100px; /* Ensure it has some height if image fails badly */
    text-align: center;
}

.thumbnail-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures the image covers the item area, might crop */
    display: block;
}

.thumbnail-item .image-error-placeholder {
    font-size: 0.8em;
    color: #cc0000;
    padding: 10px;
}


/* Fullscreen View Styling */
#fullscreen-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#fullscreen-view.active {
    display: flex;
    opacity: 1;
}

/* ADDED: Wrapper for fullscreen content (title and image) */
.fullscreen-content {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    max-height: 90%;
}

/* ADDED: Title for the fullscreen image */
#fullscreen-title {
    color: white;
    font-family: sans-serif;
    font-size: 1.2rem; /* A good 'medium' size */
    text-align: left;
    padding-bottom: 15px; /* Space between title and image */
}

#fullscreen-image {
    /* MODIFIED: Size is now relative to its new parent, .fullscreen-content */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensures entire image is visible, might show letterboxing */
    border-radius: 5px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    min-height: 0; /* ADDED: Fix for flexbox sizing issue with images */
}


#close-fullscreen {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

#close-fullscreen:hover {
    color: #ccc;
}