*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #FFFBE6 0%, #FFF0C2 40%, #FFE39A 100%);
    padding: 24px;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    background: #FFFDF5;
    border-radius: 18px;
    padding: 32px 24px 32px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
    border: 2px solid #F6C301;
}

h1 {
    text-align: center;
    margin: 0 0 24px;
    font-size: 28px;
    color: #1A1A1A;
    font-weight: 800;
}

h2 {
    margin: 16px 0;
    font-size: 22px;
    color: #333019;
    font-weight: 700;
}

h3 {
    margin: 16px 0 8px;
    font-size: 18px;
    color: #4A3B1F;
    font-weight: 600;
}

.step {
    margin-top: 16px;
}

.step-hidden {
    display: none;
}

.step-help {
    margin: 0 0 16px;
    color: #4a5568;
}

/* Product cards */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    background: #FFFBEA;
    border-radius: 14px;
    border: 2px solid #F6C301;
    cursor: pointer;
    transition: 0.2s box-shadow, 0.2s border-color, 0.2s transform, 0.2s background-color;
    text-align: center;
}

.product-card:hover {
    box-shadow: 0 10px 24px rgba(246, 195, 1, 0.35);
    border-color: #DCA601;
    background-color: #FFF1C2;
    transform: translateY(-2px);
}

.product-shape {
    width: 70px;
    height: 70px;
    margin-bottom: 12px;
    border: 3px solid #1A1A1A;
    background: #FFFDF5;
}

.product-card input[type="radio"] {
    margin-top: 8px;
}

.product-shape-round {
    border-radius: 50%;
}

.product-shape-square {
    border-radius: 10px;
}

.product-shape-softtoy {
    border-radius: 18px;
    position: relative;
    background: linear-gradient(
        135deg,
        #FFFDF5 0%,
        #FFF1C2 50%,
        #FFE39A 100%
    );
}

.product-shape-softtoy::before,
.product-shape-softtoy::after {
    content: "";
    position: absolute;
    top: -14px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #4a5568;
    background: #fff;
}

.product-shape-softtoy::before {
    left: 6px;
}

.product-shape-softtoy::after {
    right: 6px;
}

.product-shape-shirt {
    border-radius: 10px;
    position: relative;
}

.product-shape-shirt::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 12px;
    right: 12px;
    height: 20px;
    border-radius: 12px;
    border: 2px solid #1A1A1A;
    background: repeating-linear-gradient(
        90deg,
        #F6C301,
        #F6C301 8px,
        #1A1A1A 8px,
        #1A1A1A 12px
    );
}

.product-shape-plate {
    border-radius: 50%;
    box-shadow: inset 0 0 0 6px #FFE39A;
    background: radial-gradient(circle, #FFFDF5 0%, #FFF1C2 70%, #FFE39A 100%);
}

.product-shape-slate {
    border-radius: 6px;
}

.product-title {
    font-size: 14px;
    font-weight: 700;
    color: #3B3018;
}

/* Step 2 count grid */

.count-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    gap: 8px;
    margin-top: 8px;
    max-width: 320px;
}

.count-btn {
    border-radius: 8px;
    border: 1px solid #cbd5e0;
    background: #f7fafc;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    cursor: pointer;
    transition: 0.2s background-color, 0.2s border-color, 0.2s transform, 0.2s box-shadow;
}

.count-btn:hover {
    background: #edf2ff;
    border-color: #667eea;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.count-btn.active {
    background: #667eea;
    border-color: #4c51bf;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

/* Fields */

.field {
    margin: 12px 0;
}

.field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #2d3748;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #E2BF5F;
    font-size: 14px;
    background: #FFFDF8;
}

.field input:focus {
    outline: none;
    border-color: #F6C301;
    box-shadow: 0 0 0 2px rgba(246, 195, 1, 0.25);
}

/* Upload list */

.upload-row {
    border-radius: 12px;
    border: 1px solid #F6D46E;
    padding: 10px 10px 12px;
    margin-bottom: 8px;
    background: #FFFBEA;
}

.upload-row-header {
    font-weight: 600;
    margin-bottom: 6px;
    color: #2d3748;
}

.upload-row-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.upload-row-body input[type="file"] {
    max-width: 260px;
}

.upload-status {
    font-size: 13px;
    color: #4a5568;
}

/* Crop area */

.crop-area {
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #F6D46E;
    background: #FFF7D6;
}

/* Fixed viewport for image + overlay */
.crop-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    overflow: hidden;
    background: #1A1A1A;
    min-height: 820px; /* enough for largest cropBox (~800px) */
}

/* The image is moved and scaled under the fixed overlay */
#cropImage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    /* no default scale/translate here; JS will set it */
    max-width: none;
    max-height: none;
}

/* Overlay: fixed size, centered */
#cropTemplateOverlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 20;
    border: 3px dashed #F6C301;
    background: rgba(246, 195, 1, 0.08);
    box-sizing: border-box;
}

/* Crop actions */

.crop-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Preview */

.preview-list {
    margin-top: 16px;
}

#previewImages {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preview-item {
    width: 130px;
    padding: 6px;
    border-radius: 8px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.preview-item img {
    width: 100%;
    border-radius: 6px;
}

.preview-label {
    font-size: 12px;
    margin-bottom: 4px;
}

.preview-missing {
    font-size: 12px;
    color: #e53e3e;
}

/* Orientation toggle */
.orient-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: auto; /* push Back/Use buttons to the right */
    font-size: 13px;
    color: #4a5568;
}

.orient-btn {
    border-radius: 999px;
    border: 1px solid #E2BF5F;
    background: #FFFBEA;
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    color: #3B3018;
}

.orient-btn.active {
    background: #F6C301;
    border-color: #DCA601;
    color: #1A1A1A;
}

/* Details & summary */

.details-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.2fr);
    gap: 16px;
    margin-top: 18px;
}

.summary-box {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #F6D46E;
    background: #FFFBEA;
}

/* Buttons */

.step-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-small {
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 9px 18px;
    font-weight: 600;
}

.btn-primary {
    background: #F6C301;
    color: #1A1A1A;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background: #DCA601;
}

.btn-secondary {
    background: #FFF7D6;
    color: #3B3018;
    border: 1px solid #E2BF5F;
}

.btn-secondary:hover {
    background: #FFEEC0;
}

.btn-success {
    background: #5BBF57;
    color: #FFFFFF;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn-success:hover {
    background: #43A645;
}

.btn-small {
    background: #FFFBEA;
    color: #3B3018;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid #E2BF5F;
}

.btn-small:hover {
    background: #FFEEC0;
}

/* Responsive */

@media (max-width: 720px) {
    .container {
        padding: 20px 12px 24px;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .crop-wrapper {
        min-height: 600px;
    }
}