* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: transparent; /* Allow canvas to show through */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: Arial, sans-serif;
}

.menu-screen .menu-content {
    position: absolute;
    top: 200px; /* Match the top position of the side boxes */
    left: 50%;
    transform: translateX(-50%);
    padding: 30px 40px; /* Reduced top/bottom padding */
    padding-bottom: 80px; /* Reduced from 120px but still extra space for map buttons */
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    text-align: center;
    max-width: 500px;
    width: 80%;
    z-index: 10;
    margin-top: 0; /* Remove the margin-top since we're using absolute positioning */
}

.menu-screen .main-menu-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px; /* Reduced from 15px to bring elements closer */
}

.menu-screen h1 {
    font-size: 6.9em; /* Tripled from 2.3em */
    position: absolute;
    top: 60px; /* Position at the top of the screen */
    left: 0;
    right: 0;
    margin: 0 auto;
    text-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff;
    color: #00ffff;
    line-height: 1.2;
    z-index: 20; /* Ensure it appears above the game canvas */
    text-align: center;
    width: 100%;
    pointer-events: none; /* Allow clicking through the title */
}

.name-input {
    width: 60%; /* Slightly increased from 55% */
    padding: 0.6em; /* Reduced padding */
    margin: 0; /* Remove auto margins for flex container alignment */
    font-size: 1.0em; /* Reduced font size from 1.4em */
    background-color: white;
    color: black;
    border: none;
    border-radius: 5px;
    text-align: center;
    outline: none;
    /* Remove all transition effects - will be handled by JS */
    transition: none;
    /* Set minimal initial shadow */
    box-shadow: 0 0 2px rgba(0, 255, 255, 0.1);
    /* Use hardware acceleration */
    transform: translateZ(0);
    /* Tell browser to optimize for these properties */
    will-change: transform, box-shadow;
}

/* Remove focus styles completely - handled by JavaScript */
.name-input:focus {
    outline: none;
    /* No other styles - all handled by JS */
}

.name-input::placeholder {
    color: #666;
}

/* Game mode select dropdown styling */
.game-mode-select {
    padding: 0.6em 0.8em;
    font-size: 1.0em;
    background-color: white;
    color: black;
    border: none;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0, 255, 255, 0.1);
    transition: box-shadow 0.3s, transform 0.3s;
    width: auto;
    font-weight: bold;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.3em center;
    background-size: 1.4em;
    padding-right: 1.6em;
}

.game-mode-select:hover {
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.6);
    background-color: #f5f5f5;
}

.game-mode-select:focus {
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
    outline: none;
    border: 1px solid rgba(0, 255, 255, 0.4);
}

.game-mode-select option {
    font-weight: normal;
    padding: 8px;
}

.menu-screen button#start-game { /* Added ID for specificity */
    padding: 0.6em 1.2em; /* Reduced padding */
    font-size: 1.0em; /* Reduced font size from 1.4em */
    background-color: #00ffff;
    color: black;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    margin: 8px 0 15px 0; /* Reduced margins to bring elements closer */
}

.menu-screen button#start-game:hover { /* Added ID for specificity */
    background-color: #00e6e6;
    transform: scale(1.05);
    box-shadow: 0 0 15px #00ffff;
}

.game-hint {
    color: #FFA500; /* Orange color */
    font-size: 18px;
    margin-top: 10px;
    font-style: italic;
    text-shadow: 0 0 5px rgba(255, 165, 0, 0.7);
    animation: pulse 2s infinite;
}

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

.hidden {
    display: none;
}

#main-menu-leaderboard {
    position: absolute; 
    top: 200px; /* Pushed down from 160px to account for the title */
    left: calc(50% + 270px); /* Position left edge 20px away from center box right edge */
    width: 300px; 
    max-height: calc(100vh - 230px); /* Adjusted to account for title */
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.6); 
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    text-align: left; 
    z-index: 11; 
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

#main-menu-leaderboard h4 {
    color: #00FFFF;
    margin-top: 0;
    margin-bottom: 15px; /* Increased margin */
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    padding-bottom: 10px; /* Increased padding */
    text-align: center; 
    font-size: 1.1em; /* Slightly larger title */
}

#main-menu-leaderboard ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

#main-menu-leaderboard li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px; /* Increased spacing */
    padding: 5px 0; /* Increased padding */
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15); /* Slightly more visible border */
}

#main-menu-leaderboard li:last-child {
    border-bottom: none; /* Remove border from last item */
}

