* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.header p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.progress {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
    transform: translateY(-2px);
}

.game-board {
    
    margin-bottom: 30px;
    position: relative;
}

.row {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 10px;
}

.tag-item {
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-weight: 500;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.tag-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.tag-item.selected {
    border-color: #3498db;
    background: #e3f2fd;
    transform: scale(1.05);
}

.tag-item.locked {
    border-color: #27ae60;
    background: #e8f5e8;
    cursor: not-allowed;
    animation: pulse 2s infinite;
    position: relative;
}

.row-locked::before {
    content: attr(data-category);
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #27ae60;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
    z-index: 10;
}

.row-locked {
    position: relative;
    background: rgba(39, 174, 96, 0.1);
    border: 3px solid #27ae60;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.2);
}

.row-locked .tag-item {
    margin: 0;
}

.categories-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.categories-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

.categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.category-badge {
    background: #3498db;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.game-complete {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border-radius: 15px;
    margin-top: 20px;
    animation: celebrate 0.6s ease;
}

.game-complete h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.game-complete p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes celebrate {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* 响应式设计 - 平板设备 */
@media (max-width: 1024px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
    
    .tag-item {
        padding: 18px;
        font-size: 1.1rem;
    }
}

/* 响应式设计 - 手机设备 */
@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }
    
    .game-container {
        padding: 15px;
        border-radius: 15px;
        margin: 5px;
    }
    
    .header {
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    .header p {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .game-info {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .progress {
        font-size: 1rem;
        text-align: center;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    
    /* 保持4×6的网格结构，通过缩小间距和字体来适应手机屏幕 */
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        margin-bottom: 20px;
    }
    
    .tag-item {
        padding: 8px 4px;
        font-size: 0.8rem;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-width: 2px;
        word-break: break-word;
        text-align: center;
        line-height: 1.2;
    }
    
    .tag-item:hover {
        transform: translateY(-2px);
    }
    
    .tag-item.locked::before {
        font-size: 0.6rem;
        padding: 1px 6px;
        top: -6px;
    }
    
    .categories-panel {
        padding: 15px;
        margin-top: 15px;
    }
    
    .categories-panel h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    .category-badge {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .game-complete {
        padding: 25px;
        margin-top: 15px;
    }
    
    .game-complete h2 {
        font-size: 1.8rem;
    }
    
    .game-complete p {
        font-size: 1rem;
    }
    
    /* 手机端拖拽优化 */
    .tag-item.drag-over::before {
        font-size: 1.2rem;
    }
    
    .tag-item.dragging {
        transform: scale(0.9);
    }
    
    /* 手机端完成行样式 */
    .row-locked {
        padding: 10px;
        gap: 2px;
        border-width: 2px;
    }
    
    .row-locked .tag-item {
        padding: 6px 3px;
        font-size: 0.75rem;
        min-height: 45px;
    }
}

/* 超小屏幕手机适配 */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.6rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    /* 保持4×6的网格结构，进一步缩小间距 */
    .game-board {
        gap: 4px;
    }
    
    .tag-item {
        padding: 6px 3px;
        font-size: 0.75rem;
        min-height: 45px;
        line-height: 1.1;
    }
    
    .progress {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .tag-item.locked::after {
        width: 12px;
        height: 12px;
        font-size: 0.5rem;
    }
}

/* Sortable.js 拖拽样式 */
.sortable-ghost {
    opacity: 0.4;
    background: #3498db;
    border-color: #3498db;
}

.sortable-chosen {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.sortable-drag {
    opacity: 0.8;
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.tag-item.dragging {
    opacity: 0.6;
    transform: scale(0.95);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.tag-item.drag-over {
    border-color: #3498db;
    background: #e3f2fd;
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(52, 152, 219, 0.3);
}

.tag-item.drag-over::before {
    content: '⇄';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: #3498db;
    opacity: 0.7;
}

/* 拖拽时的光标样式 */
.tag-item[draggable="true"] {
    cursor: grab;
}

.tag-item[draggable="true"]:active {
    cursor: grabbing;
}

/* 拖拽时的动画效果 */
.tag-item {
    transition: all 0.2s ease;
}

/* 防止拖拽时文本被选中 */
.tag-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 配置面板样式 */
.config-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #e0e0e0;
    animation: slideDown 0.3s ease;
}

.config-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.3rem;
}

.config-item {
    margin-bottom: 20px;
}

.config-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.config-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.rows-value {
    font-weight: bold;
    color: #3498db;
    font-size: 1.1rem;
    min-width: 60px;
    text-align: center;
}

.config-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

@keyframes slideDown {
    0% { 
        transform: translateY(-20px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* 配置面板响应式设计 */
@media (max-width: 768px) {
    .config-panel {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .config-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .slider {
        width: 100%;
    }
    
    .config-buttons {
        flex-direction: column;
    }
    
    .config-buttons .btn {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
}

/* 移动端触摸拖拽优化 */
@media (max-width: 768px) {
    /* 触摸拖拽时的视觉反馈 */
    .tag-item.dragging {
        opacity: 0.8;
        transform: scale(1.1);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        transition: transform 0.1s ease;
    }
    
    /* 触摸拖拽目标样式 */
    .tag-item.drag-over {
        border-color: #3498db;
        background: #e3f2fd;
        transform: scale(1.05);
        box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
        animation: pulse-target 0.5s infinite alternate;
    }
    
    @keyframes pulse-target {
        0% { transform: scale(1.05); }
        100% { transform: scale(1.1); }
    }
    
    /* 触摸拖拽指示器 */
    .tag-item.drag-over::before {
        content: '⇄';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 1.8rem;
        color: #3498db;
        opacity: 0.8;
        z-index: 10;
    }
    
    /* 触摸拖拽时的body样式 */
    body.touch-dragging {
        cursor: grabbing;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    /* 防止触摸时页面滚动 */
    .tag-item {
        touch-action: pan-x pan-y;
    }
    
    /* 触摸拖拽时的行样式 */
    .row .tag-item.dragging {
        margin: 0;
    }
    
    /* 触摸拖拽时的锁定行处理 */
    .row-locked .tag-item {
        touch-action: none;
        pointer-events: none;
    }
    
    /* 触摸拖拽时的选中状态 */
    .tag-item.selected {
        border-color: #e74c3c;
        background: #fdedec;
    }
    
    /* 触摸拖拽时的过渡效果 */
    .tag-item {
        transition: all 0.15s ease;
    }
    
    /* 触摸拖拽时的文字阴影 */
    .tag-item.dragging {
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

/* 配置面板样式 */
.config-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #e0e0e0;
    animation: slideDown 0.3s ease;
}

.config-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.3rem;
}

.config-item {
    margin-bottom: 20px;
}

.config-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.config-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.rows-value {
    font-weight: bold;
    color: #3498db;
    font-size: 1.1rem;
    min-width: 60px;
    text-align: center;
}

.config-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

@keyframes slideDown {
    0% { 
        transform: translateY(-20px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* 配置面板响应式设计 */
@media (max-width: 768px) {
    .config-panel {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .config-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .slider {
        width: 100%;
    }
    
    .config-buttons {
        flex-direction: column;
    }
    
    .config-buttons .btn {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
}

/* 移动端触摸拖拽优化 */
@media (max-width: 768px) {
    /* 触摸拖拽时的视觉反馈 */
    .tag-item.dragging {
        opacity: 0.8;
        transform: scale(1.1);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        transition: transform 0.1s ease;
    }
    
    /* 触摸拖拽目标样式 */
    .tag-item.drag-over {
        border-color: #3498db;
        background: #e3f2fd;
        transform: scale(1.05);
        box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
        animation: pulse-target 0.5s infinite alternate;
    }
    
    @keyframes pulse-target {
        0% { transform: scale(1.05); }
        100% { transform: scale(1.1); }
    }
    
    /* 触摸拖拽指示器 */
    .tag-item.drag-over::before {
        content: '⇄';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 1.8rem;
        color: #3498db;
        opacity: 0.8;
        z-index: 10;
    }
    
    /* 触摸拖拽时的body样式 */
    body.touch-dragging {
        cursor: grabbing;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    /* 防止触摸时页面滚动 */
    .tag-item {
        touch-action: pan-x pan-y;
    }
    
    /* 触摸拖拽时的行样式 */
    .row .tag-item.dragging {
        margin: 0;
    }
    
    /* 触摸拖拽时的锁定行处理 */
    .row-locked .tag-item {
        touch-action: none;
        pointer-events: none;
    }
    
    /* 触摸拖拽时的选中状态 */
    .tag-item.selected {
        border-color: #e74c3c;
        background: #fdedec;
    }
    
    /* 触摸拖拽时的过渡效果 */
    .tag-item {
        transition: all 0.15s ease;
    }
    
    /* 触摸拖拽时的文字阴影 */
    .tag-item.dragging {
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}