* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Impact', 'Arial Black', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    background-color: #111;
    overscroll-behavior: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Speed Lines Vignette Overlay for Rage Mode */
#speed-lines-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: radial-gradient(circle, transparent 40%, rgba(255, 60, 0, 0.45) 85%, rgba(255, 0, 80, 0.75) 100%);
    box-shadow: inset 0 0 120px rgba(255, 200, 0, 0.6);
}

#speed-lines-overlay.active {
    opacity: 1;
    animation: speedPulse 0.4s infinite alternate ease-in-out;
}

@keyframes speedPulse {
    0% { transform: scale(1.0); }
    100% { transform: scale(1.02); }
}

/* Top Notch (Mobile phone camera cutout) */
.mobile-notch {
    position: absolute;
    top: max(6px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 24px;
    background: #000;
    border-radius: 14px;
    z-index: 100;
    pointer-events: none;
}

/* Top Bar Container with Safe-Area insets */
.top-bar {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 0;
    width: 100%;
    padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 80;
    pointer-events: none;
}

/* Top Left Home Button */
.btn-home {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    transition: transform 0.15s, background 0.15s;
    touch-action: manipulation;
}

.btn-home:hover {
    transform: scale(1.08);
    background: rgba(0, 0, 0, 0.6);
}

/* Audio Toggle Button (compact, respects safe areas) */
#audio-toggle {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 52px);
    left: max(16px, env(safe-area-inset-left));
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: #FFF;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
    pointer-events: auto;
    transition: transform 0.15s;
    touch-action: manipulation;
}

#audio-toggle:hover {
    transform: scale(1.1);
}

/* Top Center Level & Progress */
.level-center-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: min(240px, 45vw);
}

.level-title-text {
    font-size: 20px;
    font-weight: 800;
    color: #FFFFFF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    border: 2px solid #FFFFFF;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

#level-progress-bar {
    width: 0%;
    height: 100%;
    background: #00A8FF;
    border-radius: 4px;
    transition: width 0.1s linear;
}

