body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0; /* Remove body padding, container will handle it */
    background-color: #121212; /* Dark background for body */
    font-size: 0.75rem; /* Set a base font size */
    color: #e0e0e0; /* Light default text color */
    height: 100vh; /* Make body fill viewport height */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    display: flex; /* Use flexbox for overall page layout */
    flex-direction: column; /* Stack children vertically */
    overflow: hidden; /* Prevent body from scrolling */
}

*, *::before, *::after {
    box-sizing: border-box; /* Apply border-box to all elements for consistent sizing */
}

.container {
    background-color: #1e1e1e; /* Darker background for container */
    padding: 15px;
    border-radius: 0; /* No border radius if it's full screen */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    width: 95%;
    max-width: 95%;
    margin: auto;
    box-sizing: border-box; /* Ensure padding is included in width/height */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow container to fill the body's flex space */
    overflow: hidden; /* Prevent container from causing page scroll if its content is too big */
}

h1 {
    text-align: center;
    color: #e0e0e0;
    font-size: 1.5em;
    margin-top: 0; /* Remove top margin for h1 if padding is on container */
    margin-bottom: 10px;
    flex-shrink: 0; /* Prevent h1 from shrinking if space is tight */
}
h2 {
    color: #cccccc; /* Lighter color for h2 */
    font-size: 1.2em;
    margin-top: 5px;
    margin-bottom: 8px;
}

#rcon-client { 
    display: flex;
    flex-direction: row; /* Main layout: controls on left, output on right */
    flex-grow: 1; /* Allows rcon-client to fill available space in .container */
    min-height: 0; /* Crucial for flex children that need to scroll */
}

#left-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    flex: 1 1 0;
}

#right-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
}

label {
    display: block;
    margin-bottom: 2px; /* Further reduced margin below labels */
    font-weight: bold;
}

input[type="text"],
input[type="password"],
input[type="number"], /* Added to match styling */
select,
textarea {
    width: 100%; /* Let parent control width with padding */
    box-sizing: border-box;
    padding: 6px; /* Further reduced padding for inputs/selects */
    margin-bottom: 8px; /* Further reduced margin below inputs/selects */
    border: 1px solid #444; /* Darker border */
    border-radius: 4px;
    background-color: #2c2c2c; /* Dark input background */
    color: #e0e0e0; /* Light text in inputs */
}

button {
    background-color: #007bff; /* A common dark mode accent blue */
    color: white;
    padding: 6px 10px; /* Further reduced button padding */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em; /* Slightly smaller font for buttons */
    margin-top: 4px; /* Further reduced top margin */
}

button:hover {
    background-color: #0056b3; /* Darker blue on hover */
}
/* This div will wrap the response area label and the response area itself */
#response-area-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* This is key: it takes up available vertical space */
    min-height: 0; /* Important for flex children that scroll */
    margin-bottom: 10px; /* Space between response area and controls */
    margin-top: 0px;
}

/* Style for the label within the response area container */
#response-area-container > label {
    flex-shrink: 0; /* Ensure the label doesn't shrink and maintains its height */
    /* background-color: rgba(255, 0, 0, 0.3); /* Temporary: Highlight the label area */
}

#response-area {
    width: 100%;
    /* height: 100%; Removed: Let flex-grow handle height */
    flex-grow: 1; /* Allow response area to take available vertical space in its flex parent */
    min-height: 0; /* Crucial for scrolling within a flex item */
    border: 1px solid #333; /* Darker border for response area */
    padding: 10px;
    overflow-y: auto;
    background-color: #2c2c2c;
    color: #f0f0f0; /* Slightly brighter text for output */
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap; /* Ensures long lines wrap */
    border-radius: 4px;
    /* background-color: rgba(0, 255, 0, 0.3); /* Temporary: Highlight the response area */
    box-sizing: border-box; /* Include padding and border in height calculation */
}

