* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 20px;
    max-width: 900px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    background: linear-gradient(45deg, #f7fafc, #edf2f7);
    padding: 15px;
    border-radius: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info > div {
    font-weight: bold;
    color: #2d3748;
    font-size: 1.1em;
}

.game-rules {
    background: linear-gradient(45deg, #fed7d7, #feb2b2);
    padding: 10px 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    border: 2px solid #fc8181;
}

.game-rules p {
    color: #742a2a;
    font-weight: bold;
    font-size: 1em;
    margin: 0;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls button {
    background: linear-gradient(45deg, #4299e1, #3182ce);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3);
}

.controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 153, 225, 0.4);
}

.controls button:active {
    transform: translateY(0);
}

#hintBtn {
    background: linear-gradient(45deg, #f6ad55, #ed8936);
}

#hintBtn:hover {
    box-shadow: 0 6px 20px rgba(246, 173, 85, 0.4);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin: 0 auto;
    max-width: 600px;
    background: linear-gradient(45deg, #f7fafc, #edf2f7);
    padding: 20px;
    border-radius: 15px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.tile {
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, #fff, #f7fafc);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-color: #4299e1;
}

.tile.selected {
    background: linear-gradient(45deg, #4299e1, #3182ce);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(66, 153, 225, 0.4);
    border-color: #2b6cb0;
}

.tile.matched {
    background: linear-gradient(45deg, #48bb78, #38a169);
    color: white;
    transform: scale(0.9);
    opacity: 0.7;
    pointer-events: none;
}

.tile.hint {
    background: linear-gradient(45deg, #f6ad55, #ed8936);
    border-color: #dd6b20;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.connection-line {
    position: absolute;
    background: linear-gradient(90deg, #ff6b6b, #ff8e8e, #ff6b6b);
    z-index: 200;
    pointer-events: none;
    border-radius: 2px;
    box-shadow: 
        0 0 6px rgba(255, 107, 107, 0.8),
        0 0 12px rgba(255, 107, 107, 0.4);
    animation: connectionAppear 0.6s ease-out;
}

@keyframes connectionAppear {
    0% { 
        opacity: 0;
        transform: scale(0, 1);
    }
    50% { 
        opacity: 0.8;
        transform: scale(0.5, 1);
    }
    100% { 
        opacity: 1;
        transform: scale(1, 1);
    }
}

/* 为垂直线条添加特殊动画 */
.connection-line[data-direction="vertical"] {
    animation: connectionAppearVertical 0.6s ease-out;
}

@keyframes connectionAppearVertical {
    0% { 
        opacity: 0;
        transform: scale(1, 0);
    }
    50% { 
        opacity: 0.8;
        transform: scale(1, 0.5);
    }
    100% { 
        opacity: 1;
        transform: scale(1, 1);
    }
}

/* SVG路径绘制动画 */
@keyframes drawPath {
    0% {
        stroke-dashoffset: 100%;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.game-overlay, .hint-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content, .hint-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.overlay-content h2, .hint-content h3 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 2em;
}

.hint-content h3 {
    font-size: 1.5em;
}

.overlay-content p, .hint-content p {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.1em;
}

.final-stats {
    background: linear-gradient(45deg, #f7fafc, #edf2f7);
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: left;
}

.final-stats p {
    margin: 10px 0;
    color: #2d3748;
    font-weight: bold;
}

#playAgainBtn, #closeHintBtn {
    background: linear-gradient(45deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

#closeHintBtn {
    background: linear-gradient(45deg, #f56565, #e53e3e);
    padding: 12px 24px;
    font-size: 1em;
}

#playAgainBtn:hover, #closeHintBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

#closeHintBtn:hover {
    box-shadow: 0 6px 20px rgba(245, 101, 101, 0.4);
}

/* 卡片尺寸控制 */
.size-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #f7fafc, #edf2f7);
    padding: 15px;
    border-radius: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.size-control label {
    font-weight: bold;
    color: #2d3748;
    font-size: 1em;
}

#tileSizeSlider {
    width: 150px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #cbd5e0, #4299e1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#tileSizeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #4299e1, #3182ce);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
    transition: all 0.3s ease;
}

#tileSizeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.5);
}

#tileSizeSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #4299e1, #3182ce);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
}

#tileSizeValue {
    font-weight: bold;
    color: #4299e1;
    min-width: 50px;
    text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        margin: 10px;
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .game-board {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
        padding: 15px;
    }
    
    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        padding: 10px;
    }
    
    .tile {
        width: 45px;
        height: 45px;
        font-size: 1.2em;
    }
}
