body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-image: url('../img/space.jpg');
    background-size: cover;
    background-position: center;
    font-family: 'Arial', sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 10px;
    box-sizing: border-box;
}

.lang-switch {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    z-index: 100;
}

#lang-toggle {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
    margin: 0;
}

#chessboard {
    border-radius: 16px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    background-color: #c19a6b;
    /* Fallback color */
}

.controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(30, 200, 200, 0.5);
    padding: 10px;
    border-radius: 16px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
}

/* 模式選擇介面 - 玻璃材質外框 */
.mode-selection {
    width: 100%;
    max-width: 600px;
    min-height: 400px;
    text-align: center;
    background: rgba(30, 200, 200, 0.5);
    /* 半透明背景 */
    border: 1px solid rgba(30, 200, 200, 0.3);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    /* 玻璃模糊效果 */
    -webkit-backdrop-filter: blur(5px);
    /* 兼容 Safari */
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.mode-selection h1 {
    margin: 0 0 20px;
    font-size: 48px;
    color: #fff;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    font-weight: bold;
    letter-spacing: 2px;
}

.mode-selection h2 {
    margin: 0 0 40px;
    font-size: 32px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 美化按鈕 */
button {
    padding: 12px 24px;
    font-size: 18px;
    cursor: pointer;
    background: linear-gradient(135deg, #f0c14b, #d89e00);
    /* 漸層背景 */
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    margin: 10px 0;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    /* Optimize touch response */
}

button:hover {
    transform: translateY(-2px);
    /* 懸停時微微上移 */
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

button:active {
    transform: translateY(1px);
    /* 點擊時下沉 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mode-btn {
    width: 200px;
    /* 固定寬度讓按鈕更統一 */
}

p {
    font-size: 18px;
    margin: 5px 0;
    color: #fff;
    text-align: center;
}

@media (max-width: 600px) {
    .mode-selection h2 {
        font-size: 24px;
    }

    button {
        font-size: 16px;
        padding: 10px 20px;
    }

    p {
        font-size: 14px;
    }
}