/* ========== 自定义样式 custom.css ========== */

/* 全局重置 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', 'PingFang SC', sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* 游戏容器 */
#game-container { position: relative; width: 100%; height: 100%; }

/* 画布包装器 */
#canvas-wrapper {
    position: absolute;
    top: 50%; left: 50%;
    transform-origin: 0 0;
}

/* 画布 */
#game-canvas {
    display: block;
    background: #e5e5f0;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 255, 100, 0.15);
}

/* 状态栏 */
#status-bar {
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 10;
}
#score { color: #00ff88; }


#rules-link {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 100;                 /* 高于排行榜、暂停按钮等 */
    background: rgba(10, 10, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffd700;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    backdrop-filter: blur(6px);
    transition: background 0.2s;
}

#rules-link:hover {
    background: rgba(20, 20, 50, 0.9);
    color: #fff;
}



/* 排行榜 */
#leaderboard {
    position: absolute;
    top: 60px; right: 15px;
    width: 180px;
    max-height: 60%;
    background: rgba(10, 10, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #fff;
    padding: 12px;
    overflow-y: auto;
    backdrop-filter: blur(6px);
    z-index: 55;
    font-size: 14px;
}
#leaderboard h3 {
    text-align: center;
    margin-bottom: 8px;
    color: #ffd700;
    font-size: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 5px;
}
.lb-entry {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.lb-entry .name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lb-entry .points { color: #00ff88; font-weight: bold; }

/* 聊天框通用 */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    font-size: 13px;
    color: #f4362d;
    list-style: none;
}
#chat-messages li { margin-bottom: 4px; word-break: break-all; }
.chat-name { color: #ffcc00; font-weight: bold; }
.chat-system { color: #888; font-style: italic; }
#chat-input-area {
    display: flex;
    border-top: 1px solid rgba(255,255,255,0.2);
}
#chat-input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: none;
    padding: 8px 12px;
    color: #f4362d;               /* 输入文字颜色 */
    outline: none;
    font-size: 13px;
}
#chat-input::placeholder { color: #666; }
#chat-send {
    background: #00aa55;
    border: none;
    color: white;
    padding: 0 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
#chat-send:hover { background: #00cc66; }

/* 虚拟方向键（默认隐藏） */
.ctrl-btn {
    width: 55px; height: 55px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    color: white;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ctrl-row { display: flex; justify-content: center; }
.ctrl-btn:active { background: rgba(0, 255, 100, 0.5); border-color: #00ff88; }

/* 验证码 */
.captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}
#captcha-img {
    width: auto;
    height: 40px;
    background: #fff;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

/* 登录弹窗遮罩 */
#login-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-content {
    background: #1e1e3a;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 16px;
    padding: 30px 40px;
    text-align: center;
    color: #fff;
    min-width: 280px;
    backdrop-filter: blur(10px);
}
.modal-content h2 { margin-bottom: 20px; color: #ffd700; }
#login-modal .modal-content input {
    width: 100%;
    padding: 12px 15px;
    margin: 6px 0;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 18px;
    text-align: center;
    outline: none;
}
#login-modal .modal-content input::placeholder { color: #aaa; }
#login-modal .modal-content button {
    width: 100%;
    padding: 12px 0;
    margin: 8px 0;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
}
#login-btn { background: #00aa55; }
#login-btn:hover { background: #00cc66; }
#register-btn { background: #008CBA; }
#register-btn:hover { background: #00a5d9; }
#chongzhi-btn { background: #851494; }
#chongzhi-btn:hover { background: #851494; }

/* 暂停按钮 */
#pause-btn {
    position: absolute;
    right: 15px;
    bottom: 15px;
    background: #00cc66;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: rgb(253, 253, 238);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(6px);
    z-index: 60;
    transition: background 0.2s;
    min-width: 80px;
    text-align: center;
}
#pause-btn:hover { background: #00cc66; }

/* 暂停/重生遮罩 */
#pause-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(4px);
}
.pause-text {
    background: rgba(10, 10, 30, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 20px 40px;
    color: #ffd700;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px #000;
}

/* 聊天框桌面端样式 */
#chat-container {
    position: absolute;
    bottom: 15px;
    left: 15px;
    width: 260px;
    max-height: 80vh;
    min-height: 120px;
    height: 200px;
    background: rgba(10, 10, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(6px);
    z-index: 70;
    overflow: hidden;
}
#chat-resize-handle {
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    cursor: ns-resize;
    flex-shrink: 0;
    transition: background 0.2s;
}
#chat-resize-handle:hover { background: rgba(255, 255, 255, 0.5); }



@media (max-width: 768px) {
    /* ... 画布全屏、隐藏方向键、排行榜折叠等其他样式保持不变 ... */

    #rules-link {
        top: 8px;
        right: 8px;
        font-size: 12px;
        padding: 3px 10px;
    }

    /* ========== 聊天框折叠（左侧把手） ========== */
    #chat-container {
        position: absolute;
        bottom: 60px;
        left: 10px;
        z-index: 100;
        width: auto;
        height: auto !important;
        min-height: unset !important;
        max-height: unset !important;
        background: transparent !important;
        border: none !important;
        display: block;
        overflow: visible;
    }
    #chat-resize-handle {
        height: 30px !important;
        line-height: 30px;
        text-align: center;
        color: rgb(32, 185, 45);
        font-size: 14px;
        background: rgb(10, 10, 30);
        border-radius: 12px;
        cursor: pointer;
        padding: 0 15px;
        display: inline-block;
        position: relative;
        z-index: 1;
    }
    #chat-resize-handle::after { content: "聊天 ▼"; }

    /* 折叠状态隐藏内容 */
    #chat-messages,
    #chat-input-area {
        display: none;
    }

    /* 展开状态 */
    .chat-expanded {
        display: flex !important;
        flex-direction: column;
        height: 40vh !important;        /* 固定高度，便于内部滚动 */
        width: 260px;
        left: 10px;
        bottom: 60px;
        background: rgba(10, 10, 30, 0.8) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        border-radius: 12px;
        overflow: hidden;
        position: absolute;
    }
    .chat-expanded #chat-resize-handle {
        border-radius: 12px 12px 0 0;
        width: 100%;
        padding: 0;
        display: block;
        height: 30px !important;
        line-height: 30px;
        background: rgb(10, 10, 30);
        color: rgb(32, 185, 45);
        font-size: 14px;
        text-align: center;
    }
    .chat-expanded #chat-resize-handle::after {
        content: "聊天 ▲";
    }

    /* 展开后显示消息列表 */
    .chat-expanded #chat-messages {
        display: block;                 /* 覆盖折叠时的 none */
        flex: 1;
        overflow-y: auto;
        padding: 8px 10px;
        font-size: 13px;
        color: #f4362d;
    }
    /* 展开后显示输入区域 */
    .chat-expanded #chat-input-area {
        display: flex;                  /* 覆盖折叠时的 none */
        align-items: stretch;
        border-top: 1px solid rgba(255,255,255,0.2);
        flex-shrink: 0;
    }
    .chat-expanded #chat-input {
        flex: 1;
        box-sizing: border-box;
        padding: 8px 12px;
        border: none;
        background: rgba(255,255,255,0.1);
        color: #f4362d;
        font-size: 13px;
        outline: none;
    }
    .chat-expanded #chat-send {
        box-sizing: border-box;
        padding: 8px 14px;
        border: none;
        background: #00aa55;
        color: white;
        font-weight: bold;
        font-size: 13px;
        cursor: pointer;
        white-space: nowrap;
    }
}