button {
    font-size: 16px;
}
#game-container {
    width: 601.6px;
    height: 451.2px;
    border: 1.88px solid black;
    background-color: #f0f0f0;
    position: relative;
    overflow: hidden;
}

#speedrun-timer {
    position: absolute;
    top: 9.4px;
    left: 9.4px;
    background-color: rgba(0, 0, 0, 0.7);
    color: limegreen;
    padding: 4.7px 9.4px;
    border-radius: 4.7px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 18.8px;
    font-weight: bold;
    z-index: 50;
    white-space: nowrap;
}

#player {
    width: 18.8px;
    height: 18.8px;
    background-color: blue;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#enemy {
    width: 18.8px;
    height: 18.8px;
    background-color: red;
    position: absolute;
    transform: translate(-50%, -50%);
}

#enemy.boss {
    background-color: purple;
    border: 2.82px solid gold;
}

#enemy.secret-boss {
    background-color: darkred;
    border: 3.76px solid yellow;
    box-shadow: 0 0 14.1px orange;
}

.health-bar {
    width: 28.2px;
    height: 4.7px;
    background-color: grey;
    border: 0.94px solid black;
    position: absolute;
    top: -9.4px;
    left: 50%;
    transform: translateX(-50%);
    box-sizing: border-box;
}

.health-fill {
    width: 100%;
    height: 100%;
    background-color: green;
}

#melee-range-indicator {
    position: absolute;
    border: 1px dashed black;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0.5;
}

#range-range-indicator {
    position: absolute;
    border: 1px dashed black;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0.2;
}

#bullet {
    position: absolute;
    width: 7.52px;
    height: 7.52px;
    background-color: black;
    border-radius: 50%;
    z-index: 60;
    pointer-events: none;
    opacity: 1;
}

#bullet.terra-blade-active {
    background-color: limegreen;
}

#sword-effect {
    position: absolute;
    width: 37.6px;
    height: 37.6px;
    border: 1.88px solid deepskyblue;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 60;
    pointer-events: none;
}

#sword-effect.terra-blade-active {
    border-color: limegreen;
    background-color: rgba(0, 255, 0, 0.3);
}

.sword-animation {
    animation: swing 0.2s ease-out forwards;
}

#sword-effect.terra-blade-active.sword-animation {
    animation: terraSwing 0.2s ease-out forwards;
}

@keyframes swing {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
        box-shadow: 0 0 4.7px white;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
        box-shadow: 0 0 14.1px white;
    }
    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
        box-shadow: 0 0 4.7px white;
    }
}

@keyframes terraSwing {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
        box-shadow: 0 0 4.7px limegreen;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
        box-shadow: 0 0 14.1px limegreen;
        border-color: limegreen;
    }
    100% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
        box-shadow: 0 0 4.7px limegreen;
    }
}

#summon-dot {
    position: absolute;
    width: 14.1px;
    height: 14.1px;
    background-color: yellowgreen;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    pointer-events: none;
    transition: transform 0.1s ease-out;
}

.summon-attack-effect {
    animation: summonPulse 0.1s ease-out;
}

@keyframes summonPulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}


/* Title Screen Styles */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1a1a2e;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#game-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 45.12px;
    text-align: center;
    margin-bottom: 28.2px;
    text-shadow: 1.88px 1.88px 0px rgba(255,255,255,0.2),
                 -1.88px -1.88px 0px rgba(0,0,0,0.2);
}

#game-version {
    font-family: 'Courier New', Courier, monospace;
    font-size: 18.8px;
    text-align: center;
    margin-top: -14.1px;
    color: #cccccc;
}

#start-game-btn, #settings-btn, #title-leaderboard-btn {
    padding: 14.1px 28.2px;
    font-size: 22.56px;
    background-color: #e94560;
    color: white;
    border: 2.82px solid #f0a500;
    border-radius: 4.7px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 14.1px;
    font-family: 'Courier New', Courier, monospace;
}

#start-game-btn:hover, #settings-btn:hover, #title-leaderboard-btn:hover {
    background-color: #f0a500;
    border-color: #e94560;
}


#upgrade-menu, #stats-menu, #settings-menu, #game-over-screen, #shop-menu, #credits-screen, #leaderboard-carousel-wrapper, #inventory-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 376px;
    min-height: 235px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border: 1.88px solid white;
    border-radius: 9.4px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 18.8px;
    z-index: 100;
    box-sizing: border-box;
    text-align: center;
}

#upgrade-menu h2, #stats-menu h2, #settings-menu h2, #game-over-screen h2, #shop-menu h2, #credits-screen h2, #leaderboard-carousel-wrapper h2, #inventory-menu h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