.status-message {
    padding: 10px;
    margin-bottom: 10px; /* Reduced margin */
    border-radius: 4px;
    text-align: center;
    font-size: 0.9em;
    flex-shrink: 0; /* Prevent status message from shrinking */
}
.status-message.success { background-color: #28a745; color: #ffffff; border: 1px solid #1e7e34; } /* Dark mode success */
.status-message.error { background-color: #dc3545; color: #ffffff; border: 1px solid #b02a37; }   /* Dark mode error */
.status-message.info { background-color: #17a2b8; color: #ffffff; border: 1px solid #117a8b; }    /* Dark mode info */

.command-section {
    margin-bottom: 0px; /* Reduced spacing between command sections */
}
.arg-input-group { margin-bottom: 6px; } /* Further reduced margin */
.arg-input-group label { font-weight: normal; margin-right: 5px; }

#logout-button {
    background-color: #c82333; /* Dark mode red */
    margin-left: 0; /* No margin needed if parent handles padding/alignment */
}
#logout-button:hover { background-color: #aF1d29; }

hr.section-divider {
    border: 0;
    border-top: 1px solid #444; /* Darker, subtle divider */
    margin: 10px 0; /* Reduced vertical margin for hr */
}

.button-group-horizontal {
    display: flex;
    align-items: center; /* Vertically align items if they have different heights */
}

.button-group-horizontal button {
    margin-top: 4px; /* Keep consistent top margin for buttons */
}
#left-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chatbox-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#chatbox-container {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

#chat-input-area {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

/* Chatbox Styles */
#chatbox-section {
    /* Assumes it's a child of #right-panel (display:flex, flex-direction:column) */
    /* Now a child of #left-panel */
    height: 40%;
    /* flex-shrink: 0; Removed: Allow chatbox-section to shrink if needed, defaults to 1 */
    display: flex;
    flex-direction: column;
    margin-top: 0px;
    min-height: 0; /* Important for flex children that need to scroll */
    padding: 0 10px 10px 10px; /* Horizontal padding to match controls-wrapper, and bottom padding */
    border-top: 1px solid #333; /* Separator from controls */
    flex-grow: 1; /* Allow chatbox-section to fill space in left panel if needed */
}

#chat-input-area {
    display: flex; /* Align input and button horizontally */
    margin-top: 8px; /* Space between chat messages container and input area */
    flex-shrink: 0; /* Prevent the input area from shrinking */
}

#chat-input {
    flex-grow: 1; /* Input takes available space */
    margin-right: 8px; /* Space between input and button */
    margin-bottom: 0; /* Override default input margin if any */
    padding: 6px; /* Consistent padding */
}

#send-chat-message-button {
    flex-shrink: 0; /* Prevent button from shrinking */
    margin-top: 0; /* Override default button margin if any */
    padding: 6px 10px; /* Consistent padding */
}

#chatbox-section h2 {
    margin-top: 0;
    margin-bottom: 0px;
    font-size: 1.1em; /* Slightly smaller than main h2 */
    color: #cccccc;
    flex-shrink: 0; /* Prevent h2 from shrinking */
}

#chatbox-container {
    border: 1px solid #333;
    padding: 10px;
    overflow-y: auto;
    background-color: #2c2c2c; /* Match response-area */
    color: #f0f0f0; /* Match response-area text color */
    font-family: 'Courier New', Courier, monospace; /* Match response-area font */
    border-radius: 4px;
    flex-grow: 1; /* Takes remaining space in #chatbox-section */
    min-height: 0; /* Crucial for scrolling within flex item */
    line-height: 1.4;
    margin-bottom: 10px;
}

.chat-message {
    margin-bottom: 5px;
    padding: 2px 0;
    overflow-wrap: break-word;
    word-break: break-word; /* Helps break long strings without spaces */
}

.chat-timestamp {
    color: #888888;
    margin-right: 5px;
}

.chat-channel {
    color: #a0a0a0;
    font-style: italic;
    margin-right: 5px;
}

