body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-image: url('/Windows.webp');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

#app-container {
    background: #fff;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 900px;
    position: relative;
    text-align: center;
    margin-bottom: 40px;
}

/* Style for the top-left GIF */
#top-left-gif {
    position: absolute; /* Position it absolutely */
    top: 10px; /* 10px from the top */
    left: 10px; /* 10px from the left */
    width: 50px; /* Set a reasonable size */
    height: auto; /* Maintain aspect ratio */
    z-index: 10; /* Ensure it's above other elements */
    pointer-events: none; /* Don't interfere with clicks on elements below it */
}

/* Style for the bottom-left Fish GIF */
#bottom-left-gif {
    position: absolute;
    top: 70px; /* Position below the top-left gif (adjust based on gif height + spacing) */
    left: 10px; /* Align with the top-left gif */
    width: 60px; /* Slightly larger size */
    height: auto;
    z-index: 10;
    cursor: pointer; /* Indicate it's clickable */
}

h1 {
    color: #1c1e21;
    margin-top: 0;
}

#controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dddfe2;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #606770;
    font-weight: 600;
}

input[type="text"], input[type="file"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    min-width: 200px;
    font-size: 1em;
}

input::file-selector-button {
    font-weight: bold;
    color: #1877f2;
    padding: 0.5em 1em;
    border: 1px solid transparent;
    border-radius: 5px;
    background-color: #e7f3ff;
    cursor: pointer;
}

button {
    background-color: #42b72a;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: background-color 0.2s;
    height: 38px; /* Match input height */
}

button:hover {
    background-color: #36a420;
}

#download-btn {
    background-color: #1877f2;
    margin-top: 20px;
}

#download-btn:hover {
    background-color: #166fe5;
}

/* Style for the new Clear All button */
#clear-all-btn {
    background-color: #f02849; /* Red color, similar to delete item */
    margin-top: 10px; /* Add some space below download */
    margin-right: 10px; /* Add some space between buttons */
}

#clear-all-btn:hover {
    background-color: #d1213b; /* Darker red on hover */
}

/* New style for the Post to Gallery button */
#post-to-gallery-btn {
    background-color: #6a5acd; /* A pleasing purple */
    margin-top: 10px; /* Align with clear all */
}

#post-to-gallery-btn:hover {
    background-color: #5b4fac; /* Darker purple on hover */
}

#mute-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    background-color: #f0f2f5;
    color: #333;
    border: 1px solid #ccc;
    font-size: 0.9em;
    padding: 5px 10px;
    font-weight: normal;
    z-index: 10; /* Ensure it's above controls */
}

#mute-btn:hover {
    background-color: #e9ebee;
}

#meme-canvas-container {
    padding: 10px;
    border: 1px dashed #ccc;
    background-color: #f9f9f9;
}

#meme-canvas {
    width: 100%;
    height: 600px;
    background-color: white;
    position: relative;
    overflow: hidden;
    border: 1px solid #ddd;
    user-select: none; /* Prevent text selection during drag */
    touch-action: none; /* Disable default touch actions */
}

#meme-title {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.2em;
    font-weight: bold;
    width: 95%;
    text-align: center;
    pointer-events: none; /* Don't interfere with dragging */
    z-index: 5; /* Ensure title is above items */
}

.meme-item {
    position: absolute;
    cursor: grab;
    text-align: center;
    width: 150px; /* Fixed width for consistency */
    padding: 5px;
    background: rgba(255, 255, 255, 0.7); /* Slightly more opaque background */
    border: 1px solid rgba(0,0,0,0.1); /* subtle border */
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Use hover to show delete button */
}

