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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    color: #ff4444;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #888;
    font-size: 1rem;
}

.instructions {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #888;
    font-size: 0.9rem;
    line-height: 1.6;
}

.folder-upload {
    text-align: center;
    margin-bottom: 1.5rem;
}

.folder-btn {
    display: inline-block;
    background: #1a1a2e;
    border: 2px solid #ff4444;
    color: #ff6666;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.folder-btn:hover {
    background: #2a2a3e;
}

.folder-hint {
    color: #555;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.upload-card {
    background: #1a1a2e;
    border: 2px dashed #333;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    overflow: hidden;
}

.upload-card:hover {
    border-color: #ff4444;
    background: #1f1f35;
}

.upload-card.has-image {
    border-color: #44ff44;
    border-style: solid;
    cursor: grab;
}

.upload-card.dragging {
    opacity: 0.4;
}

.upload-card.touch-over {
    border-color: #ff8844 !important;
    background: #2a2a3e;
}

.touch-ghost {
    position: fixed;
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    opacity: 0.8;
    pointer-events: none;
    z-index: 9999;
}

.upload-card .number {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 68, 68, 0.8);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

.upload-card .label {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #ff6666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.upload-card .preview {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.upload-card .preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    object-fit: contain;
}

.upload-card .placeholder {
    color: #555;
    font-size: 0.85rem;
}

.upload-card .placeholder .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.25rem;
}

.upload-card .remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 50, 50, 0.9);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 1;
}

.upload-card .remove-btn:hover {
    background: rgba(255, 0, 0, 1);
}

.upload-card input[type="file"] {
    display: none;
}

.actions {
    text-align: center;
    margin-bottom: 2rem;
}

#generateBtn {
    background: #ff4444;
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#generateBtn:hover:not(:disabled) {
    background: #ff6666;
    transform: scale(1.02);
}

#generateBtn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.hint {
    color: #666;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.progress-section {
    text-align: center;
    margin-bottom: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #1a1a2e;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff8844);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#progressText {
    color: #aaa;
}

.result-section {
    text-align: center;
}

.result-section h2 {
    color: #44ff44;
    margin-bottom: 1rem;
}

.result-section video {
    width: 100%;
    max-width: 480px;
    border-radius: 12px;
    margin-bottom: 1rem;
    background: #000;
}

.download-options {
    margin-top: 1rem;
}

.download-label {
    color: #aaa;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.download-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.download-btn {
    display: inline-block;
    background: #44ff44;
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    transition: background 0.2s;
}

.download-btn:hover {
    background: #66ff66;
}

.download-btn.loading {
    pointer-events: none;
    opacity: 0.7;
    min-width: 140px;
}

.download-btn.loading::after {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #000;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

@media (max-width: 600px) {
    .upload-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        font-size: 1.5rem;
    }
}
