body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #2c2c2c;
    color: #ffffff;
    height: 100vh;
    font-size: 16px; /* Base font size for rem scaling */
    overflow: hidden;
}

#hover-container {
    font-family: 'JetBrains Mono', monospace;

    display: none;
    z-index: 1000;
    position: absolute;
    top: 0;
    left: 0;

    border: 2px solid #25035c;
    outline: 2px solid #130512;
    border-radius: 0.5rem;
    color: #ffffff;
    background-color: #130512;
    padding: 0.5rem;

    white-space: pre;
}

#modal-container {
    font-family: 'JetBrains Mono', monospace;

    display: none;
    z-index: 1000;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
}

#modal-content {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 300px;
    min-height: 150px;
    background-color: #130512;
    border: 2px solid #25035c;
    outline: 2px solid #130512;
    border-radius: 0.5rem;
    padding: 1.5rem;
}

#modal-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#modal-content p {
    margin: 0;
}

#modal-content .modal-buttons {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

#modal-content .modal-url {
    color: pink;
    margin: 0.5rem 0;
}

#modal-content button {
    margin: 0;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.3rem;
    background-color: #4caf50;
    color: #ffffff;
    cursor: pointer;
}

#modal-content button:hover {
    background-color: #45a049;
}

#container {
    height: 100vh;
    display: flex;
    padding: 0.5rem;
    gap: 0.5rem;
    box-sizing: border-box;
}

#chat-area {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 0.3rem;
    overflow: hidden;
}

#player-list-container {
    width: calc(min(20rem, 30vw));
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 0.3rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Add margin at bottom to make room for fixed status bar */
    margin-bottom: 5rem;
}

#player-list-container h2 {
    margin: 0;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    background-color: rgba(0, 0, 0, 0.2);
}

#player-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Important for flex child scrolling */
}

#player-list li {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.2rem;
    transition: background-color 0.2s ease;
}

#player-list li:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.player-head-container {
    --scale: 3.75;

    position: relative;
    width: 30px;
    height: 30px;
    overflow: hidden;
}

/* Base layer */
.player-head {
    position: absolute;
    transform: scale(var(--scale));
    transform-origin: top left;
    image-rendering: pixelated;
    top: calc(-8px * var(--scale));
    left: calc(-8px * var(--scale));
}

/* Hat layer */
.player-head-overlay {
    position: absolute;
    transform: scale(var(--scale));
    transform-origin: top left;
    image-rendering: pixelated;
    top: calc(-8px * var(--scale));
    left: calc(-40px * var(--scale));
}

.player-name {
    font-family: 'JetBrains Mono', monospace;

    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-chat-icon {
    display: none;
    cursor: pointer;
    border: none;
    width: 1.25rem;
    height: 1.25rem;
}

#tab-list {
    font-family: 'JetBrains Mono', monospace;

    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #555;
    border-radius: 0.3rem;
    display: none;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

#tab-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#tab-list li {
    padding: 4px 8px;
    cursor: pointer;
    color: #ffffff;
}

#tab-list li.selected {
    background-color: #007bff;
}

#messages {
    font-family: 'JetBrains Mono', monospace;

    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column-reverse; /* Makes new messages appear at bottom */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.1);
    scrollbar-gutter: stable;
}

#load-more-container {
    display: none;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

#load-more-button {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 0.3rem;
    background-color: #4caf50;
    color: #ffffff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    display: inline-block;
}

#load-more-button:hover {
    background-color: #45a049;
}

.message {
    position: relative;
    padding: 0.5rem;
    word-break: break-word;
    white-space: pre-wrap;
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* Ensure items start from the top */
}

.message.ping {
    background-color: rgba(76, 175, 80, 0.1);
    border-radius: 0 2px 2px 0;
}

.message.ping::before {
    content: '';
    position: absolute;
    left: calc(-0.25rem + 2px);
    top: 0;
    bottom: 0;
    width: 0.25rem;
    border-radius: 2px;
    background-color: #4caf50;
}

.message a {
    text-decoration: none;
}
.message a.mc-underlined {
    text-decoration: underline;
}

.message-time {
    color: #b7b7b7;
    font-size: 0.75rem;
    margin-right: 0.3rem;
    padding-top: 0.25rem;
    flex-shrink: 0;
}

#input-area {
    font-family: 'JetBrains Mono', monospace;

    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#message-input-container {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: stretch;
}

#direct-message-clear {
    display: none;
    padding: 0.5rem;
    border: none;
    border-radius: 0.3rem;
    background-color: rgba(255, 255, 255, 0.1);
    width: 1.5rem;
    cursor: pointer;
}

#direct-message-clear:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#input-alert {
    display: none;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #aaa;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

#message-input {
    flex-grow: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 0.3rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 1rem;
    resize: none;
    line-height: 1.45rem;
    margin: 0;
    font-family: inherit;
}

#message-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#message-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
}

#message-input.error {
    outline: 2px solid #f44336;
}

#message-send-button {
    padding: 0.6rem 0.6rem;
    border: 1px inset transparent;
    border-radius: 0.3rem;
    background-color: #4caf50;
    cursor: pointer;
    width: 1.25rem;
    height: 1.25rem;
}

#message-send-button:hover {
    background-color: #45a049;
}

#status-container {
    position: fixed;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: calc(min(20rem, 30vw) - 2rem);
    height: 2.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    border-radius: 0.3rem;
    background-color: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    padding: 1rem;
}

#status {
    font-size: 0.9rem;
    box-sizing: border-box;
    overflow: hidden;
    white-space: normal;
    max-height: 2.5rem;
}
#status[data-status='connected'] {
    color: #ffffff;
}
#status[data-status='in-game'] {
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
}
#status[data-status='disconnected'] {
    color: #f44336;
}
#status[data-status='error'] {
    color: #ff9800;
}

#sidebar-toggle {
    display: none;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}

@media (max-width: 620px) {
    #container {
        padding: 3rem 0 0 0; /* Make room for status bar */
    }

    #messages {
        padding: 0.5rem;
    }

    #chat-area {
        border-radius: 0;
    }

    #input-area {
        padding: 0.5rem;
    }

    #player-list-container {
        display: none;
    }
    #player-list-container.mobile-menu-open {
        display: flex;
        position: absolute;
        top: 3rem;
        left: 0;
        width: calc(100vw - 1rem);
        height: calc(100vh - 3rem);
        background-color: #2c2c2c;
        padding: 0.5rem;
        border-radius: 0;
        margin: 0;
        flex-direction: column;
    }
    #player-list-container.mobile-menu-open h2 {
        border-radius: 0.3rem;
        flex-shrink: 0;
    }

    #player-list {
        padding: 0.5rem 0;
    }

    #status {
        padding: 0 2.5rem 0 1.5rem;
        max-height: 1.25rem;
    }

    #status-container {
        top: 0;
        bottom: auto;
        left: 0;
        right: 0;
        width: auto;
        height: 1rem;
        border-radius: 0;
    }

    #sidebar-toggle {
        display: block;
        top: auto;
        bottom: auto;
        right: 0.75rem;
    }
}