#main-menu-leaderboard li span:first-child { /* Rank */
    font-weight: bold;
    margin-right: 10px; /* Increased margin */
    color: #00FFFF;
    min-width: 30px; /* Increased min-width */
}

#main-menu-leaderboard li span:nth-child(2) { /* Name */
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 15px; /* Increased margin */
    color: #FFFFFF;
}

#main-menu-leaderboard li span:last-child { /* Time */
    font-weight: bold;
    font-family: "Courier New", Courier, monospace;
    color: #DDDDDD;
    white-space: nowrap; /* Prevent time from wrapping */
}

/* Gold, Silver, Bronze Styling */

/* Define the glow animation */
@keyframes medalGlowGold {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 12px rgba(255, 215, 0, 0.7); }
}
@keyframes medalGlowSilver {
    0%, 100% { box-shadow: 0 0 5px rgba(192, 192, 192, 0.4); }
    50% { box-shadow: 0 0 12px rgba(192, 192, 192, 0.7); }
}
@keyframes medalGlowBronze {
    0%, 100% { box-shadow: 0 0 5px rgba(205, 127, 50, 0.4); }
    50% { box-shadow: 0 0 12px rgba(205, 127, 50, 0.7); }
}

#main-menu-leaderboard li:nth-child(1) {
    border-left: 5px solid #FFD700; /* Gold border - thicker */
    /* background-color: rgba(255, 215, 0, 0.08); */ /* Replaced with gradient */
    background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 70%);
    /* animation: medalGlowGold 2s infinite ease-in-out; */ /* REMOVED */
}
#main-menu-leaderboard li:nth-child(1) span:first-child {
    color: #FFD700; /* Gold rank color */
    font-weight: bold;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.7); /* Gold text glow */
}

/* Style name and time for 1st place */
#main-menu-leaderboard li:nth-child(1) span:nth-child(2),
#main-menu-leaderboard li:nth-child(1) span:last-child {
    font-weight: bold;
    /* color: #FFFACD; */ /* Replaced with gradient text */
    background: linear-gradient(90deg, #B8860B, #FFD700, white, #FFD700, #B8860B);
    background-clip: text;
    -webkit-background-clip: text; /* For Safari/Chrome */
    color: transparent;
    /* Add a subtle outer glow to complement */
    text-shadow: 0 0 3px rgba(255, 215, 0, 0.3);
}

#main-menu-leaderboard li:nth-child(2) {
    border-left: 5px solid #C0C0C0; /* Silver border - thicker */
    /* background-color: rgba(192, 192, 192, 0.08); */ /* Replaced with gradient */
    background: radial-gradient(circle, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 70%);
    /* animation: medalGlowSilver 2.2s infinite ease-in-out; */ /* REMOVED */
}
#main-menu-leaderboard li:nth-child(2) span:first-child {
    color: #C0C0C0; /* Silver rank color */
    font-weight: bold;
    text-shadow: 0 0 6px rgba(192, 192, 192, 0.7); /* Silver text glow */
}

/* Style name and time for 2nd place */
#main-menu-leaderboard li:nth-child(2) span:nth-child(2),
#main-menu-leaderboard li:nth-child(2) span:last-child {
    font-weight: bold;
    /* color: #F5F5F5; */ /* Replaced with gradient text */
    background: linear-gradient(90deg, #808080, #C0C0C0, white, #C0C0C0, #808080);
    background-clip: text;
    -webkit-background-clip: text; /* For Safari/Chrome */
    color: transparent;
    /* Add a subtle outer glow to complement */
    text-shadow: 0 0 3px rgba(192, 192, 192, 0.3);
}

#main-menu-leaderboard li:nth-child(3) {
    border-left: 5px solid #CD7F32; /* Bronze border - thicker */
    /* background-color: rgba(205, 127, 50, 0.08); */ /* Replaced with gradient */
    background: radial-gradient(circle, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 70%);
    /* animation: medalGlowBronze 2.4s infinite ease-in-out; */ /* REMOVED */
}
#main-menu-leaderboard li:nth-child(3) span:first-child {
    color: #CD7F32; /* Bronze rank color */
    font-weight: bold;
    text-shadow: 0 0 6px rgba(205, 127, 50, 0.7); /* Bronze text glow */
}

/* Style name and time for 3rd place */
#main-menu-leaderboard li:nth-child(3) span:nth-child(2),
#main-menu-leaderboard li:nth-child(3) span:last-child {
    font-weight: bold;
    /* color: #FFE4B5; */ /* Replaced with gradient text */
    background: linear-gradient(90deg, #8B4513, #CD7F32, white, #CD7F32, #8B4513);
    background-clip: text;
    -webkit-background-clip: text; /* For Safari/Chrome */
    color: transparent;
    /* Add a subtle outer glow to complement */
    text-shadow: 0 0 3px rgba(205, 127, 50, 0.3);
}
/* End Medal Styling */

