/* --- Global Styles & Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #000;
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: auto;
}

/* --- MOBILE MODE LOCK --- */
body.mobile-mode {
    overflow: hidden; 
    touch-action: none; 
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* --- Main Game Layout --- */
#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* --- THE SCREEN (Fixed Internal Resolution) --- */
#screen {
    width: 800px;  /* Matched to internal canvas size */
    height: 450px; /* Matched to internal canvas size */
    background: #6b8cff;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    flex-shrink: 0;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* --- Heads-Up Display (HUD) --- */
#hud {
    position: absolute;
    top: 10px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 16px; /* Tighter fixed size relative to screen */
    font-weight: bold;
    text-shadow: 2px 2px 2px #000;
    pointer-events: none;
    z-index: 10;
}

.player-hud, .timer-hud {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-hud span, .timer-hud span {
    line-height: 1.2;
}

/* --- TOGGLE BUTTON --- */
#mobile-btn {
    position: fixed;
    top: 10px; left: 10px;
    z-index: 2000;
    background: #333;
    color: white;
    border: 2px solid white;
    font-size: 12px;
    padding: 8px;
    cursor: pointer;
    font-family: inherit;
}

body.mobile-mode #mobile-btn { display: none; }

/* --- MOBILE CONTROLS OVERLAY --- */
#mobile-controls {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3000;
    display: none; 
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px;
    box-sizing: border-box;
}

body.mobile-mode #mobile-controls {
    display: flex;
}

.mobile-control-btn {
    pointer-events: auto; 
    width: 70px; height: 70px;
    background: rgba(255,255,255,0.15);
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    color: white;
    font-size: 30px;
    display: flex; justify-content: center; align-items: center;
    user-select: none;
    backdrop-filter: blur(4px);
    margin-bottom: 20px;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-control-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.95);
}

#mobile-dpad {
    display: flex;
    gap: 15px; 
    margin-left: 20px;
    margin-bottom: 20px;
}

#mobile-action {
    margin-right: 40px;
    margin-bottom: 40px;
}

/* --- Start Menu Styles --- */
#start-menu {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#start-menu h1 {
    font-size: 40px;
    margin-bottom: 20px;
    text-shadow: 3px 3px 0px #ff0000;
}

#start-menu button {
    font-family: inherit;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    background-color: #333;
    border: 3px solid #fff;
    padding: 10px 20px;
    margin: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

#start-menu button:hover {
    background-color: #fff;
    color: #000;
}
