body {
    margin: 0; 
    padding: 0; 
    display: flex; 
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    min-height: 100vh;
    background-color: #87CEEB; 
    font-family: 'Comic Sans MS', 'Arial', sans-serif; 
    overflow-x: hidden;
    position: relative; 
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px; 
    padding: 5px;
    box-sizing: border-box;
}

h1.main-title { 
    color: #FF4500; 
    text-shadow: 2px 2px #000000; 
    margin-top: 10px;
    margin-bottom: 5px; 
    font-size: clamp(20px, 5vw, 24px);
    text-align: center;
}

.game-stats { 
    display: flex; 
    justify-content: space-around; 
    width: 100%; 
    max-width: 320px; 
    margin-bottom: 5px; 
}

.stat-display { 
    font-size: clamp(16px, 4vw, 18px); 
    color: #FFFFFF; 
    text-shadow: 1px 1px #000000; 
}

#gameCanvas { 
    border: 3px solid #333; 
    box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
    display: block; 
    width: 100%; 
    max-width: 400px; 
    aspect-ratio: 400 / 600; 
    margin: 0 auto; 
}

.screen-overlay { 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.85); 
    color: white; 
    padding: clamp(10px, 3vw, 20px); 
    border-radius: 12px; 
    text-align: center; 
    z-index: 10; 
    border: 3px solid #FFB800; 
    width: 90%; 
    max-width: 360px; 
    box-shadow: 0px 0px 20px rgba(0,0,0,0.6); 
    max-height: 90vh; 
    overflow-y: auto;
    box-sizing: border-box;
}

.screen-overlay h2 { 
    color: #FF4500; 
    margin-top: 0; 
    margin-bottom: clamp(10px, 3vh, 15px); 
    font-size: clamp(20px, 5vw, 26px); 
}

.screen-overlay p { 
    font-size: clamp(13px, 3vw, 16px); 
    margin: clamp(5px, 1.5vh, 8px) 0; 
    line-height: 1.4; 
}

#startScreen .instructions { 
    margin-bottom: clamp(10px, 3vh, 15px); 
    text-align: left; 
    border: 1px dashed #FFD700; 
    padding: clamp(8px, 2vw, 12px) clamp(10px, 2.5vw, 15px); 
    border-radius: 5px; 
    background-color: rgba(255, 255, 255, 0.05); 
    width: 95%; 
    box-sizing: border-box; 
}

#startScreen .instructions p { 
    margin: clamp(4px, 1vh, 6px) 0; 
    font-size: clamp(12px, 2.5vw, 15px); 
}

#startScreen .objective-text { 
    font-style: italic; 
    margin-top: clamp(8px, 2vh, 10px); 
    margin-bottom: clamp(15px, 3vh, 20px); 
    width: 95%; 
    box-sizing: border-box; 
    font-size:clamp(13px, 3vw, 14px); 
}

.screen-overlay button { 
    background-color: #FFD700; 
    color: #222; 
    padding: clamp(8px, 2vh, 10px) clamp(15px, 4vw, 20px); 
    border: none;
    border-radius: 8px; 
    font-size: clamp(14px, 3.5vw, 16px); 
    cursor: pointer; 
    margin-top: clamp(10px, 2vh, 15px); 
    font-weight: bold; 
    transition: background-color 0.2s ease; 
}

#startButton { margin-top: 0; }
#restartButton:hover, #startButton:hover, #submitInitialsButton:hover { background-color: #FFA500; }

#gameOverScreen p { 
    font-size: clamp(14px, 3.5vw, 16px); 
    margin: clamp(8px, 1.5vh, 10px) 0; 
}

#loadingMessage { 
    font-size: clamp(18px, 4vw, 20px); 
    color: #FFFFFF; 
    text-shadow: 1px 1px #000000; 
    margin-bottom: 10px; 
    display: none; 
}
        
#gameOverInfo { 
    margin-bottom: clamp(8px, 2vh, 10px); 
    width:100%;
}

#initialsEntrySection { 
    display: none; 
    margin: clamp(8px, 2vh, 10px) 0; 
    padding: clamp(10px, 2vw, 15px); 
    border-top: 1px dashed #FFD700; 
    border-bottom: 1px dashed #FFD700; 
    width: 90%; 
    box-sizing: border-box; 
}

#initialsEntrySection h3 { 
    margin-top: 0; 
    margin-bottom: 8px; 
    color: #FFA500; 
    font-size: clamp(16px, 4vw, 18px); 
}

#initialsEntrySection label { 
    display: block; 
    margin-bottom: 5px; 
    font-size: clamp(12px, 2.5vw, 13px); 
}

#initialsEntrySection input[type="text"] { 
    padding: 7px; 
    font-size: clamp(14px, 3vw, 15px); 
    text-align: center; 
    text-transform: uppercase; 
    border-radius: 4px; 
    border: 1px solid #ccc; 
    margin-bottom: 8px; 
    width: 70px; 
}

#submitInitialsButton { 
    margin-top: 5px; 
    padding: clamp(7px, 1.8vh, 8px) clamp(12px, 3vw, 15px); 
    font-size: clamp(13px, 3vw, 15px); 
}

#highScoreDisplayArea { 
    width: 100%; 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    margin-top:clamp(8px, 2vh, 10px);
}

#highScoreSection { 
    margin-top: 0; 
    padding-top: 0; 
    width: 90%; 
    box-sizing: border-box;
}

#highScoreSection h3 { 
    margin-top: 0; 
    margin-bottom: 6px; 
    color: #FFD700; 
    font-size: clamp(14px, 3.5vw, 16px);
}

#highScoreList { 
    list-style-type: decimal; 
    padding-left: 30px; 
    margin: 0 auto; 
    max-height: 90px; 
    overflow-y: auto; 
    width: fit-content; 
}

#highScoreList li { 
    font-size: clamp(12px, 2.5vw, 13px); 
    margin-bottom: 3px; 
    text-align: left; 
}

.powered-by { 
    margin-top: 10px; 
    margin-bottom: 75px; /* Space for touch controls if they are at the very bottom */
    font-size: clamp(10px, 2.5vw, 12px); 
    color: #FFFFFF; 
    text-shadow: 1px 1px #000000; 
    text-align: center;
}

.powered-by a { 
    color: #FFD700; 
    text-decoration: none; 
    font-weight: bold; 
}

.powered-by a:hover { 
    text-decoration: underline; 
    color: #FFA500; 
}

#touchControls { 
    display: none; 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%;
    padding: 5px 0; 
    box-sizing: border-box; 
    background-color: rgba(0, 0, 0, 0.15);
    z-index: 20; 
    justify-content: space-around; 
    align-items: center;
    height: 70px; 
}

.touch-button {
    background-color: rgba(255, 221, 0, 0.6); 
    color: #222; 
    border: 1px solid rgba(0,0,0,0.4); 
    border-radius: 50%; 
    width: 55px; 
    height: 55px; 
    font-size: 24px; 
    font-weight: bold; 
    display: flex;
    justify-content: center; 
    align-items: center; 
    user-select: none; 
    -webkit-user-select: none; 
    -webkit-tap-highlight-color: transparent; 
}
.touch-button:active { background-color: rgba(255, 165, 0, 0.7); }