body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    color: #fff;
    font-family: Arial, sans-serif;
    width: 100vw;
    height: 100vh;
    display: block;
}

#connection-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-width: 25%;
    background-color: #111;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

#connection-ui input {
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #0ff;
    background-color: #222;
    color: #fff;
    border-radius: 4px;
    width: 90%; /* Ensure input takes up most of the width */
    box-sizing: border-box; /* Include padding in width calculation */
}

#playerNameDisplay {
    margin-bottom: 10px;
    padding: 8px 12px; /* Similar padding to input */
    background-color: #282828; /* Slightly different background */
    color: #eee;
    border: 1px dashed #0aa; /* Dashed to indicate clickable */
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em; /* Match input font size */
    text-align: center;
    width: 90%; /* Match input width */
    box-sizing: border-box; /* Include padding in width calculation */
}

#playerNameDisplay:hover {
    border-color: #0ff;
    background-color: #333;
}

#highScoreDisplay {
    margin-bottom: 15px;
    color: #aaa;
    font-size: 0.9em;
}

#highScoreDisplay span {
    color: #fff;
    font-weight: bold;
}

/* Styles for Upgrade Selection */
#start-upgrade-selection {
    width: 90%; /* Match input width */
    box-sizing: border-box;
    margin-top: 5px; /* Space above the upgrade selection */
}

.upgrades-button {
    width: 100%;
    padding: 8px;
    background-color: #111; /* Match modal background */
    color: #fff;
    border: 1px solid #444; /* Less bright border */
    border-radius: 4px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrades-button:hover {
    background-color: #222;
    border-color: #555;
}

.down-caret {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.upgrades-section {
    display: none;
    width: 100%;
    margin-top: 10px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-in-out;
}

.upgrades-section.open {
    display: block;
    max-height: 300px; /* Adjust based on expected content */
}

.upgrades-icons {
    display: flex;
    flex-wrap: wrap;
    padding: 10px 0;
    gap: 10px;
    justify-content: center;
}

.upgrade-icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 70px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.upgrade-icon-container:hover {
    background-color: #222;
}

.upgrade-icon-container.selected {
    background-color: #333;
}

.upgrade-icon {
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-bottom: 5px;
    border-radius: 4px;
    background-color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
}

.upgrade-icon.upgrade-none {
    font-size: 0.8em;
    color: #aaa;
}

.upgrade-icon.upgrade-heavy-laser {
    background-image: url("heavy_laser_upgrade.png");
}

.upgrade-icon.upgrade-spread-fire {
    background-image: url("spread_fire_upgrade.png");
}

.upgrade-name {
    font-size: 0.8em;
    text-align: center;
    color: #aaa; /* Less bright text */
}
/* End of Styles for Upgrade Selection */

#playstyle-buttons {
    display: flex;
    gap: 10px; /* Adds space between the buttons */
    width: 100%; /* Make the container take full width of parent */
    margin-top: 10px; /* Add some space above the buttons */
}

#playstyle-buttons button {
    flex-grow: 1; /* Allows buttons to grow and fill available space */
}

#connection-ui button {
    padding: 10px 15px;
    background-color: #0aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#connection-ui #upgradesButton {
    background-color: transparent; /* Specific color for the upgrades button */
}

#connection-ui button:hover {
    background-color: #0cc;
}

/* Style for the specific info button to override general #connection-ui button styles */
#connection-ui #infoButton {
    background-color: rgba(60, 60, 60, 0.6); /* Specific subtle background */
    color: #999; /* Specific subtle text color */
    border: 1px solid #333; /* Specific darker, more subtle border */
    border-radius: 50%; /* Specific roundness */
    width: 24px; /* Specific small width */
    height: 24px; /* Specific small height */
    font-size: 14px; /* Specific smaller font */
    font-weight: normal; /* Specific different font weight */
    padding: 0; /* Explicitly no padding to override general button padding */
    margin-top: 12px; /* Space above the button */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    transition:
        background-color 0.2s,
        color 0.2s;
    text-decoration: none;
    line-height: 1; /* Helps center the '?' in some browsers */
}

#connection-ui #infoButton:hover {
    background-color: rgba(
        80,
        80,
        80,
        0.7
    ); /* Specific subtle hover background */
    color: #ccc; /* Specific subtle hover text color */
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 100; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1a1a1a;
    color: #f1f1f1;
    margin: auto;
    padding: 20px;
    border: 1px solid #0aa;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0, 200, 200, 0.3);
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: #0ff;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    margin-top: 0;
    color: #0cc;
}

.modal-content ul {
    list-style-type: none;
    padding-left: 0;
}

.modal-content ul li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.modal-content ul li strong {
    color: #0ee;
}

.modal-content ul ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-top: 5px;
}

.modal-content ul ul li {
    margin-bottom: 5px;
    font-size: 0.9em;
}

