body {
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
    background-color: #f4f0e6;
    color: #333;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-image: url('tiki_background.png');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
}

.attribution-banner {
    top: 10px;
    right: 10px;
    position: fixed;
    font-size: 0.75rem;
    color: #444;
    z-index: 10000;
    background-color: rgba(255, 255, 255, 0.75);
    padding: 5px 10px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    font-weight: normal;
}

.attribution-banner a {
    color: #5a783a;
    text-decoration: none;
    font-weight: bold;
}

.attribution-banner a:hover {
    text-decoration: underline;
}

header {
    text-align: center;
    margin-bottom: 20px;
    color: #5a783a;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

h2 {
    font-size: 1.8rem;
    margin: 30px 0 20px;
    color: #5a783a;
    text-align: center;
}

.container {
    background-color: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #5a783a;
}

.input-section {
    margin-bottom: 30px;
}

input, select, button {
    font-size: 1.1rem;
    padding: 10px;
    margin: 5px 0;
    border-radius: 5px;
    border: 1px solid #ccc;
}

input {
    width: calc(100% - 22px);
}

select {
    width: 100%;
    margin-bottom: 15px;
}

button {
    background-color: #5a783a;
    color: white;
    border: none;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    transition: background-color 0.3s;
    position: relative; 
    min-height: 45px; 
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

button:not(:disabled):hover {
    background-color: #6a884a;
}

.post-button {
    background-color: #b06b2c; 
    margin: 15px 0;
}

.post-button:not(:disabled):hover {
    background-color: #c57b3c;
}

.result-section {
    margin-top: 30px;
    text-align: center;
    display: none;
}

.result-section.show {
    display: block;
    animation: fadeIn 0.5s;
}

.character-name {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #5a783a;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.character-image {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    border: 3px solid #5a783a;
    cursor: pointer;
}

.audio-controls {
    margin-top: 20px;
    width: 100%; 
    display: flex; 
    justify-content: center; 
}

audio {
    border-radius: 5px;
}

.loading {
    margin: 20px 0;
    text-align: center;
    font-style: italic;
    color: #666;
    display: none;
}

.loading.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.error {
    color: #d12600;
    margin-top: 10px;
    font-weight: bold;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner.show {
    display: inline-block !important;
}

button .button-text,
button .spinner {
    display: inline-block; 
    vertical-align: middle;
}

button:disabled .button-text {
}

.improvement-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 20px 0;
    gap: 10px;
}

.improvement-button {
    flex: 1 1 150px;
    margin: 5px; 
    background-color: #7a985a;
}

.improvement-button:not(:disabled):hover {
    background-color: #8aa86a;
}

.info-banner {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid #5a783a;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: justify;
}

.gallery-section {
    margin-top: 40px;
    border-top: 2px dashed #5a783a;
    padding-top: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.gallery-item {
    background-color: #f9f7f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0d8c0;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.gallery-image-container {
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    position: relative;
    overflow: hidden;
}

.gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    cursor: pointer;
}

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

.gallery-info {
    padding: 12px;
    background: white;
}

.gallery-name {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #5a783a;
}

.gallery-user {
    font-size: 0.8rem;
    color: #666;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 5px;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    color: #666;
    font-style: italic;
}

#square-viewport-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
}

#square-viewport-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Character Dance Animations */

/* Bouncing animation */
@keyframes character-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(calc(-15px * var(--dance-intensity, 1))); }
}

/* Shaking animation */
@keyframes character-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(calc(5deg * var(--dance-intensity, 1))); }
    75% { transform: rotate(calc(-5deg * var(--dance-intensity, 1))); }
}

/* Wiggling animation */
@keyframes character-wiggle {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(calc(10px * var(--dance-intensity, 1))); }
    75% { transform: translateX(calc(-10px * var(--dance-intensity, 1))); }
}

/* Spinning animation */
@keyframes character-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(calc(360deg * var(--dance-intensity, 1))); }
}

/* Dance class that applies the appropriate animation based on data attribute */
.character-image.dancing[data-dance-style="bounce"] {
    animation: character-bounce calc(var(--dance-duration, 2000ms) / var(--bounce-cycles, 3)) 
               ease-in-out var(--bounce-cycles, 3);
    transform-origin: bottom center;
}

.character-image.dancing[data-dance-style="shake"] {
    animation: character-shake calc(var(--dance-duration, 2000ms) / 8) 
               ease-in-out calc(8 * var(--dance-intensity, 1));
    transform-origin: center;
}

