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

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: #333;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            touch-action: manipulation;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 10px;
        }

        header {
            text-align: center;
            margin-bottom: 20px;
            color: white;
        }

        header h1 {
            font-size: 2rem;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }

        header p {
            font-size: 1rem;
            opacity: 0.9;
        }

        .upload-section {
            background: white;
            border-radius: 15px;
            padding: 20px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            margin-bottom: 20px;
        }

        .btn {
            padding: 15px 25px;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            min-height: 44px; /* iOS touch target */
            min-width: 44px;
            display: inline-block;
            text-align: center;
        }

        .btn.primary {
            background: linear-gradient(45deg, #667eea, #764ba2);
            color: white;
        }

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

        .btn.secondary {
            background: #f8f9fa;
            color: #6c757d;
            border: 2px solid #dee2e6;
        }

        .btn.secondary:hover {
            background: #e9ecef;
            border-color: #adb5bd;
        }

        .btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .filename {
            margin-top: 15px;
            font-style: italic;
            color: #666;
        }

        .processing {
            background: white;
            border-radius: 15px;
            padding: 30px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            margin-bottom: 20px;
        }

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

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

        .image-container {
            background: white;
            border-radius: 15px;
            padding: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            margin-bottom: 20px;
        }

        #canvas {
            max-width: 100%;
            height: auto;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            display: block;
            margin: 0 auto 15px;
            touch-action: none;
        }

        .controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            align-items: end;
            margin-bottom: 15px;
        }

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

        .control-group label {
            font-weight: 600;
            color: #333;
            font-size: 0.9rem;
        }

        .control-group select {
            padding: 12px;
            border: 2px solid #dee2e6;
            border-radius: 6px;
            font-size: 1rem;
            background: white;
            min-height: 44px;
        }

        .range-container {
            position: relative;
        }

        .control-group input[type="range"] {
            -webkit-appearance: none;
            width: 100%;
            height: 44px;
            background: transparent;
            outline: none;
            padding: 0;
            margin: 0;
        }

        .control-group input[type="range"]::-webkit-slider-track {
            width: 100%;
            height: 8px;
            background: #dee2e6;
            border-radius: 4px;
        }

        .control-group input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 24px;
            height: 24px;
            background: #667eea;
            cursor: pointer;
            border-radius: 50%;
            margin-top: -8px;
        }

        .control-group input[type="range"]::-moz-range-track {
            width: 100%;
            height: 8px;
            background: #dee2e6;
            border-radius: 4px;
            border: none;
        }

        .control-group input[type="range"]::-moz-range-thumb {
            width: 24px;
            height: 24px;
            background: #667eea;
            cursor: pointer;
            border-radius: 50%;
            border: none;
            margin-top: -8px;
        }

        .range-value {
            font-weight: bold;
            color: #667eea;
            font-size: 0.9rem;
        }

        .button-group {
            display: flex;
            gap: 10px;
            grid-column: 1 / -1;
            justify-content: center;
            flex-wrap: wrap;
        }

        .mode-indicator {
            background: #e3f2fd;
            border: 2px solid #2196f3;
            border-radius: 8px;
            padding: 10px;
            margin: 10px 0;
            text-align: center;
            font-weight: bold;
            color: #1976d2;
        }

        .mode-indicator.active {
            background: #c8e6c9;
            border-color: #4caf50;
            color: #2e7d32;
        }

        .instructions {
            background: white;
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }

        .instructions h3 {
            margin-bottom: 15px;
            color: #333;
        }

        .instructions ul {
            list-style-position: inside;
            line-height: 1.6;
        }

        .instructions li {
            margin-bottom: 8px;
            color: #666;
        }

        .hidden {
            display: none !important;
        }

        .error-message {
            background: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
            padding: 15px;
            border-radius: 8px;
            margin: 10px 0;
        }

        /* Mobile-specific styles */
        @media (max-width: 768px) {
            .container {
                padding: 5px;
            }
            
            header h1 {
                font-size: 1.5rem;
            }
            
            .upload-section, .image-container, .instructions {
                padding: 15px;
                margin-bottom: 15px;
            }
            
            .controls {
                grid-template-columns: 1fr;
                gap: 12px;
            }
            
            .button-group {
                flex-direction: column;
                align-items: center;
            }

            .btn {
                width: 100%;
                max-width: 300px;
                margin: 5px 0;
            }
        }

        /* iOS Safari specific fixes */
        @supports (-webkit-touch-callout: none) {
            body {
                -webkit-overflow-scrolling: touch;
            }
            
            input[type="range"] {
                -webkit-appearance: none;
            }
        }