body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: url('images/background.png'); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: 'Courier New', Courier, monospace; 
    overflow-x: hidden; 
}

#mainLayout {
    display: flex;
    flex-wrap: wrap; 
    gap: 20px; 
    align-items: flex-start; 
    justify-content: center;
    width: 100%;
    max-width: 1200px; 
    padding: 20px;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.4); 
    border-radius: 20px;
}

#centerColumn {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(800px, calc((100vh - 150px) * 1.333)); 
}

#mainTitle {
    width: 100%; 
    color: #fff;
    font-size: clamp(32px, 5vw, 54px); 
    margin: 0 0 15px 0;
    text-shadow: 4px 4px 0 #000;
    letter-spacing: 4px;
    text-align: center;
}

#gameContainer {
    position: relative; 
    width: 100%; 
    aspect-ratio: 4 / 3; 
    box-shadow: 8px 8px 0px rgba(0,0,0,0.5); 
}

canvas {
    display: block; 
    width: 100%; 
    height: 100%;
    border: 4px solid #555;
    box-sizing: border-box;
}

#rightColumn {
    display: flex;
    flex-direction: column;
    gap: 15px; 
    width: 100%;
    max-width: 250px;
    height: auto; 
    justify-content: flex-start; 
}

.uiPanel {
    background-color: #727272; 
    border: 4px solid #4a4a4a;
    border-top-color: #9e9e9e; 
    border-left-color: #9e9e9e;
    padding: 15px;
    color: white;
    text-align: center;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.3);
}

.uiPanel h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #ffaa00;
    text-shadow: 2px 2px 0 #000;
}

.uiPanel p {
    margin: 0;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
}

#leaderboardPanel {
    flex-grow: 1; 
    text-align: left;
    overflow: hidden; 
}

#leaderboardList {
    margin: 0;
    padding-left: 25px;
    font-size: 13px; 
    line-height: 2;
    text-shadow: 1px 1px 0 #000;
}

#leaderboardList li {
    white-space: nowrap; 
}

.rank-1 { color: #FFD700; font-weight: bold; font-size: 15px; } 
.rank-2 { color: #C0C0C0; font-weight: bold; } 
.rank-3 { color: #CD7F32; font-weight: bold; } 
.rank-normal { color: #ffffff; }

#btnPause {
    background-color: #555;
    color: white;
    border: 4px solid #333;
    border-top-color: #777;
    border-left-color: #777;
    padding: 15px;
    font-size: 24px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.3);
}

#btnPause:hover { background-color: #ffaa00; color: white; border-color: #ffcc00; }

#startMenu {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(17, 17, 17, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10; 
}

#titleText {
    font-size: clamp(30px, 8vw, 60px); 
    margin-bottom: 20px;
    color: #ffaa00;
    text-shadow: 4px 4px 0 #000;
    text-align: center;
}

#playerNameInput {
    background-color: #222;
    color: #fff;
    border: 4px solid #444;
    border-top-color: #111;
    border-left-color: #111;
    padding: 15px;
    font-size: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    width: 80%; 
    max-width: 300px;
    outline: none;
}

#playerNameInput:focus { border-color: #ffaa00; }

#difficultyButtons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    background-color: #555;
    color: white;
    border: 4px solid #333;
    border-top-color: #777;
    border-left-color: #777;
    padding: 15px 30px; 
    margin: 10px;
    font-size: 18px; 
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
}

button:hover { background-color: #ffaa00; color: white; border-color: #ffcc00; }

#btnGuide {
    background-color: #2b2b2b;
    font-size: 16px;
    margin-top: 30px;
}
#btnGuide:hover {
    background-color: #ffaa00;
    border-color: #ffcc00;
}

#startPrompt {
    font-size: clamp(16px, 4vw, 24px); 
    color: yellow;
    animation: flash 1s infinite alternate;
    text-align: center;
    margin-top: 15px;
}

#guideOverlay {
    position: absolute;
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 90%; 
    max-width: 600px; 
    height: auto; 
    max-height: 90%; 
    overflow-y: auto; 
    background-color: #333;
    border: 6px solid #555;
    border-top-color: #888;
    border-left-color: #888;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 20; 
    text-align: center;
    box-shadow: 8px 8px 0px rgba(0,0,0,0.8);
    padding: 20px;
    box-sizing: border-box;
}

#guideOverlay h2 {
    color: #ffaa00;
    margin-top: 0;
    font-size: clamp(24px, 5vw, 36px);
    text-shadow: 2px 2px 0 #000;
}

#guideOverlay p, #guideOverlay ul {
    font-size: clamp(14px, 3vw, 16px);
    margin: 5px 0;
}

@keyframes flash {
    from { opacity: 1; }
    to { opacity: 0.2; }
}

@media (max-width: 1100px) {
    #mainLayout {
        flex-direction: column;
        align-items: center;
    }
    
    #rightColumn {
        flex-direction: row; 
        flex-wrap: wrap;
        width: 100%;
        max-width: 800px;
        height: auto;
        min-height: auto;
        justify-content: center;
    }

    #leaderboardPanel {
        width: 100%; 
    }

    #btnPause {
        width: 100%; 
    }
}