.meme-item:hover {
    cursor: grab; /* Keep grab cursor on hover */
    border-color: #1877f2; /* Highlight on hover */
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.meme-item:active {
    cursor: grabbing;
    z-index: 1000; /* Bring item to front when dragging */
}

/* Style for the delete button */
.delete-item-btn {
    position: absolute;
    top: -10px; /* Position outside the top edge */
    right: -10px; /* Position outside the right edge */
    background-color: #f02849; /* Facebook red */
    color: white;
    border: 2px solid white; /* White border for visibility */
    border-radius: 50%; /* Make it round */
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    line-height: 20px; /* Vertically center the 'X' */
    cursor: pointer;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
    z-index: 10; /* Ensure it's above the item */
    display: none; /* Hidden by default */
    transition: background-color 0.2s;
    height: 24px; /* Override button height */
}

.meme-item:hover .delete-item-btn {
    display: block; /* Show on hover */
}

.delete-item-btn:hover {
    background-color: #d1213b; /* Darker red on hover */
}

.meme-item img {
    max-width: 100%;
    height: auto; /* Maintain aspect ratio based on width */
    display: block;
    pointer-events: none; /* Don't interfere with drag or delete button clicks */
}

.meme-item .caption {
    font-size: 1em;
    font-weight: 500;
    margin-top: 5px;
    word-wrap: break-word;
    pointer-events: auto; /* Allow clicking/double-clicking on caption */
    padding: 0 2px; /* Add some padding */
}

/* Style for when the caption is being edited */
.meme-item .caption[contenteditable="true"] {
    outline: none; /* Remove default outline */
    background-color: rgba(255, 255, 255, 0.9); /* Slightly different background */
    cursor: text;
}

/* Optional: Animation for the fish gif when stamping is enabled */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.1); opacity: 0.9; }
}

/* --- Gallery Styles --- */
#gallery-container {
    background: #fff;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 900px;
    text-align: center;
}

#gallery-container h2 {
    color: #1c1e21;
    margin-top: 0;
    margin-bottom: 20px;
}

#gallery-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Responsive grid */
    gap: 20px; /* Space between gallery items */
    padding: 0;
    list-style: none;
}

.gallery-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden; /* Hide parts of image that might exceed */
    background-color: #f9f9f9;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    text-align: left;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.gallery-item:hover {
    transform: translateY(-5px); /* Slight lift effect */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.gallery-item img {
    width: 100%;
    height: 150px; /* Fixed height for images */
    object-fit: contain; /* Keep aspect ratio and fit */
    background-color: white; /* Background for the image area */
    border-bottom: 1px solid #eee;
}

.gallery-item .details {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow details to take up remaining space */
}

.gallery-item .meme-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 5px;
    word-break: break-word; /* Break long words */
    color: #333;
}

.gallery-item .creator-info {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    color: #606770;
    margin-top: 5px; /* Add a little space below title */
     margin-bottom: 10px; /* Add space before buttons */
}

.gallery-item .creator-info img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
    background-color: #ccc; /* Placeholder background */
    flex-shrink: 0; /* Prevent avatar from shrinking */
    border: none; /* Remove border from avatar image */
    height: 24px; /* Override potential height from general img rule */
}

.gallery-item .creator-info span {
    word-break: break-word; /* Break long usernames */
}

/* Style for action buttons container in gallery items */
.gallery-item .action-buttons {
    display: flex;
    gap: 8px; /* Space between buttons */
    margin-top: auto; /* Push buttons to the bottom */
    justify-content: center; /* Center buttons */
}

/* Style for individual gallery buttons */
.gallery-btn {
    padding: 5px 10px; /* Smaller padding */
    font-size: 0.9em; /* Smaller font size */
    font-weight: normal; /* Less bold */
    height: auto; /* Auto height */
}

/* Specific style for download button */
.download-gallery-btn {
    background-color: #1877f2; /* Facebook blue */
}

.download-gallery-btn:hover {
    background-color: #166fe5; /* Darker blue */
}

/* Specific style for delete button */
.delete-gallery-btn {
    background-color: #f02849; /* Facebook red */
}

.delete-gallery-btn:hover {
    background-color: #d1213b; /* Darker red */
}


#gallery-loading,
#gallery-empty {
    font-size: 1.1em;
    color: #606770;
}