* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1400px;
    padding: 20px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* 登录界面 */
.login-box {
    background: white;
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 450px;
    margin: 0 auto;
}

.login-box h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.input-group {
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-small {
    padding: 10px 20px;
    font-size: 14px;
}

.tips {
    margin-top: 20px;
    padding: 15px;
    background: #f0f4ff;
    border-radius: 10px;
    color: #667eea;
    font-size: 14px;
}

/* 游戏界面 */
#gameScreen {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h2 {
    font-size: 1.8em;
}

.room-info {
    font-size: 1.1em;
    background: rgba(255,255,255,0.2);
    padding: 8px 15px;
    border-radius: 20px;
}

.main-content {
    display: flex;
    gap: 20px;
    padding: 20px;
    min-height: 600px;
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.players-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
}

.players-panel h3 {
    margin-bottom: 15px;
    color: #667eea;
}

#playersList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-item {
    background: white;
    padding: 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.player-name {
    font-weight: bold;
    color: #333;
}

.player-score {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.chat-panel {
    flex: 1;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
}

.chat-panel h3 {
    margin-bottom: 15px;
    color: #667eea;
}

#chatMessages {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 15px;
    overflow-y: auto;
    max-height: 300px;
    margin-bottom: 10px;
}

.chat-message {
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-nickname {
    font-weight: bold;
    color: #667eea;
    margin-right: 5px;
}

.chat-time {
    font-size: 12px;
    color: #999;
    margin-left: 5px;
}

.chat-text {
    color: #333;
}

.system-message {
    text-align: center;
    color: #999;
    font-style: italic;
    font-size: 14px;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
}

.chat-input {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.chat-input button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.chat-input button:hover {
    background: #5568d3;
}

/* 游戏区域 */
.game-area {
    flex: 1;
}

.game-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: #f8f9fa;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #e9ecef;
}

.game-content {
    display: none;
}

.game-content.active {
    display: block;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

/* 词语信息区域 */
.word-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.word-display {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
    padding: 12px 20px;
    background: #f0f4ff;
    border-radius: 10px;
    min-width: 200px;
    text-align: center;
}

.timer {
    font-size: 2em;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 10px 20px;
    border-radius: 50%;
    min-width: 70px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    animation: pulse 1s infinite;
}

.timer.warning {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    animation: shake 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.hint-btn, .skip-btn {
    background: #ffa500;
    color: white;
}

.hint-btn:hover, .skip-btn:hover {
    background: #ff8c00;
}

/* 绘画控制区域 */
.drawing-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-group label {
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

/* 画笔粗细 */
.brush-size {
    display: flex;
    gap: 5px;
}

.size-btn {
    padding: 8px 15px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s;
}

.size-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.size-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 工具按钮 */
.tool-btn {
    background: #6c757d;
    color: white;
}

.tool-btn:hover {
    background: #5a6268;
}

.tool-btn.active {
    background: #28a745;
}

/* 颜色选择器 */
.color-picker {
    display: flex;
    gap: 6px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.color-btn:hover {
    transform: scale(1.15);
}

.color-btn.active {
    border-color: #333;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
    transform: scale(1.1);
}

/* 画布容器 */
.canvas-container {
    position: relative;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

#drawingCanvas {
    display: block;
    width: 100%;
    height: auto;
    border: 3px solid #667eea;
    border-radius: 15px;
    background: white;
    cursor: crosshair;
}

#drawingCanvas.eraser-mode {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text y="18" font-size="20">🧹</text></svg>') 12 12, auto;
}

/* 倒计时遮罩 */
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10em;
    font-weight: bold;
    color: white;
    z-index: 10;
    animation: countdownPulse 1s ease;
}

.countdown-overlay.show {
    display: flex;
}

@keyframes countdownPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* 五子棋 */
.gomoku-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 0;
    max-width: 600px;
    margin: 20px auto;
    background: #DEB887;
    padding: 10px 10px 10px 10px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    position: relative;
}

/* 棋盘网格线 */
.gomoku-board::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background-image: 
        linear-gradient(to right, #8B4513 1px, transparent 1px),
        linear-gradient(to bottom, #8B4513 1px, transparent 1px);
    background-size: calc(100% / 15) calc(100% / 15);
    pointer-events: none;
}

.gomoku-cell {
    aspect-ratio: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.gomoku-cell:hover:not(.filled)::after {
    content: '';
    width: 90%;
    height: 90%;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
}

.gomoku-cell.filled {
    cursor: not-allowed;
}

.gomoku-cell.filled::before {
    content: '';
    width: 90%;
    height: 90%;
    border-radius: 50%;
    position: absolute;
    z-index: 1;
    transition: all 0.2s;
}

.gomoku-cell.black::before {
    background: radial-gradient(circle at 30% 30%, #555, #000);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.gomoku-cell.white::before {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.game-status {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .chat-panel {
        max-height: 300px;
    }
}

/* Toast 动画 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 按钮hover效果增强 */
.btn-small {
    transition: all 0.3s ease;
}

.btn-small:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-small:active:not(:disabled) {
    transform: translateY(0);
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 玩家列表动画 */
.player-item {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .chat-panel {
        max-height: 300px;
    }
    
    .drawing-controls {
        justify-content: center;
    }
    
    .tool-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .login-box {
        padding: 30px 20px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .header h2 {
        font-size: 1.5em;
    }

    .game-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .word-info {
        justify-content: center;
    }
    
    .word-display {
        font-size: 1.1em;
        min-width: auto;
    }
    
    .timer {
        font-size: 1.5em;
        min-width: 60px;
        padding: 8px 15px;
    }
    
    .drawing-controls {
        padding: 10px;
        gap: 10px;
    }
    
    .tool-group label {
        font-size: 12px;
    }
    
    .size-btn, .btn-small {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .color-btn {
        width: 28px;
        height: 28px;
    }

    #drawingCanvas {
        width: 100%;
        height: auto;
    }
    
    .countdown-overlay {
        font-size: 6em;
    }

    .gomoku-board {
        max-width: 100%;
        padding: 5px;
    }
    
    .chat-panel {
        min-height: 250px;
    }
}

@media (max-width: 480px) {
    .login-box h1 {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .word-display {
        font-size: 1em;
        padding: 10px 15px;
    }
    
    .timer {
        font-size: 1.3em;
        min-width: 50px;
        padding: 6px 12px;
    }
    
    .drawing-controls {
        gap: 8px;
    }
    
    .tool-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .countdown-overlay {
        font-size: 4em;
    }
    
    .gomoku-board {
        max-width: 100%;
        padding: 3px;
    }
}

