* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    font-family: Inter, Arial, sans-serif;

    --bg: #111318;
    --panel: #1b1f27;
    --panel-soft: #222733;
    --panel-hover: #2a3140;

    --text: #f4f6f8;
    --muted: #99a3b3;

    --accent: #e66aa4;
    --accent-soft: rgba(230, 106, 164, 0.15);

    --green: #50d890;
    --border: rgba(255, 255, 255, 0.08);

    --radius: 14px;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* Login */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 430px;

    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;

    padding: 36px;

    text-align: center;
}

.logo {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-card h1 {
    margin: 0 0 10px;
    font-size: 30px;
}

.login-card p {
    margin: 0 0 24px;
    color: var(--muted);
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#loginForm input {
    width: 100%;
    padding: 14px 16px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: #11151c;
    color: var(--text);

    outline: none;
}

#loginForm input:focus {
    border-color: var(--accent);
}

#loginForm button {
    padding: 14px 16px;

    border: 0;
    border-radius: 10px;

    background: var(--accent);
    color: white;

    font-weight: 700;
}

.login-error {
    min-height: 22px;
    margin-top: 14px;
    color: #ff7b7b;
}

/* Main chat */

.chat-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 76px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 22px;

    background: #171b22;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 30px;
}

.brand-title {
    font-size: 19px;
    font-weight: 800;
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;

    color: var(--muted);
    font-size: 14px;
}

.status-dot {
    width: 9px;
    height: 9px;

    border-radius: 50%;
    background: var(--green);

    box-shadow: 0 0 10px rgba(80, 216, 144, 0.55);
}

.layout {
    flex: 1;

    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 240px;

    min-height: 0;
}

/* Sidebars */

.rooms-panel,
.users-panel {
    background: var(--panel);
    padding: 18px 14px;
}

.rooms-panel {
    border-right: 1px solid var(--border);
}

.users-panel {
    border-left: 1px solid var(--border);
}

.panel-title {
    margin: 0 8px 12px;

    color: var(--muted);
    font-size: 12px;
    font-weight: 800;

    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.room {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 11px 12px;

    border: 0;
    border-radius: 9px;

    background: transparent;
    color: var(--muted);

    text-align: left;
}

.room:hover {
    background: var(--panel-hover);
    color: var(--text);
}

.room.active {
    background: var(--accent-soft);
    color: var(--text);
    font-weight: 700;
}

.room.active span {
    color: var(--accent);
}

/* Chat panel */

.chat-panel {
    min-width: 0;

    display: flex;
    flex-direction: column;

    background: #141820;
}

.chat-header {
    min-height: 70px;

    display: flex;
    align-items: center;

    padding: 14px 20px;

    background: var(--panel-soft);
    border-bottom: 1px solid var(--border);
}

.chat-header h2 {
    margin: 0;
    font-size: 20px;
}

.room-description {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.messages {
    flex: 1;

    min-height: 0;
    overflow-y: auto;

    padding: 20px;
}

/* Messages */

.message {
    margin-bottom: 10px;
    line-height: 1.5;
    word-break: break-word;
}

.message-time {
    margin-right: 7px;
    color: #778291;
    font-size: 12px;
}

.message-name {
    margin-right: 7px;
    color: var(--accent);
    font-weight: 800;
}

.message.bot .message-name {
    color: #80bfff;
}

.message.system {
    color: var(--muted);
    font-style: italic;
}

.message.system::before {
    content: "•";
    margin-right: 8px;
    color: var(--accent);
}

/* Message form */

.message-form {
    display: flex;
    gap: 10px;

    padding: 14px;

    background: var(--panel-soft);
    border-top: 1px solid var(--border);
}

.message-form input {
    flex: 1;
    min-width: 0;

    padding: 13px 15px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: #11151c;
    color: var(--text);

    outline: none;
}

.message-form input:focus {
    border-color: var(--accent);
}

.message-form button {
    padding: 12px 18px;

    border: 0;
    border-radius: 10px;

    background: var(--accent);
    color: white;

    font-weight: 800;
}

/* User list */

.user-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 9px;

    padding: 9px 10px;
    border-radius: 8px;

    color: var(--text);
}

.user-item:hover {
    background: var(--panel-hover);
}

.user-icon {
    width: 26px;
    height: 26px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: rgba(255, 255, 255, 0.07);
}

.user-item.bot .user-icon {
    background: rgba(128, 191, 255, 0.12);
}

.user-item.bot .user-name {
    color: #80bfff;
    font-weight: 800;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive */

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 170px minmax(0, 1fr);
    }

    .users-panel {
        display: none;
    }
}

@media (max-width: 650px) {
    .brand-subtitle {
        display: none;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .rooms-panel {
        display: none;
    }

    .topbar {
        padding: 12px 14px;
    }

    .message-form {
        flex-direction: column;
    }

    .message-form button {
        width: 100%;
    }
}

/* =========================================================
   Trivia Top 5
   ========================================================= */

.trivia-ranking {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.trivia-ranking-title {
    margin-bottom: 12px;
}

.trivia-top {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trivia-rank-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;

    padding: 9px 10px;
    border-radius: 8px;

    background: rgba(255, 255, 255, 0.035);
}

.trivia-rank-item:first-child {
    background: rgba(255, 193, 7, 0.08);
}

.trivia-position {
    font-size: 15px;
    text-align: center;
}

.trivia-player {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 14px;
    font-weight: 600;
}

.trivia-points {
    min-width: 28px;

    padding: 3px 7px;
    border-radius: 999px;

    text-align: center;
    font-size: 12px;
    font-weight: 700;

    background: rgba(255, 255, 255, 0.08);
}

.trivia-empty {
    padding: 10px;

    font-size: 13px;
    opacity: 0.55;
    text-align: center;
}
