* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#root {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f8f8;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    .toolbar .setting-item {
        min-width: auto;
        flex: 1;
    }
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.settings-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    justify-content: center;
}

@media (min-width: 769px) {
    .settings-group {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .settings-group {
        flex-direction: column;
        gap: 10px;
    }

    .setting-item {
        min-width: auto !important;
        flex: 1;
    }
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
    flex: 1;
    min-width: 200px;
}

@media (min-width: 769px) {
    .setting-item {
        min-width: 180px;
        max-width: 300px;
    }
}

@media (min-width: 1200px) {
    .setting-item {
        max-width: 250px;
    }
}

.setting-item label {
    font-weight: bold;
    white-space: nowrap;
}

.setting-item select,
.setting-item input {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    min-width: 0;
    width: 100%;
}

@media (min-width: 769px) {
    .setting-item select,
    .setting-item input {
        min-width: 100px;
        max-width: 150px;
    }
}

@media (min-width: 1200px) {
    .setting-item select,
    .setting-item input {
        max-width: 180px;
    }
}

.blocks-result-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 768px) {
    .blocks-result-container {
        flex-direction: row;
    }
}

.blocks-section {
    flex: 1;
    min-width: 0;
}

@media (max-width: 480px) {
    .blocks-section {
        overflow-x: auto;
        padding-bottom: 10px;
    }
}

.result-section {
    flex: 1;
    min-width: 0;
}

.container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: repeat(5, 1fr);
    }

    .block {
        min-height: 60px;
    }
}

@media (max-width: 480px) {
    .container {
        grid-template-columns: repeat(5, 1fr);
        min-width: 300px; /* 确保5列能正常显示 */
    }

    .block {
        min-height: 50px;
    }
}

.block {
    aspect-ratio: 1;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #f9f9f9;
    cursor: pointer;
    overflow: hidden;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23cccccc' d='M19 11h-6V5h-2v6H5v2h6v6h2v-6h6v-2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.3s ease;
}

@media (max-width: 480px) {
    .block {
        background-size: 16px 16px;
    }
}

.block:hover {
    border-color: #3498db;
    background-color: #e0f2f1;
}

.block.drag-over {
    border-color: #009688;
    background-color: #e0f2f1;
}

.block img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    z-index: 1;
    display: block;
}

/* 对齐方式样式 */
.block img.align-top-center {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 100%;
    max-height: 100%;
}

.block img.align-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
}

.block img.align-bottom-center {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 100%;
    max-height: 100%;
}

.block img.align-top-left {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    max-height: 100%;
}

.block img.align-top-right {
    position: absolute;
    top: 0;
    right: 0;
    max-width: 100%;
    max-height: 100%;
}

.block .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: none;
    z-index: 2;
    font-size: 12px;
    line-height: 1;
}

@media (max-width: 768px) {
    .block .remove-btn {
        width: 16px;
        height: 16px;
        font-size: 10px;
        top: 3px;
        right: 3px;
    }
}

@media (max-width: 480px) {
    .block .remove-btn {
        width: 14px;
        height: 14px;
        font-size: 8px;
        top: 2px;
        right: 2px;
    }
}

.block:hover .remove-btn {
    display: block;
}

.result-container {
    margin-top: 30px;
    text-align: center;
    padding: 20px;
    background: #f8f8f8;
    border-radius: 8px;
}

.result-container img {
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.membership-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.membership-popup {
    background: white;
    border-radius: 10px;
    padding: 20px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.membership-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.membership-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.close-btn:hover {
    color: #333;
    background: #f5f5f5;
    border-radius: 50%;
}
.membership-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.membership-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.membership-btn:hover {
    border-color: #007bff;
    background: #e7f3ff;
    transform: translateY(-2px);
}
.membership-title {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}
.membership-price {
    color: #007bff;
    font-weight: bold;
    font-size: 16px;
}
