* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    color: #333;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}



.main {
    flex: 1;
    padding: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0.8;
}

.hidden {
    display: none !important;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.modal-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.accept-btn {
    background-color: #27ae60;
}

.accept-btn:hover {
    background-color: #219a52;
}

.reject-btn {
    background-color: #e74c3c;
}

.reject-btn:hover {
    background-color: #c0392b;
}

#room-section h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

#create-room-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#create-room-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#create-room-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.join-room {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#room-id-input {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#room-id-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#join-room-btn {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#join-room-btn:hover {
    background-color: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#join-room-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.room-info {
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.player-info {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-align: center;
    width: 100%;
}

.player-info.red {
    color: #FF6B6B;
    border: 2px solid #FF6B6B;
}

.player-info.black {
    color: #34495E;
    border: 2px solid #34495E;
}

.turn-indicator {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    margin-bottom: 1rem;
}

.turn-indicator.red {
    background-color: #FF6B6B;
    color: white;
}

.turn-indicator.black {
    background-color: #34495E;
    color: white;
}

.check-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #e74c3c;
    color: white;
    padding: 2rem 4rem;
    font-size: 2rem;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: translate(-50%, -50%) scale(1); }
    to { transform: translate(-50%, -50%) scale(1.05); }
}

.game-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    height: 100%;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 150px;
}

.left-sidebar {
    align-items: flex-end;
}

.right-sidebar {
    align-items: flex-start;
}

.game-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-btn {
    width: 100%;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 900px) {
    .game-layout {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-sidebar {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        min-width: auto;
        gap: 2rem;
    }
    
    .left-sidebar {
        order: 1;
        flex: 1;
        align-items: center;
    }
    
    .chessboard {
        order: 2;
    }
    
    .right-sidebar {
        order: 3;
        flex: 1;
        align-items: center;
    }
    
    .game-buttons {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .player-info {
        font-size: 1rem;
        padding: 0.3rem 0.8rem;
    }
    
    .turn-indicator {
        font-size: 1rem;
        padding: 0.3rem 0.8rem;
        margin-bottom: 0.5rem;
    }
    
    .game-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

.chessboard {
    padding-left: 13px;
    padding-right: 13px;
    padding-top: 12px;
    padding-bottom: 12px;
    width: 100%;
    max-width: 750px;
    aspect-ratio: 9/10;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(10, 1fr);
    border: 2px solid #8B4513;
    background-image: url('table.jpeg');
    background-size: 100% 100%;
    background-position: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    transform-style: preserve-3d;
}

.cell:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.cell.selected {
    background-color: rgba(100, 200, 100, 0.5);
}

.cell.valid-move {
    background-color: rgba(100, 200, 100, 0.5) !important;
    position: relative;
    z-index: 2;
}

.cell.last-move {
    background-color: rgba(100, 149, 237, 0.5) !important;
    position: relative;
    z-index: 1;
}

.piece {
    width: 88%;
    height: 88%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "KaiTi", "STKaiti", serif;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
    position: relative;
    z-index: 1;
}

.piece:hover {
    filter: brightness(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* 棋子移动动画 */
.piece.moving {
    position: absolute !important;
    z-index: 100 !important;
    transition: all 0.3s ease-in-out;
}

@keyframes move {
    0% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 棋子被吃动画 */
.piece.captured {
    animation: capture 0.5s ease-in-out forwards;
}

@keyframes capture {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.piece.red {
    background-color: #E63946;
    color: white;
    box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.35),  /* 向下内阴影：压暗边缘 */
    inset 0 -2px 3px rgba(255, 255, 255, 0.2), /* 向上内阴影：加顶部高光 */
    0 3px 6px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2); /* 外阴影：浮起来 */
}

.piece.black {
    background-color: #34495E;
    color: white;
    box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 -2px 3px rgba(255, 255, 255, 0.15),
    0 3px 6px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2);
}




.game-info {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
}



/* 游戏结束弹窗 */
#game-over-modal .modal-content {
    min-width: 300px;
}

#game-over-message {
    font-size: 1.2rem;
    margin: 1rem 0;
    color: #e74c3c;
    font-weight: bold;
}

/* 等待对方确认弹窗 */
#rematch-waiting-modal .modal-content {
    min-width: 280px;
}

/* 对方离开弹窗 */
#opponent-left-modal .modal-content {
    min-width: 280px;
}

#opponent-left-modal p {
    color: #e74c3c;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main {
        padding: 0.5rem;
    }
    
    .section {
        padding: 1.5rem;
    }
    
    .join-room {
        flex-direction: column;
    }
    
    #room-id-input {
        width: 100%;
    }
    
    .chessboard {
        max-width: 100%;
    }
    
    .game-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 1rem;
    }
    
    #create-room-btn, #join-room-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    #room-id-input {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
}