* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', monospace;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    color: #fff;
    overflow: hidden;
    height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(0, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

#gameContainer {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.overlay {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
}

/* Main Menu Styles */
.menu-content {
    text-align: center;
    animation: floatIn 1s ease-out;
}

.game-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    background: linear-gradient(45deg, #00ffff, #ff00ff, #ffff00);
    background-size: 300% 300%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease-in-out infinite;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    margin-bottom: 1rem;
}

.game-subtitle {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #00ffff;
    margin-bottom: 3rem;
    opacity: 0.8;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.menu-btn, .audio-btn, .control-btn {
    padding: 1rem 2rem;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: clamp(0.8rem, 2vw, 1rem);
    background: linear-gradient(45deg, #00ffff, #0080ff);
    border: none;
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0, 255, 255, 0.3);
}

.menu-btn:hover, .audio-btn:hover, .control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 255, 255, 0.5);
    background: linear-gradient(45deg, #ff00ff, #ffff00);
}

/* Game Screen Styles */
#gameScreen {
    flex-direction: column;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-ui {
    width: 100%;
    max-width: 800px;
    padding: 1rem;
    z-index: 50;
}

.ui-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.score-info {
    display: flex;
    gap: 2rem;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
    font-weight: 700;
}

.score-info span {
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.game-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    padding: 0.5rem;
    font-size: 1rem;
    min-width: 40px;
    border-radius: 50%;
}

#gameCanvas {
    width: 100%;
    max-width: 800px;
    height: calc(100vh - 120px);
    max-height: 600px;
    border: 2px solid #00ffff;
    border-radius: 15px;
    background: linear-gradient(180deg, #000033, #000066);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.3),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    touch-action: none;
    user-select: none;
}

.touch-controls {
    display: none;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    left: 0;
    right: 0;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
}

.touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(0, 255, 255, 0.3);
    border: 2px solid #00ffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #00ffff;
    user-select: none;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.touch-btn:active {
    background: rgba(0, 255, 255, 0.6);
    transform: scale(0.95);
}

/* Fire Button for Laser Power-up */
.fire-btn {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    right: 20px;
    width: 80px;
    height: 50px;
    background: linear-gradient(45deg, #ff0000, #ff6600);
    border: 2px solid #ffff00;
    border-radius: 25px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
    user-select: none;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    z-index: 101;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
    animation: pulseFireButton 1.5s ease-in-out infinite;
}

.fire-btn:active {
    background: linear-gradient(45deg, #ff6600, #ffff00);
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.5);
}

.fire-btn.show {
    display: flex;
}

@keyframes pulseFireButton {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 25px rgba(255, 0, 0, 0.6);
    }
}

/* How to Play Screen */
.how-to-play-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 15px;
    border: 2px solid #00ffff;
    backdrop-filter: blur(10px);
}

.how-to-play-content h2 {
    text-align: center;
    color: #00ffff;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.instructions-container {
    display: grid;
    gap: 1.5rem;
}

.instruction-section {
    background: rgba(0, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.instruction-section h3 {
    color: #ffff00;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    margin-bottom: 1rem;
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

.instruction-section p {
    color: #fff;
    line-height: 1.6;
    font-size: clamp(0.8rem, 2vw, 1rem);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.control-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-item strong {
    color: #00ffff;
    display: block;
    margin-bottom: 0.5rem;
}

.control-item ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.control-item li {
    color: #fff;
    margin-bottom: 0.3rem;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
}

.brick-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.brick-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
}

.powerups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.powerup-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: clamp(0.7rem, 1.8vw, 0.9rem);
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
}

.tips-list li {
    color: #fff;
    margin-bottom: 0.8rem;
    padding-left: 1rem;
    position: relative;
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    line-height: 1.5;
}

.tips-list li::before {
    content: "▶";
    color: #00ffff;
    position: absolute;
    left: 0;
}

.scoring-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.scoring-info div {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: clamp(0.7rem, 1.6vw, 0.85rem);
    text-align: center;
}

.how-to-play-buttons {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 255, 255, 0.3);
}

/* Mobile optimizations for how-to-play */
@media (max-width: 768px) {
    .how-to-play-content {
        padding: 1rem;
        margin: 0.5rem;
        max-height: 85vh;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .brick-types,
    .powerups-grid {
        grid-template-columns: 1fr;
    }
    
    .scoring-info {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .instruction-section {
        padding: 1rem;
    }
}

/* Pause and Game Over Screens */
.pause-content, .gameover-content, .level-content, .boss-content {
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

.pause-content h2, .gameover-content h2, .level-content h2, .boss-content h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 2rem;
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

/* Power-up Notification */
.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #ff00ff, #ffff00);
    color: #000;
    padding: 1rem 2rem;
    border-radius: 15px;
    font-weight: 700;
    font-size: 1.2rem;
    opacity: 0;
    z-index: 200;
    transition: all 0.3s ease;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
}

.notification.show {
    opacity: 1;
    animation: powerupPop 2s ease-out forwards;
}

/* Boss Health Bar */
.boss-health {
    width: 300px;
    height: 20px;
    background: rgba(255, 0, 0, 0.3);
    border: 2px solid #ff0000;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1rem;
}

#bossHealthBar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff0000, #ff6600);
    transition: width 0.5s ease;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .touch-controls {
        display: none; /* Hide touch buttons for drag control */
    }
    
    .ui-top {
        padding: 0.3rem 0.8rem;
    }
    
    .score-info {
        gap: 1rem;
        font-size: 0.7rem;
    }
    
    #gameCanvas {
        height: calc(100vh - 200px);
        height: calc(100dvh - 200px); /* Dynamic viewport height for mobile */
        min-height: 400px;
        border-radius: 10px;
        margin-bottom: env(safe-area-inset-bottom, 20px);
    }
    
    #gameScreen {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .game-title {
        font-size: 3rem;
    }
    
    .menu-buttons {
        flex-direction: row;
        justify-content: center;
        gap: 2rem;
    }
    
    #gameCanvas {
        height: calc(100vh - 100px);
    }
}

/* Animations */
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes powerupPop {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1) translateY(-50px);
    }
}

/* Particle Effects */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #00ffff;
    border-radius: 50%;
    pointer-events: none;
    animation: particleExplode 0.8s ease-out forwards;
}

@keyframes particleExplode {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0) translate(var(--dx), var(--dy));
    }
}