#lobby-list-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 50px;
}

#lobby-list {
    width: 960px;
    min-height: 240px;
    text-align: center;
}

#lobby-list p {
    text-align: center;
}

#lobby-list-table {
    width: 960px;
    min-height: 80px !important;
    text-align: center;
}

#lobby-actions {
    margin: 20px 0;
}

#lobby-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin-top: 20px;
}

#lobby-table th,
#lobby-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
}

#lobby-table th {
    font-family: Inter-Medium, sans-serif;
    color: #ffdd5a;
}

#lobby-table tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.status-open { color: #28a745; font-weight: bold; }
.status-generating { color: #ffc107; font-weight: bold; }
.status-done { color: #17a2b8; font-weight: bold; }

.no-lobbies {
    text-align: center !important;
    color: #ea166c;
    font-size: 20px;
}

#lobby-create-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

#lobby-create {
    width: 990px;
    min-height: 360px;
    text-align: center;
    margin-bottom: 50px;
}

#lobby-create p {
    text-align: left;
}

#lobby-create-tables-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
}

#lobby-create .table-wrapper {
    margin: 10px;
}

#lobby-create .table-wrapper select,
#lobby-create .table-wrapper input:not([type="checkbox"]) {
    width: 200px;
}

#lobby-create table td {
    text-align: left;
    padding: 4px 8px;
    vertical-align: top;
}

#lobby-create-submit {
    margin: 30px 0;
}

#lobby-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 80px;
}

#lobby-container {
    width: 1300px;
    min-height: 500px;
    margin-bottom: 50px;
    padding: 20px;
}

#lobby-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

.lobby-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-meta {
    font-size: 0.9rem;
    color: white;
}

.lobby-status-0 { color: #28a745; font-weight: bold; }
.lobby-status-1 { color: #ffc107; font-weight: bold; }
.lobby-status-2 { color: #17a2b8; font-weight: bold; }
.lobby-status--1 { color: #dc3545; font-weight: bold; }

#lobby-main {
    display: grid;
    grid-template-columns: 600px 1fr;
    column-gap: 20px;
    row-gap: 12px;
    align-items: start;
}

#lobby-sidebar {
    grid-column: 1;
    padding-right: 7px;
}

#lobby-sidebar h3 {
    margin-bottom: 10px;
    color: #ffdd5a;
}

#lobby-players {
    list-style: none;
    padding: 7px;
    margin: 0;
    max-height: 410px;
    overflow-y: auto;
    background: rgba(0.1, 0.1, 0.1, 0.4);
    border-radius: 4px;
}

.lobby-player-loading {
    padding: 7px;
    color: #aaa;
    font-size: 0.85rem;
    font-style: italic;
}

.lobby-player {
    padding: 7px 7px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lobby-player-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.lobby-player strong {
    font-size: 1rem;
    color: #ffdd5a;
    flex: 1;
}

.player-yaml-count {
    font-size: 0.75rem;
    font-weight: normal;
    color: #aaa;
}

.player-yamls {
    list-style: none;
    padding: 0 0 0 15px;
    margin: 0;
    font-size: 0.85rem;
}

.player-yamls li {
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.yaml-slot-name {
    width: 120px;
    min-width: 120px;
    color: white;
    font-size: 0.85rem;
    cursor: default;
}

.yaml-slot-name > span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: underline dotted rgba(255, 255, 255, 0.4);
    text-underline-offset: 3px;
}

.yaml-game-name {
    flex: 1;
    color: #ea166c;
    font-weight: bold;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

a.yaml-game-name:hover {
    text-decoration: underline;
}

.yaml-download-btn {
    color: #b44ad9;
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}

.yaml-download-btn:hover {
    color: #d780ff;
}

.yaml-delete-btn {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.yaml-delete-btn:hover {
    color: #a71d2a;
}

.yaml-delete-btn:active {
    padding: 0 4px;
    margin: 0;
}

.kick-btn {
    -webkit-appearance: none;
    appearance: none;
    font-size: 0.75rem;
    padding: 2px 8px;
    margin-top: 4px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 3px;
    cursor: pointer;
    color: #856404;
    box-sizing: border-box;
    line-height: 1.2;
}

.kick-btn:hover {
    background: #ffc107;
    color: #000;
}

.kick-btn:active {
    background: #e0a800;
    color: #000;
    padding: 2px 8px;
    margin-top: 4px;
    margin-right: 0;
    margin-bottom: 0;
}

#yaml-upload-area {
    grid-column: 1;
    padding-right: 7px;
}

#yaml-upload-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

#yaml-file-input {
    font-size: 0.8rem;
}

#yaml-upload-btn {
    width: 100%;
}

