* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 100%;
    max-width: 600px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    gap: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-label {
    font-weight: bold;
    color: #555;
}

#time, #score {
    font-size: 1.2em;
    color: #333;
    min-width: 30px;
}

.game-controls {
    display: flex;
    gap: 10px;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

#start-btn {
    background-color: #4CAF50;
    color: white;
}

#restart-btn {
    background-color: #2196F3;
    color: white;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.game-board-container {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 保持正方形比例 */
}

#game-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 10px;
}

#line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 允许点击穿透到下面的元素 */
    z-index: 10;
}

.tile {
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.tile.selected {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #333;
    z-index: 5;
}

.tile.matched {
    animation: fadeOut 0.5s forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    border-radius: 10px;
    z-index: 20;
}

.game-over h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-over p {
    font-size: 1.2em;
    margin-bottom: 30px;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        gap: 15px;
    }

    .game-info {
        width: 100%;
        justify-content: space-around;
    }

    .game-controls {
        width: 100%;
        justify-content: space-around;
    }

    #game-board {
        gap: 5px;
    }
}