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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh; /* 动态视口高度，修复移动端 100vh 问题 */
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 12px;
    overflow-y: auto;
}

/* ──────────── 游戏主容器 ──────────── */
.game-container {
    background: rgba(0, 0, 0, 0.85);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    border: 2px solid #f093fb;
    width: 100%;
    max-width: 860px;
    display: flex;
    flex-direction: column;
    align-self: flex-start;
}

/* ──────────── 顶部标题栏 ──────────── */
.game-header {
    text-align: center;
    margin-bottom: 12px;
}

.game-header h1 {
    font-size: clamp(18px, 5vw, 26px);
    color: #f093fb;
    margin-bottom: 10px;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(240, 147, 251, 0.15);
    padding: 8px 18px;
    border-radius: 8px;
    border: 1.5px solid #f093fb;
    min-width: 80px;
}

.stat-label {
    font-size: 11px;
    color: #b8c0ff;
    margin-bottom: 4px;
}

.stat-value {
    font-size: clamp(18px, 5vw, 24px);
    font-weight: bold;
    color: #f093fb;
}

/* ──────────── 游戏画布区 ──────────── */
.game-area {
    position: relative;
    margin-bottom: 12px;
    border: 3px solid #f093fb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    line-height: 0; /* 消除 canvas 底部空隙 */
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background: linear-gradient(to bottom, #1a1a2e 0%, #16213e 100%);
    touch-action: none; /* 防止滚动干扰 */
}

/* ──────────── 底部提示 ──────────── */
.game-footer {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1.5px solid #667eea;
    text-align: center;
    color: #b8c0ff;
    font-size: clamp(11px, 3vw, 13px);
}

/* ──────────────────────────────────────
   全屏模态层（开始 & 结束屏幕）
   position: fixed → 与 canvas 尺寸完全无关
────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0; /* top/right/bottom/left: 0 */
    z-index: 100;
    background: rgba(10, 10, 30, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-box {
    background: linear-gradient(160deg, #1e1e3f 0%, #2a1040 100%);
    border: 2px solid #f093fb;
    border-radius: 18px;
    padding: 32px 28px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 12px 40px rgba(240, 147, 251, 0.25);
    /* 保证内容不超出视口时垂直居中；超出时可滚动 */
    margin: auto;
}

.modal-hero-icon {
    font-size: clamp(52px, 15vw, 80px);
    line-height: 1;
    animation: bounce 1.2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-14px); }
}

.modal-title {
    font-size: clamp(22px, 6vw, 32px);
    color: #f093fb;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-title.gameover {
    color: #f5576c;
}

.modal-subtitle {
    font-size: clamp(13px, 3.5vw, 15px);
    color: #b8c0ff;
    text-align: center;
}

/* 操作提示 */
.modal-tips {
    background: rgba(102, 126, 234, 0.2);
    border: 1.5px solid rgba(240, 147, 251, 0.4);
    border-radius: 10px;
    padding: 16px 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(12px, 3.5vw, 14px);
    color: #e0e0e0;
}

.tip-key {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: bold;
    font-size: clamp(12px, 3.5vw, 13px);
    min-width: 46px;
    text-align: center;
    border: 1.5px solid #b8c0ff;
    flex-shrink: 0;
}

/* 分数展示（结束屏幕） */
.modal-scores {
    background: rgba(240, 147, 251, 0.15);
    border: 2px solid #f5576c;
    border-radius: 12px;
    padding: 18px 28px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-label {
    font-size: clamp(13px, 3.5vw, 15px);
    color: #b8c0ff;
}

.score-val {
    font-size: clamp(20px, 6vw, 28px);
    font-weight: bold;
    color: #f093fb;
}

.score-val.best {
    color: #ffd700;
}

/* 主操作按钮 */
.modal-btn.primary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 14px 0;
    width: 100%;
    max-width: 240px;
    font-size: clamp(15px, 4.5vw, 17px);
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.45);
    font-family: inherit;
    border: 2px solid #d63384;
}

.modal-btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(245, 87, 108, 0.55);
}

.modal-btn.primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(245, 87, 108, 0.4);
}

/* ──────────── 移动端全屏适配 ──────────── */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .game-container {
        max-width: 100%;
        border-radius: 0;
        border: none;
        border-left: none;
        border-right: none;
        padding: 8px 0;
    }

    .game-header {
        margin-bottom: 6px;
        padding: 0 8px;
    }

    .game-area {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
    }

    .game-footer {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 8px;
    }

    /* 触摸操作区域提示条 */
    .touch-hint {
        display: block;
    }
}

/* 默认隐藏触摸提示条，移动端才显示 */
.touch-hint {
    display: none;
    text-align: center;
    padding: 12px;
    background: linear-gradient(180deg, rgba(240, 147, 251, 0.2) 0%, rgba(245, 87, 108, 0.3) 100%);
    border-top: 1px solid rgba(240, 147, 251, 0.4);
    color: #f093fb;
    font-size: 13px;
    font-weight: 500;
}

/* ──────────── 小屏微调 ──────────── */
@media (max-width: 400px) {
    .modal-box {
        padding: 24px 18px;
        gap: 14px;
    }

    .modal-tips {
        padding: 12px 14px;
    }

    .modal-scores {
        padding: 14px 18px;
    }
}