.drop-zone {
    margin-top: 5px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s ease;
    background-color: rgba(0.1, 0.1, 0.1, 0.4);
}

.drop-zone.drag-over {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.drop-zone p {
    margin: 0;
    color: #ffdd5a;
    font-size: 0.8rem;
}

#lobby-chat {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    overflow-y: auto;
    height: 500px;
    padding: 10px;
    background: rgba(0.1, 0.1, 0.1, 0.4);
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

.chat-msg {
    display: grid;
    grid-template-columns: 3.5em 1fr;
    column-gap: 6px;
    align-items: baseline;
    padding: 3px 0;
    line-height: 1.4;
}

.msg-delete-btn {
    background: none;
    border: none;
    color: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 4px;
    line-height: 1;
    color: pink;
}

.chat-msg:hover .msg-delete-btn {
    color: #ea166c;
}

.msg-delete-btn:hover {
    color: #ea166c !important;
}

.chat-time-col {
    display: flex;
    align-items: baseline;
    gap: 2px;
    white-space: nowrap;
}

.chat-time {
    font-size: 0.75rem;
    color: white;
    white-space: nowrap;
    text-align: left;
}

.chat-content {
    overflow-wrap: break-word;
    word-break: break-word;
}

.chat-sender {
    color: #ea166c;
    margin-right: 4px;
}

.chat-system {
    font-style: italic;
}

.chat-system-text {
    color: pink;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chat-text {
    overflow-wrap: break-word;
    word-break: break-word;
}

#chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

#chat-input:focus {
    outline: none;
    border-color: #652895;
}

.lobby-btn {
    -webkit-appearance: none;
    appearance: none;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    box-sizing: border-box;
    line-height: 1.2;
}

.lobby-btn:hover {
    background: #f0f0f0;
}

.lobby-btn:active {
    background: #e0e0e0;
    padding: 8px 16px;
    margin: 0;
}

.lobby-btn-primary,
#create-lobby-button {
    align-items: center;
    background-color: #652895;
    border-radius: 42px;
    border-width: 0;
    color: #FFFFFF;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    justify-content: center;
    line-height: 16px;
    padding: 14px 28px;
    text-align: center;
    text-decoration: none;
    text-shadow: rgba(255, 255, 255, 0.4) 0 0 4px,
        rgba(255, 255, 255, 0.2) 0 0 12px,
        rgba(57, 31, 91, 0.6) 1px 1px 4px,
        rgba(57, 31, 91, 0.32) 4px 4px 16px;
    user-select: none;
}

a.lobby-btn-primary,
a.lobby-btn-primary:hover {
    color: #ffffff !important;
}

.lobby-btn-primary:hover,
#create-lobby-button:hover {
    background-image: linear-gradient(#652895, #b44ad9 50%);
}

.lobby-btn-primary:disabled,
#create-lobby-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-image: none;
}

.lobby-btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.lobby-btn-danger:hover {
    background: #a71d2a;
}

.lobby-btn-purple {
    background: #652895;
    color: #fff;
    border-color: #652895;
}

.lobby-btn-purple:hover {
    background: #7d35b5;
}

#lobby-generate {
    grid-column: 1 / 3;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    text-align: center;
}

#lobby-generate #close-btn {
    display: block;
    margin: 20px auto 0;
}


#lobby-generating {
    grid-column: 1 / 3;
    padding: 20px;
    background-color: #8BC6EC;
    background-image: linear-gradient(0deg, #093C4F 0%, #09194F 100%);
    border-radius: 25px;
    text-align: center;
}

#lobby-generating h2 {
    color: #ffc107;
    font-weight: bold;
}

