/* 通用样式 */
:root {
    --primary-color: #4a6cf7;
    --primary-dark: #3a5bd9;
    --secondary-color: #a777e3;
    --text-color: #333;
    --light-text: #666;
    --border-color: #ddd;
    --bg-color: #f0f2f5;
    --card-bg: #fff;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --playing-color: #e74c3c;
    --waiting-color: #f39c12;
}

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 登录容器 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    background-size: 200% 200%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 登录框样式 */
.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    text-align: center;
    transform: translateY(0);
    transition: transform 0.3s, box-shadow 0.3s;
}

.login-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.logo img {
    width: 200px;
    margin-bottom: 1rem;
}

.login-box h1 {
    color: #4a6cf7;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-box h2 {
    color: #555;
    margin-bottom: 2rem;
    font-size: 1.3rem;
    font-weight: 500;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
    text-align: left;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border 0.3s;
}

.form-group input:focus {
    border-color: #4a6cf7;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

/* 按钮样式 */
.login-btn {
    width: 100%;
    padding: 12px;
    background-color: #4a6cf7;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.login-btn:hover {
    background-color: #3a5bd9;
    transform: translateY(-2px);
}

.login-btn:active {
    transform: translateY(0);
}

/* 底部链接 */
.bottom-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.bottom-links a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s;
}

.bottom-links a:hover {
    color: #4a6cf7;
    text-decoration: underline;
}

/* 错误消息 */
.error-message {
    color: #e74c3c;
    margin: 1rem 0;
    padding: 10px;
    background: #fde8e8;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .login-box {
        padding: 1.5rem;
        margin: 0 15px;
    }
    
    .login-box h1 {
        font-size: 1.8rem;
    }
    
    .bottom-links {
        flex-direction: column;
        gap: 10px;
    }
}

/* 大厅容器 */
.lobby-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color);
    min-height: 100vh;
}

/* 头部样式 */
.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.lobby-header h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 2rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-weight: 600;
    color: var(--text-color);
}

.logout-btn {
    padding: 8px 15px;
    background-color: var(--error-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
}

.logout-btn:hover {
    background-color: #c0392b;
}

/* 创建房间区域 */
.create-room-section {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.create-room-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.3rem;
}

.create-room-form {
    display: flex;
    gap: 10px;
}

.room-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
}

.room-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.2);
}

.primary-btn {
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-btn.disabled-btn {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.primary-btn:hover:not(.disabled-btn) {
    background-color: #45a049;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
}

/* 房间列表区域 */
.room-list-section {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.room-list-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.3rem;
}

.room-list-header {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--light-text);
    margin-bottom: 10px;
}

.room-list-header span {
    padding: 0 10px;
}

.header-room-name {
    flex: 3;
}

.header-status, .header-players, .header-owner {
    flex: 1;
    text-align: center;
}

.header-action {
    flex: 1;
    text-align: right;
}

/* 房间项样式 */
.room-list {
    display: flex;
    flex-direction: column;
}

.room-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.room-item:last-child {
    border-bottom: none;
}

.room-name {
    flex: 3;
    font-weight: 500;
    padding: 0 10px;
}

.room-status, .room-players, .room-owner {
    flex: 1;
    text-align: center;
    padding: 0 10px;
}

.room-action {
    flex: 1;
    text-align: right;
    padding: 0 10px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
}

.status-badge.waiting {
    background-color: var(--waiting-color);
}

.status-badge.playing {
    background-color: var(--playing-color);
}

.join-btn {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.join-btn:hover {
    background-color: var(--primary-dark);
}

.playing-text {
    color: var(--light-text);
    font-size: 0.9rem;
}

.no-rooms {
    text-align: center;
    padding: 40px 0;
    color: var(--light-text);
    font-size: 1.1rem;
}

.captcha-grid {
    display: grid;
    grid-template-columns: 1fr 100px; /* 输入框占剩余空间，图片固定宽度 */
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 1rem;
    text-align: left;
}

.captcha-grid label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
    text-align: left;
    grid-column: span 2; /* 标签跨两列 */
}

.captcha-grid input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border 0.3s;
}

.captcha-grid input:focus {
    border-color: #4a6cf7;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

.captcha-img {
    max-width: 100%; /* 图片不超出列宽 */
    height: 40px; /* 固定高度 */
    object-fit: contain; /* 保持比例 */
}

/* 警告提示样式 */
.alert {
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* 创建房间按钮禁用状态 */
.primary-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.primary-btn:disabled:hover {
    background-color: #cccccc;
    transform: none;
}

/* 房间页面样式 */
.room-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.room-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.room-header h1 {
    color: #4a6cf7;
    margin-bottom: 10px;
}

.room-info {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.room-status {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.room-status.waiting {
    background-color: #f39c12;
    color: white;
}

.room-status.playing {
    background-color: #e74c3c;
    color: white;
}

.room-owner {
    color: #666;
}

/* 玩家列表 */
.player-list {
    margin-bottom: 30px;
}

.player-list h2 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.players {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.player-card {
    display: flex;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s;
}

.player-card.ready {
    background-color: #e8f5e9;
    border-left: 4px solid #2ecc71;
}

.player-card.offline {
    opacity: 0.6;
    filter: grayscale(50%);
}

.player-card.offline .player-name {
    text-decoration: line-through;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #4a6cf7;
    margin-right: 15px;
}

.player-info {
    flex: 1;
}

.player-name {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

.player-status {
    font-size: 0.8rem;
    color: #666;
}

.kick-btn {
    padding: 5px 10px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.kick-btn:hover {
    background-color: #c0392b;
}

/* 操作区域 */
.action-area {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.host-actions, .player-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.game-select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.primary-btn {
    padding: 10px 20px;
    background-color: #4a6cf7;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.primary-btn:hover {
    background-color: #3a5bd9;
}

.danger-btn {
    padding: 10px 20px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.danger-btn:hover {
    background-color: #c0392b;
}

.secondary-btn {
    padding: 10px 20px;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.secondary-btn:hover {
    background-color: #7f8c8d;
}

.ready-btn {
    padding: 10px 20px;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.ready-btn.cancel-ready {
    background-color: #e67e22;
}

.ready-btn:hover {
    opacity: 0.9;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .players {
        grid-template-columns: 1fr;
    }
    
    .host-actions, .player-actions {
        flex-direction: column;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .lobby-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .login-box {
        width: 90%;
        padding: 15px;
    }
    
    .create-room-form {
        flex-direction: column;
    }
    
    .room-list-header {
        display: none;
    }
    
    .room-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 20px 0;
        position: relative;
    }
    
    .room-name {
        flex: auto;
        width: 100%;
        font-weight: 600;
        font-size: 1.1rem;
    }
    
    .room-status, .room-players, .room-owner {
        flex: auto;
        width: 100%;
        text-align: left;
        padding: 2px 10px;
        font-size: 0.9rem;
        color: var(--light-text);
    }
    
    .room-status::before {
        content: "状态: ";
        font-weight: 500;
    }
    
    .room-players::before {
        content: "玩家: ";
        font-weight: 500;
    }
    
    .room-owner::before {
        content: "房主: ";
        font-weight: 500;
    }
    
    .room-action {
        position: absolute;
        right: 10px;
        top: 20px;
    }
}