#gameCanvas {
    display: block; /* Canvas is visible by default for loading starfield */
    background-color: #050505;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#kill-feed-container {
    position: absolute;
    top: 45px; /* Positioned below the King of the Server UI */
    left: 10px;
    width: 300px; /* Adjust as needed */
    max-height: 200px; /* Adjust as needed */
    overflow-y: hidden; /* New messages appear at top, old ones pushed down/out */
    display: flex;
    flex-direction: column-reverse; /* New messages at the bottom, visually appears at top */
    z-index: 5; /* Below connection UI but above canvas if needed */
    pointer-events: none; /* Prevent interaction with the feed */
}

.kill-feed-message {
    color: #fff;
    padding: 4px 8px;
    margin-top: 4px;
    border-radius: 3px;
    font-size: 0.8em;
    animation: fadeInOut 2s forwards; /* 5s total: fade in, stay, fade out */
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(10px);
    } /* Start transparent and slightly down */
    10% {
        opacity: 1;
        transform: translateY(0);
    } /* Fade in and move up to position */
    80% {
        opacity: 1;
        transform: translateY(0);
    } /* Stay visible */
    100% {
        opacity: 0;
        transform: translateY(-10px);
    } /* Fade out and move slightly up */
}

#king-of-the-server-ui {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 5px 10px;
    display: none;
}

#kingOfTheServerDisplay {
    font-family: "Monaco", "Menlo", "Consolas", "Courier New", monospace;
    font-size: 0.9em;
    font-weight: bold;
    color: #00ff00;
    text-align: center;
    white-space: nowrap;
}

#player-score-ui {
    display: none;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    text-align: flex-end;
    align-items: flex-end;
}

#player-score-display {
    display: flex;
    color: white;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    font-size: 0.9em;
    font-family: "Monaco", "Menlo", "Consolas", "Courier New", monospace;
    margin-bottom: 5px;
    white-space: nowrap;
    justify-content: flex-end;
}

#radarCanvas {
    display: none;
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
    cursor: pointer;
    transition:
        opacity 0.2s,
        box-shadow 0.2s;
}

#weapon-controls-ui {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    background-color: rgba(17, 17, 17, 0.8);
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

#weapon-controls-ui button {
    padding: 8px 12px;
    margin-right: 10px;
    background-color: #077;
    color: #fff;
    border: 1px solid #0aa;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#weapon-controls-ui button:last-child {
    margin-right: 0;
}

#weapon-controls-ui button:hover {
    background-color: #099;
}

#weapon-controls-ui {
    display: none;
}

#respawn-ui {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    background-color: #1a0000;
    border: 2px solid #ff0000;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    color: #ffdddd;
}

#respawn-ui h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #ff8888;
}

#respawn-ui p {
    margin-bottom: 20px;
    font-size: 1.1em;
}

#respawn-ui button {
    padding: 12px 25px;
    background-color: #cc0000;
    color: #fff;
    border: 1px solid #ff4444;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2em;
}

#respawn-ui button:hover {
    background-color: #ee0000;
    border-color: #ff6666;
}

/* Loading Screen Styles */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #050505; /* Same as gameCanvas background */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Ensure it's on top */
    overflow: hidden;
}

#loading-content-group {
    display: flex;
    align-items: center;
    justify-content: center; /* This will center the content if its width is less than parent */
    opacity: 0; /* Start invisible, fade in with animation */
    transform: translateX(-150vw); /* Start far off-screen to the left */
    position: relative; /* To allow z-indexing if needed, though likely not over progress bar */
}

.ship-flying #loading-content-group {
    /* Animation applied to the group */
    animation: flyInGroup 3s ease-out forwards;
}

#loading-ship {
    width: 100px; /* Adjust as needed */
    height: auto;
    transform: rotate(
        90deg
    ); /* Assuming ship's "up" in image is its front, to make it face right */
    margin-right: 15px; /* Space between ship and text */
    position: relative; /* For z-index stacking */
    z-index: 2; /* Ensure ship is on top of text */
}

#loading-text {
    font-size: 2.5em;
    color: #0ff;
    text-shadow:
        0 0 10px #0ff,
        0 0 20px #0ff;
    white-space: nowrap;
    position: relative; /* For z-index stacking */
    z-index: 1; /* Ensure text is below ship */
    margin-right: 3rem;
}

#loading-bar-container {
    width: 60%;
    max-width: 400px;
    height: 20px;
    background-color: #222;
    border: 1px solid #0aa;
    border-radius: 5px;
    position: absolute;
    bottom: 20%;
    overflow: hidden; /* Ensure progress bar stays within container */
}

#loading-bar-progress {
    width: 0%; /* Initial progress */
    height: 100%;
    background-color: #0ff;
    border-radius: 3px;
    transition: width 0.5s ease-out; /* Smooth progress update */
}

@keyframes flyInGroup {
    0% {
        opacity: 0;
        transform: translateX(-150vw) scale(0.8); /* Start far left, slightly smaller */
    }
    97% {
        opacity: 1;
        transform: translateX(10vw) scale(1.05); /* Overshoot slightly and grow a bit */
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1); /* Settle in the center, normal size */
    }
}