.chat-whisper {
    color: #d8bfd8; /* Light purple for whispers */
    font-style: italic;
    margin-right: 5px;
}

.chat-player-name {
    color: #72bcd4; /* A distinct color for player names */
    font-weight: bold;
}

.chat-player-name.admin {
    color: #ffb366; /* Orange/gold for admins */
}

.server-info-display {
    font-size: 0.9em;
    color: #ccc; /* Light grey, adjust as needed */
    margin-right: 15px; /* Space before logout button */
}

#password-section p {
    margin-bottom: 15px;
    color: #ddd; /* Light text color for the "Connecting to..." message */
}

/* DPI-based font size adjustments */

/* For screens with a resolution of at least 144dpi (1.5dppx) */
/* This is a common threshold for "high-resolution" displays that aren't quite "Retina" */
@media (min-resolution: 1.5dppx), (min-resolution: 144dpi) {
    body {
        font-size: 0.85rem; /* Slightly larger base font */
    }
}

/* For screens with a resolution of at least 192dpi (2dppx) - e.g., "Retina" displays */
@media (min-resolution: 2dppx), (min-resolution: 192dpi) {
    body {
        font-size: 0.6rem;
    }
}

/* Apply the same font family to server chat log and rcon title labels */
#response-area-container > label,
#chatbox-section h2 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Set specific font sizes for rcon output label and server chat log title */
#response-area-container > label {
    font-size: 1.1em; /* Larger font for rcon output label */
}

#chatbox-section h2 {
    font-size: 1.1em; /* Slightly larger font for server chat log title */
}

/* Map Modal Styles */
.map-modal-overlay {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* 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.7); /* Black w/ opacity */
    justify-content: center; /* Center content horizontally */
    align-items: center; /* Center content vertically */
}

.map-modal-content {
    background-color: #1e1e1e; /* Dark background for modal content */
    margin: auto; /* Auto margins for centering, though flex handles it */
    padding: 20px;
    border: 1px solid #444; /* Darker border */
    border-radius: 8px;
    width: 80%; /* Could be a fixed width or percentage */
    max-width: 900px; /* Max width for the map */
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
    color: #e0e0e0; /* Light text color */
    position: relative; /* For positioning the close button */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    justify-content: center; /* Center content vertically if needed */
}

.map-modal-close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
}

.map-modal-close-button:hover,
.map-modal-close-button:focus {
    color: #fff; /* Brighter on hover/focus */
    text-decoration: none;
    cursor: pointer;
}

#map-controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    gap: 10px; /* Space between buttons/span */
}

#map-controls-bar button {
    padding: 5px 10px; /* Slightly more padding for better clickability */
    font-size: 1em; /* Make buttons a bit larger */
    min-width: 40px; /* Ensure buttons have a decent width */
    line-height: 1; /* Ensure text is centered vertically */
}

#zoom-level-display {
    font-size: 0.9em;
    color: #ccc;
    min-width: 50px; /* Prevents layout shift when text changes */
    text-align: center;
    padding: 0 5px;
}

#map-player-search {
    padding: 5px 8px;
    font-size: 0.9em;
    width: 150px; /* Adjust as needed */
    margin: 0 5px; /* Give it some breathing room */
    /* Inherits general input styling, but we can override if needed */
    background-color: #3a3a3a; /* Slightly different background for map context */
    border-color: #555;
}

#map-image-container {
    width: 100%;
    aspect-ratio: 1 / 1; /* Make the map window always square */
    background-color: #2c2c2c; /* Slightly lighter background for the map area */
    border: 1px solid #333;
    border-radius: 4px;
    display: flex;
    justify-content: center; /* Center the image if it's smaller than the container */
    align-items: center; /* Center the image if it's smaller than the container */
    margin-top: 15px;
    overflow: hidden; /* Important if image is very large before CSS resizes it */
    position: relative; /* Remains relative for any potential absolute children if needed */
    max-width: 70vh; /* Constrain the initial viewport width to match height */
    max-height: 70vh;
    min-width: 300px;
    min-height: 300px;
    margin-left: auto;
    margin-right: auto;
}

