body {
    font-family: 'Arial', sans-serif;
    background: #121212;
    color: #1e1e1e;
    margin: 0;
    padding: 20px;
    /* min-height: 100vh; */
}


.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #535151;
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

h1 {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    letter-spacing: 5px;
    font-size: 2.5rem;
    margin: 0;
}

.controls div {
    font-size: 1rem;
    font-weight: bold;
    color: #e0e0e0;
}

.tile-front {
    background: #2c2c2c;
    color: #e0e0e0;
    transform: rotateY(0);
}

.tile.selected .tile-front {
    background: #3a3a3a;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.line {
    background: rgba(255, 255, 255, 0.5);
    position: absolute;
    height: 3px;
    transform-origin: 0 0;
    z-index: 10;
}

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

.controls {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    margin-left: 25px;
    margin-right: 25px;
    align-items: center;
    width: calc(100% - 40px);
}

.controls_left {
    display: flex;
    gap: 20px;
}

.controls_right {
    display: flex;
    gap: 10px;
    align-items: center;
}


.controls_right button{
    height: 42px;
    line-height: 1;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1.6rem;
    transition: all 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0);
    box-sizing: border-box;
}



.controls_right button:focus,
.controls_right button:focus-visible,
.controls_left select:focus,
.controls_left select:focus-visible {
    outline: none;
    box-shadow: none;
}




.controls button:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

.controls button:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 5px;
}

/* Sound toggle button styles */
.sound-toggle {
    font-size: 1.2rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
}

/* .sound-toggle.muted {
    background: rgba(62, 1, 1, 0.1);
} */

.board {
    display: grid;
    grid-template-columns: repeat(16, minmax(0, 1fr));
    gap: 6px;
    perspective: 1000px;
    width: 100%;
    height: 100%;
    padding: 30px;
    box-sizing: border-box;
    position: relative; /* Needed for positioning the SVG line overlay */
}

@keyframes boardRefresh {
    0% {
        outline-color: rgba(0, 255, 0, 0.7);
        outline-offset: 0px;
        box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) inset;
    }
    50% {
        outline-color: rgba(0, 255, 0, 0.0);
        outline-offset: 10px;
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.2) inset;
    }
    100% {
        outline-color: rgba(0, 255, 0, 0);
        outline-offset: 0px;
        box-shadow: 0 0 0 rgba(0, 255, 0, 0) inset;
    }
}

.board.refreshing {
    animation: boardRefresh 2.4s ease-out;
    outline: 2px solid rgba(0, 255, 0, 0); /* 初始透明，动画中渐显 */
    outline-offset: 0px;
    border-radius: 10px;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.1) inset; /* 微弱内发光背景 */
    transition: box-shadow 2.56s ease;
}


.tile {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* 保持为正方形 */
    transform-style: preserve-3d;
    transition: transform 0.5s, box-shadow 0.3s;
    cursor: pointer;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.tile.flipped {
    transform: rotateY(180deg);
}

.tile-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.1rem;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), inset 0 -1px 1px rgba(0, 0, 0, 0.3);
}

