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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: white;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.grid-cell {
    aspect-ratio: 1 / 1;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.grid-cell:hover {
    border-color: #999;
    background: #e8e8e8;
}

.grid-cell.has-image {
    border: none;
    background: none;
}

.grid-cell.has-image:hover::after {
    content: "Drag to move • Click to change";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    text-align: center;
    padding: 10px;
}

.grid-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.grid-cell.has-image {
    cursor: grab;
}

.grid-cell.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.grid-cell.drag-over {
    border: 2px solid #007bff;
    background: rgba(0, 123, 255, 0.1);
}

/* Download Section */
.download-section {
    margin-top: 20px;
    text-align: center;
}

/* Footer */
.footer {
    margin-top: 30px;
    padding-top: 20px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.footer a {
    color: #999;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
}

.footer a:hover {
    color: #666;
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
}

.modal-content h2 {
    margin-bottom: 10px;
    color: #333;
    font-size: 20px;
}

.crop-instructions {
    text-align: center;
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
}

.crop-container {
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 4px;
    padding: 20px;
}

#cropCanvas {
    width: 400px;
    height: 400px;
    max-width: 100%;
    cursor: move;
    border: 1px solid #ddd;
}

.zoom-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

#zoomSlider {
    flex: 1;
    max-width: 200px;
    height: 6px;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
}

#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

#zoomSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
}

.fill-control {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.crop-controls {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-zoom {
    background: #f8f9fa;
    color: #333;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 20px;
    border: 1px solid #ddd;
}

.btn-zoom:hover {
    background: #e9ecef;
    border-color: #999;
}

.btn-fill {
    background: #28a745;
    color: white;
    padding: 8px 24px;
}

.btn-fill:hover {
    background: #218838;
}

.btn-download {
    background: #007bff;
    color: white;
    padding: 12px 32px;
    font-size: 16px;
}

.btn-download:hover {
    background: #0056b3;
}

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

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

@media (max-width: 640px) {
    .container {
        max-width: 100%;
    }

    .modal-content {
        padding: 20px;
    }
}