/* Top Right Coin Pill */
.coin-pill {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.coin-amount {
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.coin-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE043, #FFB300);
    border: 2px solid #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #925300;
    font-size: 15px;
    font-weight: 900;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Left Vertical Slap / Rage Meter with Mobile Scaling */
.vertical-rage-container {
    position: absolute;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(60px, env(safe-area-inset-bottom));
    width: 32px;
    height: clamp(160px, 26vh, 220px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 80;
}

.vertical-rage-bar-wrapper {
    position: relative;
    width: 22px;
    height: 100%;
    background: rgba(28, 35, 45, 0.9);
    border: 3px solid #111;
    border-radius: 6px 6px 4px 4px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transform: perspective(100px) rotateY(-4deg);
}

#vertical-rage-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(0deg, #FFB300, #FF3D00, #FF0055);
    transition: height 0.15s ease-out;
}

/* Bottom Flame Hand Icon on Meter */
.rage-flame-icon-btn {
    position: absolute;
    bottom: -18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #1C232D;
    border: 3px solid #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 2;
    transition: transform 0.2s, box-shadow 0.2s;
}

.vertical-rage-container.pulsing-glow .rage-flame-icon-btn {
    animation: flamePulse 0.3s infinite alternate ease-in-out;
    border-color: #FFB300;
    box-shadow: 0 0 16px #FF5500, 0 0 25px #FFCC00;
}

.vertical-rage-container.pulsing-glow .vertical-rage-bar-wrapper {
    border-color: #FFB300;
    box-shadow: 0 0 20px #FF5500;
}

@keyframes flamePulse {
    0% { transform: scale(1.0); }
    100% { transform: scale(1.15); }
}

@keyframes rageGlowAnim {
    0% { transform: scale(1.0); }
    100% { transform: scale(1.06); }
}

/* Modals & Screens with Mobile Responsiveness */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    z-index: 200;
    transition: opacity 0.3s ease, visibility 0.3s;
    touch-action: manipulation;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-card {
    background: linear-gradient(135deg, #1E293B, #0F172A);
    border: 4px solid #FFF;
    border-radius: 26px;
    padding: clamp(20px, 4vh, 32px) clamp(16px, 4vw, 32px);
    max-width: 400px;
    max-height: 88vh;
    overflow-y: auto;
    width: 90%;
    text-align: center;
    color: #FFF;
    box-shadow: 0 16px 40px rgba(0,0,0,0.6);
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    touch-action: manipulation;
}

@keyframes popIn {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-title {
    font-size: clamp(30px, 5.5vh, 42px);
    color: #FFD700;
    text-shadow: 3px 3px 0 #FF2A55, 6px 6px 0 #111;
    margin-bottom: 6px;
    letter-spacing: 2px;
    transform: rotate(-2deg);
}

.game-subtitle {
    font-size: 14px;
    color: #A0AEC0;
    margin-bottom: 18px;
    font-family: -apple-system, sans-serif;
    font-weight: 600;
}

.instructions-box {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    font-family: -apple-system, sans-serif;
    color: #E2E8F0;
}

.instructions-box span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(180deg, #00FF88, #00AA55);
    border: 4px solid #FFF;
    border-radius: 36px;
    color: #111;
    font-size: 26px;
    padding: 14px 32px;
    cursor: pointer;
    box-shadow: 0 6px 0 #006633, 0 10px 20px rgba(0,0,0,0.4);
    transition: transform 0.1s, box-shadow 0.1s;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #006633, 0 14px 24px rgba(0,0,0,0.5);
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #006633;
}

/* Kick Power Meter Modal */
#kick-meter-modal .modal-card {
    background: linear-gradient(135deg, #2B0938, #15051D);
    border-color: #FF0077;
    max-width: 380px;
}

.meter-title {
    font-size: 28px;
    color: #FFEA00;
    text-shadow: 2px 2px 0 #FF0055;
    margin-bottom: 12px;
}

.meter-gauge-container {
    position: relative;
    width: 240px;
    height: 120px;
    margin: 10px auto 20px auto;
    overflow: hidden;
}

.meter-arc {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    border: 24px solid transparent;
    border-top-color: #00FF88;
    border-left-color: #FF3300;
    border-right-color: #FF9900;
    box-sizing: border-box;
    transform: rotate(45deg);
}

.meter-needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 6px;
    height: 100px;
    background: #FFF;
    border: 2px solid #000;
    transform-origin: bottom center;
    border-radius: 4px;
    box-shadow: 0 0 10px #FFF;
    transition: transform 0.04s linear;
}

.meter-hint {
    font-size: 14px;
    color: #FFF;
    margin-bottom: 16px;
    font-family: -apple-system, sans-serif;
}

/* Game Over Modal */
.gameover-title {
    font-size: 38px;
    color: #FF2A2A;
    text-shadow: 3px 3px 0 #000;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px;
}

.stat-label {
    font-size: 12px;
    color: #94A3B8;
    font-family: -apple-system, sans-serif;
}

.stat-value {
    font-size: 22px;
    color: #FFD700;
    margin-top: 4px;
}

/* Victory Modal */
.victory-title {
    font-size: 40px;
    color: #FFD700;
    text-shadow: 3px 3px 0 #FF0055, 5px 5px 0 #000;
    margin-bottom: 8px;
}

.grade-badge {
    display: inline-block;
    background: linear-gradient(90deg, #FF0077, #FF9900);
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 18px;
    color: #FFF;
    border: 2px solid #FFF;
    margin-bottom: 16px;
}

.final-score-callout {
    background: rgba(255, 215, 0, 0.15);
    border: 2px dashed #FFD700;
    border-radius: 16px;
    padding: 12px;
    margin: 12px 0 20px 0;
}

.final-score-callout .big-score {
    font-size: 40px;
    color: #00FF88;
    text-shadow: 2px 2px 0 #000;
}

/* Virtual Steering Hint on screen for mobile/desktop */
.steering-hint {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    letter-spacing: 1px;
    font-family: -apple-system, sans-serif;
    pointer-events: none;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
    animation: swipeHint 1.6s infinite alternate ease-in-out;
}

@keyframes swipeHint {
    0% { transform: translateX(-65%); }
    100% { transform: translateX(-35%); }
}

/* Mobile Small Screen Media Queries */
@media (max-width: 480px), (max-height: 720px) {
    .instructions-box {
        font-size: 12px;
        gap: 6px;
        padding: 10px 12px;
        margin-bottom: 16px;
    }
    .btn-primary {
        font-size: 20px;
        padding: 12px 24px;
        border-radius: 28px;
    }
    .gameover-title, .victory-title {
        font-size: clamp(26px, 5vh, 34px);
    }
    .stats-grid {
        margin: 12px 0;
        gap: 8px;
    }
    .stat-value {
        font-size: 18px;
    }
    .final-score-callout {
        padding: 8px;
        margin: 8px 0 16px 0;
    }
    .final-score-callout .big-score {
        font-size: 30px;
    }
    .meter-gauge-container {
        width: 200px;
        height: 100px;
        margin: 6px auto 14px auto;
    }
    .meter-arc {
        width: 200px;
        height: 200px;
        border-width: 18px;
    }
    .meter-needle {
        height: 80px;
    }
}
