* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #a78bfa 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

p {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.upload-group {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 320px;
}

.upload-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

input[type="file"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #ddd;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

input[type="file"]:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

input[type="file"]::file-selector-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 1rem;
    transition: background 0.3s ease;
}

input[type="file"]::file-selector-button:hover {
    background: #5a6fd8;
}

.preview-container {
    margin-top: auto;
    text-align: center;
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.preview-container h3 {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

canvas {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.controls-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.controls {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.text-controls-section {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.control-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    gap: 0.4rem;
}

.control-group label {
    width: 100%;
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

input[type="range"] {
    flex-grow: 1;
    cursor: pointer;
    -webkit-appearance: none;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #5a6fd8;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #667eea;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #5a6fd8;
}

.number-input {
    width: 65px;
    padding: 0.4rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.3s ease;
    background: white;
}

.number-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

span {
    width: 65px;
    text-align: right;
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.9rem;
    background: #e9ecef;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

#apply-watermark {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid transparent;
}

#apply-watermark:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

#download-result {
    background: linear-gradient(135deg, #54ba4e 0%, #27ae60 100%);
    color: white;
}

#download-result:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.3);
}

#download-result:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#reset {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

#reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.3);
}

.watermark-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.option-group {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.option-group input[type="radio"] {
    margin-right: 0.5rem;
}

.option-group label {
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    margin: 0;
    font-size: 0.8rem;
}

.text-watermark-area {
    width: 100%;
}

.text-watermark-area input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    background: white;
}

.text-watermark-area input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.file-upload-area {
    width: 100%;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    background: #fafafa;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.file-upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-1px);
}

.file-upload-area.drag-over {
    border-color: #667eea;
    background: #eef2ff;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

.file-upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-area .upload-content {
    pointer-events: none;
}

.file-upload-area p {
    margin: 0 0 0.4rem 0;
    color: #495057;
    font-weight: 600;
    font-size: 0.85rem;
}

.file-upload-area span {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 500;
}

.instructions {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
}

.instructions h3 {
    margin-bottom: 0.75rem;
    color: #2c3e50;
    font-size: 1rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 0.5rem 0;
    color: #6c757d;
    border-bottom: 1px solid #f0f0f0;
}

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

.instructions strong {
    color: #2c3e50;
    font-weight: 700;
}

.instructions p {
    margin-bottom: 0.75rem;
    color: #495057;
    font-weight: 600;
    font-size: 0.9rem;
}

.instructions .note {
    font-size: 0.75rem;
    color: #6c757d;
    font-style: italic;
    margin-top: 0.4rem;
}

#text-controls {
    border-top: 1px solid #e9ecef;
    padding-top: 1rem;
}

#text-controls .control-row {
    margin-bottom: 1rem;
}

#text-controls .control-row:last-child {
    margin-bottom: 0;
}

#font-color {
    width: 50px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.result-container {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.result-container h3 {
    margin-bottom: 0.75rem;
    color: #2c3e50;
    font-size: 1rem;
}

#result-canvas {
    width: 100%;
    height: auto;
    max-width: 1000px;
    display: block;
    margin: 0 auto;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

#target-preview {
    width: 200px !important;
    height: 200px !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        margin: 5px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .upload-section, .controls-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .watermark-options {
        gap: 0.5rem;
    }
    
    .option-group {
        padding: 0.5rem;
    }
    
    .file-upload-area {
        padding: 0.75rem;
    }
    
    .file-upload-area p {
        font-size: 0.8rem;
    }
    
    .control-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .number-input {
        width: 100%;
    }
    
    span {
        width: 100%;
        text-align: center;
    }
    
    .actions {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    
    button {
        width: 100%;
        max-width: 250px;
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    .instructions {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .instructions li {
        font-size: 0.8rem;
    }
    
    .instructions h3 {
        font-size: 0.9rem;
    }
}
