* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
}

.upload-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    width: 100%;
    padding-top: 20px;
}

.logo-icon {
    width: 100%;
    height: auto;
    max-width: 200px;
    object-fit: contain;
}

.logo-text {
    font-size: 2.2em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
}

.page-title {
    text-align: left;
    color: #333;
    margin-bottom: 15px;
    font-size: 2.5em;
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    text-align: left;
    color: #333;
    margin-bottom: 15px;
    font-size: 2.5em;
    font-weight: 700;
    line-height: 1.2;
}

.version-badge {
    font-size: 0.4em;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: normal;
    vertical-align: middle;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.sub-headline {
    text-align: left;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.2em;
    line-height: 1.6;
}

.upload-instruction {
    text-align: center;
    color: #666;
    margin: 30px 0 20px;
    font-size: 1em;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
    align-items: center;
}

.text-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.image-column {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-image {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.why-choose-section {
    margin-top: 60px;
    padding: 40px 0;
    width: 100%;
}

.why-choose-section h2 {
    text-align: center;
    color: #333;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 40px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.feature-item {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.feature-item svg {
    width: 32px;
    height: 32px;
    stroke: #667eea;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.feature-item:hover svg {
    transform: scale(1.1);
}

.feature-item h3 {
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 10px;
}

.feature-item p {
    color: #666;
    font-size: 1em;
    line-height: 1.6;
}

.feature-item strong {
    color: #667eea;
    font-weight: 600;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-content svg {
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.upload-content p {
    color: #666;
    margin: 10px 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-block;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.preview-container {
    margin-top: 30px;
    text-align: center;
}

.preview-container h3 {
    color: #333;
    margin-bottom: 20px;
}

#previewImage {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.preview-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.image-stats {
    background: #f8f9ff;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    text-align: left;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.stat-value {
    font-size: 1em;
    color: #333;
    font-weight: 600;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #fcc;
}

/* Editor Page Styles */
.editor-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    margin: 20px auto;
}

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

.editor-header .logo-container {
    margin-bottom: 15px;
}

.editor-header .page-title {
    margin-bottom: 10px;
}

.editor-header h1 {
    margin-bottom: 10px;
}

.editor-header .image-stats {
    margin-top: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.editor-main .image-stats {
    margin: 0;
    margin-top: 20px;
}

.editor-main {
    display: grid;
    grid-template-columns: 1fr 1fr 300px;
    gap: 30px;
}

.canvas-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lithophane-preview-container {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    max-height: 80vh;
    overflow: hidden;
    position: relative;
}

.preview-image-wrapper {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.lithophane-preview-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border: 20px solid #2C2C2C;
    border-radius: 4px;
    box-sizing: border-box;
    box-shadow: 
        /* Outer shadow for depth */
        0 10px 40px rgba(0, 0, 0, 0.3),
        /* Top-left highlight for 3D bevel */
        inset -10px -10px 20px rgba(255, 255, 255, 0.1),
        /* Bottom-right shadow for 3D bevel */
        inset 10px 10px 20px rgba(0, 0, 0, 0.5),
        /* Inner shadow for frame depth */
        inset 0 0 10px rgba(0, 0, 0, 0.3);
    transform: rotateY(25deg) rotateX(2deg) scale(0.85);
    transition: transform 0.3s ease;
    object-fit: contain;
    position: relative;
}

.canvas-container {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    max-height: 80vh;
    overflow: hidden;
    position: relative;
}

#editorCanvas {
    touch-action: none; /* Prevent default touch behaviors like scrolling/zooming */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: white;
    display: block;
}

.toolbar {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 20px;
}

.toolbar h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.tool-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.tool-group:last-child {
    border-bottom: none;
}

.tool-group h3 {
    color: #555;
    font-size: 1em;
    margin-bottom: 15px;
    font-weight: 600;
}

.tool-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-row label {
    color: #666;
    font-size: 0.9em;
    white-space: nowrap;
}

.control-row input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

/* Range slider track */
.control-row input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    transition: background 0.2s;
}

.control-row input[type="range"]::-moz-range-track {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    transition: background 0.2s;
}

.control-row input[type="range"]:hover::-webkit-slider-runnable-track {
    background: #d0d0d0;
}

.control-row input[type="range"]:hover::-moz-range-track {
    background: #d0d0d0;
}

/* Range slider thumb */
.control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: grab;
    margin-top: -8px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.control-row input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: grab;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.control-row input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.control-row input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.control-row input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.15);
}

.control-row input[type="range"]:active::-moz-range-thumb {
    cursor: grabbing;
    transform: scale(1.15);
}

.control-row input[type="number"] {
    width: 60px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex-shrink: 0;
}

.aspect-ratio-select,
.control-row select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 0.9em;
    cursor: pointer;
    transition: border-color 0.2s;
}

