/* 保留所有原有样式，优化头像相关样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

:root {
    --primary: #10B981;
    --primary-light: #d1fae5;
    --success: #52c41a;
    --secondary: #6B7280;
    --green-500: #10B981;
    --green-600: #059669;
    --green-700: #047857;
    --green-800: #065F46;
    --gray-200: #f5f5f5;
    --gray-300: #e5e5e5;
    --gray-400: #d1d5db;
    --gray-500: #6B7280;
    --warning: #faad14;
    --danger: #ff4d4f;
    --border: #e5e5e5;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --drawer-border: 3px solid var(--primary); /* 画手高亮边框 */
    --gradient-primary: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-success: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
    --gradient-secondary: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
    --gradient-warning: linear-gradient(135deg, #faad14 0%, #d48806 100%);
    --gradient-danger: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    padding: 20px;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.page-title {
    text-align: center;
    color: var(--primary);
    margin-bottom: 30px;
    font-size: 32px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-bottom: 15px;
}

.page-title::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

.room-login {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.room-login::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4CAF50, #2196F3, #FF9800);
}

.login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.login-header h3 {
    color: #333;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.login-icon {
    font-size: 28px;
    opacity: 0.8;
}

.nickname-display {
    margin-bottom: 25px;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary-light), #e3f2fd);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nickname-label {
    font-weight: 500;
    color: #555;
    font-size: 16px;
}

.nickname-value {
    font-weight: 600;
    color: var(--primary);
    font-size: 16px;
}

.action-cards {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
    align-items: center;
}

.action-card {
    background: transparent;
    border-radius: 0;
    overflow: visible;
    border: none;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.card-header {
    background: transparent;
    padding: 0 0 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
}

.card-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.card-icon {
    font-size: 20px;
    opacity: 0.7;
}

.card-content {
    padding: 0;
}

.input-group {
    display: flex;
    justify-content: flex-start;
}

.input-with-button {
    display: flex;
    width: 100%;
    max-width: 300px;
}

.btn-block {
    width: 100%;
    max-width: 200px;
    display: block;
    padding: 12px 15px;
    font-size: 14px;
    height: 42px;
    box-sizing: border-box;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    outline: none;
    color: white;
}

.input-with-button button {
    padding: 12px 15px;
    height: 42px;
    box-sizing: border-box;
}

.room-list-section {
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e9ecef;
}

.section-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
}

.section-header h4 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.section-icon {
    font-size: 18px;
    opacity: 0.7;
}

.room-list {
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .action-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .room-login {
        padding: 20px;
    }
    
    .login-header h3 {
        font-size: 20px;
    }
    
    .login-icon {
        font-size: 24px;
    }
    
    .card-content {
        padding: 15px;
    }
}

.input-group {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.input-with-button {
    display: flex;
    width: 100%;
    max-width: 300px;
}

.input-with-button input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 6px 0 0 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
    height: 42px;
    box-sizing: border-box;
}

.input-with-button input:focus {
    border-color: var(--primary);
}

.input-with-button button {
    padding: 12px 15px;
    border: none;
    border-radius: 0 6px 6px 0;
    background-color: var(--primary);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    height: 42px;
    box-sizing: border-box;
}

.input-with-button button:hover {
    background-color: #059669;
}

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

.room-list-section {
    margin-bottom: 15px;
    text-align: left;
}

.room-list-section h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
}

.room-list {
    height: auto;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    background: white;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.room-list::-webkit-scrollbar {
    width: 6px;
}

.room-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.room-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.room-list::-webkit-scrollbar-thumb:hover {
    background: #3388ff;
}

.room-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background-color: white;
    border-radius: 8px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

.room-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.room-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.room-id {
    font-weight: 600;
    color: var(--primary); /* 绿色 */
    font-family: 'Comic Sans MS', cursive, sans-serif; /* 卡通字体 */
    font-size: 18px; /* 增大字体 */
    text-shadow: 1px 1px 0 var(--primary-light); /* 绿色文字阴影 */
    margin-right: 10px;
}

.room-count {
    font-size: 14px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
}

/* 人数图标 */
.room-count::before {
    content: "👥";
    margin-right: 5px;
    font-size: 16px;
}

.join-room-btn {
    padding: 8px 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.join-room-btn:hover {
    background-color: #059669;
    transform: scale(1.05);
}

.join-active-game {
    background-color: #52c41a;
}

.join-active-game:hover {
    background-color: #389e0d;
}

/* 游戏中状态样式 */
.game-status {
    padding: 6px 12px;
    background-color: #FED7D7;
    color: #C53030;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

/* 游戏中图标 */
.game-status::before {
    content: "🎮";
    margin-right: 5px;
    font-size: 14px;
}

.room-login input {
    padding: 12px 15px;
    width: 220px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

    .room-login input:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.2);
    }

#nicknameText {
    font-weight: bold;
    color: var(--primary);
    font-size: 18px;
}

.room-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-grow: 1;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.join-room-btn {
    margin-left: 10px;
    padding: 8px 12px;
    font-size: 12px;
}

.btn {
    padding: 12px 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    outline: none;
    height: 42px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

/* 按钮悬停效果 */
.btn:hover::before {
    left: 100%;
}

/* 一键邀请按钮 - 主绿色 */
.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }

/* 结束绘画和提交答案按钮 - 成功绿 */
.btn-success {
    background: var(--gradient-success);
    color: white;
}

    .btn-success:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }

/* 清空画布按钮 - 深绿 */
.btn-secondary {
    background: var(--gradient-secondary);
    color: white;
}

    .btn-secondary:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }

