* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #333;
font-family: system-ui, -apple-system, BlinkMacSystemFont,
             "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;

    overflow: hidden; 
    touch-action: none; 
    user-select: none;
}

.game-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    padding: 10px; 
}

.game-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 1; 
    background: #f7f7f7;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden; 
    transition: background-color 1s ease;
}

canvas {
    display: block;
    width: 100%; 
    height: 100%;
}

.ui-layer { z-index: 100; position: absolute; }

/* 顶部栏布局：分数靠右，按钮靠左 */
.top-bar {
    top: -40px; /* 移到游戏框外面上方 */
    right: 10px;
    left: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    color: #fff;
    pointer-events: none; /* 防止遮挡点击 */
}
.score-board { text-align: left; pointer-events: none; }

.user-btn {
    background: #ffffff;              /* 白色底 */
    color: #333;                      /* 深色文字 */
    padding: 6px 16px;                /* 稍微加一点左右 padding 更好看 */
    border-radius: 999px;             /* 圆角胶囊风格（看你喜不喜欢） */
    font-size: 12px;
    cursor: pointer;
    pointer-events: auto;             /* 允许点击 */
    border: 1px solid rgba(0,0,0,0.08); /* 轻微描边 */
}

/* 悬停时稍微加点阴影 / 变深一点 */
.user-btn:hover {
    background: #f5f5f5;
    border-color: rgba(0,0,0,0.15);
}

/* Buff 状态栏 */
.buff-bar {
    top: 10px;
    left: 10px;
    display: flex;
    gap: 5px;
    pointer-events: none;
}
.buff-icon {
    width: 24px; height: 24px;
    background: #fff;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
}
.buff-progress {
    position: absolute; bottom: 0; left: 0; height: 3px; background: rgba(0,0,0,0.5); width: 100%;
}

/* 游戏结束面板 */
#game-message {
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: #535353; display: none;
    background: rgba(255, 255, 255, 0.98); padding: 25px;
    border-radius: 12px; border: 2px solid #535353; 
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    width: 85%; max-width: 320px;
}
.game-over-title { margin:0 0 10px 0; font-size:24px; color:#ff4444; }
#final-score { font-size:20px; font-weight:bold; margin-bottom:20px; }

/* 按钮样式 */
.btn {
    padding: 10px 0; border-radius: 6px; cursor: pointer; font-size: 14px;
    border: none; color: #fff; font-weight: bold; margin: 5px; flex: 1;
}
.btn:active { transform: translateY(2px); opacity: 0.9; }
.btn-green { background: #00C851; }
.btn-blue { background: #33b5e5; }
.btn-gray { background: #7f8c8d; }
.login-btn-over { background: #ffbb33; color: #333; width: 100%; display: none; }
.btn-group { display: flex; justify-content: space-between; gap: 10px; }

/* 排行榜弹窗的关闭按钮 */
.rank-close-btn {
    display: block;
    margin: 20px auto 0;      /* 居中 + 和列表拉开一点距离 */
    padding: 10px 26px;       /* 左右多给一点空间，按钮不再压着字 */
    border-radius: 8px;     /* 胶囊圆角 */
    background: #2ecc71;      /* 背景色绿色 */
    flex: 0 0 auto;           /* 不要受 .btn 的 flex:1 影响 */
}

/* 鼠标悬停时稍微变深一点（可选） */
.rank-close-btn:hover {
    background: #27ae60;
}


/* 弹窗 */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: none; justify-content: center; align-items: center;
    z-index: 999; backdrop-filter: blur(5px);
}
.modal-content {
    background: #fff; padding: 25px; border-radius: 10px; width: 85%; max-width: 320px;
    text-align: center; color: #333; border: 2px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-content input {
    display: block; width: 100%; margin: 15px 0; padding: 10px;
    border: 2px solid #ddd; border-radius: 6px; font-size: 16px;
}

.rank-list {
    list-style: none; padding: 0; text-align: left; 
    max-height: 250px; overflow-y: auto; margin: 15px 0;
    border-top: 1px dashed #ccc; border-bottom: 1px dashed #ccc;
}
.rank-item {
    display: flex; justify-content: space-between; padding: 10px 5px; 
    border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.rank-item:nth-child(odd) { background: #fafafa; }

.tutorial {
    position: absolute; top: 20%; width: 100%; text-align: center;
    color: #888; font-size: 12px; pointer-events: none;
    opacity: 0.8; animation: fadeOut 8s forwards; animation-delay: 2s;
    z-index: 5; font-weight: bold; text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    transition: opacity 1s ease;
}
.game-started .tutorial { opacity: 0; }
@keyframes fadeOut { to { opacity: 0; } }