:root {
    --bg: #030911;
    --bg-2: #07101a;
    --panel: #08131e;
    --panel-2: #0c1824;
    --panel-glass: rgba(8, 19, 30, .96);
    --line: rgba(145, 171, 194, .14);
    --line-strong: rgba(169, 190, 211, .25);
    --text: #f4f6f8;
    --muted: #8794a2;
    --crimson: #856de8;
    --crimson-soft: rgba(133, 109, 232, .15);
    --cyan: #bdda38;
    --green: #bdda38;
}

@media (max-width: 760px) {
    .topbar {
        min-height: 58px;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        padding: max(8px, env(safe-area-inset-top)) 11px 8px;
    }
    .brand { flex: 1 1 auto; min-width: 0; }
    .brand-mark { width: 23px; height: 23px; }
    .brand-name { font-size: 12px; }
    .me { flex: 0 0 auto; margin: 0; gap: 7px; }
    .me-avatar { width: 34px; height: 34px; display: block; }
    .me-info,
    .topbar-online { display: none; }
    .me-coins { min-width: 66px; padding: 7px 9px; font-size: 11px; }
    .account-exit { width: 36px; height: 36px; }

    .topbar .tabs {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: max(7px, env(safe-area-inset-bottom));
        z-index: 50;
        width: auto;
        min-height: 60px;
        display: grid;
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 2px;
        padding: 4px;
        border: 1px solid rgba(145, 171, 194, .22);
        border-radius: 16px;
        background: rgba(3, 11, 19, .97);
        box-shadow: 0 14px 45px rgba(0, 0, 0, .55);
        backdrop-filter: blur(18px);
    }
    .topbar .tab {
        min-width: 0;
        min-height: 50px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 4px 2px;
        border-radius: 11px;
        font-size: 10px;
    }
    .topbar .tab img { display: block; width: 18px; height: 18px; margin: 0; }
    .topbar .tab span { display: block; }

    .view { padding: 8px 7px calc(82px + env(safe-area-inset-bottom)); }
    #view-game.is-active {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 6px 6px calc(76px + env(safe-area-inset-bottom));
    }
    .home-shell,
    .lobby-dashboard {
        height: 100%;
        min-height: 0;
        padding-bottom: 0;
    }
    .rooms-panel { min-height: 0; }
    .lobby-empty { min-height: 0; }

    .dashboard-chat {
        height: auto;
        min-height: 0;
        overflow: hidden;
    }
    .dashboard-chat #homeChat,
    .dashboard-chat .community-chat {
        height: 100%;
        min-height: 0;
    }
    .dashboard-chat .community-chat { display: flex; flex-direction: column; }
    .dashboard-chat .community-chat-head { flex: 0 0 auto; min-height: 0; padding: 6px; }
    .dashboard-chat .community-scopes {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
        overflow: visible;
    }
    .dashboard-chat .community-scope {
        width: auto;
        min-width: 0;
        min-height: 34px;
        padding: 6px 4px;
        overflow: hidden;
        font-size: 11px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .dashboard-chat .community-chat-body {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .dashboard-chat .community-thread { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
    .dashboard-chat .thread-messages {
        flex: 1 1 auto;
        min-height: 0;
        padding: 6px 8px 4px;
    }
    .dashboard-chat .thread-empty { height: 100%; min-height: 0; }
    .dashboard-chat .thread-empty img { display: none; }
    .dashboard-chat .thread-empty b { font-size: 12px; }
    .dashboard-chat .thread-empty span { font-size: 9px; }
    .dashboard-chat .community-compose {
        flex: 0 0 auto;
        padding: 4px 6px 6px;
        border-top: 0;
    }
}

@media (max-width: 390px) {
    .brand-name { letter-spacing: .12em; }
    .me { gap: 5px; }
    .me-avatar { width: 32px; height: 32px; }
    .me-coins { min-width: 58px; padding-inline: 7px; }
    .account-exit { width: 34px; height: 34px; }
    .dashboard-chat .community-scope { font-size: 10px; }
}

html, body {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(96, 116, 208, .16), transparent 46%),
        radial-gradient(ellipse at 12% 92%, rgba(58, 132, 170, .1), transparent 40%),
        radial-gradient(ellipse at 88% 84%, rgba(122, 82, 190, .1), transparent 42%),
        linear-gradient(180deg, #05080f 0%, #01050a 100%);
    background-attachment: fixed;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: .5;
    background-image:
        linear-gradient(rgba(109, 132, 153, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(109, 132, 153, .045) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse at 50% 50%, transparent 34%, black 82%);
}

.app::before {
    opacity: .16;
    background-image:
        radial-gradient(circle at 52% 38%, rgba(123, 103, 225, .08), transparent 31%),
        linear-gradient(rgba(109, 132, 153, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(109, 132, 153, .025) 1px, transparent 1px);
    background-size: 100% 100%, 56px 56px, 56px 56px;
}

.brand-mark,
.boot-mark {
    filter: drop-shadow(0 0 10px rgba(201, 230, 49, .24));
}

.btn.primary {
    border-color: rgba(113, 162, 238, .78);
    background: linear-gradient(118deg, #7152d3 0%, #5d76d8 48%, #438ed9 100%);
    box-shadow: 0 12px 28px rgba(42, 80, 157, .22), inset 0 1px rgba(255, 255, 255, .2);
}

.btn.primary:hover:not(:disabled) {
    background: linear-gradient(118deg, #7a5cdb 0%, #6780e1 48%, #4a9ae5 100%);
}

@media (min-width: 1200px) {
    .topbar {
        min-height: 75px;
        height: 75px;
        grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
        gap: clamp(12px, 2vw, 28px);
        padding: 0 clamp(18px, 2.6vw, 49px);
        border-color: rgba(145, 171, 194, .12);
        background: rgba(2, 8, 15, .94);
        box-shadow: 0 10px 34px rgba(0, 0, 0, .18);
    }

    .brand { gap: 17px; }
    .brand-mark { width: 25px; height: 25px; }
    .brand-name { font-size: 16px; letter-spacing: .28em; }

    .topbar .tabs { align-self: stretch; min-width: 0; justify-content: center; gap: 6px; }
    .topbar .tab {
        flex: 0 1 150px;
        min-height: 75px;
        padding: 8px 14px;
        border: 0;
        border-radius: 0;
        font-size: 14px;
        font-weight: 620;
    }
    .topbar .tab img { width: 17px; height: 17px; margin-right: 8px; filter: brightness(2) saturate(.12); }
    .topbar .tab.is-active {
        border: 0;
        background: linear-gradient(180deg, transparent 20%, rgba(74, 86, 119, .18));
        box-shadow: inset 0 -2px #8a76ec;
    }

    .me { gap: 12px; }
    .me-avatar { width: 46px; height: 46px; border-color: rgba(75, 154, 217, .45); }
    .me-name { font-size: 14px; }
    .me-sub { margin-top: 3px; color: #4b8de0; font-size: 10px; }
    .me-coins { min-width: 68px; padding: 9px 13px; font-size: 13px; text-align: center; }
    .topbar-online { padding: 9px 12px; }
    .account-exit { width: 38px; height: 38px; }

    .view { padding: 22px 31px 27px; }
    #view-game.is-active { overflow: hidden; }
    .home-shell { width: 100%; height: 100%; min-height: 0; max-width: none; }
    .lobby-dashboard {
        height: 100%;
        min-height: 0;
        grid-template-columns: minmax(0, 1fr) clamp(232px, 21%, 288px);
        grid-template-rows: minmax(0, 1fr) minmax(0, .82fr);
        gap: 15px;
    }

    .rooms-panel,
    .dashboard-chat,
    .people-card {
        border-color: rgba(122, 157, 189, .22);
        border-radius: 17px;
        background:
            radial-gradient(circle at 93% -14%, rgba(64, 110, 145, .08), transparent 35%),
            linear-gradient(145deg, rgba(8, 19, 30, .985), rgba(5, 15, 24, .985));
        box-shadow: inset 0 1px rgba(255, 255, 255, .025), 0 18px 46px rgba(0, 0, 0, .16);
    }

    .rooms-panel.room-browser { grid-template-rows: auto minmax(0, 1fr); }
    .room-toolbar {
        min-height: 0;
        display: flex;
        align-items: stretch;
        justify-content: center;
        gap: 10px;
        padding: 8px 12px;
        background: rgba(4, 13, 23, .34);
        overflow: hidden;
    }
    .mode-grid {
        flex: 0 1 auto;
        grid-template-columns: repeat(3, minmax(76px, 108px));
        gap: 7px;
        min-width: 0;
    }
    .mode-card {
        min-height: 44px;
        padding: 6px 5px;
        border-radius: 10px;
        background: linear-gradient(145deg, rgba(10, 24, 36, .96), rgba(5, 15, 24, .96));
    }
    .mode-card.is-active {
        border-color: #806be6;
        background: linear-gradient(145deg, rgba(25, 32, 51, .98), rgba(6, 17, 28, .98));
        box-shadow: 0 0 22px rgba(112, 91, 213, .12);
    }
    .mode-card.is-active b { color: #ddd6ff; }
    .mode-card.is-active small { color: #a99fe0; }
    .room-actions {
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        gap: 8px;
        min-width: 0;
    }
    .room-actions .btn { min-height: 44px; border-radius: 10px; }
    .room-actions .search-game {
        width: auto;
        padding: 6px 20px;
        border-color: rgba(138, 118, 236, .5);
        background: linear-gradient(120deg, rgba(118, 90, 220, .3), rgba(70, 132, 208, .24));
        color: #e7ecff;
        box-shadow: 0 10px 24px rgba(48, 60, 132, .18), inset 0 1px rgba(255, 255, 255, .06);
    }
    .room-actions .search-game:hover:not(:disabled) {
        border-color: rgba(160, 143, 245, .72);
        background: linear-gradient(120deg, rgba(131, 103, 232, .42), rgba(80, 146, 222, .34));
        color: #f3f6ff;
    }
    .room-actions .btn b { font-size: 12px; }
    .room-actions .create-shortcut { width: 44px; min-width: 44px; flex: 0 0 44px; padding: 0; }
    .room-actions .create-shortcut b { font-size: 22px; }

    .room-grid {
        margin: 0 17px 10px;
        padding: 0;
        overflow: hidden;
    }
    .lobby-empty {
        min-height: 0;
        border-color: rgba(122, 157, 189, .18);
        background: #06111b;
        border-radius: 12px;
    }
    .lobby-empty > img {
        border-radius: 12px;
        opacity: 1;
        filter: none;
        mask-image: none;
        -webkit-mask-image: none;
    }
    .lobby-empty h3 {
        max-width: 22ch;
        font-size: clamp(20px, 1.6vw, 26px);
    }
    .empty-create {
        min-height: 48px;
        margin-top: 22px;
        padding: 10px 20px;
        border-color: rgba(163, 183, 202, .32);
        background: rgba(7, 16, 25, .68);
        font-size: 13px;
    }

    .dashboard-chat { display: block; }
    .dashboard-chat > header { display: none; }
    .section-kicker { color: #9c91e5; font-size: 10px; letter-spacing: .18em; }
    .dashboard-chat #homeChat { height: 100%; padding: 0; }
    .dashboard-chat .community-chat-head { min-height: 40px; }
    .dashboard-chat .community-chat-head { padding: 12px 20px 9px; border-bottom: 0; }
    .dashboard-chat .community-scopes { width: 310px; }
    .dashboard-chat .community-scope { min-height: 39px; font-size: 12px; }
    .dashboard-chat .community-scope.is-active { border-color: rgba(133, 109, 232, .35); background: rgba(91, 78, 139, .3); }
    .dashboard-chat .community-chat-body {
        margin-top: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }
    .dashboard-chat .thread-messages { padding: 14px 20px 8px; }
    .dashboard-chat .thread-empty img { width: 130px; max-height: 70px; border-radius: 0; opacity: 1; filter: none; mask-image: none; }
    .dashboard-chat .thread-empty b { margin-top: 5px; font-size: 14px; }
    .dashboard-chat .thread-empty span { margin-top: 6px; font-size: 11px; line-height: 1.5; }
    .dashboard-chat .thread-message { grid-template-columns: 38px 76px minmax(0, 1fr); gap: 5px; padding-block: 2px; }
    .dashboard-chat .thread-message b { font-size: 11.5px; }
    .dashboard-chat .thread-message time { font-size: 9.5px; }
    .dashboard-chat .thread-message p { font-size: 12.5px; line-height: 1.3; }
    .dashboard-chat .community-compose { padding: 6px 20px 14px; }
    .dashboard-chat .community-input { min-height: 48px; padding: 12px 60px 12px 14px; background: rgba(3, 11, 19, .8); font-size: 14px; }
    .dashboard-chat .community-compose .emoji-toggle,
    .dashboard-chat .community-compose .community-send { width: 46px; height: 46px; }

    .people-card { grid-template-rows: auto minmax(0, 1fr); }
    .people-head { padding: 13px 13px 9px; }
    .people-tabs { padding: 4px; }
    .people-tabs button { min-height: 33px; padding: 6px 8px; font-size: 11.5px; }
    .people-tabs button.is-active { border-color: rgba(155, 139, 235, .24); background: rgba(74, 79, 107, .34); }
    .people-list { padding: 6px 10px 12px; }
    .person-row { min-height: 56px; }
    .person-avatar { width: 36px; height: 36px; }
    .person-copy b { font-size: 13px; }
    .person-copy small,
    .person-row em { font-size: 11px; }
    .person-row em { color: #bdda38; }
}
