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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-touch-callout: none; /* Disable callout on iOS */
    -webkit-user-select: none; /* Disable text selection */
    user-select: none;
    margin: 0;
    padding: 0;
}

.game-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    position: relative;
    justify-content: center;
}

.game-container {
    position: relative;
    width: 800px;
    max-width: 100vw;
    height: 600px;
    max-height: 100vh;
    background: #1a1a2e;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Mobile responsive */
@media (max-width: 900px) {
    body {
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden;
        height: 100vh;
        width: 100vw;
        position: fixed;
        top: 0;
        left: 0;
    }
    
    .game-wrapper {
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        gap: 0;
        align-items: stretch;
        justify-content: flex-start;
        margin: 0;
        padding: 0;
        position: fixed;
        top: 0;
        left: 0;
    }
    
    .game-container {
        width: 100vw !important;
        min-width: 0;
        height: calc(100vh - 180px);
        border-radius: 0;
        flex: 0 0 auto;
        margin: 0;
        padding: 0;
        position: relative;
        order: 1;
    }
    
    .upgrade-panel {
        width: 100% !important;
        max-width: 100vw !important;
        height: 180px !important;
        margin: 0;
        padding: 10px;
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        border-top: 2px solid rgba(255, 255, 255, 0.2);
        border-left: none;
        overflow-x: auto;
        overflow-y: hidden;
        z-index: 5;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        box-sizing: border-box;
    }
    
    .upgrade-panel-title {
        display: none;
    }
    
    .upgrade-item {
        width: calc((100vw - 40px) / 4);
        min-width: 80px;
        max-width: 120px;
        margin-bottom: 0;
        flex-shrink: 0;
        padding: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .upgrade-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin-top: 5px;
    }
    
    .upgrade-name {
        display: block;
        font-size: 10px;
        color: #fff;
        font-weight: bold;
        text-align: center;
        margin-top: 2px;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    }
    
    .upgrade-desc {
        display: none;
    }
    
    .upgrade-progress-container {
        width: 100%;
        margin-top: 3px;
    }
    
    .upgrade-progress-text {
        font-size: 9px;
    }
    
    .upgrade-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .upgrade-level {
        font-size: 16px;
        margin-top: 3px;
        text-align: center;
    }
    
    .menu-screen h1,
    .game-over-screen h1 {
        font-size: 36px;
    }
    
    .instructions {
        font-size: 14px;
    }
    
    .score-panel {
        font-size: 16px;
    }
}

/* Very small mobile screens */
@media (max-width: 600px) {
    .game-container {
        height: calc(100vh - 150px) !important;
    }
    
    .upgrade-panel {
        height: 150px !important;
        padding: 8px;
        gap: 6px;
    }
    
    .upgrade-item {
        width: calc((100vw - 32px) / 4);
        min-width: 70px;
        max-width: 100px;
        padding: 6px;
    }
    
    .upgrade-icon {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .upgrade-name {
        font-size: 9px;
    }
    
    .upgrade-level {
        font-size: 16px;
    }
}

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

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    pointer-events: none;
    z-index: 10;
}

.score-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.score-panel .score,
.score-panel .level,
.score-panel .time {
    display: block;
}

.score-to-next {
    width: 180px;
    color: #ffd700;
    opacity: 0.95;
}

.score-to-next-label {
    font-size: 12px;
    margin-bottom: 3px;
    letter-spacing: 0.3px;
}

.score-to-next-track {
    width: 100%;
    height: 8px;
    border: 1px solid rgba(255, 215, 0, 0.55);
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.45);
}

.score-to-next-bar {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd700 0%, #ff9f1c 100%);
    transition: width 0.15s linear;
}

.score-to-next-value {
    margin-top: 2px;
    font-size: 11px;
}

.game-info {
    margin-top: 10px;
}

.powerup-indicator {
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    min-height: 20px;
}

