:root {
    --bg: #0F0F1A;
    --card: #1A1A2E;
    --accent: #7C3AED;
    --blue: #3B82F6;
    --orange: #F97316;
    --text: #F8FAFC;
}

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

body {
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-header {
    position: absolute;
    top: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
}

.score-display, .best-score {
    background: var(--card);
    border-radius: 16px;
    padding: 12px 24px;
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.15);
}

.score-display {
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.best-score {
    border: 1px solid rgba(249, 115, 22, 0.3);
    text-align: center;
}

.label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #64748B;
    display: block;
}

.score-display .value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7C3AED, #3B82F6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.best-score .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #F97316;
}

canvas {
    display: block;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(124, 58, 237, 0.2);
}

.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 26, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.game-over-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.game-over-title {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #F97316, #EF4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.game-over-score {
    font-size: 1.2rem;
    color: #64748B;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.game-over-score .final {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text);
    display: block;
}

.restart-btn {
    margin-top: 24px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    background: linear-gradient(135deg, #7C3AED, #3B82F6);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.3);
    text-transform: uppercase;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.4);
}

.restart-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.combo-text {
    position: absolute;
    pointer-events: none;
    font-weight: 900;
    font-size: 1.5rem;
    color: #7C3AED;
    animation: comboUp 0.8s ease-out forwards;
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.6);
    z-index: 15;
}

@keyframes comboUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(1.5);
    }
}

.instructions {
    position: absolute;
    bottom: 100px;
    color: #64748B;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
    z-index: 5;
}

/* Tap area indicator for mobile */
.tap-area {
    display: none;
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.1);
    border: 2px solid rgba(124, 58, 237, 0.2);
    z-index: 4;
    animation: tapPulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes tapPulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.5; }
    50% { transform: translateX(-50%) scale(1.1); opacity: 1; }
}

@media (pointer: coarse) {
    .tap-area { display: block; }
    .instructions { bottom: 140px; font-size: 0.75rem; }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ===== 竖屏手机适配 ===== */
@media (max-width: 500px) and (orientation: portrait) {
    .game-container {
        max-width: 100%;
        max-height: 100vh;
        padding: 0 6px;
    }
    .game-header {
        padding: 0 10px;
        top: 8px;
    }
    .score-display, .best-score {
        padding: 6px 12px;
        border-radius: 10px;
    }
    .score-display .value {
        font-size: 1.3rem;
    }
    .best-score .value {
        font-size: 1rem;
    }
    .best-score {
        min-width: 70px;
    }
    .label {
        font-size: 0.6rem;
    }
    canvas {
        border-radius: 10px;
        max-width: 100%;
    }
    .game-over-title {
        font-size: 1.8rem;
    }
    .game-over-score .final {
        font-size: 2rem;
    }
    .restart-btn {
        padding: 12px 36px;
        font-size: 1rem;
    }
    .instructions {
        bottom: 16px;
        font-size: 0.75rem;
    }
}

/* ===== 横屏手机适配 ===== */
@media (max-width: 900px) and (orientation: landscape) {
    .game-container {
        max-width: 100%;
        max-height: 100vh;
        flex-direction: row;
        padding: 0 8px;
        gap: 10px;
    }
    .game-header {
        position: static;
        width: auto;
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        padding: 0;
        flex-shrink: 0;
    }
    .score-display, .best-score {
        padding: 6px 10px;
        border-radius: 10px;
        min-width: 60px;
        text-align: center;
    }
    .score-display .value {
        font-size: 1.1rem;
    }
    .best-score .value {
        font-size: 0.9rem;
    }
    .label {
        font-size: 0.55rem;
    }
    canvas {
        border-radius: 10px;
        max-height: 85vh;
        max-width: 65vw;
    }
    .game-over-overlay {
        border-radius: 10px;
    }
    .game-over-title {
        font-size: 1.5rem;
    }
    .game-over-score .final {
        font-size: 1.8rem;
    }
    .restart-btn {
        padding: 10px 28px;
        font-size: 0.9rem;
    }
    .instructions {
        display: none !important;
    }
    .combo-text {
        font-size: 1.1rem;
    }
}

/* ── Fixed Ad Area (in game-over overlay) ── */
.ad-area {
    margin: 10px auto 0;
    padding: 6px;
    width: 260px;
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: 10px;
    text-align: center;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.ad-area-label {
    font-size: 8px;
    font-weight: 600;
    color: rgba(255,255,255,0.25);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-area-placeholder {
    color: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-area-placeholder svg {
    width: 20px;
    height: 20px;
}