body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f5f7;
    margin: 0;
    padding: 0;
}

header {
    background-color: #fff;
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.tab {
    padding: 10px 25px;
    background-color: #eee;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.tab.active {
    background-color: #007bff;
    color: #fff;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.card {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

.card h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.card span {
    font-size: 14px;
    color: #888;
}

/* Modal Styles */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.hidden { display: none !important; }

/* Editor Styles */
.editor-section {
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.editor-controls {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 12px;
    color: #888;
}

.control-group input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 80px;
}

#edit-name { width: 150px; }

.editor-workspace {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
}

.editor-sidebar {
    width: 250px;
}

.dice-grid.editable .dice-container {
    cursor: pointer;
    transition: transform 0.1s;
}

.editor-instructions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
    border: 1px solid #eee;
    padding: 15px 25px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.instr-text p {
    margin: 0;
    font-size: 14px;
    color: #444;
}

.instr-legend {
    display: flex;
    gap: 20px;
}

.legend-item {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.brush-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #eef6ff;
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid #d0e4ff;
    font-weight: bold;
    color: #007bff;
    margin-top: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.editor-main-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.mini-preview-wrap {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #eee;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.mini-preview-wrap h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mini-dot-grid {
    display: inline-grid;
    gap: 1px;
    background-color: #f0f0f0;
    padding: 3px;
    border-radius: 4px;
}

.mini-dot {
    width: 6px;
    height: 6px;
    border-radius: 1px;
}

.modal-content {
    background-color: #fff;
    padding: 40px;
    border-radius: 16px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.modal-main-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.detail-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
}

.config-panel {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
    width: 200px;
    text-align: left;
}

.config-panel h3 {
    margin-top: 0;
    font-size: 18px;
    margin-bottom: 15px;
}

.config-description {
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.config-description p {
    margin: 5px 0;
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot-blue { color: #3498db; font-size: 16px; }
.dot-red { color: #e74c3c; font-size: 16px; }

.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 12px;
    color: #333;
    font-weight: bold;
}

.config-group label span {
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.slider-wrap {
    padding: 5px 0;
}

input[type="range"] {
    width: 100%;
    margin: 10px 0;
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    margin-top: -5px;
    margin-bottom: 5px;
}

.slider-labels span {
    font-size: 10px;
    color: #bbb;
    user-select: none;
}

.slider-info {
    font-size: 11px;
    color: #888;
    margin-top: 8px;
    border-top: 1px dashed #eee;
    padding-top: 4px;
}

.status-tag {
    background: #eefdf3;
    color: #27ae60;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    margin: 15px 0;
    text-align: center;
    border: 1px solid #d4f5e0;
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.save-btn {
    width: 100%;
    padding: 12px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
}

.edit-btn {
    width: 100%;
    padding: 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
}

.edit-btn:hover {
    background-color: #2980b9;
}

.sub-patterns-area {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    width: 100%;
}

.sub-patterns-area h4 {
    margin: 0 0 15px 0;
    color: #666;
}

.sub-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.sub-item {
    flex: 0 0 auto;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.sub-item:hover {
    border-color: #007bff;
    background: #eef6ff;
}

.sub-item-preview {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-bottom: 5px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 6px;
}

.sub-item-label {
    font-size: 12px;
    color: #333;
}

.nav-btn {
    background: #f0f0f0;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #e0e0e0;
}

.nav-btn.hidden {
    visibility: hidden;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
}

/* Dice Grid */
.dice-grid {
    display: inline-grid;
    gap: 4px;
    background-color: #eee;
    padding: 10px;
    border-radius: 8px;
    margin-top: 0;
}

.dice-container {
    display: flex;
}

.modal-main-wrap h2 {
    margin-top: 0;
    margin-bottom: 25px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    color: #333;
    font-weight: bold;
}

.grid-label {
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    color: #444;
    background: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.dice-container.marked {
    position: relative;
}

.dice-container.marked::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #27ae60;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 5;
}

.mini-preview-section {
    text-align: center;
    margin-bottom: 15px;
}

.mini-preview-section h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #999;
    text-transform: uppercase;
}

/* --- 移动端响应式优化 (max-width: 768px) --- */
@media (max-width: 768px) {
    main {
        padding: 15px 10px;
    }

    .tabs {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tab {
        padding: 8px 15px;
        font-size: 14px;
        flex: 1 1 auto;
        min-width: 80px;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    /* 编辑器适配 */
    .editor-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .editor-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .control-group input, #edit-name {
        width: 100% !important;
        box-sizing: border-box;
    }

    .editor-instructions {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
    }

    .instr-legend {
        flex-wrap: wrap;
        gap: 10px;
    }

    .editor-workspace {
        flex-direction: column;
        gap: 20px;
    }

    .editor-sidebar {
        width: 100%;
    }

    /* 详情弹窗适配 */
    .modal-content {
        padding: 45px 15px 20px;
        flex-direction: column;
        width: 95%;
        max-height: 95vh;
    }

    .modal-main-wrap {
        width: 100%;
    }

    .detail-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .config-panel {
        width: 100%;
        box-sizing: border-box;
    }

    /* 导航按钮位置调整 */
    .nav-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.8);
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 10;
    }

    .nav-btn.prev { left: 5px; }
    .nav-btn.next { right: 5px; }

    /* 骰子网格支持滚动 */
    .dice-grid {
        max-width: 100%;
        overflow-x: auto;
        padding: 10px 5px;
        display: inline-grid;
    }

    .sub-list {
        padding-bottom: 5px;
    }
}
