/* Homepage floating chat + right-hand ratings rail. */

/* Screenshot #1: remove the old live-world block immediately, before JS reparents widgets. */
.live-world-section {
    display: none !important;
}

/* The old chat section is only a server-rendered staging container. */
.home-chat-section {
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.home-chat-section > .section-heading {
    display: none !important;
}

.home-chat-section > .home-chat-shell {
    min-height: 0 !important;
    height: 0;
    overflow: visible;
}

.home-chat-section .home-rankings-panel {
    visibility: hidden;
}

/* Main content + ratings: ratings are a separate column outside the bordered world card. */
.home-world-layout {
    width: min(1600px, 96vw);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 330px);
    gap: 20px;
    align-items: start;
}

.home-world-layout > .world-section {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.home-world-layout > .home-rankings-panel {
    width: 100%;
    min-width: 0;
    margin: 0;
    align-self: start;
    visibility: visible;
}

.home-world-layout .home-rankings-panel {
    padding: 20px;
}

.home-world-layout .home-ranking-cards {
    gap: 8px;
}

.home-world-layout .home-ranking-item {
    padding: 14px 12px;
}

.home-world-layout .home-ranking-leader {
    grid-template-columns: 28px minmax(0, 1fr);
}

.home-world-layout .home-ranking-current {
    gap: 10px;
}

/* Floating chat GUI. */
.home-chat-panel {
    position: fixed !important;
    right: 24px;
    bottom: 88px;
    z-index: 90;
    width: min(430px, calc(100vw - 32px));
    max-height: min(700px, calc(100vh - 125px));
    margin: 0 !important;
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(18px) scale(.985);
    transform-origin: bottom right;
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .38) !important;
}

.home-chat-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}

.home-chat-head {
    flex: 0 0 auto;
    align-items: center;
}

.home-chat-messages {
    min-height: 180px;
    max-height: min(390px, calc(100vh - 330px)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

.home-chat-form {
    position: relative;
    flex: 0 0 auto;
}

.home-chat-window-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.home-chat-close,
.home-chat-emoji-toggle {
    appearance: none;
    border: 1px solid var(--line-strong);
    background: var(--panel-3);
    color: var(--text);
    border-radius: 10px;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font: inherit;
}

.home-chat-close {
    font-size: 22px;
    line-height: 1;
}

.home-chat-close:hover,
.home-chat-emoji-toggle:hover,
.home-chat-emoji-toggle.is-open {
    border-color: var(--accent);
}

.home-chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 95;
    min-width: 116px;
    height: 50px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: var(--panel-solid);
    color: var(--text);
    box-shadow: 0 14px 42px rgba(0, 0, 0, .28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.home-chat-launcher:hover,
.home-chat-launcher[aria-expanded="true"] {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.home-chat-launcher-icon {
    font-size: 20px;
    line-height: 1;
}

.home-chat-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    display: inline-grid;
    place-items: center;
    font-size: 11px;
    font-weight: 900;
}

.home-chat-unread[hidden] {
    display: none !important;
}

.home-chat-compose-tools {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.home-chat-cooldown {
    color: var(--muted);
    font-size: 12px;
    min-height: 18px;
    text-align: right;
}

.home-chat-emoji-picker {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 4;
    width: min(330px, 90vw);
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--panel-solid);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .32);
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.home-chat-emoji-picker[hidden] {
    display: none !important;
}

.home-chat-emoji-picker button {
    appearance: none;
    border: 0;
    border-radius: 8px;
    background: transparent;
    min-width: 34px;
    min-height: 34px;
    font-size: 21px;
    cursor: pointer;
}

.home-chat-emoji-picker button:hover {
    background: var(--panel-3);
}

.home-chat-form button[type="submit"]:disabled {
    opacity: .55;
    cursor: not-allowed;
}

@media (max-width: 1220px) {
    .home-world-layout {
        width: min(1280px, 92vw);
        grid-template-columns: 1fr;
    }

    .home-world-layout > .home-rankings-panel {
        width: min(100%, 620px);
        justify-self: end;
    }
}

@media (max-width: 700px) {
    .home-chat-launcher {
        right: 12px;
        bottom: 12px;
        min-width: 104px;
        height: 46px;
    }

    .home-chat-panel {
        right: 8px;
        bottom: 68px;
        width: calc(100vw - 16px);
        max-height: calc(100vh - 84px);
        border-radius: 18px !important;
    }

    .home-chat-messages {
        max-height: calc(100vh - 310px) !important;
    }

    .home-world-layout {
        width: min(100% - 24px, 1280px);
    }

    .home-world-layout > .home-rankings-panel {
        width: 100%;
    }

    .home-chat-emoji-picker {
        grid-template-columns: repeat(6, 1fr);
        width: min(300px, calc(100vw - 52px));
    }
}