/* Leaderboard Carousel Specific Styles */
.carousel-nav-container {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

#leaderboard-carousel {
    display: flex;
    overflow-x: hidden;
    scroll-snap-type: x mandatory;
    width: 100%;
    height: auto;
    flex-grow: 1;
    transition: transform 0.3s ease-in-out;
}

.leaderboard-page {
    flex: 0 0 100%;
    scroll-snap-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.leaderboard-page h3 {
    margin-top: 5px;
    margin-bottom: 10px;
    color: #f0a500;
}

#leaderboard-carousel-wrapper ol {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 10px 0;
    text-align: left;
    width: 90%;
    max-height: 200px;
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    padding-top: 5px;
    padding-bottom: 5px;
}

#leaderboard-carousel-wrapper li {
    font-size: 16.92px;
    margin-bottom: 5px;
}

.leaderboard-nav-btn {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin: 0 5px;
}

.leaderboard-nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}


#inventory-menu #equipped-items {
    width: 90%;
    text-align: left;
    margin-bottom: 9.4px;
    padding: 9.4px;
    border: 1px solid gray;
    background-color: rgba(255, 255, 255, 0.1);
}

#inventory-menu #equipped-items p {
    margin: 4.7px 0;
    font-size: 15.04px;
}

.equipped-item-slot {
    font-weight: bold;
    color: #4CAF50;
}

#inventory-menu ul {
    list-style: none;
    padding: 0;
    width: 90%;
    max-height: 188px;
    overflow-y: auto;
    margin-bottom: 18.8px;
    border: 1px solid gray;
    background-color: rgba(255, 255, 255, 0.1);
}

#inventory-menu li {
    padding: 4.7px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#inventory-menu li:last-child {
    border-bottom: none;
}

.inventory-item-btn {
    width: 100%;
    padding: 9.4px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.04px;
    text-align: left;
    margin: 0;
}

.inventory-item-btn:hover {
    background-color: #0056b3;
}


#credits-screen {
    background-color: rgba(0, 0, 0, 0.9);
}

#credits-screen h2 {
    font-size: 28.2px;
    margin-bottom: 18.8px;
    color: gold;
}

#credits-screen p {
    font-size: 16.92px;
    margin-bottom: 9.4px;
}

/* Styles for Restart and Close buttons that are NOT on the Credits screen */
#close-leaderboard-btn, #close-inventory-menu-btn {
    display: block;
    width: 80%;
    padding: 11.28px;
    margin-top: 18.8px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
    margin-left: auto;
    margin-right: auto;
}

#close-leaderboard-btn:hover, #close-inventory-menu-btn:hover {
    background-color: #0056b3;
}

/* Styles for buttons on end screens (Game Over and Credits) to match Title Screen buttons */
#game-over-screen #restart-btn,
#credits-screen button {
    display: block;
    width: 80%;
    padding: 14.1px 28.2px;
    margin-top: 14.1px;
    background-color: #e94560;
    color: white;
    border: 2.82px solid #f0a500;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 22.56px;
    font-family: 'Courier New', Courier, monospace;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    margin-left: auto;
    margin-right: auto;
}

#game-over-screen #restart-btn:hover,
#credits-screen button:hover {
    background-color: #f0a500;
    border-color: #e94560;
}


#controls {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: 18.8px;
    gap: 18.8px;
}

#joystick-container {
    display: grid;
    grid-template-columns: repeat(3, 65.8px);
    grid-template-rows: repeat(3, 65.8px);
    gap: 4.7px;
    width: 206.8px;
    height: 206.8px;
    background-color: #333;
    border-radius: 9.4px;
    padding: 9.4px;
    box-shadow: inset 0 0 9.4px rgba(0,0,0,0.5);
    position: relative;
}

#joystick-container button {
    width: 65.8px;
    height: 65.8px;
    border-radius: 50%;
    font-size: 15.04px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 3.76px 5.64px rgba(0,0,0,0.3);
    text-align: center;
    line-height: 1.2;
}

#joystick-container button:hover {
    background-color: #0056b3;
}

#up-btn {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}
#left-btn {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}
#right-btn {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
}
#down-btn {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
}

#action-buttons-container {
    display: grid;
    grid-template-columns: repeat(2, 94px);
    gap: 9.4px;
    padding: 9.4px;
    background-color: #333;
    border-radius: 9.4px;
    box-shadow: inset 0 0 9.4px rgba(0,0,0,0.5);
}