.btn-secondary.active {
    background: var(--primary);
    color: white;
}

/* 已移除的按钮样式 */
.btn-warning {
    background: var(--gradient-warning);
    color: white;
}

    .btn-warning:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

    .btn-danger:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }

.error-text {
    color: var(--danger);
    margin-top: 10px;
    font-size: 14px;
    height: 20px;
    line-height: 20px;
}

.game-container {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--gradient-primary);
}

/* 玩家头像总区域：整合为一个区域，包含标题和头像列表 */
.players-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--gray-200);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.players-title {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.players-title::before {
    content: "👥";
    margin-right: 8px;
    font-size: 18px;
}

.player-avatars-list {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* 玩家容器：包含头像列表和邀请按钮 */
.players-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* 邀请区域样式：移到玩家列表右侧 */
.invite-section {
    margin-left: 20px;
    flex-shrink: 0;
}

/* 统一玩家头像样式（强化兜底，确保视觉可见） */
.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333 !important; /* 强制深色文字，避免与浅色背景融合 */
    font-weight: 600;
    font-size: 16px;
    position: relative;
    transition: all 0.3s;
    border: 1px solid #eee; /* 增加边框，让头像轮廓更明显 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player-avatar:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

    /* 画手头像高亮：强化视觉效果 */
    .player-avatar.drawer {
        border: 2px solid #9C27B0 !important; /* 紫色边框 */
        box-shadow: 0 0 12px rgba(156, 39, 176, 0.6), 0 0 0 2px rgba(156, 39, 176, 0.3) !important;
        transform: scale(1.05); /* 轻微放大，突出画手 */
        position: relative;
        animation: drawerGlow 1.5s infinite alternate;
    }

    .player-avatar.drawer::after {
        content: "✏️";
        position: absolute;
        top: -8px;
        right: -8px;
        background: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    /* 画手头像发光动画 */
    @keyframes drawerGlow {
        0% {
            box-shadow: 0 0 12px rgba(156, 39, 176, 0.6), 0 0 0 2px rgba(156, 39, 176, 0.3);
        }
        100% {
            box-shadow: 0 0 18px rgba(156, 39, 176, 0.8), 0 0 0 3px rgba(156, 39, 176, 0.4);
        }
    }

    .player-avatar .nickname-tooltip {
        position: absolute;
        bottom: -25px;
        left: 50%;
        transform: translateX(-50%);
        background: #333;
        color: white !important;
        padding: 2px 8px;
        border-radius: 4px;
        font-size: 12px;
        white-space: nowrap;
        display: none;
        z-index: 10; /* 提升层级，避免被遮挡 */
    }

    .player-avatar:hover .nickname-tooltip {
        display: block;
    }



.canvas-wrapper {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    background: white;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.word-display {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--gray-200);
    color: var(--primary);
    padding: 15px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-bottom: 3px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.word-info {
    display: flex;
    flex-direction: column;
}

.word-label {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 5px;
    color: var(--primary);
}

.word-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* 移除动画效果，防止文本大小变化 */
    white-space: nowrap; /* 防止文本换行 */
    overflow: hidden; /* 防止内容溢出 */
    text-overflow: ellipsis; /* 文本过长时显示省略号 */
    color: var(--primary);
}

/* 移除了 pulse 动画，防止文本大小变化 */

#drawCanvas {
    width: 100%;
    height: 450px;
    display: block;
    margin-top: 80px; /* 为词显示区域留出空间 */
}

.draw-tools {
    display: none;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
}

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

.tool-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.preset-brushes {
    display: flex;
    gap: 10px;
    margin-left: 15px;
}

.preset-brush {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--border);
    transition: all 0.2s;
}

    .preset-brush:hover {
        box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.2);
    }

    .preset-brush.active {
        box-shadow: 0 0 0 2px var(--primary);
    }

#colorPicker {
    width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    background: transparent;
}

#lineWidth {
    padding: 8px;
    width: 80px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.message-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--light-gray);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.message-title {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.message-title::before {
    content: "💬";
    margin-right: 8px;
    font-size: 18px;
}

.message-area {
    height: 150px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    background: white;
    font-size: 14px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.message-area::-webkit-scrollbar {
    width: 6px;
}

.message-area::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.message-area::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.message-area::-webkit-scrollbar-thumb:hover {
    background: #3388ff;
}

    .message-area div {
        margin-bottom: 8px;
        padding: 5px 0;
        border-bottom: 1px dashed #eee;
    }

        .message-area div:last-child {
            border-bottom: none;
        }

.guess-section {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: var(--gray-200);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

#guessInput {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.3s;
}

    #guessInput:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }

/* 添加页面加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.room-login, .game-container {
    animation: fadeIn 0.5s ease-out;
}

/* 添加悬停效果 */
.room-item, .player-avatar, .btn {
    animation: fadeIn 0.5s ease-out;
}

/* 改进输入框样式 */
.room-login input, .input-with-button input, #guessInput {
    transition: all 0.3s ease;
}

.room-login input:focus, .input-with-button input:focus, #guessInput:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 添加页面底部样式 */
body::after {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--gradient-primary);
    z-index: 1000;
}

@media (max-width: 768px) {
    .input-group {
        flex-direction: column;
        align-items: center;
    }

    .draw-tools {
        flex-wrap: wrap;
    }

    #drawCanvas {
        height: 300px;
    }

    .players-container {
        flex-direction: column;
        align-items: center;
    }
    
    .player-avatars-list {
        justify-content: center;
    }

    .invite-section {
        margin-left: 0;
        margin-top: 10px;
        text-align: center;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .room-login, .game-container {
        padding: 20px;
    }
}