#main-menu-leaderboard p {
    font-style: italic;
    color: #ccc;
    text-align: center;
}

#extra-menu-options {
    display: none; /* Hide the left side box */
}

/* Skin selector button next to start game */
#skin-selector {
    width: 60px; /* 50% larger */
    height: 60px; /* 50% larger */
    cursor: pointer;
    margin-right: 15px; /* Changed from margin-left to margin-right */
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 2px;
    transition: all 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

#skin-selector:hover {
    transform: scale(1.1);
    box-shadow: none;
    border: none;
}

#skin-selector img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
}

/* Map buttons with transparent cyan styling */
#map-toggle-button,
#map-toggle-button-alt {
    padding: 10px 15px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    opacity: 0.8;
    flex: 1;
    white-space: nowrap;
    min-width: 140px;
    background: linear-gradient(145deg, rgba(0, 255, 255, 0.2), rgba(0, 180, 180, 0.4));
    border: 1px solid rgba(0, 255, 255, 0.4);
    color: white;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

#map-toggle-button:hover,
#map-toggle-button-alt:hover {
    opacity: 1;
    background: linear-gradient(145deg, rgba(0, 255, 255, 0.3), rgba(0, 180, 180, 0.5));
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 255, 255, 0.4);
}

#map-toggle-button.active,
#map-toggle-button-alt.active {
    border-color: #FFD700; /* Gold border for selected map */
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.5));
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    opacity: 1;
}

/* Button container to hold both start game and skin selector */
.button-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0 15px 0;
    width: 100%;
}

/* Simple skins menu */
#skins-menu {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    max-width: 450px;
    height: 60vh;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    z-index: 2000 !important;
    border: 1px solid rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    overflow: auto;
}

/* This ensures the menu is shown when the hidden class is removed */
#skins-menu:not(.hidden) {
    display: block !important;
}

/* Makes sure all menus can be properly shown when needed */
#skins-menu:not(.hidden) {
    display: block !important;
    z-index: 2000 !important; /* Higher than anything else */
}

.skins-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columns */
    gap: 2px; /* Reduced from 5px for closer vertical spacing */
    margin-bottom: 10px; /* Reduced from 20px */
    padding: 0 10px; 
    justify-items: center;
}

.skin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0px; /* Reduced from 2px */
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease;
    border: none; /* Remove border */
    width: 100%; /* Take full width of grid cell */
    max-width: 130px; /* Reduced maximum width */
    margin-bottom: -15px; /* Added negative margin to bring rows closer */
}

.skin-item:hover {
    background-color: transparent; /* Remove background color on hover */
    transform: scale(1.05);
}

/* Remove selected class styling since we're using image scaling instead */
.skin-item.selected {
    background-color: transparent;
    border-color: transparent;
}

.skin-preview-img {
    width: 120px;
    height: 120px;
    margin-bottom: 0; /* Remove margin since there's no text below */
    object-fit: contain;
    border-radius: 5px;
    background-color: transparent; /* Make background transparent */
    transition: transform 0.2s ease; /* Add transition for smooth scaling */
}

/* Remove skin-name class since we're not using text labels anymore */
.skin-name {
    display: none;
}

/* Ensure the close button inside the menu div stays at the bottom */
#skins-menu > div { /* The inner div */
    display: flex;
    flex-direction: column;
    height: 100%; /* Make inner div take full height */
    /* Padding is already applied via inline style in index.html */
}

#skins-menu > div > h2 {
    flex-shrink: 0; /* Prevent title shrinking */
    margin-bottom: 5px; /* Reduced from 15px */
    text-align: center; /* Center the title text */
    padding-top: 5px; /* Reduced from 10px */
}

/* --- Generic Close Button Styling for Submenus --- */
#close-skins-button,
#close-gamemodes-button,
#close-locked-names-button {
    position: absolute; /* Position relative to parent menu */
    top: 15px;          /* Space from top */
    left: 15px;         /* Space from left */
    margin-top: 0;      /* Remove bottom alignment margin */
    margin-left: 0;     /* Remove center alignment margin */
    width: auto;        /* Let content determine width */
    padding: 8px 15px;  /* Adjust padding */
    flex-shrink: 0;     /* Prevent shrinking */
    font-size: 0.9em;   /* Slightly smaller font */
}

