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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

header {
    text-align: center;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-shadow: 0 0 40px rgba(102, 126, 234, 0.3);
}

.subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Help Tooltip */
.help-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 35, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    z-index: 1000;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 100px rgba(102, 126, 234, 0.2);
    animation: fadeInScale 0.3s ease-out;
}

.help-tooltip.hidden {
    display: none;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.help-tooltip h3 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #667eea, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.help-tooltip ul {
    list-style: none;
    margin-bottom: 24px;
}

.help-tooltip li {
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.help-tooltip li:last-child {
    border-bottom: none;
}

.help-tooltip li strong {
    color: #a8d8ea;
}

.help-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.help-close:hover {
    color: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

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

/* Overlay for help tooltip */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

.help-overlay.hidden {
    display: none;
}

.canvas-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: visible;
}

#mainCanvas {
    display: block;
    background: #0d0d12;
    border-radius: 16px;
    cursor: none;
    touch-action: none;
}

/* Brush Cursor Preview */
.brush-cursor {
    position: absolute;
    pointer-events: none;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.15s ease, width 0.1s ease, height 0.1s ease;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.canvas-wrapper:hover .brush-cursor {
    opacity: 1;
}

.brush-cursor::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.canvas-glow {
    position: absolute;
    inset: -2px;
    border-radius: 18px;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #667eea);
    background-size: 300% 300%;
    animation: glowRotate 4s ease-in-out infinite;
    z-index: -1;
    opacity: 0.6;
}

@keyframes glowRotate {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* Progress Bar */
.progress-container {
    width: 100%;
    max-width: 600px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-top: -12px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 100%;
    animation: progressGradient 2s ease-in-out infinite;
    border-radius: 10px;
    transition: width 0.3s ease;
}

@keyframes progressGradient {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.progress-label {
    position: absolute;
    right: 0;
    top: 12px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

/* Color Presets */
.color-presets {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.preset-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.preset-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-preset {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-preset:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.color-preset.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 800px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 140px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-picker-wrapper {
    position: relative;
    width: 50px;
    height: 36px;
}

.color-picker-wrapper input[type="color"] {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s ease;
}

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

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.control-group span {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

.checkbox-group {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.checkbox-group:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
    font-size: 0.8rem;
}

.checkbox-group input[type="checkbox"] {
    accent-color: #764ba2;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.clear-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
}

.info-bar {
    display: flex;
    gap: 24px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-variant-numeric: tabular-nums;
    z-index: 10;
}

.morph-status {
    color: #4ecdc4;
    font-weight: 500;
}

.morph-status.morphing {
    color: #f093fb;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 2rem;
    }

    .controls {
        padding: 16px;
        gap: 16px;
    }

    .control-group {
        min-width: 100%;
    }

    .button-group {
        width: 100%;
        justify-content: center;
    }

    .color-presets {
        flex-direction: column;
        align-items: flex-start;
    }

    .preset-colors {
        justify-content: center;
    }

    .help-tooltip {
        padding: 24px;
        max-height: 80vh;
        overflow-y: auto;
    }

    .info-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .canvas-wrapper {
        max-width: 100%;
    }

    #mainCanvas {
        max-width: 100%;
        height: auto;
    }
}

/* Status indicators */
.morph-status.drawing {
    color: #fbbf24;
}

.morph-status.waiting {
    color: #60a5fa;
}

/* State buttons */
.state-buttons {
    display: flex;
    gap: 8px;
}

.state-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.state-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.state-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.morph-status.complete {
    color: #34d399;
}

/* Keyboard shortcut hints in help */
.help-tooltip h4 {
    font-weight: 500;
}

.help-tooltip li strong {
    display: inline-block;
    min-width: 50px;
}

/* Canvas active state glow */
.canvas-wrapper.drawing .canvas-glow {
    opacity: 0.9;
    animation: glowPulse 0.5s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.9;
    }

    50% {
        opacity: 0.7;
    }
}

/* Smooth transition for progress bar */
.progress-container {
    transition: opacity 0.3s ease;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .brush-cursor {
        display: none;
    }

    .color-preset:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }
}