#action-buttons-container button {
    width: 94px;
    height: 94px;
    border-radius: 50%;
    font-size: 13.16px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #28a745;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 3.76px 5.64px rgba(0,0,0,0.3);
    text-align: center;
    line-height: 1.2;
}

#action-buttons-container button:hover {
    background-color: #218838;
}

#settings-menu .settings-options button {
    display: block;
    width: 90%;
    padding: 11.28px;
    margin-bottom: 9.4px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
}

#settings-menu .settings-options button:hover {
    background-color: #45a049;
}

.upgrade-options button, .shop-options button {
    display: block;
    width: 90%;
    padding: 11.28px;
    margin-bottom: 9.4px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
}

.upgrade-options button:hover, .shop-options button:hover {
    background-color: #45a049;
}


/* Styling for the new login panel and its elements */
#login-panel {
    width: 90%;
    max-width: 300px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

#login-panel h3 {
    margin-top: 0;
    color: white;
    font-size: 20px;
    margin-bottom: 5px;
}

#login-panel input[type="text"],
#login-panel input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
    text-align: center;
}

#login-panel input[type="text"]::placeholder,
#login-panel input[type="password"]::placeholder {
    color: #bbb;
}

#login-panel button {
    display: block;
    width: 100%;
    padding: 11.28px;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
    font-family: 'Courier New', Courier, monospace;
    border: none;
    transition: background-color 0.3s ease;
    margin-top: 0;
    margin-bottom: 0;
}

#login-submit-btn {
    background-color: #28a745;
}

#login-submit-btn:hover {
    background-color: #218838;
}

#login-cancel-btn {
    background-color: #dc3545;
}

#login-cancel-btn:hover {
    background-color: #c82333;
}

#login-message {
    margin-top: 10px;
    font-weight: bold;
    font-size: 14px;
}

/* NEW: Styling for the save game panel and its elements */
#save-game-panel {
    width: 90%;
    max-width: 300px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

#save-game-panel h3 {
    margin-top: 0;
    color: white;
    font-size: 20px;
    margin-bottom: 5px;
}

#save-game-panel input[type="text"],
#save-game-panel input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
    text-align: center;
}

#save-game-panel input[type="text"]::placeholder,
#save-game-panel input[type="password"]::placeholder {
    color: #bbb;
}

#save-game-panel button {
    display: block;
    width: 100%;
    padding: 11.28px;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
    font-family: 'Courier New', Courier, monospace;
    border: none;
    transition: background-color 0.3s ease;
    margin-top: 0;
    margin-bottom: 0;
}

#save-game-submit-btn {
    background-color: #007bff;
}

#save-game-submit-btn:hover {
    background-color: #0056b3;
}

#save-game-cancel-btn {
    background-color: #6c757d;
}

#save-game-cancel-btn:hover {
    background-color: #5a6268;
}

#save-game-message {
    margin-top: 10px;
    font-weight: bold;
    font-size: 14px;
}

/* NEW: Styling for the load game panel and its elements */
#load-game-panel {
    width: 90%;
    max-width: 300px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

#load-game-panel h3 {
    margin-top: 0;
    color: white;
    font-size: 20px;
    margin-bottom: 5px;
}

#load-game-panel input[type="text"],
#load-game-panel input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: white;
    font-size: 16px;
    box-sizing: border-box;
    text-align: center;
}

#load-game-panel input[type="text"]::placeholder,
#load-game-panel input[type="password"]::placeholder {
    color: #bbb;
}

#load-game-panel button {
    display: block;
    width: 100%;
    padding: 11.28px;
    border-radius: 4.7px;
    cursor: pointer;
    font-size: 15.98px;
    font-family: 'Courier New', Courier, monospace;
    border: none;
    transition: background-color 0.3s ease;
    margin-top: 0;
    margin-bottom: 0;
}

#load-game-submit-btn {
    background-color: #ffc107; /* A distinct color for load */
    color: black;
}

#load-game-submit-btn:hover {
    background-color: #e0a800;
}

#load-game-cancel-btn {
    background-color: #6c757d;
}

#load-game-cancel-btn:hover {
    background-color: #5a6268;
}

#load-game-message {
    margin-top: 10px;
    font-weight: bold;
    font-size: 14px;
}


.hidden {
    display: none !important;
}

#coin-display {
    position: absolute;
    top: 9.4px;
    right: 9.4px;
    background-color: gold;
    color: black;
    padding: 4.7px 9.4px;
    border-radius: 4.7px;
    font-weight: bold;
    z-index: 50;
}

#leaderboard-error-message {
    color: red;
    font-weight: bold;
    margin-top: 20px;
    font-size: 18px;
}