/* 全局样式重置与基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --uno: #EC4899;
    --primary: #000000;
}

body {
    background-color: #f5f7fa;
    min-height: 100vh;
    padding: 10px; /* 移动端减少内边距 */
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.container {
    background-color: white;
    padding: 15px; /* 移动端减少内边距 */
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%; /* 宽度自适应 */
    max-width: 100%; /* 移动端取消最大宽度限制 */
}

/* 房间区域样式 */
.room-section {
    margin-bottom: 15px; /* 移动端减少间距 */
    padding: 25px; /* 增加内边距，使界面更加舒适 */
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background-color: #fafafa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); /* 添加轻微阴影 */
}

    .room-section h2 {
        margin-bottom: 20px; /* 增加标题下方间距 */
        color: #2d3748;
        font-size: 22px; /* 稍微增大标题字体 */
        font-weight: 600;
        text-align: center; /* 移动端居中标题 */
        position: relative; /* 添加相对定位 */
        padding-bottom: 10px; /* 添加底部内边距 */
    }

    .room-section h2:after {
        content: "" /* 添加伪元素作为装饰线 */;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 250px;
        height: 3px;
        background-color: var(--uno);
        border-radius: 2px;
    }

.input-group {
    margin-bottom: 10px; /* 移动端减少间距 */
    display: flex;
    flex-direction: column; /* 移动端改为纵向排列 */
    align-items: stretch; /* 拉伸输入框 */
}

    .input-group label {
        display: block;
        width: 100%;
        font-weight: 500;
        color: #4a5568;
        margin-bottom: 5px; /* 移动端添加标签与输入框的间距 */
        font-size: 14px;
    }

    .input-group input {
        padding: 10px 12px;
        width: 100%; /* 输入框宽度100% */
        border: 1px solid #cbd5e0;
        border-radius: 8px;
        font-size: 14px;
        transition: border-color 0.2s ease;
    }

        .input-group input:focus {
            outline: none;
            border-color: var(--uno);
            box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.1);
        }

/* 昵称显示样式 */
.nickname-display {
    margin-bottom: 15px;
    padding: 12px;
    background-color: rgba(236, 72, 153, 0.1);
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

#nicknameText {
    font-weight: bold;
    color: var(--uno);
}

/* 输入框与按钮组合样式 */
.input-with-button {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-button input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.input-with-button input:focus {
    outline: none;
    border-color: var(--uno);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.1);
}

.input-with-button button {
    flex-shrink: 0;
    padding: 10px 16px;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: auto; /* 按钮宽度自适应内容 */
    margin: 0; /* 重置按钮边距 */
}

.input-with-button button:hover {
    transform: translateY(-2px);
}

.input-with-button button:active {
    transform: translateY(0);
}

/* 按钮样式变体 */
/* 进入房间按钮 - 保持蓝色 */
.btn-primary {
    background-color: #EC4899; /* 主粉色 */
}

.btn-primary:hover {
    background-color: #DB2777; /* 深粉色 */
    box-shadow: 0 4px 8px rgba(236, 72, 153, 0.2);
}

/* 创建房间按钮 */
.btn-success {
    background-color: #F472B6; /* 浅粉色 */
}

.btn-success:hover {
    background-color: #EC4899; /* 主粉色 */
}

/* 准备按钮 */
button[onclick="playerReady()"] {
    background-color: #FB7185; /* 亮粉色 */
}

button[onclick="playerReady()"]:hover {
    background-color: #F43F5E; /* 深亮粉色 */
}

/* 抽牌按钮 */
button[onclick="drawCard()"] {
    background-color: #EC4899; /* 主粉色 */
}

button[onclick="drawCard()"]:hover {
    background-color: #DB2777; /* 深粉色 */
    box-shadow: 0 4px 8px rgba(236, 72, 153, 0.2);
}

/* 错误消息样式 */
.error-message {
    color: #e53e3e;
    font-size: 14px;
    margin-top: 5px;
    padding: 8px 12px;
    background-color: rgba(229, 62, 62, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(229, 62, 62, 0.2);
    display: none; /* 默认隐藏 */
}

/* 按钮组样式 */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* 允许按钮在移动端换行 */
}

    .button-group button {
        flex: 1;
        min-width: 120px; /* 设置最小宽度，确保按钮不会太小 */
        margin: 15px auto;
    }

/* 房间列表样式 */
.room-list-section {
    margin-top: 20px;
}

.room-list-section h4 {
    margin-bottom: 10px;
    color: #4a5568;
    font-size: 16px;
    font-weight: 600;
}

