:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #102a3b;
    background: #e6f1f8;
    --ink: #102a3b;
    --mute: #415d70;
    --edge: rgba(255, 255, 255, 0.83);
    --telegram-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
    --telegram-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 3% 7%, #c4deed 0%, transparent 44%),
        radial-gradient(ellipse at 89% 92%, #ccede4 0%, transparent 43%),
        linear-gradient(141deg, #edf6fa, #dfeef5 71%, #e7f4f1);
}

h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid #156e8b; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.glass {
    background: linear-gradient(151deg, rgba(255, 255, 255, 0.71), rgba(244, 253, 255, 0.39));
    border: 1px solid var(--edge);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.85), 0 12px 30px rgba(36, 90, 122, 0.09);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
}

.site-header {
    padding-top: var(--telegram-top);
    background: rgba(233, 245, 251, 0.71);
    border-bottom: 1px solid rgba(255, 255, 255, 0.77);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.header-inner, .shell { width: min(1120px, calc(100% - 44px)); margin-inline: auto; }
.header-inner { min-height: 76px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 760; letter-spacing: -0.04em; }
.navigation {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    border-radius: 99px;
    margin-inline: auto;
    background: rgba(101, 149, 171, 0.12);
}
.navigation a { padding: 8px 16px; border-radius: 99px; color: #385567; font-size: 14px; font-weight: 660; white-space: nowrap; }
.navigation a[aria-current] { color: var(--ink); background: #fffdfd; box-shadow: 0 1px 5px #153e5220; }

.search {
    min-width: 0;
    width: clamp(160px, 24vw, 255px);
    min-height: 42px;
    padding-inline: 13px;
    border-radius: 99px;
    display: flex;
    gap: 8px;
    align-items: center;
    color: #33586d;
}
.search svg { flex: 0 0 auto; }
.search input { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search input:focus { outline: 0; }
.search:focus-within { outline: 2px solid #237c9b; outline-offset: 2px; }

.shell { padding: 34px 0 max(35px, var(--telegram-bottom)); }
.hero {
    position: relative;
    min-height: 440px;
    overflow: hidden;
    border-radius: 30px;
    isolation: isolate;
    display: grid;
    align-items: center;
    background: #102c40;
    color: #f6fbfb;
    box-shadow: 0 21px 48px rgba(18, 61, 83, 0.22);
}
.hero > img { position: absolute; width: 100%; height: 100%; object-fit: cover; object-position: right 55%; z-index: -2; }
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(90deg, #102c40 2%, rgba(16, 44, 64, 0.93) 27%, rgba(16, 44, 64, 0.45) 64%, rgba(16, 44, 64, 0.03));
}
.hero-copy { padding: clamp(30px, 5.3vw, 64px); max-width: 670px; }
.hero h1 { font-size: clamp(40px, 6vw, 72px); font-weight: 770; letter-spacing: -0.06em; line-height: 0.97; max-width: 600px; }
.hero p { margin-top: 16px; max-width: 36ch; color: #e0ebf2; font-size: clamp(15px, 1.6vw, 18px); line-height: 1.5; }
.hero .actions { margin-top: 24px; }
.player-count {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 16px;
    border-radius: 99px;
    padding: 5px 10px;
    background: #edf6f8;
    color: #264f61;
    font-size: 12px;
    font-weight: 720;
    font-variant-numeric: tabular-nums;
}
.hero .player-count { color: #f1fffc; background: #154a5dbf; border: 1px solid #e2fffc38; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #7893a0; }
.is-live .pulse { background: #38ba83; box-shadow: 0 0 0 3px #38ba8333; }

.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 99px;
    width: fit-content;
    font-size: 14px;
    font-weight: 720;
    cursor: pointer;
    transition: background-color 150ms ease, box-shadow 150ms ease;
}
.button[aria-disabled="true"], .button:disabled { opacity: 0.52; cursor: default; }
.primary { color: #f6fffd; background: #175269; box-shadow: inset 0 1px #ffffff37, 0 5px 10px #183c5025; }
.primary:hover:not([aria-disabled="true"]) { background: #24677d; }
.hero .primary { color: #0a3435; background: #9aefcf; border-color: #d8ffee; }
.hero .primary:hover:not([aria-disabled="true"]) { background: #c2f8e3; }
.hero-secondary { color: white; background: #f0fcff1f; border-color: #f0fcff50; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.hero-secondary:hover { background: #f0fcff35; }
.secondary { color: #173b4b; background: #f8fdffbe; border-color: white; }
.secondary:hover { background: #fff; }

.room-callout { margin-top: 18px; padding: 19px 23px; border-radius: 24px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.room-callout h2, .friend-card h2, .game-card h2 { font-size: 20px; letter-spacing: -0.025em; }
.room-callout p, .friend-card p, .game-card p { margin-top: 5px; color: var(--mute); font-size: 14px; line-height: 1.5; }
.room-callout .button { flex: 0 0 auto; }

.section-heading { margin-bottom: 21px; }
.section-heading h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -0.05em; line-height: 1.1; }
.catalog-grid, .friend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 16px; }
.catalog-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 295px), 1fr)); }
.game-card, .friend-card, .empty-state { border-radius: 24px; overflow: hidden; }
.game-card img { width: 100%; height: auto; aspect-ratio: 16 / 9; display: block; object-fit: cover; }
.game-card-body, .friend-card, .empty-state { padding: 20px; }
.game-card .player-count { margin-bottom: 9px; }
.game-card .actions, .friend-card .button { margin-top: 15px; }
.friend-card .room-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border-radius: 14px;
    color: #19546b;
    background: linear-gradient(#f8fdff, #cfe9ef);
    border: 1px solid #fff;
}
.join-form { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.join-form .button { margin: 0; }
.join-form input {
    flex: 1 1 140px;
    min-width: 0;
    height: 44px;
    background: #fff9;
    border: 1px solid #fff;
    border-radius: 99px;
    color: var(--ink);
    padding: 0 12px;
    text-transform: uppercase;
}
.join-form input::placeholder { text-transform: none; }
.network-status { margin-top: 15px; font-size: 13px; color: var(--mute); }

@media (max-width: 680px) {
    .header-inner, .shell { width: calc(100% - 28px); }
    .header-inner { min-height: 64px; gap: 12px; justify-content: space-between; }
    .search { width: clamp(130px, 45vw, 220px); }
    .navigation {
        position: fixed;
        z-index: 3;
        bottom: max(12px, var(--telegram-bottom));
        left: 50%;
        transform: translateX(-50%);
        background: rgba(230, 244, 251, 0.93);
        border: 1px solid white;
        box-shadow: 0 8px 26px rgba(25, 67, 91, 0.19);
        -webkit-backdrop-filter: blur(19px);
        backdrop-filter: blur(19px);
    }
    .navigation a { min-height: 40px; display: grid; place-items: center; }
    .site-header { -webkit-backdrop-filter: none; backdrop-filter: none; }
    .shell { padding-top: 18px; padding-bottom: calc(78px + var(--telegram-bottom)); }
    .hero { min-height: 470px; align-items: end; border-radius: 25px; }
    .hero-copy { padding: 24px 19px; }
    .hero > img { object-position: 55% top; }
    .hero::after {
        background: linear-gradient(0deg, #102c40 10%, rgba(16, 44, 64, 0.91) 42%, rgba(16, 44, 64, 0.1) 87%);
    }
    .hero .button { padding-inline: 13px; }
    .room-callout { padding: 15px; gap: 10px; }
    .room-callout h2 { font-size: 17px; }
    .room-callout p { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
