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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
}

#game-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    background: #87CEEB;
    position: relative;
    z-index: 1;
    pointer-events: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

#game-canvas.playing {
    touch-action: none;
    pointer-events: auto;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    background: rgba(10, 10, 30, 0.88);
    z-index: 10;
    padding: 20px;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.overlay > * {
    margin: 7px 0;
}

.overlay.hidden {
    display: none !important;
}

.title {
    font-size: 2.5rem;
    color: #FFD700;
    text-shadow: 3px 3px 0 #e67e22, 0 0 30px rgba(255, 215, 0, 0.4);
    text-align: center;
    letter-spacing: 1px;
}

.gameover-title {
    color: #ff6b6b;
    text-shadow: 3px 3px 0 #c0392b;
}

.subtitle {
    color: #ddd;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.score-block {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px 40px;
    text-align: center;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1.8;
}

.score-block strong {
    color: #FFD700;
    font-size: 1.2em;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 50px;
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    min-width: 220px;
    text-align: center;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    z-index: 11;
    display: inline-block;
}

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

.btn-primary {
    background: #f39c12;
    background: -webkit-linear-gradient(315deg, #f39c12, #e67e22);
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: #eee;
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: 220px;
}

/* HUD */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

.hud.hidden {
    display: none !important;
}

.hud-row {
    background: rgba(0, 0, 0, 0.45);
    border-radius: 20px;
    padding: 6px 14px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    margin-right: 10px;
    margin-bottom: 6px;
}

.hud-label {
    color: #aaa;
    font-weight: 400;
    margin-right: 6px;
}

#hud-score, #hud-best {
    color: #FFD700;
    min-width: 40px;
}

.speed-row {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.speed-bar {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.speed-fill {
    height: 100%;
    width: 30%;
    background: #2ecc71;
    background: -webkit-linear-gradient(left, #2ecc71, #f1c40f, #e74c3c);
    background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
    border-radius: 4px;
}

.btn-icon {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    margin-left: auto;
}

.btn-icon:active {
    -webkit-transform: scale(0.9);
    transform: scale(0.9);
}

/* Hints */
.hint {
    color: #888;
    font-size: 0.85rem;
    margin-top: 8px;
}

.desktop-hint { display: block; }
.mobile-hint { display: none; }

@media (max-width: 1024px) {
    .desktop-hint { display: none; }
    .mobile-hint { display: block; }
    .title { font-size: 2rem; }
}

@media (max-width: 768px) {
    .btn {
        min-width: 180px;
        padding: 12px 30px;
    }

    .hud {
        padding: 8px 10px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

@media (max-width: 320px) {
    .btn {
        min-width: 150px;
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .title { font-size: 1.6rem; }
}
