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

:root {
    --primary-color: #6c5ce7;
    --primary-hover: #5b4cdb;
    --secondary-color: #a29bfe;
    --accent-color: #fd79a8;
    --bg-color: #0f0f1a;
    --surface-color: #1a1a2e;
    --surface-hover: #252540;
    --text-color: #ffffff;
    --text-muted: #a0a0b0;
    --border-color: #2d2d44;
    --success-color: #00b894;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --border-radius: 12px;
}

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

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--bg-color) 100%);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

main {
    flex: 1;
    display: flex;
    padding: 1.5rem;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.controls-panel {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group > label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input[type="range"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

select:hover, select:focus {
    border-color: var(--primary-color);
    outline: none;
}

select option {
    background: var(--surface-color);
    color: var(--text-color);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    padding: 0;
    border-radius: 4px;
    background: var(--bg-color);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--text-color);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--text-color);
}

.value-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

.color-inputs {
    display: flex;
    gap: 0.75rem;
}

.color-input {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.color-input label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 2px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    flex: 1;
    min-width: calc(33% - 0.5rem);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.animation-controls, .download-controls {
    display: flex;
    gap: 0.5rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: var(--text-color);
}

.btn-success:hover {
    background: #00a381;
    transform: translateY(-2px);
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    min-height: 400px;
}

#illusion-canvas {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    border-radius: 8px;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.canvas-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.canvas-overlay span {
    font-size: 1.5rem;
    color: var(--text-color);
    background: var(--primary-color);
    padding: 1rem 2rem;
    border-radius: 8px;
}

footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Mobile Responsive Design */
@media (max-width: 900px) {
    main {
        flex-direction: column;
        padding: 1rem;
    }

    .controls-panel {
        width: 100%;
        max-height: none;
        order: 2;
    }

    .canvas-container {
        order: 1;
        min-height: 300px;
    }

    #illusion-canvas {
        max-height: 50vh;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .color-inputs {
        flex-wrap: wrap;
    }

    .color-input {
        min-width: calc(33% - 0.5rem);
    }
}

@media (max-width: 500px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header .subtitle {
        font-size: 0.9rem;
    }

    .controls-panel {
        padding: 1rem;
    }

    .preset-btn {
        min-width: calc(50% - 0.25rem);
    }

    .btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    footer p {
        font-size: 0.8rem;
    }
}

/* Animation for interactive elements */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.btn:active {
    transform: scale(0.98);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for keyboard navigation */
button:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
