/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 1000px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

/* 游戏标题 */
.game-title {
    font-size: 2.5rem;
    color: #4a5568;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* 游戏信息栏 */
.game-info {
    display: flex;
    justify-content: space-around;
    background: #f7fafc;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.info-label {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
}

/* 游戏容器 */
.game-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    overflow: hidden;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

/* 游戏面板 */
.game-board {
    display: grid;
    gap: 2px;
    background: #e2e8f0;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    padding: 10px;
    margin: 0 auto;
}

/* 不同难度的网格布局 */
.game-board.easy {
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(6, 60px);
}

.game-board.normal {
    grid-template-columns: repeat(10, 50px);
    grid-template-rows: repeat(8, 50px);
}

.game-board.hard {
    grid-template-columns: repeat(12, 45px);
    grid-template-rows: repeat(10, 45px);
}

/* 游戏方块 */
.cell {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    position: relative;
    overflow: hidden;
}

.cell:hover {
    background: #f7fafc;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell.selected {
    background: #4299e1;
    border-color: #3182ce;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.5);
}

.cell.matched {
    background: #48bb78;
    border-color: #38a169;
    animation: matchAnimation 0.6s ease-out forwards;
}

.cell.empty {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

.cell.hinted {
    background: #ed8936;
    animation: hintAnimation 1s ease-in-out infinite;
}

@keyframes matchAnimation {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes hintAnimation {
    0%, 100% { transform: scale(1); background: #ed8936; }
    50% { transform: scale(1.05); background: #f6ad55; }
}

/* 连接线样式 */
.connection-line {
    position: absolute;
    background: #4299e1;
    height: 3px;
    z-index: 100;
    pointer-events: none;
    animation: drawLine 0.5s ease-out forwards;
}

.connection-line.horizontal {
    width: 0;
}

.connection-line.vertical {
    height: 0;
    width: 3px;
}

@keyframes drawLine {
    to { width: 100%; height: 100%; }
}

/* 控制面板 */
.control-section {
    margin-bottom: 20px;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    min-width: 100px;
}

.btn-primary {
    background: #4299e1;
    color: white;
}

.btn-primary:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
    transform: translateY(-2px);
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background: #c53030;
    transform: translateY(-2px);
}

.btn-info {
    background: #38b2ac;
    color: white;
}

.btn-info:hover {
    background: #319795;
    transform: translateY(-2px);
}

/* 难度选择 */
.difficulty-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.difficulty-select {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-select:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 游戏说明 */
.game-instructions {
    background: #f7fafc;
    border-radius: 10px;
    padding: 20px;
    text-align: left;
}

.game-instructions h3 {
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

.game-instructions ul {
    list-style-type: disc;
    padding-left: 20px;
    color: #4a5568;
    line-height: 1.6;
}

.game-instructions li {
    margin-bottom: 8px;
}

/* 模态框 */
.modal {
    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;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #2d3748;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.2rem;
    color: #4a5568;
    margin-bottom: 15px;
}

.win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .game-info {
        gap: 5px;
    }
    
    .info-item {
        min-width: 60px;
    }
    
    .info-label {
        font-size: 0.8rem;
    }
    
    .info-value {
        font-size: 1.2rem;
    }
    
    /* 调整不同难度的网格大小 */
    .game-board.easy {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(6, 45px);
    }
    
    .game-board.normal {
        grid-template-columns: repeat(10, 38px);
        grid-template-rows: repeat(8, 38px);
    }
    
    .game-board.hard {
        grid-template-columns: repeat(12, 32px);
        grid-template-rows: repeat(10, 32px);
    }
    
    .cell {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-width: 90px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.8rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    /* 进一步调整网格大小 */
    .game-board.easy {
        grid-template-columns: repeat(8, 38px);
        grid-template-rows: repeat(6, 38px);
    }
    
    .game-board.normal {
        grid-template-columns: repeat(10, 32px);
        grid-template-rows: repeat(8, 32px);
    }
    
    .game-board.hard {
        grid-template-columns: repeat(12, 28px);
        grid-template-rows: repeat(10, 28px);
    }
    
    .cell {
        font-size: 1.2rem;
    }
    
    .control-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .difficulty-selector {
        flex-direction: column;
        gap: 10px;
    }
}
