:root {
    --card-width: 300px;
    --card-height: 424px;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
}

.container {
    text-align: center;
}

h1 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 1.5rem;
    /*h1与上方边界的距离*/
    margin-top: 0;
    padding-top: 0;
}

.card-container {
    margin: 20px auto;
    width: var(--card-width);
}

.card {
    width: 100%;
    height: var(--card-height);
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    margin-top: 20px;
    text-align: center; /* 居中对齐卡片信息 */
}

.card-title {
    font-size: 1.5rem;
    color: #2c3e50;
    margin-bottom: 1rem;
    font-weight: 600;
}

.card-description {
    font-size: 1rem;
    color: #7f8c8d;
    line-height: 1.5;
    white-space: pre-line; /* 允许显示换行符 */
}

.default-message {
    font-size: 1.5rem;
    color: #7f8c8d;
    text-align: center;
}

.button-group {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#drawBtn {
    background: #3498db;
    color: white;
}

#saveBtn {
    background: #2ecc71;
    color: white;
}

hr {
    margin: 40px 0;
    border: none;
    border-top: 1px solid #ddd;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 2rem;
    padding: 0 15px;
}

.card-preview {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-preview img {
    width: 100%;
    height: 340px;
    /* height: auto; */
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.preview-info {
    padding: 5px;
}

.hidden {
    display: none;
}

.loader {
    border: 4px solid #f3f3f3;
    border-radius: 50%;
    border-top: 4px solid #3498db;
    width: 40px;
    height: 40px;
    animation: spin 2s linear infinite;
}

footer {
    text-align: center;
    padding: 20px 0;
    background-color: #f5f5f5;
    margin-top: 40px;
}

footer p {
    color: #7f8c8d;
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.5;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* 模态框样式 */
.modal {
    display: none; /* 隐藏模态框 */
    position: fixed; /* 固定位置 */
    z-index: 1000; /* 置于顶部 */
    padding-top: 60px; /* 上方内边距 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* 允许滚动 */
    background-color: rgba(0, 0, 0, 0.8); /* 背景颜色（半透明黑色） */
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain; /* 保持图片比例 */
}

.close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* 在模态框显示时，让它变为可见 */
.show {
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    :root {
        --card-width: 280px;
        --card-height: 396px;
    }

    h1 {
        font-size: 1.75rem;
    }

    .card-container {
        width: 90%;
    }

    .card {
        height: calc(90vw * 1.413); /* 保持图片比例 */
    }

    .card-preview img {
        height: 300px;
    }

    button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }
}