/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a6fa5;
    --secondary-color: #5d8bb9;
    --accent-color: #ff9800;
    --bg-color: #f5f7fa;
    --text-color: #333;
    --border-radius: 8px;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --board-color: #e6c78f;
    --board-border: #a57a31;
}

body {
    font-family: "Microsoft YaHei", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif;
    background: linear-gradient(135deg, var(--bg-color), #e8f0ff);
    background-attachment: fixed;
    line-height: 1.6;
    color: var(--text-color);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 30px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-weight: bold;
}

/* 顶部导航栏 */
.navbar {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 15px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

/* 按钮样式 */
.btn {
    padding: 12px 22px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    margin: 5px;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.btn:hover::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(100, 100);
        opacity: 0;
    }
}

.btn-primary {
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-success {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: white;
}

.btn-info {
    background: linear-gradient(145deg, #1abc9c, #16a085);
    color: white;
}

.btn-secondary {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-danger {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

/* 首页菜单样式 */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 30px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(5px);
    margin-top: 20px;
}

.button-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 300px;
}

.button-group .btn {
    margin: 10px 0;
    padding: 15px;
    font-size: 18px;
}

#roomJoinForm {
    width: 100%;
    max-width: 300px;
    transition: var(--transition);
}

#roomIdInput {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: var(--transition);
}

#roomIdInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
    outline: none;
}

.share-options {
    margin-top: 20px;
    width: 100%;
}

.share-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#qrcode {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* 游戏页面样式 */
.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.player-status {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    background-color: rgba(255, 255, 255, 0.8);
}

.player-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #ccc;
    transition: var(--transition);
}

.player-0 .player-indicator {
    background-color: #000;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.player-1 .player-indicator {
    background-color: #fff;
    border: 1px solid #000;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.active .player-indicator {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
    transform: scale(1.1);
}

.game-message {
    text-align: center;
    font-weight: bold;
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--border-radius);
    background-color: rgba(255, 255, 255, 0.7);
}

/* 棋盘样式 */
.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.game-board-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    transition: var(--transition);
    touch-action: none;
}

.game-board {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 auto;
    background-color: var(--board-color);
    border: 2px solid var(--board-border);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: block;
    border-radius: 4px;
    transition: var(--transition);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* 棋盘单元格 */
.cell {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.6);
    background-color: var(--board-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.cell:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 棋子样式 */
.piece {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0);
    animation: appear 0.3s forwards;
}

@keyframes appear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 黑棋 */
.piece.player-1 {
    background: radial-gradient(circle at 30% 30%, #444, #000);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

/* 白棋 */
.piece.player-2 {
    background: radial-gradient(circle at 30% 30%, #fff, #f0f0f0);
    border: 1px solid #d1d1d1;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

/* 胜利高亮效果 */
.piece.winning {
    animation: winning-pulse 1.5s infinite;
}

@keyframes winning-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* 等待遮罩层样式 */
.waiting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    color: white;
    text-align: center;
    border-radius: var(--border-radius);
    backdrop-filter: blur(3px);
}

.waiting-content {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 80%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.waiting-content h2 {
    margin-bottom: 15px;
    color: #fff;
}

.waiting-content p {
    margin-bottom: 15px;
    color: #eee;
}

.waiting-content input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: var(--border-radius);
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
}

.waiting-content #qrcode {
    margin: 20px auto;
    padding: 10px;
    background-color: #fff;
    border-radius: var(--border-radius);
    width: fit-content;
}

/* 匹配页面样式 */
.matching-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-top: 40px;
}

.matching-container h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 28px;
}

.matching-container p {
    margin-bottom: 20px;
    color: var(--text-color);
}

.matching-container .button-group {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.debug-section {
    margin-top: 30px;
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: left;
}

.debug-section h3 {
    color: #666;
    font-size: 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

#connectionStatus {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    background-color: #f0f0f0;
    color: #666;
    margin-right: 10px;
    position: relative;
}

.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 5px;
    vertical-align: middle;
}

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

.hidden {
    display: none !important;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 600px) {
    .board .cell {
        width: 100%;
        padding-bottom: 100%;
    }
    
    .board .piece {
        top: 10%;
        left: 10%;
        width: 80%;
        height: 80%;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .room-info {
        flex-direction: column;
        width: 100%;
    }

    .container {
        padding: 15px 10px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .game-board-container {
        margin: 0 auto;
    }
    
    .game-board {
        width: 100%;
        height: auto;
        touch-action: none;
    }
    
    .status-bar {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .status-indicator, .game-status, .player-info {
        margin: 5px 0;
        width: 100%;
        text-align: center;
    }
    
    .game-controls .btn {
        padding: 12px 20px;
        font-size: 16px;
    }
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.status-indicator {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    background-color: #f1c40f;
    color: #333;
    margin: 5px;
    display: inline-flex;
    align-items: center;
    transition: var(--transition);
}

.status-indicator.connected {
    background-color: #2ecc71;
    color: white;
    padding-left: 12px;
}

.status-indicator.disconnected {
    background-color: #e74c3c;
    color: white;
    padding-left: 12px;
}

.game-status {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 20px;
}

.game-status.error {
    color: #e74c3c;
}

.player-info {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 500;
    color: var(--primary-color);
}

.btn-small {
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 4px;
}

.share-options {
    margin: 15px 0;
    width: 100%;
}

.share-options input {
    width: calc(100% - 120px);
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.qr-container p {
    margin-top: 10px;
    color: #888;
    font-size: 14px;
}

.highlight {
    animation: highlight 1s infinite alternate;
}

@keyframes highlight {
    from { box-shadow: 0 0 5px rgba(52, 152, 219, 0.5); }
    to { box-shadow: 0 0 15px rgba(52, 152, 219, 0.8); }
}

/* 状态框样式 */
.status-box {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 20px 0;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.status-box:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
}

.wait-time {
    font-size: 2.2em;
    font-weight: bold;
    margin: 25px 0 15px;
    color: var(--primary-color);
}

.queue-info {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;
    margin: 10px 0;
    font-size: 14px;
    color: #666;
}

#queueCount {
    font-weight: bold;
    color: var(--primary-color);
}

.match-status {
    font-style: italic;
    color: #666;
    margin-top: 15px;
    font-size: 14px;
}

.connection-status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 15px;
}

.connection-status.connected {
    background-color: #2ecc71;
    color: white;
}

.connection-status.disconnected {
    background-color: #e74c3c;
    color: white;
}

/* 调试区域 */
.debug-area {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(248, 248, 248, 0.9);
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    display: none;
}

.debug-area.show {
    display: block;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.debug-toggle {
    margin-top: 15px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    text-align: center;
    padding: 5px 15px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    display: inline-block;
}

.debug-toggle:hover {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
}

/* 添加动画和过渡效果 */
.fade-in {
    animation: fadeIn 0.5s;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 30px;
} 