/* Style for the map toggle - repositioned inside the menu content box */
#map-toggle-container {
    position: absolute;
    top: auto; /* Remove the fixed top position */
    bottom: 20px; /* Reduced from 30px */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row; 
    gap: 15px;
    z-index: 1000;
    width: 90%; /* Set width to control button sizes */
}

/* Input row styling for name input and game mode select */
.input-row {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 4px; /* Even smaller gap between inputs */
    align-items: center;
    margin-bottom: 2px; /* Add a small space below the row */
}

/* Add styles for bot name tags */
.bot-name-tag {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    text-shadow: 1px 1px 2px black; /* Slight shadow for readability */
    white-space: nowrap; /* Prevent wrapping */
    transform: translateX(-50%); /* Center horizontally */
    z-index: 998; /* Below player namecard (999) but above most other things */
    pointer-events: none; /* Ignore mouse events */
    transition: opacity 0.2s ease-in-out; /* Optional: fade effect */
}

/* Add styles for bot tag labels (displayed above the name) */
.bot-tag-label {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.6);
    color: #FF9900; /* Orange color like in screenshot */
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    text-shadow: 1px 1px 2px black; /* Slight shadow for readability */
    white-space: nowrap; /* Prevent wrapping */
    transform: translateX(-50%); /* Center horizontally */
    z-index: 998; /* Same z-index as name tags */
    pointer-events: none; /* Ignore mouse events */
    transition: opacity 0.2s ease-in-out; /* Optional: fade effect */
}

/* Style for menus and other UI elements */
/* ... (rest of your existing CSS) ... */

/* Add this for the kill message */
#kill-message {
    position: absolute;
    top: 150px; /* Position above the hole instead of at center */
    left: 50%;
    transform: translateX(-50%);
    color: #00ff00;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 10px currentColor, 0 0 15px currentColor;
    padding: 10px 20px;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.7);
}

/* Make sure it's above the game canvas but potentially below modals */
canvas {
    display: block;
    /* Ensure canvas doesn't interfere with absolute positioned elements */
    position: relative; 
}

/* Speedrun Start Message Styling */
#speedrun-start-message {
    position: absolute;
    top: 40%; /* Position vertically */
    left: 50%;
    transform: translate(-50%, -50%);
    color: #00ffff; /* Cyan */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.9); /* White glow */
    font-size: 2.2em; /* Larger text */
    font-weight: bold;
    z-index: 1002; /* Above kill message and other game elements */
    opacity: 0; /* Start hidden */
    transition: opacity 0.5s ease-out; /* Fade-out transition */
    pointer-events: none; /* Don't block mouse interactions */
    white-space: nowrap; /* Prevent wrapping */
    text-align: center;
    background-color: rgba(0, 0, 0, 0.6); /* Optional dark background for contrast */
    padding: 20px 30px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

/* Game Over Screen Styling */
#game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 10000; /* Increased z-index to be above everything */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease; /* Faster transition */
    pointer-events: none;
    will-change: opacity; /* Hardware acceleration hint */
}

#game-over-screen.visible {
    opacity: 1;
    pointer-events: all;
}

/* Hide UI elements when game over screen is visible */
#game-over-screen.visible ~ .bot-name-tag,
#game-over-screen.visible ~ .bot-tag-label,
#game-over-screen.visible ~ #player-nameplate,
#game-over-screen.visible ~ .nameplate-container,
#game-over-screen.visible ~ .player-name,
#game-over-screen.visible ~ .player-name-display,
#game-over-screen.visible ~ #nameplate {
    display: none !important;
}

.game-over-content {
    background: linear-gradient(135deg, #300, #900);
    border: 4px solid #f00;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 40px rgba(255, 0, 0, 0.7);
    max-width: 90%;
    width: 450px;
    will-change: transform; /* Hardware acceleration hint */
    transform: translateZ(0); /* Force GPU rendering */
}

#game-over-screen h1 {
    color: #f00;
    font-size: 4em;
    margin: 0 0 20px 0;
    text-shadow: 0 0 10px #f00;
    /* Removed flicker animation for better performance */
}

#game-over-screen p {
    color: #fff;
    font-size: 1.3em;
    margin-bottom: 30px;
    text-shadow: 0 0 5px #000;
}

#restart-game {
    background: linear-gradient(to bottom, #600, #900);
    color: #fff;
    border: 2px solid #f00;
    padding: 12px 24px;
    font-size: 1.2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s; /* Faster transition */
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

#restart-game:hover {
    background: linear-gradient(to bottom, #900, #c00);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
}