#lobby-result {
    grid-column: 1 / 3;
    padding: 20px;
    background-color: #8BC6EC;
    background-image: linear-gradient(0deg, #093C4F 0%, #09194F 100%);
    border-radius: 25px;
    text-align: center;
}

#lobby-result h2 {
    color: white;
    font-weight: bold;
}

#lobby-result a {
    margin: 5px 10px;
    color: white;
}

#lobby-join {
    max-width: 400px;
    margin: 20px auto;
    text-align: center;
}

.lobby-join-explainer {
    font-size: 0.85rem;
    color: #ccc;
    margin-bottom: 20px;
    text-align: left;
    line-height: 1.5;
}

.lobby-back-link {
    display: inline-block;
    margin-top: 18px;
    font-size: 0.85rem;
    color: #aaa;
    text-decoration: none;
}

.lobby-back-link:hover {
    color: #fff;
    text-decoration: underline;
}

.join-field {
    margin-bottom: 15px;
    text-align: left;
}

.join-field label {
    display: block;
    margin-bottom: 4px;
    font-family: Inter-Medium, sans-serif;
}

.join-field input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.lobby-expired {
    color: #dc3545;
    font-weight: bold;
    text-align: center !important;
}

.lobby-preview {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
}

.lobby-preview-meta {
    margin: 4px 0;
    font-size: 0.9rem;
    color: white;
}

.settings-tip {
    position: relative;
    cursor: help;
    font-size: 0.8rem;
    color: #aaa;
    text-decoration: underline dotted;
    white-space: nowrap;
}

.settings-tip-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    background: #1a1a2e;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #ddd;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    text-decoration: none;
}

.settings-tip:hover .settings-tip-content {
    display: block;
}

.settings-tip.tip-upward .settings-tip-content {
    top: auto;
    bottom: 100%;
}

.server-password-row {
    margin-top: 10px;
    font-size: 0.9rem;
}

.server-password-reveal {
    cursor: help;
    margin-left: 6px;
}

.server-password-reveal .password-value {
    display: none;
    color: #ffdd5a;
    font-family: monospace;
    user-select: all;
}

.server-password-reveal:hover .password-placeholder {
    display: none;
}

.server-password-reveal:hover .password-value {
    display: inline;
}

.lobby-info-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#settings-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

#settings-modal.open {
    display: flex;
}

#settings-modal-content {
    max-width: 860px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    background-color: #8BC6EC;
    background-image: linear-gradient(0deg, #093C4F 0%, #09194F 100%);
    border-radius: 25px;
    padding: 30px;
}

#settings-modal-content h2 {
    margin-bottom: 20px;
}

#settings-form-grid {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.settings-section {
    flex: 1;
    min-width: 280px;
}

.settings-section h3 {
    margin-bottom: 10px;
}

.settings-section table td {
    padding: 4px 8px;
    vertical-align: middle;
}

.settings-section select,
.settings-section input[type="text"] {
    width: 180px;
}

#settings-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.badge-custom-apworlds {
    background: #f0a500;
    color: #000;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.8rem;
    font-weight: bold;
}

.yaml-custom-tag {
    font-size: 0.9rem;
    flex-shrink: 0;
    cursor: default;
    line-height: 1;
}

.yaml-custom-tag-missing {
    filter: grayscale(1) sepia(1) hue-rotate(300deg) saturate(8) brightness(0.85);
}


.apworld-upload-btn {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: 1px solid #e07b00;
    color: #e07b00;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.apworld-upload-btn:hover {
    background: #e07b00;
    color: #fff;
}

.apworld-upload-btn:active {
    background: #b85e00;
    color: #fff;
    padding: 1px 6px;
    margin: 0;
    border: 1px solid #b85e00;
}

.apworld-status-ok {
    color: #28a745;
    font-size: 0.75rem;
    flex-shrink: 0;
    cursor: default;
}

.apworld-missing {
    color: #ffc107;
    font-size: 1rem;
    flex-shrink: 0;
    cursor: default;
}

.yaml-world-version {
    color: #8ab4f8;
    font-size: 0.7rem;
    flex-shrink: 0;
    cursor: default;
    opacity: 0.85;
}

