/* Start Screen Styles */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.start-container {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: min(500px, 90vw);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.game-title {
    color: #fff;
    font-size: clamp(1.8rem, 8vw, 2.5rem);
    margin-bottom: clamp(20px, 5vh, 30px);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.start-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(15px, 3vh, 30px);
    margin-bottom: clamp(20px, 4vh, 30px);
    text-align: left;
}

@media (min-width: 768px) {
    .start-content {
        grid-template-columns: 1fr 1fr;
    }
}

.controls-info, .powerups-info {
    background: rgba(255, 255, 255, 0.1);
    padding: clamp(15px, 3vw, 20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.controls-info h3, .powerups-info h3 {
    color: #fff;
    margin-bottom: clamp(10px, 2vh, 15px);
    font-size: clamp(1rem, 4vw, 1.2rem);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 8px;
}

.controls-info p {
    color: #e0e0e0;
    margin: clamp(6px, 1.5vh, 8px) 0;
    font-size: clamp(0.85rem, 3vw, 0.95rem);
    line-height: 1.4;
}

.powerup-item {
    display: flex;
    align-items: center;
    margin: clamp(8px, 2vh, 12px) 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.powerup-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.powerup-item img {
    width: clamp(25px, 6vw, 30px);
    height: clamp(25px, 6vw, 30px);
    margin-right: clamp(8px, 2vw, 12px);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.powerup-item span {
    color: #fff;
    font-size: clamp(0.85rem, 3vw, 0.95rem);
}

.start-button {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: clamp(1rem, 4vw, 1.3rem);
    font-weight: bold;
    padding: clamp(12px, 3vh, 15px) clamp(30px, 8vw, 40px);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: min(200px, 60vw);
    position: relative;
    z-index: 10;
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
    background: linear-gradient(135deg, #ff7979, #ff3838);
}

.start-button:active {
    transform: translateY(-1px);
}

/* Animation for screen transition */
@keyframes fadeOut {
    from { 
        opacity: 1; 
        visibility: visible;
    }
    to { 
        opacity: 0; 
        visibility: hidden;
    }
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}

.screen.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

#game-container.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Improved Mobile-Friendly Layout */
:root {
    --primary-bg: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.2);
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--primary-bg);
    color: #fff;
    overflow: hidden;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: clamp(60px, 12vh, 90px);
    box-sizing: border-box;
}

#top-bar {
    width: 95%;
    max-width: 480px;
    padding: clamp(8px, 2vh, 12px);
    text-align: center;
    background: var(--glass-bg);
    border-bottom: 2px solid var(--glass-border);
    backdrop-filter: blur(14px);
    font-size: clamp(0.9rem, 3.5vw, 1.15rem);
    font-weight: bold;
    border-radius: 16px;
    margin-top: clamp(4px, 1vh, 8px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    box-sizing: border-box;
}

#gameCanvas {
    width: 94vw;
    height: calc(92vh - 160px);
    max-width: 500px;
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 18px;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(8px);
    margin-top: clamp(8px, 2vh, 12px);
    box-shadow: inset 0 0 18px rgba(0,0,0,0.6);
    box-sizing: border-box;
}

.controls-container {
    position: fixed;
    bottom: 2.5%;
    width: 100%;
    height: clamp(140px, 20vh, 180px);
    pointer-events: none;
}

/* D-Pad */
.d-pad {
    position: absolute;
    bottom: 8%;
    left: 6%;
    width: min(28vw, 160px);
    height: min(28vw, 160px);
    display: grid;
    grid-template-areas:
        ". up ."
        "left . right"
        ". down .";
    pointer-events: auto;
}

.arrow {
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1rem, 6vw, 1.75rem);
    color: #fff;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.arrow:active {
    transform: scale(0.9);
    background: rgba(255,255,255,0.25);
}

#arrow-up   { grid-area: up; }
#arrow-down { grid-area: down; }
#arrow-left { grid-area: left; }
#arrow-right{ grid-area: right; }

/* Shoot Button */
#shoot-btn {
    position: absolute;
    bottom: 8%;
    right: 6%;
    width: min(26vw, 150px);
    height: min(26vw, 150px);
    background: rgba(255, 100, 100, 0.28);
    border: 2px solid rgba(255, 120, 120, 0.9);
    border-radius: 50%;
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1rem, 5vw, 1.6rem);
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.6);
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#shoot-btn:active {
    transform: scale(0.9);
    box-shadow: 0 0 12px rgba(255,120,120,1);
}