/* Side Upgrade Panel - Outside game container */
.upgrade-panel {
    width: 200px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 15px;
    pointer-events: none;
    z-index: 10;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.upgrade-panel-title {
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.upgrade-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    border-left: 3px solid transparent;
}

.upgrade-item.has-upgrade {
    border-left-color: #ffd700;
    background: rgba(255, 255, 255, 0.1);
}

.upgrade-icon {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

.upgrade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upgrade-name {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.upgrade-desc {
    color: #ccc;
    font-size: 10px;
}

.upgrade-progress-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    margin-top: 5px;
    position: relative;
    overflow: hidden;
}

.upgrade-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4 0%, #00ff88 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.upgrade-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 1;
    white-space: nowrap;
}

.upgrade-level {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    min-width: 40px;
    text-align: center;
}

/* Upgrade icon colors */
.upgrade-icon.rapidfire {
    background: #ff6b6b;
}

.upgrade-icon.multishot {
    background: #4ecdc4;
}

.upgrade-icon.powerboost {
    background: #ffe66d;
}

.upgrade-icon.altlane {
    background: #a29bfe;
}

/* Upgrade flash effect */
.upgrade-icon.flash.rapidfire {
    animation: upgradeFlashRed 0.5s ease-out;
}

.upgrade-icon.flash.multishot {
    animation: upgradeFlashCyan 0.5s ease-out;
}

.upgrade-icon.flash.powerboost {
    animation: upgradeFlashYellow 0.5s ease-out;
}

.upgrade-icon.flash.altlane {
    animation: upgradeFlashPurple 0.5s ease-out;
}

@keyframes upgradeFlashRed {
    0% {
        box-shadow: 0 0 0 #ff6b6b;
        transform: scale(1);
    }
    30% {
        box-shadow: 0 0 30px #ff6b6b, 0 0 50px #ff6b6b;
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 #ff6b6b;
        transform: scale(1);
    }
}

@keyframes upgradeFlashCyan {
    0% {
        box-shadow: 0 0 0 #4ecdc4;
        transform: scale(1);
    }
    30% {
        box-shadow: 0 0 30px #4ecdc4, 0 0 50px #4ecdc4;
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 #4ecdc4;
        transform: scale(1);
    }
}

@keyframes upgradeFlashYellow {
    0% {
        box-shadow: 0 0 0 #ffe66d;
        transform: scale(1);
    }
    30% {
        box-shadow: 0 0 30px #ffe66d, 0 0 50px #ffe66d;
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 #ffe66d;
        transform: scale(1);
    }
}

@keyframes upgradeFlashPurple {
    0% {
        box-shadow: 0 0 0 #a29bfe;
        transform: scale(1);
    }
    30% {
        box-shadow: 0 0 30px #a29bfe, 0 0 50px #a29bfe;
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 #a29bfe;
        transform: scale(1);
    }
}

/* Mobile responsive - upgrade panel adjustments */
@media (max-width: 900px) and (min-width: 601px) {
    .upgrade-panel {
        padding: 10px;
        font-size: 12px;
    }
    
    .upgrade-icon {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }
    
    .upgrade-name {
        font-size: 11px;
    }
    
    .upgrade-desc {
        font-size: 9px;
    }
    
    .upgrade-level {
        font-size: 16px;
    }
    
    .upgrade-panel-title {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

.menu-screen,
.game-over-screen,
.victory-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    color: #fff;
}

.menu-screen h1,
.game-over-screen h1 {
    font-size: 48px;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    color: #ffd700;
}

.victory-screen h1 {
    font-size: 48px;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    color: #ffd700;
    animation: victoryTitlePulse 2s ease-in-out infinite, victoryTitleGlow 1.5s ease-in-out infinite alternate;
    transform-origin: center;
}

@keyframes victoryTitlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes victoryTitleGlow {
    0% {
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.5);
    }
    100% {
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 1), 0 0 50px rgba(255, 165, 0, 0.8);
    }
}

.instructions {
    text-align: center;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.8;
    color: #ccc;
}

.victory-message {
    text-align: center;
    font-size: 24px;
    margin-bottom: 20px;
    color: #ffd700;
    font-weight: bold;
    animation: victoryMessageSlide 1s ease-out, victoryMessageFade 2s ease-in-out infinite 1s;
}

@keyframes victoryMessageSlide {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes victoryMessageFade {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.continue-message {
    text-align: center;
    font-size: 18px;
    margin-bottom: 30px;
    color: #4ecdc4;
    font-style: italic;
    animation: continueMessageBlink 1.5s ease-in-out infinite;
}

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

.victory-screen .final-score {
    animation: scoreAppear 1.5s ease-out 0.5s both;
}

@keyframes scoreAppear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.instructions strong {
    color: #ffd700;
}

.game-button {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.game-button:active {
    transform: translateY(0);
}

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

#finalScore {
    font-size: 32px;
    font-weight: bold;
}

/* Touch/Click areas for mobile - now hidden, using canvas click instead */
.touch-area {
    display: none;
}