.character-image.dancing[data-dance-style="wiggle"] {
    animation: character-wiggle calc(var(--dance-duration, 2000ms) / 8) 
               ease-in-out calc(8 * var(--dance-intensity, 1));
}

.character-image.dancing[data-dance-style="spin"] {
    animation: character-spin var(--dance-duration, 2000ms) 
               ease-in-out var(--dance-intensity, 1);
    transform-origin: center;
}

/* Cocktail Sections */
.cocktail-recipes-section, .custom-cocktail-section {
    margin-top: 40px;
    border-top: 2px dashed #8a5a2c; 
    padding-top: 20px;
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.recipe-card {
    background-color: #fffaf0; 
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #deb887; 
    padding: 15px;
}

.recipe-card h3 {
    color: #8a5a2c; 
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.recipe-card img.cocktail-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 2px solid #deb887;
}

.recipe-card p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 8px;
}

.recipe-card ul {
    list-style-type: disc;
    margin-left: 20px;
    padding-left: 0;
    font-size: 0.9rem;
}

.recipe-card strong {
    color: #6b4a24; 
}

.custom-cocktail-section .ingredient-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.custom-cocktail-section label {
    font-weight: bold;
    color: #6b4a24;
    margin-bottom: -5px; 
}

#mix-cocktail-button {
    background-color: #8a5a2c;
    margin-top: 10px;
}

#mix-cocktail-button:not(:disabled):hover {
    background-color: #a06b3c;
}

.custom-cocktail-result {
    margin-top: 20px;
    padding: 20px;
    background-color: #fffaf0;
    border: 1px solid #deb887;
    border-radius: 8px;
    text-align: center;
}

.custom-cocktail-result h3 {
    color: #8a5a2c;
    font-size: 1.5rem;
}

.custom-cocktail-result img.cocktail-image {
    max-width: 80%;
    height: auto;
    max-height: 300px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    margin: 15px auto;
    border: 3px solid #8a5a2c;
}

.custom-cocktail-result p {
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    white-space: pre-wrap; 
}

/* Cocktail Gallery Styles */
.cocktail-gallery-section {
    margin-top: 40px;
    border-top: 2px dashed #8a5a2c;
    padding-top: 20px;
}

.save-button {
    background-color: #8a5a2c;
    margin: 15px 0;
}

.save-button:not(:disabled):hover {
    background-color: #9a6a3c;
}

.cocktail-gallery-item {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cocktail-gallery-item:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(138, 90, 44, 0.25);
}

.gallery-base-spirit {
    font-size: 0.8rem;
    color: #8a5a2c;
    margin-bottom: 5px;
}

.gallery-custom-ingredients {
    font-size: 0.75rem;
    color: #5a783a;
    font-style: italic;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Cocktail Detail Modal */
.cocktail-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cocktail-detail-modal.open {
    opacity: 1;
    visibility: visible;
}

.cocktail-detail-content {
    background-color: #fff;
    border-radius: 10px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 30px;
    background: none;
    border: none;
    cursor: pointer;
    color: #8a5a2c;
    padding: 0;
    width: 40px;
    height: 40px;
    line-height: 1;
    border-radius: 50%;
}

.close-modal:hover {
    background-color: rgba(138, 90, 44, 0.1);
}

.cocktail-detail-content h2 {
    color: #8a5a2c;
    margin-top: 0;
    grid-column: 1 / -1;
    text-align: center;
}

.cocktail-detail-image-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.cocktail-detail-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    border: 3px solid #8a5a2c;
    border-radius: 8px;
}

.cocktail-detail-info {
    display: flex;
    flex-direction: column;
}

.cocktail-ingredients {
    margin-top: 20px;
}

.cocktail-ingredients h3 {
    color: #8a5a2c;
    margin-bottom: 10px;
}

.cocktail-creator {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px dashed #deb887;
}

.creator-name {
    font-weight: bold;
    color: #5a783a;
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .cocktail-detail-content {
        grid-template-columns: 1fr;
        padding: 20px;
    }
}

/* Animation for save success */
@keyframes saveGlow {
    0% { box-shadow: 0 0 5px rgba(138, 90, 44, 0.6); }
    50% { box-shadow: 0 0 15px rgba(138, 90, 44, 0.6); }
    100% { box-shadow: 0 0 5px rgba(138, 90, 44, 0.6); }
}