/* SVG图标大小控制 */
.tile-face img {
    width: 60%;
    height: 60%;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
    /*添加图片不可拖动属性*/
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

.tile-front {
    color: #333;
    border: 1px solid #5a5f5c;
    /* 添加砖块纹理效果 */
    background-size: 100% 100%, 10px 10px, 10px 10px;
    background-position: 0 0, 0 0, 0 0;
    transform: rotateY(0);
}

.tile.selected .tile-front {
    background: linear-gradient(135deg, #a5c7c5 0%, #8fb2b0 50%, #7a9e9c 100%);
    box-shadow: inset 0 0 8px rgba(66, 165, 245, 0.7), inset 0 1px 3px rgba(255, 255, 255, 0.5);
    /* 保持砖块纹理但改变颜色 */
    background-image: 
        linear-gradient(135deg, #a5c7c5 0%, #8fb2b0 50%, #7a9e9c 100%),
        linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 100% 100%, 10px 10px, 10px 10px;
    background-position: 0 0, 0 0, 0 0;
    border: 1px solid #6a8a88;
}

.tile-front-gray-dark {
    background: linear-gradient(135deg, #8a9188 0%, #79807c 50%, #6c726e 100%);
}

.tile-front-green-dark {
    background: linear-gradient(135deg, #5e7d68 0%, #4e6c58 50%, #3e5848 100%);
}

.tile-front-blue-dark {
    background: linear-gradient(135deg, #5a6e86 0%, #495e74 50%, #394c5f 100%);
}

.tile-front-purple-dark {
    background: linear-gradient(135deg, #5c476c 0%, #4b3a5a 50%, #3c2d47 100%);
}

.tile-front-red-dark {
    background: linear-gradient(135deg, #6e3e3e 0%, #5b3131 50%, #4a2626 100%);
}

.tile-front-brown-dark {
    background: linear-gradient(135deg, #64503e 0%, #52402f 50%, #413021 100%);
}

.tile.matched {
    opacity: 0;
    transition: opacity 0.3s ease-out; /* Smooth fade out */
    pointer-events: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.tile.shake {
    animation: shake 0.5s ease-in-out;
}

/* 添加下压动画效果 */
@keyframes press {
    0% { transform: scale(1) translateY(0); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); }
    50% { transform: scale(0.97) translateY(2px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
    100% { transform: scale(1) translateY(0); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); }
}

.tile.pressed {
    animation: press 0.2s ease-in-out;
}

@media (max-width: 1200px) {
    .board {
        grid-template-columns: repeat(8, 1fr);
    }
}

@media (max-width: 600px) {
    .board {
        grid-template-columns: repeat(4, 1fr);
    }
}

.connection-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Line should not interfere with clicks */
    z-index: 10;         /* Draw line above tiles */
}

.connection-line path {
    stroke: limegreen;
    stroke-width: 4;    /* Make line thicker */
    stroke-linecap: round; /* Nicer line ends */
    stroke-linejoin: round;/* Nicer corners */
    fill: none;
    animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1.0) !important; /* 使用更平滑的缓动函数 */
}

/* 下拉菜单样式优化 */
#fillMode {
    padding: 0px 3px 0px 0px;
    min-width: auto;
    background: #535151;
    box-shadow: none;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0);
    color: white;
    border: none;
    font-size: 1rem;
}

#fillMode:focus {
    outline: none;
    box-shadow: none;
}

#fillMode option {
    text-align: center !important;
    background-color: #2c2c2c;
    color: white;
    padding: 10px 15px !important;
    cursor: pointer;
    border:none;
    border-radius: 0;
    text-indent: 0;
    direction: ltr;
    text-align-last: center;
}

@media (max-width: 768px) {

    .board {
        padding-top: 0px;
    }

    #fillMode {
        font-size: 0.85rem;
    }
    
    select {
        padding: 6px 35px 6px 10px;
        font-size: 0.85rem;
    }
    

    .controls {
        flex-direction: column;
        align-items: stretch;
        font-size: 0.95rem;
        gap: 6px;
    }

    .controls_left, .controls_right {
        flex-direction: row;
        justify-content: flex-start;
        gap: 8px;
        font-size: 0.95rem;
    }


    .welcome-screen {
        max-width: 90%;
        max-height: 80vh;
        padding: 15px;
    }

    .welcome-title {
        font-size: 3rem;
        margin-bottom: 4rem;
    }

    .start-button {
        padding: 0.8rem 1.6rem;
        font-size: 1.3rem;
    }
}

/* 提示高亮样式 */
.tile.hint .tile-front {
    border: 3px solid limegreen;
    box-shadow: 0 0 10px rgba(50, 205, 50, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 10px rgba(50, 205, 50, 0.7); }
    50% { box-shadow: 0 0 20px rgba(50, 205, 50, 0.9); }
    100% { box-shadow: 0 0 10px rgba(50, 205, 50, 0.7); }
}