.room-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    background-color: #f7fafc;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 6px;
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.room-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-id {
    font-weight: 600;
    color: #EC4899; /* 粉色 */
    font-family: 'Comic Sans MS', cursive, sans-serif; /* 卡通字体 */
    font-size: 18px; /* 增大字体 */
    text-shadow: 1px 1px 0 #F472B6; /* 粉色文字阴影 */
}

.room-count {
    font-size: 14px;
    color: #718096;
    display: flex;
    align-items: center;
    margin: 0;
}

/* 人数图标 */
.room-count::before {
    content: "👥";
    margin-right: 5px;
    font-size: 16px;
}

.join-room-btn {
    padding: 6px 12px;
    background-color: var(--uno);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.join-room-btn:hover {
    background-color: #db2777;
}

.join-room-btn:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

/* 游戏中状态样式 */
.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;
}

/* 按钮通用样式 */
button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 8px; /* 移动端减少间距 */
    margin-bottom: 10px; /* 移动端添加底部间距 */
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

    button:hover {
        background-color: #45a049;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
    }

    button:active {
        transform: translateY(0);
    }

    button:disabled {
        background-color: #cccccc;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

/* 一键邀请按钮 */
.invite-btn {
    background-color: #BE185D; /* 深粉色 */
}

    .invite-btn:hover {
        background-color: #9D174D; /* 更深粉色 */
    }

/* 玩法说明按钮样式（重点：缩小手机端尺寸） */
.rule-btn {
    background-color: #F472B6 !important; /* 浅粉色 */
    /* 手机端基础缩小样式 */
    padding: 6px 12px !important;
    font-size: 12px !important;
    width: auto !important; /* 取消100%宽度，自适应内容 */
    white-space: nowrap; /* 防止文字换行 */
}

/* 开始游戏按钮 */
button[onclick="startGame()"] {
    background-color: #D946EF; /* 粉紫色 */
}

button[onclick="startGame()"]:hover {
    background-color: #C026D3; /* 深粉紫色 */
}

button[onclick="startGame()"]:disabled {
    background-color: #A0AEC0;
    cursor: not-allowed;
}

/* 大屏下恢复玩法说明按钮原有尺寸 */
@media (min-width: 768px) {
    .rule-btn {
        padding: 10px 20px !important;
        font-size: 14px !important;
    }

    .button-group {
        margin-left: 15px;
    }
}

/* 移除原有灰色提示框样式，新增提醒文本样式 */
.remind-text {
    margin-left: 10px;
    font-size: 14px;
    color: #e53e3e;
    display: inline-block;
    vertical-align: middle;
}

/* 游戏区域样式 */
.game-section {
    display: none;
    margin-top: 15px; /* 移动端减少间距 */
    width: 100%;
}

/* 房间码+玩法说明容器样式（适配移动端） */
.room-code-rule-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap; /* 移动端换行 */
    gap: 10px; /* 移动端添加间距 */
}

    .room-code-rule-container h2 {
        margin: 0;
        color: #2d3748;
        font-weight: 600;
        font-size: 20px; /* 移动端缩小字体 */
    }

/* 玩家列表样式 - 可折叠（游戏开始后隐藏） */
.players-list-container {
    margin: 15px 0; /* 移动端减少间距 */
    width: 100%;
    display: block;
}

/* 出牌顺序头像容器 */
.player-avatar-container {
    margin: 15px 0;
    width: 100%;
    overflow-x: auto;
    padding: 10px 0;
    display: none; /* 初始隐藏，游戏开始后显示 */
}

.player-avatar-list {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

/* 玩家头像样式 */
.player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column; /* 垂直排列名字和倒计时 */
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    border: 2px solid #cccccc;
    flex-shrink: 0;
    /* 名字加框效果 */
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: all 0.3s ease; /* 过渡效果 */
}

    /* 当前出牌玩家高亮 */
    .player-avatar.highlight {
        border-color: #9c27b0; /* 紫色高亮 */
        box-shadow: 0 0 8px rgba(156, 39, 176, 0.5);
        background-color: #f3e5f5;
    }

    /* 剩余1-2张手牌时头像粉色样式 */
    .player-avatar.low-cards {
        border-color: #ff69b4; /* 粉色边框 */
        background-color: #ffe6f2; /* 浅粉色背景 */
        box-shadow: 0 0 8px rgba(255, 105, 180, 0.5);
    }

/* 倒计时样式 */
.countdown {
    font-size: 10px;
    color: #e53e3e;
    font-weight: bold;
    margin-top: 2px;
}