/* Game Buttons */
.game-buttons {
    position: absolute;
    top: clamp(50px, 8vh, 70px);
    left: 5%;
    display: flex;
    gap: clamp(8px, 1.5vw, 10px);
    z-index: 10;
}

.game-buttons button {
    padding: clamp(8px, 1.5vh, 10px) clamp(16px, 3vw, 20px);
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    color: #fff;
    font-weight: bold;
    backdrop-filter: blur(10px);
    margin-top: clamp(4px, 1vh, 6px);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: min(80px, 20vw);
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    -webkit-tap-highlight-color: transparent;
}

.game-buttons button:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.25);
}

/* Power-up Timer */
#powerup-timer {
    position: absolute;
    top: 20px;
    right: 20px;
    width: min(200px, 40vw);
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    overflow: hidden;
    display: none;
    z-index: 10;
}

#powerup-fill {
    height: 100%;
    background: linear-gradient(90deg, #00FF00, #FFFF00, #FF0000);
    width: 0%;
    transition: width 0.3s;
}

/* ===========================
   Responsive Design
=========================== */

/* Mobile Portrait */
@media (max-width: 480px) and (orientation: portrait) {
    #gameCanvas { 
        width: 96vw; 
        height: calc(90vh - 140px); 
    }
    
    .d-pad {
        bottom: 10%;
        left: 5%;
        width: 30vw;
        height: 30vw;
    }
    
    #shoot-btn {
        bottom: 10%;
        right: 5%;
        width: 30vw;
        height: 30vw;
    }
    
    .game-buttons {
        top: 60px;
        left: 3%;
    }
}

/* Mobile Landscape */
@media (max-width: 900px) and (orientation: landscape) {
    #game-container {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: 10px;
    }

    #top-bar {
        position: absolute;
        top: 5px;
        width: 60%;
        max-width: none;
    }

    #gameCanvas {
        width: 60vw;
        height: 90vh;
        max-height: none;
    }

    .controls-container {
        position: absolute;
        right: 2%;
        bottom: 5%;
        width: 35%;
        height: auto;
    }

    .d-pad {
        bottom: 5%;
        left: 3%;
        width: 20vw;
        height: 20vw;
        max-width: 120px;
        max-height: 120px;
    }

    #shoot-btn {
        bottom: 5%;
        right: 3%;
        width: 18vw;
        height: 18vw;
        max-width: 100px;
        max-height: 100px;
    }

    .game-buttons {
        top: 10px;
        left: 2%;
        flex-direction: column;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    #top-bar {
        width: 70%;
        padding: 16px;
    }

    #gameCanvas {
        width: 70vw;
        height: calc(85vh - 180px);
        max-width: 900px;
    }

    .controls-container {
        bottom: 3%;
        height: 200px;
    }

    .d-pad {
        width: 22vw;
        height: 22vw;
        max-width: 200px;
        max-height: 200px;
    }

    #shoot-btn {
        width: 20vw;
        height: 20vw;
        max-width: 180px;
        max-height: 180px;
    }

    .game-buttons {
        top: 80px;
        left: 3%;
    }
}

/* Short screens */
@media (max-height: 700px) {
    #gameCanvas { 
        height: calc(88vh - 140px); 
    }
    
    .controls-container { 
        bottom: 1%; 
        height: 140px;
    }
    
    .game-buttons {
        top: 50px;
    }
    
    .start-container {
        transform: scale(0.9);
    }
}

/* Very short screens */
@media screen and (orientation: portrait) and (max-height: 600px) {
    .start-container {
        transform: scale(0.8);
        margin-top: -30px;
    }
    
    .start-content {
        gap: 10px;
    }
}

/* High-resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .arrow, #shoot-btn, .game-buttons button {
        border-width: 1.5px;
    }
}

/* Prevent text selection */
.arrow, #shoot-btn, button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Debug styles */
.debug-border {
    border: 2px solid red !important;
}

#start-btn.test-click {
    background: #00ff00 !important;
    animation: pulse 0.5s;
}

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