/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    overflow: hidden;
    height: 100vh;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-box {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}
.modal-box h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: #f1f5f9;
}
.modal-box p {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 16px;
}
.modal-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
}
.modal-box input:focus { border-color: #3b82f6; }

/* 去掉 number 输入框的上下箭头 */
#exchange-yb-input::-webkit-inner-spin-button,
#exchange-yb-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#exchange-yb-input { -moz-appearance: textfield; }
.btn-primary {
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
}
.btn-primary:hover { background: #2563eb; }

/* ===== 顶部信息栏 ===== */
#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 15px; font-weight: 600; color: #f1f5f9; }
.header-info { font-size: 13px; color: #94a3b8; }
.header-info b { color: #3b82f6; margin-left: 2px; }
.header-tip { font-size: 12px; color: #64748b; }
.btn-back {
    font-size: 12px;
    color: #ffffff;
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
}
.btn-back:hover {
    color: #989898;
}

/* ===== 兑换按钮 ===== */
.btn-exchange {
    background: #22c55e;
    color: #fff;
    border: none;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
}
.btn-exchange:hover { background: #16a34a; }

/* ===== 兑换弹窗按钮组 ===== */
.modal-btns {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.modal-btns .btn-primary { width: auto; flex: 1; }
.modal-btns .btn-back {
    width: auto; flex: 1;
    text-align: center;
    font-size: 14px;
    padding: 10px 0;
    cursor: pointer;
}

/* ===== 主体区域 ===== */
#game-body { display: flex; height: calc(100vh - 48px); }

/* ===== 聊天面板 ===== */
#chat-panel {
    width: 240px;
    min-width: 240px;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
}
.chat-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    border-bottom: 1px solid #334155;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 12px;
    line-height: 1.6;
}
.chat-msg { margin-bottom: 6px; word-break: break-all; }
.chat-msg .chat-user { color: #3b82f6; font-weight: 600; margin-right: 4px; }
.chat-msg .chat-text { color: #cbd5e1; }
.chat-msg-system {
    color: #64748b;
    font-size: 11px;
    text-align: center;
    margin: 4px 0;
}
.chat-input-area {
    display: flex;
    padding: 8px;
    border-top: 1px solid #334155;
    gap: 6px;
}
.chat-input-area input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    outline: none;
}
.chat-input-area input:focus { border-color: #3b82f6; }
.chat-input-area button {
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.chat-input-area button:hover { background: #2563eb; }

/* ===== 画布区域 ===== */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}
.canvas-tip {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    pointer-events: none;
    animation: tipFade 4s ease forwards;
}
@keyframes tipFade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* ===== 排行榜 ===== */
.leaderboard {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 160px;
    background: transparent;
    border: none;
    z-index: 10;
    font-size: 12px;
    overflow: hidden;
}
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(30, 58, 95, 0.55);
    color: #f59e0b;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
}
.leaderboard-toggle {
    font-size: 16px;
    line-height: 1;
    color: #94a3b8;
}
.leaderboard-toggle:hover { color: #e2e8f0; }
.leaderboard-body {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.45);
    border-radius: 0 0 6px 6px;
}
.leaderboard.collapsed .leaderboard-body { display: none; }
.leaderboard-list { padding: 4px 0; }
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 3px 10px;
    color: #cbd5e1;
    gap: 6px;
}
.leaderboard-item:nth-child(1) .leaderboard-rank { color: #f59e0b; }
.leaderboard-item:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #cd7f32; }
.leaderboard-rank { width: 18px; font-weight: 700; text-align: center; color: #64748b; }
.leaderboard-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { color: #22c55e; font-weight: 600; }

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
