/* 基础样式 */
* {
    box-sizing: border-box;
    user-select: none; /* 避免拖拽时选中文本，提升触屏体验 */
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: #0a0a2a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

.game-main-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.game-score-board {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 12px 15px;
    margin-bottom: 15px;
}

.score-info {
    display: flex;
    justify-content: space-around;
    font-size: 1.1em;
    font-weight: bold;
    flex-wrap: wrap;
    gap: 10px;
}

.score-info div {
    background: #f0f0f0;
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05), 0 1px 1px rgba(255,255,255,0.8);
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    background: #1a1a2e;
    cursor: pointer;
    width: 100%;
    height: auto;
    touch-action: none; /* 禁止触屏默认滚动/缩放，便于拖拽拉环 */
}

.game-controls {
    text-align: center;
    margin: 20px 0 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.game-controls button {
    padding: 12px 24px;
    font-size: 1.1em;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    min-width: 110px;
}

.game-controls button:active {
    transform: scale(0.96);
}

.btn-primary {
    background: #ff6b6b;
    color: white;
}
.btn-secondary {
    background: #4ecdc4;
    color: white;
}
.btn-info {
    background: #45b7d1;
    color: white;
}

.game-history {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 12px 15px;
    margin-top: 15px;
}

.game-history h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9em;
}

.history-list li {
    padding: 6px 8px;
    border-bottom: 1px solid #ddd;
    word-break: break-word;
}
.game-area-wrapper {
    overflow-x: auto;        /* 如果 canvas 被裁切，可滚动查看全部内容 */
    -webkit-overflow-scrolling: touch;
    text-align: center;      /* 居中显示 canvas */
    margin: 0 -10px;         /* 负边距补偿父容器内边距 */
    padding: 0 10px;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    background: #1a1a2e;
    cursor: pointer;
    width: auto;             /* 改用 auto，避免强制 100% 超出 */
    max-width: 100%;         /* 保证不超出父容器 */
    height: auto;
    touch-action: none;
}

/* 移动端/平板上确保右侧有足够空白 */
@media (max-width: 900px) {
    .game-container {
        padding: 10px;
    }
    .game-area-wrapper {
        margin: 0;
        padding: 0 5px;
    }
}
/* ---------- 移动端 / 平板 响应式适配 ---------- */
/* 平板横屏 & 小桌面 */
@media (max-width: 1024px) {
    .game-container {
        padding: 8px;
    }
    .game-main-panel {
        padding: 12px;
    }
    .score-info {
        font-size: 1em;
    }
    .game-controls button {
        padding: 10px 18px;
        font-size: 1em;
        min-width: 90px;
    }
}

/* 平板竖屏 & 大手机横屏 */
@media (max-width: 768px) {
    .game-score-board {
        padding: 10px;
    }
    .score-info div {
        padding: 4px 10px;
        font-size: 0.9rem;
    }
    .game-controls {
        gap: 12px;
    }
    .game-controls button {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-width: 80px;
    }
    .history-list {
        max-height: 120px;
        font-size: 0.8rem;
    }
    .game-history h3 {
        font-size: 1rem;
    }
}

/* 手机竖屏 (宽度 ≤ 480px) */
@media (max-width: 480px) {
    .game-main-panel {
        border-radius: 12px;
        padding: 8px;
    }
    .game-score-board {
        border-radius: 12px;
        padding: 8px;
    }
    .score-info {
        gap: 6px;
    }
    .score-info div {
        padding: 3px 8px;
        font-size: 0.8rem;
    }
    .game-controls {
        gap: 8px;
        margin: 12px 0;
    }
    .game-controls button {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: 70px;
        border-radius: 30px;
    }
    .game-history {
        border-radius: 12px;
        padding: 8px 10px;
        margin-top: 12px;
    }
    .history-list {
        max-height: 100px;
        font-size: 0.7rem;
    }
    .history-list li {
        padding: 4px 6px;
    }
}

/* 针对触屏设备，增大拉环点击区域（通过 Canvas 的 JS 已处理，这里提示） */
@media (hover: none) and (pointer: coarse) {
    .game-controls button {
        padding: 12px 20px;  /* 触屏加大按钮 */
    }
    #gameCanvas {
        touch-action: none;
    }
}

/* 横屏模式优化（尤其手机横屏时高度有限） */
@media (orientation: landscape) and (max-height: 500px) {
    .game-container {
        padding: 5px;
    }
    .game-main-panel {
        padding: 8px;
    }
    .game-score-board {
        padding: 6px;
        margin-bottom: 8px;
    }
    .score-info {
        font-size: 0.8rem;
    }
    .game-controls {
        margin: 8px 0;
    }
    .game-history {
        max-height: 80px;
        overflow-y: auto;
        margin-top: 8px;
    }
    .history-list {
        max-height: 60px;
    }
}

/* 高分记录和分数区域自适应 */
#score-value, #high-score-value, #game-count {
    font-weight: bold;
    color: #e67e22;
}
/* 强制 canvas 缩放至容器宽度 */
#gameCanvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    touch-action: none;
}

/* 允许父容器滚动（以防万一） */
.game-area-wrapper {
    overflow-x: auto;
    text-align: center;
    -webkit-overflow-scrolling: touch;
}

/* 移除全局 overflow: hidden 的影响（覆盖内联样式） */
html, body {
    overflow: auto !important;
    height: auto !important;
}

.game-wrapper {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
}