* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    touch-action: none;
}

.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

.hud > * {
    pointer-events: auto;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hud-center {
    display: flex;
    justify-content: center;
}

.score-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.coin-count {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.coin-icon {
    font-size: 18px;
}

.coin-count span:last-child {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

.hud-right {
    flex-direction: row;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.btn-icon:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

.game-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.controls-hint {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 24px;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.controls-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

.hint-item {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
}

/* 遮罩层 */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 32px 24px;
    max-width: 320px;
    width: 90%;
}

.game-title {
    font-size: 36px;
    font-weight: bold;
    color: #fff;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 24px;
}

.best-score {
    font-size: 14px;
    color: #ffd700;
    margin-bottom: 24px;
}

.instructions {
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    line-height: 1.8;
}

.btn-primary, .btn-secondary {
    display: block;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 24px 0;
}

.stat-item {
    text-align: center;
}

.stat-item.highlight {
    background: rgba(255, 215, 0, 0.1);
    padding: 8px 16px;
    border-radius: 12px;
    margin: -8px -16px;
}

.stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.stat-item.highlight .stat-value {
    color: #ffd700;
}

.new-record {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 16px;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

.new-record.hidden {
    display: none;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* 响应式 */
@media (max-width: 380px) {
    .game-title {
        font-size: 28px;
    }

    .score-value {
        font-size: 24px;
    }

    .controls-hint {
        gap: 12px;
    }

    .hint-item {
        font-size: 11px;
        padding: 3px 8px;
    }
}