#map-image-container img {
    max-width: 100%; /* Ensure image is not wider than its container */
    max-height: 75vh; /* Limit image height to 75% of viewport height, adjust as needed */
    display: block; /* Removes extra space below the image if it's an inline element */
    object-fit: contain; /* Scales the image to fit within the container while maintaining aspect ratio */
    border-radius: 3px; /* Optional: slight rounding for the image itself */
}

#map-scalable-content {
    position: relative; /* For the player-markers-overlay inside it */
    width: 100%;    /* Initially try to fill the centered space provided by map-image-container */
    height: 100%;   /* The image's object-fit:contain will define the actual aspect ratio */
    transform-origin: center; /* Zoom from the center */
    transition: transform 0.1s ease-out; /* Smooth zoom transition, slightly faster */
    /* The actual width/height will be determined by the image it contains due to object-fit:contain
       and the flex properties of map-image-container. */
    cursor: grab; /* Indicate it's grabbable */
}


#server-map-image { /* Image is now inside map-scalable-content */
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Key: image fits parent, maintains aspect ratio */
    border-radius: 3px; /* Optional */
}

#player-markers-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicks to pass through to map if needed, though not used now */
    overflow: hidden; /* Just in case a marker tries to go outside */
}

.player-marker {
    position: absolute;
    /* transform: translate(-50%, -100%); Will be applied to label and dot container */
    /* background-color, color, padding, border-radius, font-size will be on the label span */
    /* white-space: nowrap; Will be on label span */
    font-family: Arial, sans-serif;
    cursor: default;
    z-index: 10; /* Ensure markers are above the map image if it had a z-index */
    /* The marker div itself is a point. SVG and Label are positioned relative to this point. */
    /* It does not need width/height. Its children will give it perceived size. */
}



.player-marker::after { /* This creates the dot below the text label */
    content: none; /* Remove the extra dot completely */
}

.player-name-label {
    display: none; /* Hidden by default */
    position: absolute;
    /* JS will set top, left, and transform for precise positioning */
    /* Example: top: 50%; left: 50%; transform: translate(-50%, -150%); */
    background-color: rgba(20, 20, 20, 0.85); /* Slightly more opaque */
    color: white;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px; /* Keep this small */
    white-space: nowrap;
    pointer-events: none; /* So it doesn't interfere with clicks on the marker dot area */
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Prevent label from leaving the map area */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.player-connector-svg {
    position: absolute;
    /* SVG is now directly attached to overlay, covering full overlay area */
    left: 0;
    top: 0;
    width: 100%; /* Full overlay width */
    height: 100%; /* Full overlay height */
    pointer-events: none;
    overflow: visible; /* Important for lines going outside the SVG's nominal bounds */
    z-index: 20; /* Ensure it's above everything */
    /* Removed display:none so it doesn't override JS visibility control */
    /* Adding debug border to help visibility */
    outline: 1px dashed rgba(255, 0, 255, 0.3);
}

.server-info-display {
    font-size: 0.9em;
    color: #ccc; /* Light grey, adjust as needed */
    margin-right: 15px; /* Space before logout button */
}

#password-section p {
    margin-bottom: 15px;
    color: #ddd; /* Light text color for the "Connecting to..." message */
}

.custom-command-row {
    margin-top: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-command-row input[type="text"] {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.custom-command-row button {
    flex-shrink: 0;
    margin-top: 0;
}

#controls-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0 0 10px 0;
    padding: 0 10px 0 10px;
    box-sizing: border-box;
}

.btn-view-logs {
    background-color: #007bff;
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 4px;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
    font-weight: normal;
    box-shadow: none;
}
.btn-view-logs:hover, .btn-view-logs:focus {
    background-color: #0056b3;
    color: white;
    text-decoration: none;
}