body {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
}

.container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.template-grid {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scroll-behavior: smooth;
}

.template-grid::-webkit-scrollbar {
    height: 8px;
}

.template-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.template-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.template-grid::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.template-item {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s;
    flex: 0 0 150px; /* Fixed width, no shrinking */
    height: 150px;
}

.template-item:hover {
    border-color: #007bff;
}

.template-item.selected {
    border-color: #007bff;
    box-shadow: 0 0 10px rgba(0,123,255,0.3);
}

.template-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

.editor {
    display: none;
    margin-top: 30px;
}

.editor.active {
    display: block;
}

.text-inputs {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-weight: bold;
    color: #555;
}

input[type="text"], select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #007bff;
}

/* Payment drawer styles */
.payment-drawer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

.payment-drawer.open {
    max-height: 400px;
    border: 2px solid #007bff;
}

.payment-content {
    padding: 20px;
}

.payment-content h4 {
    margin: 0 0 10px 0;
    color: #007bff;
}

.cancel-btn {
    background: #6c757d;
    margin-left: 10px;
}

.cancel-btn:hover {
    background: #545b62;
}

/* Account creation modal styles */
.account-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.account-modal.show {
    display: flex;
}

.account-modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.account-modal h3 {
    color: #007bff;
    margin-bottom: 15px;
}

.account-modal p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.account-modal input {
    width: 100%;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.account-modal .button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.skip-btn {
    background: #6c757d;
    color: white;
}

.skip-btn:hover {
    background: #545b62;
}

#stripe-payment-element {
    margin: 15px 0;
}

#memeCanvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    max-width: 100%;
    display: block;
    margin: 20px auto;
}

.controls {
    text-align: center;
    gap: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

button:hover {
    background: #0056b3;
}

.download-btn {
    background: #28a745;
}

.download-btn:hover {
    background: #1e7e34;
}

.save-btn, .saved-btn {
    background: #6f42c1;
}

.save-btn:hover, .saved-btn:hover {
    background: #5a32a3;
}

/* Login button styles */
.login-section {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.login-section button {
    padding: 8px 16px;
    font-size: 14px;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.primary-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
    transition: all 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,123,255,0.4);
}

/* Recent Memes Section */
.recent-memes-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #f0f0f0;
}

.recent-memes-section h3 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
}

/* Meme Viewer */
.meme-viewer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.meme-display {
    position: relative;
    margin: 0 20px;
}

#recentMemeCanvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    max-width: 100%;
    display: block;
    transition: opacity 0.3s ease;
}

.meme-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 5px;
    display: none;
}

/* Navigation Arrows */
.nav-arrow {
    background: #007bff;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
}

.nav-arrow:hover {
    background: #0056b3;
    transform: scale(1.1);
}

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

.nav-arrow:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Action Buttons */
.meme-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.share-btn {
    background: #17a2b8;
}

.share-btn:hover {
    background: #138496;
}

.template-btn {
    background: #fd7e14;
}

.template-btn:hover {
    background: #e66a02;
}

/* Thumbnail Carousel */
.thumbnail-carousel {
    margin-top: 20px;
}

.thumbnail-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scroll-behavior: smooth;
}

.thumbnail-container::-webkit-scrollbar {
    height: 6px;
}

.thumbnail-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.thumbnail-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.thumbnail-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.thumbnail-item {
    flex: 0 0 120px;
    height: 120px;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.thumbnail-item:hover {
    border-color: #007bff;
    transform: translateY(-2px);
}

.thumbnail-item.active {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.thumbnail-item canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .template-item {
        flex: 0 0 120px;
        height: 120px;
    }
    
    .meme-viewer {
        margin: 0 -10px 20px -10px;
    }
    
    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .meme-display {
        margin: 0 10px;
    }
    
    #recentMemeCanvas {
        max-width: calc(100vw - 140px);
    }
    
    .meme-actions {
        gap: 10px;
    }
    
    .meme-actions button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .thumbnail-item {
        flex: 0 0 100px;
        height: 100px;
    }
}

/* Touch/Swipe Support */
.meme-display {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* Loading Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.meme-loading {
    animation: pulse 1.5s ease-in-out infinite;
}