.players-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 10px 15px;
    background-color: #f8f8f8;
    border-radius: 8px 8px 0 0;
    border: 1px solid #e0e0e0;
    border-bottom: none;
}

    .players-list-header h3 {
        margin: 0;
        color: #4a5568;
        font-weight: 500;
        font-size: 16px; /* 移动端缩小字体 */
    }

.players-list-toggle {
    font-size: 16px; /* 移动端缩小字体 */
    color: #4a5568;
    transition: transform 0.2s ease;
}

.players-list-content {
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 0 0 8px 8px;
    border: 1px solid #e0e0e0;
    display: block;
}

    /* 折叠状态的样式 */
    .players-list-content.collapsed {
        display: none;
    }

.players-list-toggle.rotated {
    transform: rotate(180deg);
}

.player-item {
    margin: 5px 0; /* 移动端减少间距 */
    padding: 8px;
    border-bottom: 1px solid #eee;
    color: #2d3748;
    font-size: 14px; /* 移动端缩小字体 */
}

    .player-item:last-child {
        border-bottom: none;
    }

/* 移除原有回合提示框样式 */
.turn-status {
    display: none;
}

/* 弃牌堆+已出牌 横向布局样式（弃牌堆左，已出牌右） */
.discard-played-container {
    margin: 15px 0;
    width: 100%;
    display: flex;
    flex-direction: row; /* 横向排列，弃牌堆左，已出牌右 */
    align-items: flex-start;
    gap: 20px; /* 间距 */
    flex-wrap: wrap; /* 移动端换行 */
}

.discard-pile {
    margin: 0;
    width: auto;
    flex-shrink: 0; /* 不被压缩 */
}

    .discard-pile h3 {
        margin-bottom: 5px;
        color: #4a5568;
        font-weight: 500;
        font-size: 16px; /* 移动端缩小字体 */
    }

/* 已出牌区域样式 - 横向滚动 */
.played-cards {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    flex: 1; /* 占剩余宽度 */
    overflow-x: auto; /* 横向滚动 */
    white-space: nowrap; /* 防止换行 */
    min-width: 200px; /* 移动端最小宽度 */
}

    .played-cards h4 {
        margin-bottom: 10px;
        color: #718096;
        font-weight: 500;
        font-size: 14px; /* 移动端缩小字体 */
        /* 标题固定，不随滚动条移动 */
        position: sticky;
        top: 0;
        background-color: #fafafa;
        padding-bottom: 5px;
        z-index: 10;
    }

.played-cards-container {
    display: flex;
    flex-wrap: nowrap; /* 不换行，横向排列 */
    gap: 5px;
    padding-bottom: 5px;
}

/* 手牌区域样式 */
.hand-cards {
    margin: 15px 0; /* 移动端减少间距 */
    width: 100%;
    display: none; /* 初始隐藏，游戏开始后显示 */
}

    .hand-cards h3 {
        margin-bottom: 10px; /* 移动端减少间距 */
        color: #4a5568;
        font-weight: 500;
        font-size: 16px; /* 移动端缩小字体 */
    }

/* 手牌提示文本样式（灰色，放在抽牌按钮后） */
.card-action-tip {
    color: #718096; /* 灰色 */
    font-size: 14px;
    margin-left: 10px; /* 与抽牌按钮的间距 */
    display: inline-block;
    vertical-align: middle;
}

/* 卡牌样式 - 响应式调整尺寸 */
.card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px; /* 移动端缩小卡牌宽度 */
    height: 90px; /* 移动端缩小卡牌高度 */
    margin: 3px; /* 移动端减少间距 */
    border-radius: 8px;
    font-size: 18px; /* 移动端缩小字体 */
    font-weight: bold;
    color: white;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* 防止卡牌被压缩 */
}

/* 卡牌颜色样式 */
.card-red {
    background-color: #f44336;
}

.card-yellow {
    background-color: #ffeb3b;
    color: black;
}

.card-green {
    background-color: #4CAF50;
}

.card-blue {
    background-color: #2196F3;
}

.card-black {
    background-color: #000;
}

/* 已出牌的浅色样式 */
.card.played {
    opacity: 0.4;
    cursor: default;
    border-color: #e0e0e0;
    transform: scale(0.95);
}

/* 卡牌选中样式 */
.card.selected {
    border: 3px solid #ffd700;
    transform: scale(1.08);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 可出牌样式 - 紫色高亮边框 */
.card.playable {
    border: 3px solid #9c27b0; /* 紫色 */
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.5); /* 紫色阴影，增强高亮 */
    cursor: pointer;
}

