.turn-badge {
    background: #e0e0e0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    color: #333; /* 默认文字颜色 */
    transition: all 0.3s;
}

.theme-dark .turn-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.theme-dark .turn-badge.not-my-turn {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(230, 237, 243, 0.6);
}

.theme-dark .turn-badge::before {
    border-color: rgba(255, 255, 255, 0.18);
}

.theme-dark .timer-badge {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.14);
}

.theme-dark .timer-text {
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}

.theme-dark .spectator-match-info {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.theme-dark .spectator-match-name {
    color: rgba(230, 237, 243, 0.9);
}

.theme-dark .spectator-match-avatar {
    filter: brightness(0.82) contrast(1.05);
}

.theme-dark .spectator-match-vs {
    color: rgba(230, 237, 243, 0.45);
}

.theme-dark #chessboard {
    box-shadow: 0 10px 26px rgba(0,0,0,0.5);
}

.theme-dark .message-box {
    background: var(--card-bg);
    box-shadow: 0 12px 30px rgba(0,0,0,0.55);
}

.theme-dark .loading-spinner {
    border-color: rgba(255,255,255,0.18);
    border-top-color: rgba(255,255,255,0.78);
}

.theme-dark .dropdown-menu {
    background-color: var(--card-bg);
    box-shadow: 0 8px 22px rgba(0,0,0,0.55);
}

.theme-dark .dropdown-item {
    color: var(--text-main);
}

.theme-dark .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.theme-dark .dropdown-item i {
    color: rgba(230, 237, 243, 0.7);
}

.turn-badge.not-my-turn {
    opacity: 0.55;
    color: #777;
    background: #f3f3f3;
}

.turn-badge::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    /* 移除 currentColor，改用具体样式控制 */
    background-color: #333;
    border: 1px solid rgba(0,0,0,0.1);
    transition: background-color 0.3s;
}

/* 黑方回合样式 */
.turn-badge.black-turn::before {
    background-color: #000;
    box-shadow: none;
}

/* 白方回合样式 */
.turn-badge.white-turn::before {
    background-color: #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.timer-badge {
    position: relative;
    background: #f5f5f5;
    color: #333;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    border: 1px solid #d9d9d9;
    overflow: hidden;
    min-width: 60px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.timer-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: #95de64; /* Default Green */
    z-index: 1;
    transition: width 1s linear, background-color 0.5s ease;
}

.timer-text {
    position: relative;
    z-index: 2;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

.spectator-match-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.06);
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
}

.spectator-match-info.hidden {
    display: none;
}

.spectator-match-player {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.spectator-match-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
}

.spectator-match-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    display: inline-block;
    flex: 0 1 clamp(64px, 20vw, 120px);
}

.spectator-match-name .name-text {
    display: inline-block;
    white-space: nowrap;
    transform: translateX(0);
    will-change: transform;
}

.spectator-match-name.name-scroll {
    text-overflow: clip;
}

.spectator-match-name.name-scroll .name-text {
    animation: playerNameScroll var(--name-scroll-duration, 4s) ease-in-out infinite;
}

.spectator-match-piece {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex: 0 0 auto;
}

.spectator-match-piece.black {
    background: #000;
}

.spectator-match-piece.white {
    background: #fff;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

.spectator-match-vs {
    font-size: 11px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.4);
    letter-spacing: 0.6px;
    flex: 0 0 auto;
}

.refresh-icon {
    font-size: 20px;
    font-weight: bold;
}

.board-container {
    flex: 1; /* 占据剩余空间 */
    display: flex;
    justify-content: center;
    align-items: center; /* 垂直居中 */
    position: relative;
    width: 100%;
    min-height: 0; /* 关键：允许 flex 子项缩小 */
    padding: 10px 0;
}

#chessboard {
    background-color: var(--board-color);
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    max-width: 100%;
    max-height: 80vh; /* 防止过高超出屏幕太多 */
    width: auto;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

#message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#message-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.message-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    width: 80%;
    max-width: 320px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#message-overlay.show .message-box {
    transform: scale(1);
}

#message-title {
    margin: 0 0 10px;
    font-size: 24px;
    color: var(--primary-color);
}

#message-content {
    margin: 0 0 20px;
    color: var(--text-sub);
    line-height: 1.5;
}

.message-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Game Menu Dropdown */
.menu-dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 140px;
    z-index: 100;
    margin-top: 5px;
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: none;
    border: none;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-item i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
    color: #666;
}
