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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1em;
}

.upload-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.upload-box {
    position: relative;
    border: 3px dashed #ccc;
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
}

.upload-box:hover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.upload-box.has-image {
    border-style: solid;
    border-color: #667eea;
    padding: 10px;
}

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

.upload-content svg {
    color: #667eea;
    margin-bottom: 15px;
}

.upload-content h3 {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 5px;
}

.upload-content p {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.file-info {
    display: block;
    font-size: 0.85em;
    color: #999;
    margin-top: 10px;
}

.preview-image {
    display: none;
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.preview-image.show {
    display: block;
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: #ff4757;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.remove-btn:hover {
    background: #ff3838;
    transform: scale(1.1);
}

.remove-btn.show {
    display: flex;
}

.controls-section {
    margin-bottom: 40px;
}

.control-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dropdown {
    position: relative;
}

.dropdown-btn {
    width: 100%;
    padding: 15px 20px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
}

.dropdown-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.dropdown-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.dropdown-btn.active svg {
    transform: rotate(180deg);
}

.dropdown-btn svg {
    transition: transform 0.3s ease;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-radius: 10px;
    margin-top: 5px;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #667eea;
    color: white;
}

.dropdown-item.selected {
    background: #f0f0ff;
    color: #667eea;
    font-weight: 600;
}

.name-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
}

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

.custom-size-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    margin-top: 20px;
}

#customKBInputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    margin-top: 20px;
}

#customKBInputs input[type="number"] {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.custom-size-inputs input[type="number"] {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.custom-size-inputs label {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95em;
    color: #666;
}

.custom-size-inputs input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.comparison-section {
    margin-bottom: 40px;
    padding: 30px;
    background: #f8f9ff;
    border-radius: 15px;
}

.comparison-section h2 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
}

.comparison-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.stat-card.highlight {
    border: 2px solid #667eea;
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
}

.stat-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.stat-card p {
    color: #555;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.difference {
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 10px;
    display: inline-block;
}

.difference.positive {
    background: #d4edda;
    color: #155724;
}

.difference.negative {
    background: #f8d7da;
    color: #721c24;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 35px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-convert {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-convert:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-download {
    background: #2ecc71;
    color: white;
}

.btn-download:hover:not(:disabled) {
    background: #27ae60;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(46, 204, 113, 0.4);
}

.btn-reset {
    background: #e74c3c;
    color: white;
}

.btn-reset:hover {
    background: #c0392b;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(231, 76, 60, 0.4);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.merge-preview {
    margin-top: 40px;
    padding: 30px;
    background: #f8f9ff;
    border-radius: 15px;
    text-align: center;
}

.merge-preview h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.merge-preview canvas {
    display: block;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .upload-section {
        grid-template-columns: 1fr;
    }

    .control-group {
        grid-template-columns: 1fr;
    }

    .custom-size-inputs {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}