:root {
    /* Light Theme (Default) */
    --primary-color: #5d4fff;
    --primary-dark: #4937e8;
    --secondary-color: #3ecf8e;
    --secondary-dark: #2fb67e;
    --text-color: #333333;
    --text-light: #6c7586;
    --bg-color: #f4f4f4;
    --card-bg: #ffffff;
    --input-bg: #f8f9fc;
    --border-color: #e4e9f2;
    --error-color: #ff5c75;
    --success-color: #2fb67e;
    --shadow-color: rgba(76, 85, 102, 0.1);
    --shadow-color-hover: rgba(76, 85, 102, 0.12);
    --shadow-color-button: rgba(93, 79, 255, 0.25);
    --input-hover-bg: rgba(93, 79, 255, 0.06);
    --input-focus-shadow: rgba(93, 79, 255, 0.15);
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --spinner-border: rgba(255, 255, 255, 0.3);
    --status-connected-bg: #d4edda;
    --status-connected-text: #155724;
    --status-error-bg: #f8d7da;
    --status-error-text: #721c24;
    --placeholder-text: #666;
    --button-disabled-bg: #bdc3c7;
}

body.dark-theme {
    /* Dark Theme Variables */
    --primary-color: #7a70ff;
    --primary-dark: #5d4fff;
    --secondary-color: #48e0a4;
    --secondary-dark: #3ecf8e;
    --text-color: #e0e0e0;
    --text-light: #a0a0a0;
    --bg-color: #1a1a1a;
    --card-bg: #2c2c2c;
    --input-bg: #3a3a3a;
    --border-color: #444444;
    --error-color: #ff7b8f;
    --success-color: #48e0a4;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-color-hover: rgba(0, 0, 0, 0.3);
    --shadow-color-button: rgba(122, 112, 255, 0.3);
    --input-hover-bg: rgba(122, 112, 255, 0.1);
    --input-focus-shadow: rgba(122, 112, 255, 0.2);
    --overlay-bg: rgba(0, 0, 0, 0.8);
    --spinner-border: rgba(255, 255, 255, 0.2);
    --status-connected-bg: #2a4a3a;
    --status-connected-text: #a3e9c2;
    --status-error-bg: #5a2c3a;
    --status-error-text: #f7b8c2;
    --placeholder-text: #888;
    --button-disabled-bg: #555;
}

/* Scroll Animation Section */
.scroll-section {
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    /* background: var(--bg-color); */ /* Removed background */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 1.6s ease-in-out; /* Restored transition */
}

.scroll-section.scrolled-away {
    transform: translateY(-100%);
}

.scroll-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
    height: 100vh;
}

/* Tattoo element with SVG fallback */
.tattoo-element {
    position: absolute;
    top: 50%;
    left: 30%;
    transform: translate(-100%, -50%) scale(1.67); /* Set initial large scale */
    width: 90px;  /* Reduced by 40% from 150px */
    height: 90px; /* Reduced by 40% from 150px */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url('images/tattoo.webp'); /* Added tattoo image */
    opacity: 1;
    transition: all 2.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Increased duration */
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Hand element with SVG fallback */
.hand-element {
    position: absolute;
    top: 50%;
    right: 20%;
    transform: translate(0%, -50%);
    width: 200px;
    height: 300px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url('images/hand.png'); /* Updated hand image to PNG */
    opacity: 1;
    transition: all 2.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Increased duration */
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* SVG content for fallbacks */
.tattoo-svg, .hand-svg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-indicator {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-color);
    font-size: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
    animation: bounce 2s infinite;
    text-align: center;
    font-weight: 500;
}

.scroll-indicator::after {
    content: '↓';
    font-size: 24px;
    margin-top: 5px;
}

/* Styles for the Continue Button */
.continue-button {
    position: absolute;
    bottom: 5vh; /* Position similar to scroll indicator */
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease; /* Only transition the background color */
    z-index: 15; /* Above indicator, below elements */
}

.continue-button:hover {
    background-color: var(--primary-dark);
    transform: translateX(-50%); /* Override the global button hover transform */
    box-shadow: 0 4px 12px var(--shadow-color-button); /* Keep the shadow effect */
}

/* Removed rules for .tattoo-applied as JS now handles visibility directly */

/* Animation classes */
/* Removed .scroll-active .tattoo-element rule as JS now handles transform */

/* Removed .elements-connected .tattoo-element rule as JS now handles transform */

/* Removed .elements-connected .hand-element rule as JS now handles transform */

/* Removed skip animation button styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Container styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    opacity: 0;
    /* Start positioned 100vh down, will transition up */
    transform: translateY(100vh);
    transition: opacity 0.6s ease, transform 1.0s ease; /* Slightly longer transform transition */
    /* margin-top: 100vh; */ /* Removed margin-top */
    background: var(--bg-color);
    position: relative;
    z-index: 5;
}

