/* Base style reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-specific optimizations */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none;
}

/* Button font reset - Ensure all buttons inherit body font */
button {
    font-family: inherit;
    font-size: inherit;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: url('./source/Background.png') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    position: relative;
    /* Improve scrolling on mobile */
    -webkit-overflow-scrolling: touch;
}

/* Container for the entire page */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Logo in top-left corner */
.logo-container {
    position: fixed;
    top: 20px;
    left: 60px;
}

.logo-container a {
    display: block;
}

.logo-image {
    width: 100px;
    height: auto;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.logo-image:hover {
    opacity: 1;
}

/* Responsive logo adjustments */

/* Header section */

/* Header area */
.header {
    text-align: center;
    margin-top: 10px;
    animation: fadeInDown 0.8s ease-out;
}

.title {
    font-size: 40px;
    font-weight: 900;
    color: #1b1b1b;
    margin-bottom: 10px;
}

/* Selection area */
.selection-section {
    animation: fadeInDown 0.8s ease-out 0.2s both;
    margin-bottom: 30px;
}

.selection-header {
    text-align: center;
    margin-bottom: 30px;
}

.selection-header h2 {
    font-size: 24px;
    font-weight: 500;
    color: #928319;
}

.selection-header p {
    color: #7e714c;
    font-size: 18px;
    font-weight: 400;
}

/* Editing area */
.editing-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.editing-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 59, 0.1);
    border: 1px solid #ffd73b;
    color: #ffd73b;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.back-btn:hover {
    background: #ffd73b;
    color: white;
}

.editing-header h2 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

/* Input area (for editing mode) */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

#promptInput {
    width: 100%;
    min-height: 120px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

#promptInput:focus {
    outline: none;
    border-color: #ffd73b;
    box-shadow: 0 0 0 4px rgba(255, 215, 59, 0.1);
    transform: translateY(-2px);
}

/* Result area */
.result-section {
    min-height: 400px;
    position: relative;
    margin: 0px auto 30px;
}

/* Image result */
.image-result {
    animation: fadeInScale 0.6s ease-out;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    max-width: 1200px;
    margin: 2rem auto 0;
}

/* Left image area */
.image-section {
    flex: 0 0 55%;
}

.image-container {
    position: relative;
    width: 100%;
    background: transparent;
}

/* Right content area */
.content-section {
    flex: 1;
}

#generatedImage {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    max-height: 70vh;
    object-fit: contain;
    background: transparent;
}

.image-container:hover #generatedImage {
    transform: scale(1.02);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* background: linear-gradient(45deg, rgb(243, 229, 31, 0.8), rgb(255, 215, 59, 0.8)); */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 15px;
}

#generatedImage:hover+.image-overlay,
.image-overlay:hover {
    opacity: 1;
}

.overlay-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 25px;
    color: #333;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.overlay-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.image-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 24px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    height: fit-content;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.prompt-display {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.6;
    background: #f4f4f4;
    padding: 15px;
    border-radius: 10px;
    font-style: italic;
    margin-top: 0;
}

.twitter-copy-section {
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    padding: 20px 20px 10px;
}