.yaml-version-warning {
    color: #ffc107;
    font-size: 0.95rem;
    flex-shrink: 0;
    cursor: help;
}

.ready-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 2px 8px;
    height: 22px;
    box-sizing: border-box;
    line-height: 1;
    border: 1px solid #28a745;
    border-radius: 3px;
    background: none;
    color: #28a745;
    cursor: pointer;
    outline: none;
}

.ready-btn.ready-btn-on {
    background: #28a745;
    color: #fff;
}

.ready-btn:hover:not(:disabled) { background: #28a745; color: #fff; }

.ready-btn:active {
    background: #1e7e34;
    color: #fff;
    padding: 2px 8px;
    margin: 0;
    border: 1px solid #1e7e34;
}

.ready-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.ready-indicator { font-size: 0.75rem; color: #28a745; }

.custom-disclaimer {
    border: 2px solid #e07b00;
    background: rgba(224, 123, 0, 0.12);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 14px;
    color: #ffcc80;
    font-size: 0.9rem;
    text-align: left;
}

.drop-zone-label {
    color: pink;
    text-decoration: underline;
    cursor: pointer;
}

#upload-game-zone.uploading {
    border-color: #ffc107;
    background-color: rgba(255, 193, 7, 0.1);
}

@media (max-width: 768px) {
    #lobby-main {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .player-yamls li {
        flex-wrap: wrap;
        row-gap: 4px;
    }

    .yaml-game-name {
        flex: 1 1 calc(100% - 136px);
        min-width: 0;
    }

    #lobby-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        padding-right: 0;
        padding-bottom: 15px;
        order: 4;
    }

    #yaml-upload-area {
        border-right: none;
        padding-right: 0;
        border-top: 2px solid #ddd;
        padding-top: 10px;
        order: 3;
    }

    #lobby-generate,
    #lobby-generating,
    #lobby-result {
        order: 1;
    }

    #lobby-chat {
        grid-column: unset;
        grid-row: unset;
        order: 2;
    }

    #lobby-container {
        width: 98%;
        box-sizing: border-box;
        padding: 10px;
        margin-left: auto;
        margin-right: auto;
    }

    #lobby-main > * {
        width: 100%;
        box-sizing: border-box;
    }

    #chat-messages {
        height: 250px;
    }

    #lobby-create {
        width: 100%;
    }

    #lobby-list,
    #lobby-list-table {
        width: 98%;
        box-sizing: border-box;
    }

    .lobby-info-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Lobby list: table → cards */
    #lobby-table thead {
        display: none;
    }

    #lobby-table,
    #lobby-table tbody,
    #lobby-table tr,
    #lobby-table td {
        display: block;
        width: 100%;
    }

    #lobby-table tr {
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 10px 12px;
        background: rgba(0, 0, 0, 0.15);
        box-sizing: border-box;
    }

    #lobby-table tr:hover {
        background: rgba(0, 0, 0, 0.15);
    }

    #lobby-table td {
        display: flex;
        align-items: baseline;
        gap: 8px;
        padding: 3px 0;
        border-bottom: none;
    }

    #lobby-table td[data-label]::before {
        content: attr(data-label);
        color: #aaa;
        font-size: 0.8rem;
        min-width: 110px;
        flex-shrink: 0;
    }

    /* Settings cell: show content inline, hide tooltip label */
    .lobby-settings-td {
        flex-direction: column;
        align-items: flex-start;
    }

    .lobby-settings-td::before {
        content: "Settings";
        color: #aaa;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }

    .lobby-settings-td .settings-tip {
        font-size: 0;
        text-decoration: none;
        cursor: default;
        white-space: normal;
    }

    .lobby-settings-td .settings-tip-content {
        display: block;
        position: static;
        background: none;
        border: none;
        padding: 0;
        box-shadow: none;
        font-size: 0.78rem;
        color: #aaa;
        white-space: normal;
        line-height: 1.6;
    }

    /* Join button cell */
    .lobby-join-td {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        justify-content: center;
    }

    .lobby-join-td a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 8px;
        background: #652895;
        color: #fff;
        border-radius: 4px;
        text-decoration: none;
        font-size: 0.9rem;
    }

    .lobby-join-td a:hover {
        background: #7d35b5;
    }
}