/* 不可出牌样式 */
.card.unplayable {
    opacity: 0.7;
    border: 3px solid #cccccc;
    cursor: not-allowed;
}

/* 颜色选择区域样式 */
.color-select {
    display: none;
    margin: 15px 0; /* 移动端减少间距 */
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    width: 100%;
    text-align: center; /* 移动端居中 */
}

    .color-select h3 {
        margin-bottom: 10px; /* 移动端减少间距 */
        color: #4a5568;
        font-weight: 500;
        font-size: 16px; /* 移动端缩小字体 */
    }

.color-option {
    display: inline-block;
    width: 40px; /* 移动端缩小颜色选项 */
    height: 40px; /* 移动端缩小颜色选项 */
    margin: 0 8px; /* 移动端减少间距 */
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

    .color-option:hover {
        border: 2px solid #ffd700;
        transform: scale(1.1);
    }

/* 隐藏元素样式 */
.hidden {
    display: none !important;
}

/* 游戏结束遮罩样式 - 响应式调整 */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
    font-size: 24px; /* 移动端缩小字体 */
    font-weight: bold;
    display: none;
    padding: 20px; /* 移动端添加内边距 */
}

.game-over-text {
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.5; /* 移动端增加行高 */
}

.game-over-button {
    padding: 10px 24px;
    font-size: 16px; /* 移动端缩小字体 */
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 80%; /* 移动端按钮宽度80% */
}

    .game-over-button:hover {
        background-color: #45a049;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
    }

/* 抽牌按钮与提醒文本容器 - 默认隐藏，游戏开始后显示 */
.draw-card-container {
    display: none;
    align-items: center;
    flex-wrap: wrap; /* 移动端换行 */
    margin: 15px 0;
}

/* 玩法说明弹窗样式（适配移动端） */
.rule-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 10px; /* 移动端添加内边距 */
}

.rule-modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #2d3748;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

    .rule-modal-content h3 {
        margin: 0;
        color: #EC4899; /* 主粉色 */
        font-weight: 600;
    }

.rule-content {
    font-size: 14px;
    line-height: 1.6;
    margin-top: 10px;
}

    .rule-content h4 {
        margin: 10px 0;
        color: #4a5568;
    }

    .rule-content p, .rule-content ul {
        margin: 5px 0;
    }

    .rule-content ul {
        padding-left: 20px;
    }

/* 媒体查询 - 大屏设备（平板/电脑）恢复原有样式 */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    .container {
        padding: 30px;
        max-width: 1200px;
    }

    .room-section {
        margin-bottom: 30px;
        padding: 25px;
    }

        .room-section h2 {
            font-size: 24px;
            margin-bottom: 20px;
            text-align: center;
        }

    .input-group {
        flex-direction: row;
        align-items: center;
        margin: 0 auto 15px;
        display: flex;
        justify-content: center;
        width: fit-content;
    }

        .input-group label {
            width: 90px;
            margin-bottom: 0;
            margin-right: 10px;
        }

        .input-group input {
            width: 250px;
        }

    button {
        width: auto;
        margin-bottom: 0;
        margin-right: 12px;
    }

    .game-section h2 {
        font-size: 24px;
        text-align: left;
        margin-bottom: 20px;
    }

    /* 大屏房间码+玩法说明容器样式 */
    .room-code-rule-container {
        flex-wrap: nowrap; /* 大屏不换行 */
        gap: 0;
    }

    .players-list-header h3 {
        font-size: 18px;
    }

    .players-list-toggle {
        font-size: 18px;
    }

    .discard-pile h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    /* 大屏已出牌区域样式调整 */
    .played-cards {
        margin: 0;
    }

    .card {
        width: 80px;
        height: 120px;
        margin: 5px;
        font-size: 22px;
    }

    .color-option {
        width: 45px;
        height: 45px;
        margin: 0 12px;
    }

    .game-over-overlay {
        font-size: 32px;
    }

    .game-over-button {
        font-size: 18px;
        width: auto;
    }

    /* 大屏玩家头像尺寸 */
    .player-avatar {
        width: 70px;
        height: 70px;
        font-size: 16px;
    }

    /* 大屏倒计时字体 */
    .countdown {
        font-size: 12px;
    }

    /* 大屏玩法说明弹窗样式 */
    .rule-modal-content {
        padding: 30px;
        max-width: 800px;
        width: 70%;
    }

    .rule-content {
        font-size: 16px;
    }
}