.copy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.copy-header h4 {
    margin: 0;
    color: #383838;
    font-size: 24px;
    font-weight: 700;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.copy-btn {
    background: rgba(255, 215, 59, 0.1);
    border: 1px solid #ffd73b;
    color: #ffd73b;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    font-size: 12px;
}

.copy-btn:hover {
    background: #ffd73b;
    color: white;
    transform: translateY(-1px);
}

.twitter-btn {
    background: rgba(29, 161, 242, 0.1);
    border: 1px solid #1DA1F2;
    color: #1b1b1b;
}

.twitter-btn:hover {
    background: #1DA1F2;
    color: #1b1b1b;
    transform: translateY(-1px);
}

.timestamp-display {
    margin: 20px 5px 0px;
    font-size: 14px;
    color: #999;
}

/* Action Buttons Section */
.action-buttons-section {
    margin-top: 20px;
    padding: 0;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    width: 190px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-height: 50px;
    font-family: 'Nunito', sans-serif;
    text-align: center;
    justify-content: center;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.copy-action-btn {
    background: #ffd73b;
    color: #1b1b1b;
}

.copy-action-btn:hover {
    background: #ffd73b;
    color: #1b1b1b;
}

.twitter-action-btn {
    background: #1DA1F2;
    color: #1b1b1b;
}

.twitter-action-btn:hover {
    background: #1DA1F2;
    color: #1b1b1b;
}

/* Error state */
.error-state {
    text-align: center;
    padding: 30px 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    animation: shake 0.5s ease-in-out;
    width: 70%;
    margin: 0 auto;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 0px;
}

.error-title {
    color: rgb(231, 76, 60);
    font-size: 24px;
    margin-bottom: 10px;
}

.error-hint {
    color: #4d4d4d;
    font-size: 20px;
    margin-bottom: 40px;
    font-weight: 600;
    line-height: 1;
}

.error-message {
    color: #666;
    font-size: 14px;
    margin: 0 auto 0px;
    line-height: 1;
    text-align: left;
    background-color: rgb(231, 76, 60, 0.1);
    padding: 15px;
    border-radius: 15px;
    width: 90%;
}

.retry-btn {
    padding: 12px 30px;
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    border: none;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

/* Animation definitions */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Responsive design */

/* Medium screen adaptation */

/* Twitter share confirmation dialog styles - now using unified modal styles */
.twitter-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px auto;
    background: linear-gradient(135deg, #1da1f2 0%, #0d95e8 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

/* Twitter share fallback popup styles */
.twitter-fallback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.twitter-fallback-modal.show {
    opacity: 1;
    visibility: visible;
}

.twitter-fallback-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.twitter-fallback-modal .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.twitter-fallback-modal.show .modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.twitter-fallback-modal .modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px 0;
    margin-bottom: 16px;
}

.twitter-fallback-modal .warning-icon {
    font-size: 24px;
    color: #ff6b35;
}

.twitter-fallback-modal .modal-header h3 {
    font-size: 20px;
    color: #333;
    margin: 0;
    font-weight: 600;
}

.twitter-fallback-modal .modal-body {
    padding: 0 24px 20px;
}

.twitter-fallback-modal .reason-text {
    color: #666;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.twitter-fallback-modal .fallback-instruction {
    font-weight: 500;
    color: #333;
    margin-bottom: 20px;
    font-size: 16px;
}

.twitter-fallback-modal .fallback-options {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.twitter-fallback-modal .fallback-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    color: #333;
}

.twitter-fallback-modal .fallback-option:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: translateY(-2px);
}

.twitter-fallback-modal .fallback-option:active {
    transform: translateY(0);
}

.twitter-fallback-modal .option-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.twitter-fallback-modal .option-text {
    font-weight: 500;
    flex: 1;
}

.twitter-fallback-modal .manual-instructions {
    background: #f0f7ff;
    border-left: 4px solid #2196f3;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.twitter-fallback-modal .instruction-title {
    font-weight: 600;
    color: #1976d2;
    margin-bottom: 12px;
    font-size: 14px;
}

.twitter-fallback-modal .instruction-list {
    color: #555;
    font-size: 13px;
    line-height: 1.6;
    margin-left: 16px;
}

.twitter-fallback-modal .instruction-list li {
    margin-bottom: 4px;
}

.twitter-fallback-modal .modal-footer {
    padding: 0 24px 24px;
    text-align: right;
}

.twitter-fallback-modal .btn-close {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.twitter-fallback-modal .btn-close:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Mobile adaptation */

/* Kindness Story Selection Styles */
.progress-indicator {
    text-align: center;
    margin-bottom: 30px;
}

.progress-indicator span {
    background: rgba(255, 215, 59, 0.2);
    color: rgba(126, 113, 76, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 2rem;
}

.dimension-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px 20px 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.dimension-title {
    font-size: 20px;
    font-weight: 700;
    color: #2b2b2b;
    margin-bottom: 15px;
    text-align: center;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.option-card {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-height: 44px;
    /* Minimum touch target for mobile */
    justify-content: center;
}

.option-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: #f3e51f;
}

.option-card:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.option-card.selected {
    background: linear-gradient(0deg, #ebffd1, #ffe788);
    color: #1b1b1b;
    border: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(243, 229, 27, 0.3);
}

.option-emoji {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

.option-name {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
}

.generate-section {
    text-align: center;
    margin-bottom: 10px;
}

.generate-story-btn {
    background: linear-gradient(45deg, #f3e51f, #ffd73b);
    width: 280px;
    height: 52px;
    color: #1b1b1b;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;

    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;

    cursor: pointer;
}

.generate-story-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.generate-story-btn:active:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.generate-story-btn:disabled {
    background: rgba(255, 215, 59, 0.6);
    color: rgba(0, 0, 0, 0.6);
    cursor: not-allowed;
    box-shadow: none;
}

.generate-story-btn.loading {
    opacity: 0.9;
    cursor: not-allowed;
    /* min-height: 54px; Keep same height as normal state */
    justify-content: center;
}

/* Responsive Design for Selection */

/* Progress Indicator States */
.progress-indicator.pending {
    background: rgba(255, 215, 59, 0.6);
    color: #1b1b1b;
}

/* Button States */
.success {
    background: #4CAF50 !important;
    border-color: #4CAF50 !important;
    color: white !important;
}

.twitter-success {
    background: #1DA1F2 !important;
    border-color: #1DA1F2 !important;
    color: white !important;
}

.button-pressed {
    transform: scale(0.95);
    transition: transform 0.15s ease;
}

/* Layout States */
.hidden {
    display: none !important;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.toast.show {
    opacity: 1;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Mobile image preview modal */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-preview-modal.show {
    opacity: 1;
    visibility: visible;
}

.image-preview-modal .preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.image-preview-modal .preview-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.image-preview-modal .preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(45deg, rgb(243, 229, 31), rgb(255, 215, 59));
    color: white;
    flex-shrink: 0;
}

.image-preview-modal .preview-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.image-preview-modal .preview-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    font-weight: 300;
}

.image-preview-modal .preview-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-preview-modal .preview-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px 25px;
    text-align: center;
    min-height: 0;
}

.image-preview-modal .preview-image {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    object-fit: contain;
}

.image-preview-modal .preview-instruction {
    color: #555;
    font-size: 1.1rem;
    margin: 0;
    padding: 20px 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: none;
    line-height: 1.5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 20px;
    color: #584e33;
    font-size: 14px;
    font-weight: 400;
}

.footer .disclaimer {
    margin: 10px auto 10px;
    font-size: 12px;
    color: #584e33;
    line-height: 1.4;
}

/* Button loading animation */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    animation: bounce-dots 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes bounce-dots {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Generic Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 20px;
    padding: 0;
    max-width: 380px;
    width: 90%;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header h3 {
    margin: 0;
    padding: 24px 24px 0 24px;
    color: #1d1d1f;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.modal-body {
    padding: 16px 24px;
}

.modal-body input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 17px;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.modal-body input:focus {
    border-color: #ffd73b;
    box-shadow: 0 0 0 3px rgba(255, 215, 59, 0.2);
    background: rgba(255, 255, 255, 1);
}

.modal-body p {
    margin: 0;
    color: #86868b;
    font-size: 15px;
    text-align: center;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.modal-footer {
    padding: 0 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    flex: 1;
    padding: 12px 0;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.01em;
}

.modal-btn.cancel {
    background: rgba(255, 215, 59, 0.1);
    color: #1d1d1f;
    border: 1px solid rgba(255, 215, 59, 0.2);
}

.modal-btn.cancel:hover {
    background: rgba(255, 215, 59, 0.2);
}

.modal-btn.confirm {
    background: #ffd73b;
    color: #1d1d1f;
    border: 1px solid #ffd73b;
}

.modal-btn.confirm:hover {
    background: #e6c02a;
    border-color: #e6c02a;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Regenerate Modal specific styles */
#regenerateModal .modal-body p {
    margin: 0;
    color: #86868b;
    font-size: 15px;
    text-align: center;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

/* Image Loading Indicator */
.image-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
}

.image-loading-indicator .loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-loading-indicator .loading-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffd73b;
    animation: loadingDot 1.4s ease-in-out infinite both;
}

.image-loading-indicator .loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.image-loading-indicator .loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDot {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Content Loading Indicator */
.content-loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    margin: 10px 0;
}

.content-loading-indicator .loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.content-loading-indicator .loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffd73b;
    animation: loadingDot 1.4s ease-in-out infinite both;
}

.content-loading-indicator .loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.content-loading-indicator .loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Responsive Media Queries */

/* Medium desktop screens */
@media (max-width: 992px) {
    .logo-container {
        left: 30px;
    }

    .logo-image {
        width: 70px;
    }

    .logo-container a {
        width: 70px;
        height: 70px;
    }
}

/* Tablet screens */
@media (max-width: 768px) {

    /* Image result layout */
    .image-result {
        flex-direction: column;
        gap: 1rem;
    }

    .image-section {
        max-width: 90%;
        margin: 0 auto;
        flex: none;
    }

    .content-section {
        flex: none;
    }

    #generatedImage {
        max-height: 70vh;
    }

    /* Container and logo */
    .container {
        padding: 15px;
    }

    .logo-container {
        margin: 10px 0 0 10px;
        left: 10px;
    }

    .logo-image {
        width: 50px;
    }

    /* Title and headers */
    .title {
        font-size: 30px;
        margin-top: 15px;
    }

    .selection-header h2 {
        font-size: 22px;
    }

    /* Progress indicator */
    .progress-indicator span {
        word-wrap: break-word;
        white-space: normal;
        line-height: 1.3;
        font-size: 0.9rem;
        /* Slightly smaller font for tablet screens */
    }

    /* Form sections */
    .editing-section,
    .input-section {
        padding: 20px;
    }

    #promptInput {
        min-height: 100px;
        padding: 15px;
        font-size: 14px;
    }

    .examples-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .overlay-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Dimensions grid */
    .dimensions-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .dimension-section {
        padding: 15px;
        width: 90%;
        margin: 0 auto;
    }

    .option-card {
        padding: 12px 8px;
        font-size: 0.8rem;
        min-height: 48px;
        /* Larger touch target on mobile */
        gap: 6px;
    }

    .option-emoji {
        font-size: 1.2rem;
    }

    .generate-section {
        text-align: center;

        position: fixed;
        bottom: 60px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
    }

    .generate-story-btn {
        width: 220px;
        height: 48px;
        font-size: 1rem;
    }

    /* Twitter modal */
    .twitter-fallback-modal .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 0 auto;
    }

    .twitter-fallback-modal .modal-header,
    .twitter-fallback-modal .modal-body,
    .twitter-fallback-modal .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .twitter-fallback-modal .fallback-options {
        gap: 8px;
    }

    .twitter-fallback-modal .fallback-option {
        padding: 12px;
        font-size: 14px;
    }

    .twitter-fallback-modal .manual-instructions {
        padding: 12px;
        margin-bottom: 16px;
    }

    /* Image preview modal */
    .image-preview-modal {
        display: none;
        position: fixed;
        z-index: 1000;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .image-preview-modal.show {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .image-preview-modal .preview-overlay {
        display: none;
    }

    .image-preview-modal .preview-content {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(40px);
        -webkit-backdrop-filter: blur(40px);
        border-radius: 20px;
        padding: 0;
        max-width: 380px;
        width: 90%;
        max-height: 80vh;
        overflow-y: auto;
        box-shadow:
            0 20px 40px rgba(0, 0, 0, 0.15),
            0 8px 16px rgba(0, 0, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.3);
        animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        transform: scale(0.95);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;
        top: auto;
        left: auto;
        width: 90%;
        height: auto;
        flex-direction: column;
    }

    .image-preview-modal.show .preview-content {
        transform: scale(1);
    }

    .image-preview-modal .preview-header {
        padding: 24px 24px 0 24px;
        background: none;
        color: #1d1d1f;
        flex-shrink: 0;
        border-radius: 20px 20px 0 0;
    }

    .image-preview-modal .preview-header h3 {
        margin: 0;
        font-size: 20px;
        font-weight: 600;
        text-align: center;
        line-height: 1.3;
        letter-spacing: -0.02em;
        color: #1d1d1f;
    }

    .image-preview-modal .preview-close {
        position: absolute;
        top: 16px;
        right: 16px;
        background: rgba(255, 215, 59, 0.1);
        border: 1px solid rgba(255, 215, 59, 0.2);
        color: #1d1d1d;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 8px;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        font-weight: 300;
    }

    .image-preview-modal .preview-close:hover {
        background: rgba(255, 215, 59, 0.2);
    }

    .image-preview-modal .preview-body {
        padding: 16px 24px 24px;
        justify-content: center;
        flex: none;
        text-align: center;
    }

    .image-preview-modal .preview-image {
        max-height: 40vh;
        max-width: 100%;
        margin-bottom: 16px;
        border-radius: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        -webkit-touch-callout: default;
        /* Allow long-press menu for image download */
    }

    .image-preview-modal .preview-instruction {
        font-size: 15px;
        padding: 16px;
        border-radius: 12px;
        background: rgba(255, 215, 59, 0.05);
        border: 1px solid rgba(255, 215, 59, 0.1);
        margin: 0;
        line-height: 1.4;
        color: #86868b;
    }

    .twitter-copy-section {
        width: 90%;
        margin: 0 auto 15px;
        padding: 15px;
    }

    .action-buttons-section {
        padding: 0;
        gap: 12px;
    }

    .action-btn {
        width: 150px;
        gap: 5px;
        font-size: 13px;
    }

    .footer {
        max-width: 70%;
        margin: 0 auto;
        margin-top: 30px;
        font-size: 13px;
    }

    .footer .disclaimer {
        text-align: justify;
    }
}

/* Medium screens */
@media (max-width: 600px) {
    .logo-container {
        top: 8px;
        left: 8px;
    }

    .logo-image {
        width: 45px;
    }

    .title {
        font-size: 24px;
        margin-top: 0px;
    }

    .selection-header h2 {
        font-size: 18px;
    }
}

/* Phone screens */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .logo-container {
        top: 8px;
        left: 4px;
    }

    .logo-image {
        width: 40px;
    }

    .title {
        font-size: 20px;
        line-height: 1.2;
    }

    .selection-header {
        margin-bottom: 15px;
    }

    .selection-header h2 {
        font-size: 14px;
    }

    .selection-header p {
        font-size: 14px;
    }

    .option-card {
        padding: 10px 6px;
        font-size: 0.75rem;
        min-height: 44px;
    }

    .option-emoji {
        font-size: 1.1rem;
    }

    /* Enhanced touch feedback for mobile */
    .option-card:active {
        transform: translateY(1px);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
        background: rgba(255, 255, 255, 0.9);
    }

    .generate-story-btn:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    }

    /* Improve input experience on mobile */
    input,
    textarea,
    select {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 0;
        border-radius: 0;
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Better button spacing on mobile */
    button {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .progress-indicator {
        font-size: 0.85rem;
        padding: 8px 12px;
        margin-bottom: 20px;
    }

    .progress-indicator span {
        word-wrap: break-word;
        white-space: normal;
        line-height: 1.3;
        font-size: 0.8rem;
        /* Smaller font for mobile to fit full text */
    }

    .image-preview-modal .preview-content {
        width: 95%;
        max-width: 350px;
        max-height: 80vh;
    }

    .image-preview-modal .preview-header {
        padding: 16px 16px;
    }

    .image-preview-modal .preview-header h3 {
        font-size: 1.1rem;
    }

    .image-preview-modal .preview-close {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .image-preview-modal .preview-body {
        padding: 20px 16px 25px;
    }

    .image-preview-modal .preview-image {
        max-height: 45vh;
        border-radius: 10px;
        margin-bottom: 16px;
    }

    .image-preview-modal .preview-instruction {
        font-size: 0.9rem;
        padding: 16px 14px;
        line-height: 1.35;
    }

    .action-buttons-section {
        padding: 0;
        gap: 10px;
    }

    .action-btn {
        font-size: 13px;
    }
}