.aspect-ratio-select:hover,
.control-row select:hover {
    border-color: #667eea;
}

.aspect-ratio-select:focus,
.control-row select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-tool {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 80px;
}

.btn-tool:hover {
    background: #667eea;
    color: white;
}

.btn-tool:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-generate {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 12px;
    font-size: 1.3em;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.4);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Ad Popup Modal Styles */
.ad-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.ad-popup-overlay.active {
    display: flex;
}

.ad-popup-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.ad-popup-header {
    padding: 30px;
    border-bottom: 2px solid #f0f0f0;
    text-align: center;
}

.ad-popup-header h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.8em;
}

.ad-popup-spinner {
    display: flex;
    justify-content: center;
}

.ad-popup-spinner .spinner {
    margin: 0;
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.ad-popup-body {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.ad-content {
    flex: 1;
}

.fake-ad {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 25px;
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.ad-banner {
    text-align: center;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
    margin-bottom: 15px;
}

.ad-content-inner h3 {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    color: white;
}

.ad-content-inner p {
    margin: 0 0 20px 0;
    opacity: 0.95;
    line-height: 1.6;
}

.ad-features {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.ad-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 120px;
}

.ad-icon {
    font-size: 1.5em;
}

.ad-cta-button {
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.ad-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ad-cta-button:active {
    transform: translateY(0);
}

.ad-popup-status {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.ad-popup-status p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
}

@media (max-width: 768px) {
    .ad-popup-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .ad-popup-header,
    .ad-popup-body {
        padding: 20px;
    }
    
    .ad-features {
        flex-direction: column;
        gap: 15px;
    }
    
    .ad-feature {
        min-width: 100%;
    }
}

.app-footer {
    text-align: center;
    padding: 15px;
    margin-top: 40px;
    color: #666;
    font-size: 0.85em;
    width: 100%;
    max-width: 1200px;
    opacity: 0.8;
}

.app-footer p {
    margin: 0;
    color: #666;
}

@media (max-width: 768px) {
    .editor-main {
        grid-template-columns: 1fr;
    }
    
    .toolbar {
        order: -1;
    }
    
    .logo-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .logo-icon {
        width: 100%;
        height: auto;
        max-width: 150px;
        object-fit: contain;
    }
    
    .logo-text {
        font-size: 1.8em;
    }
    
    .page-title {
        font-size: 1.8em;
        text-align: center;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }
    
    .text-column {
        text-align: center;
    }
    
    .sub-headline {
        text-align: center;
        font-size: 1.1em;
    }
    
    .hero-image {
        max-width: 100%;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .upload-card {
        padding: 30px 20px;
    }
    
    .lithophane-preview-container {
        order: -2;
        min-height: 300px;
        max-height: 50vh;
    }
    
    .lithophane-preview-image {
        border-width: 15px;
        transform: rotateY(10deg) rotateX(3deg) scale(0.85);
        box-shadow: 
            0 8px 30px rgba(0, 0, 0, 0.3),
            inset -8px -8px 15px rgba(255, 255, 255, 0.1),
            inset 8px 8px 15px rgba(0, 0, 0, 0.5),
            inset 0 0 8px rgba(0, 0, 0, 0.3);
    }
}