.container.visible {
    opacity: 1;
    transform: translateY(0); /* End position */
}

/* Animation keyframes */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) translateX(-50%);
    }
    40% {
        transform: translateY(-10px) translateX(-50%);
    }
    60% {
        transform: translateY(-5px) translateX(-50%);
    }
}

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Status Bar */
.status-bar {
    padding: 10px;
    margin-bottom: 20px;
    text-align: center;
    border-radius: 5px;
    font-weight: 500;
    transition: var(--transition);
}

.status-bar.connected {
    background: var(--status-connected-bg);
    color: var(--status-connected-text);
}

.status-bar.error {
    background: var(--status-error-bg);
    color: var(--status-error-text);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 48px;
    padding: 20px;
    animation: fadeIn 0.8s ease-out;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-light);
    font-size: 18px;
    max-width: 600px;
    margin: 0 auto;
}

/* Upload Section */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 36px;
    animation: slideUp 0.5s ease-out forwards;
}

.photo-upload, .prompt-section {
    background: var(--card-bg);
    padding: 28px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.photo-upload:hover, .prompt-section:hover {
    box-shadow: 0 4px 16px var(--shadow-color-hover);
    transform: translateY(-2px);
}

h3 {
    color: var(--text-color);
    margin-bottom: 15px;
}

/* File Upload */
input[type="file"] {
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--input-bg);
    color: var(--text-color);
}

input[type="file"]:hover {
    border-color: var(--primary-color);
    background: var(--input-hover-bg);
}

/* Style file input button text */
input[type="file"]::file-selector-button {
    padding: 8px 12px;
    margin-right: 10px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-dark);
}

.preview-box {
    width: 100%;
    height: 300px;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    transition: var(--transition);
    overflow: hidden;
    background-color: var(--input-bg);
}

.preview-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--placeholder-text);
    font-style: italic;
}

/* Form Elements */
textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
    font-size: 16px;
    transition: var(--transition);
    background: var(--input-bg);
    color: var(--text-color);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--input-focus-shadow);
}

/* Buttons */
button {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    letter-spacing: 0.3px;
}

button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color-button);
}

/* Exceptions for buttons that shouldn't move */
.continue-button:hover:not(:disabled),
.error-content button:hover:not(:disabled) {
    transform: translateX(-50%); /* For continue button */
}

button:disabled {
    background: var(--button-disabled-bg);
    cursor: not-allowed;
    opacity: 0.7;
}

#generateButton {
    width: 100%;
    background: var(--secondary-color);
    margin-top: 24px;
    font-size: 17px;
    height: 50px;
}

#generateButton:hover:not(:disabled) {
    background: var(--secondary-dark);
    box-shadow: 0 4px 12px rgba(62, 207, 142, 0.25);
}

body.dark-theme #generateButton:hover:not(:disabled) {
     box-shadow: 0 4px 12px rgba(72, 224, 164, 0.3);
}

/* Result Section */
.editor-section {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 16px var(--shadow-color-hover);
    margin-top: 36px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.6s ease-out;
}

.result-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.canvas-container {
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#previewCanvas {
    width: 100%;
    height: auto;
    display: block;
}

.result-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

/* Overlays */
.loading-overlay, .error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
    color: #fff;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--spinner-border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-overlay {
     background: rgba(40, 10, 10, 0.8);
}

.error-content {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 28px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    margin: 20px;
    animation: scaleIn 0.3s ease-out;
    border: 1px solid var(--error-color);
}

.error-content h3 {
    color: var(--error-color);
    margin-bottom: 15px;
}

.error-content button {
    margin-top: 20px;
    background-color: var(--error-color);
}

.error-content button:hover {
    background-color: #d63031;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .upload-section {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 16px;
    }

    header h1 {
        font-size: 32px;
    }

    .result-actions {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .editor-section {
        padding: 20px;
    }
}

/* General Variables */
:root {
    --border-radius: 10px;
    --transition: all 0.3s ease;
}