:root {
    --bg-0: #0f121b;
    --bg-1: #131620;
    --bg-2: #1b2235;
    --bg-3: #1c2033;
    --bg-4: #20273d;
    --bg-5: #272f48;
    --border: rgba(86, 95, 115, 0.2);
    --border-strong: #434b71;
    --text-0: #ffffff;
    --text-1: #c7cbd6;
    --text-2: #8c98a9;
    --text-3: #666e97;
    --gold: #ffc701;
    --gold-soft: rgba(255, 199, 1, 0.1);
    --red: #ff4a59;
    --sidebar-w: 88px;
    --chat-w: 320px;
    --header-h: 88px;
    --topbar-h: 28px;
    --font-display: "Oswald", "Segoe UI", system-ui, sans-serif;
    --font-body: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; color-scheme: dark; }

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-1);
    background: var(--bg-1);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--gold); color: #000;
    padding: 10px 16px; border-radius: 4px; z-index: 1000;
}
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- App Shell ---------- */
.app {
    min-height: 100vh;
    background: var(--bg-1);
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-2);
    display: flex;
    align-items: center;
    padding: 0 16px 0 4px;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-2);
}
.topbar-social { display: flex; gap: 8px; align-items: center; }
.topbar-social a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; color: var(--text-3);
    transition: color .15s;
}
.topbar-social a:hover { color: var(--gold); }
.topbar-social svg { width: 13px; height: 13px; }
.topbar-promo { display: flex; gap: 24px; margin-left: 24px; }
.topbar-promo a { color: var(--text-3); transition: color .15s; }
.topbar-promo a:hover { color: var(--text-0); }
.topbar-promo a.is-active { color: var(--gold); }

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--chat-w);
    min-height: calc(100vh - var(--topbar-h));
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h));
    width: var(--sidebar-w);
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    padding-bottom: 28px;
    z-index: 4;
}

.sidebar-brand {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    background: var(--gold-soft);
    display: grid; place-items: center;
    margin-bottom: 24px;
    flex-shrink: 0;
}
.sidebar-brand-ring { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; }
.sidebar-brand img { width: 28px; height: auto; }

.sidebar-nav { flex: 1; width: 100%; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 12px; padding: 6px 0; }

.sidebar-nav a {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 10px 4px;
    color: var(--text-3);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    transition: color .15s;
}
.sidebar-nav a:hover { color: var(--text-0); }
.sidebar-nav a.is-active { color: var(--gold); background: var(--gold-soft); }
.sidebar-nav a.is-active::before {
    content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 2px; background: var(--gold); border-radius: 0 2px 2px 0;
}
.sidebar-nav img {
    filter: brightness(0) saturate(100%) invert(52%) sepia(7%) saturate(913%) hue-rotate(199deg) brightness(91%) contrast(86%);
    transition: filter .15s;
}
.sidebar-nav a:hover img { filter: none; }
.sidebar-nav a.is-active img {
    filter: brightness(0) saturate(100%) invert(78%) sepia(65%) saturate(2147%) hue-rotate(356deg) brightness(103%) contrast(104%);
}

.sidebar-chip {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 55px;
    height: 23px;
    padding: 0 8px;
    background: var(--bg-3);
    color: var(--text-2);
    font-family: var(--font-body);
    font-style: normal;
    font-size: 10px;
    border-radius: 2px;
}
.sidebar-badge {
    position: absolute;
    top: 0; right: 6px;
    background: var(--red);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 8px;
    letter-spacing: .5px;
    padding: 2px 4px;
    border-radius: 2px;
    line-height: 1;
}

.sidebar-info {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    color: var(--text-3);
    margin-top: 16px;
    border-radius: 50%;
    transition: background .15s, color .15s;
}
.sidebar-info:hover { background: var(--bg-3); color: var(--text-0); }

/* ---------- Main Column ---------- */
.main-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-1);
    background-image:
        radial-gradient(1100px 420px at 50% 200px, rgba(65, 45, 120, 0.45), transparent 70%),
        linear-gradient(180deg, #1a1d2a 0%, #131620 60%, #0f121b 100%);
    background-repeat: no-repeat;
}

.site-header {
    position: sticky;
    top: var(--topbar-h);
    z-index: 3;
    height: var(--header-h);
    background: var(--bg-1);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 32px;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
}

.site-header-logo img { width: 160px; height: auto; }

.site-header-social {
    display: flex;
    gap: 24px;
    justify-content: center;
}
.site-header-social a {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 50%;
    color: var(--text-3);
    transition: background .15s, transform .15s;
}
.site-header-social a:hover { background: var(--bg-3); transform: translateY(-1px); }

.site-header-actions {
    display: flex; align-items: center; gap: 10px;
    padding-left: 10px;
}

.lang-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 0 14px;
    height: 40px;
    min-width: 96px;
    background: var(--bg-4);
    border-radius: 2px;
    color: var(--text-0);
    font-family: var(--font-display);
    font-size: 14px;
    text-transform: uppercase;
}
.lang-btn .chevron { opacity: .7; }

.menu-btn {
    width: 40px; height: 40px;
    background: var(--gold);
    border-radius: 2px;
    display: grid; place-items: center;
    gap: 3px;
    grid-template-rows: repeat(3, 2px);
    padding: 13px 10px;
}
.menu-btn span { display: block; height: 2px; background: #161b2a; border-radius: 1px; }

/* ---------- Content ---------- */
.content {
    flex: 1;
    padding: 32px 32px 80px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: 1104px;
    width: 100%;
    margin: 0 auto;
}

/* Hero */
.hero {
    position: relative;
    height: 174px;
    border-radius: 12px;
    background: linear-gradient(180deg, #2e374d 0%, #8a6e1f 100%);
    padding: 2px;
    overflow: visible;
    box-shadow: 0 10px 40px -20px rgba(0,0,0,.5);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 48px -20px rgba(0,0,0,.6);
}
.hero-bg {
    position: absolute; inset: 2px;
    width: calc(100% - 4px); height: calc(100% - 4px);
    border-radius: 10px;
    object-fit: cover;
}
.hero-inner {
    position: relative;
    height: 100%;
    border-radius: 10px;
    overflow: visible;
}
.hero-title {
    position: absolute;
    left: 50%; top: -24px;
    transform: translateX(-50%);
    width: 338px; height: auto;
    z-index: 3;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,.5));
}
.hero-badge { position: absolute; z-index: 2; filter: drop-shadow(0 4px 12px rgba(0,0,0,.4)); }
.hero-badge-left  { left: 16px; bottom: -24px; width: 145px; }
.hero-badge-right { right: 0; bottom: -24px; width: 204px; }
.hero-corner { position: absolute; right: 32px; top: -24px; width: 152px; z-index: 2; }

.hero-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px; height: 40px;
    background: var(--bg-4);
    border-radius: 50%;
    display: grid; place-items: center;
    color: var(--text-0);
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    z-index: 4;
    transition: background .15s, transform .15s;
}
.hero-arrow:hover { background: var(--bg-5); transform: translateY(-50%) scale(1.05); }
.hero-arrow-prev { left: -24px; }
.hero-arrow-prev img { transform: rotate(180deg); }
.hero-arrow-next { right: -24px; }
.hero-arrow img { width: 14px; height: 14px; filter: brightness(0) invert(1); }

/* Game grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}
.games-grid > li { display: contents; }
.game-card {
    position: relative;
    display: block;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 250 / 163;
    background: var(--bg-2);
    transition: transform .2s ease, box-shadow .2s ease;
    will-change: transform;
}
.game-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -16px rgba(0,0,0,.6), 0 0 0 1px rgba(255,199,1,.2);
}
.game-card-img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.game-card-title {
    position: absolute;
    top: 16px; right: 20px;
    max-width: 45%;
    width: auto;
    max-height: 52px;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,.4));
}
.game-card-sm .game-card-title { max-height: 42px; }
.game-card-lg .game-card-title { max-height: 28px; right: 0; top: 24px; }
.game-card-sm { grid-column: span 3; }
.game-card-lg { grid-column: span 4; aspect-ratio: 337 / 219; }

/* Leaderboard */
.leaderboard { display: flex; flex-direction: column; gap: 28px; padding-top: 20px; }
.leaderboard-head {
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; gap: 40px;
    height: 60px;
}
.leaderboard-rule {
    height: 2px;
    background: linear-gradient(to right, rgba(39,47,72,0), var(--border-strong));
}
.leaderboard-rule-r { background: linear-gradient(to left, rgba(39,47,72,0), var(--border-strong)); }
.leaderboard-head h2 {
    color: var(--gold);
    font-size: 40px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
}
.leaderboard-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}
.leaderboard-tabs {
    display: flex; gap: 12px;
    grid-column: 2;
    justify-content: center;
}
.leaderboard-tabs button {
    padding: 6px 20px;
    min-width: 80px;
    border-radius: 2px;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-2);
    background: transparent;
    transition: background .15s, color .15s;
}
.leaderboard-tabs button.is-active {
    background: var(--gold);
    color: #1b2235;
}
.leaderboard-tabs button:hover:not(.is-active) { color: var(--text-0); }

.leaderboard-timer {
    grid-column: 3;
    justify-self: end;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--text-2);
}
.leaderboard-timer .label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.leaderboard-timer time {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--text-0);
    font-variant-numeric: tabular-nums;
}
.leaderboard-timer img { filter: invert(62%) sepia(9%) saturate(553%) hue-rotate(180deg) brightness(90%) contrast(90%); }

.leaderboard-list {
    display: grid;
    gap: 2px;
    background: var(--bg-2);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
}
.leaderboard-list li {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--bg-1);
}
.leaderboard-list li:nth-child(1) .rank { color: var(--gold); }
.leaderboard-list li:nth-child(2) .rank { color: #c0c9d9; }
.leaderboard-list li:nth-child(3) .rank { color: #b26a3a; }
.leaderboard-list .rank {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--text-3);
}
.leaderboard-list .name { color: var(--text-0); font-weight: 500; }
.leaderboard-list .amount {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

/* SEO content */
.seo {
    color: var(--text-2);
    padding: 32px;
    background: rgba(16, 20, 32, .6);
    border: 1px solid var(--border);
    border-radius: 12px;
    line-height: 1.7;
}
.seo h2 {
    color: var(--gold);
    font-family: var(--font-display);
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 12px;
}
.seo h3 {
    color: var(--text-0);
    font-family: var(--font-display);
    font-size: 18px;
    text-transform: uppercase;
    margin: 20px 0 8px;
}
.seo p { margin: 0 0 10px; }
.seo a { color: var(--gold); border-bottom: 1px dotted rgba(255,199,1,.4); }
.seo a:hover { color: #ffe084; }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--bg-0);
    border-top: 1px solid var(--border);
    padding: 48px 48px 24px;
    color: var(--text-2);
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 40px;
    margin-bottom: 32px;
}
.footer-grid > div > p { max-width: 360px; margin-top: 12px; line-height: 1.6; }
.site-footer h4 {
    color: var(--text-0);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}
.site-footer nav ul { display: flex; flex-direction: column; gap: 8px; }
.site-footer a { color: var(--text-2); transition: color .15s; }
.site-footer a:hover { color: var(--gold); }
.footer-legal {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-3);
    margin: 0;
}

/* ---------- Chat ---------- */
.chat {
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h));
    width: var(--chat-w);
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 2;
}
.chat-header {
    flex-shrink: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
}
.chat-header h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 20px;
    color: var(--text-0);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.chat-online {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gold);
    font-size: 13px;
}
.chat-online i {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(255,199,1,.15);
}

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-4) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

.chat-msg {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 12px;
}
.chat-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c3352, #1c2033);
    color: var(--text-0);
    font-family: var(--font-display);
    font-size: 11px;
    display: grid;
    place-items: center;
    margin-top: 2px;
    box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 3px var(--bg-3);
}
.chat-body header { margin-bottom: 3px; }
.chat-name {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13px;
    text-transform: lowercase;
}
.chat-name.default { color: #9aa4b8; }
.chat-name.badge   { color: #55a4ff; }
.chat-name.gold    { color: var(--gold); }
.chat-body p {
    margin: 0;
    color: var(--text-1);
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}
.chat-emoji { font-size: 20px; }

.chat-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding: 16px 24px 20px;
    background: var(--bg-1);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-rooms { display: flex; gap: 4px; }
.chat-rooms button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    height: 26px;
    border-radius: 2px;
    color: var(--text-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    transition: background .15s, color .15s;
}
.chat-rooms button.is-active {
    background: var(--bg-3);
    color: var(--text-0);
}
.chat-rooms .flag { font-size: 14px; line-height: 1; }

.chat-form {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-3);
    border-radius: 2px;
    padding: 0 14px;
}
.chat-form textarea {
    flex: 1;
    background: transparent;
    border: 0; outline: none; resize: none;
    color: var(--text-0);
    font: inherit;
    padding: 14px 0;
    min-height: 20px;
    max-height: 120px;
}
.chat-form textarea::placeholder { color: var(--text-3); }
.chat-form button[type="submit"] {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    color: var(--text-3);
    transition: color .15s;
}
.chat-form button[type="submit"]:hover { color: var(--gold); }
.chat-form svg { width: 18px; height: 18px; }

.chat-rules {
    font-size: 12px;
    color: var(--text-3);
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.chat-rules span {
    display: grid; place-items: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--bg-3);
    font-size: 9px;
    color: var(--text-0);
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
    :root { --chat-w: 300px; }
    .content { padding: 24px 24px 60px; }
    .leaderboard-head h2 { font-size: 32px; }
}

@media (max-width: 1280px) {
    .layout { grid-template-columns: var(--sidebar-w) 1fr; }
    .chat { display: none; }
    .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}

@media (max-width: 900px) {
    .site-header-social { display: none; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}


@media (max-width: 720px) {
    :root { --sidebar-w: 68px; --header-h: 72px; }
    .topbar { font-size: 10px; }
    .topbar-promo { gap: 14px; margin-left: 14px; }
    .content { padding: 16px 12px 40px; gap: 28px; }
    .site-header { padding: 0 16px; gap: 16px; grid-template-columns: auto 1fr auto; }
    .site-header-logo img { width: 120px; }
    .site-header-actions { justify-self: end; }
    .lang-btn { min-width: 0; padding: 0 10px; font-size: 12px; }
    .sidebar-nav a { font-size: 10px; }
    .sidebar-chip { display: none; }
    .hero { height: 140px; }
    .hero-title { width: 240px; top: -14px; }
    .hero-badge-left, .hero-badge-right { display: none; }
    .hero-corner { display: none; }
    .hero-arrow { display: none; }
    .games-grid { gap: 8px; }
    .leaderboard-head { grid-template-columns: 1fr; gap: 12px; }
    .leaderboard-rule { display: none; }
    .leaderboard-head h2 { font-size: 26px; }
    .leaderboard-controls { grid-template-columns: 1fr; gap: 14px; }
    .leaderboard-tabs { grid-column: 1; }
    .leaderboard-timer { grid-column: 1; justify-self: center; }
    .leaderboard-list li { grid-template-columns: 32px 1fr auto; gap: 10px; padding: 10px 14px; }
    .seo { padding: 20px; }
    .seo h2 { font-size: 22px; }
    .site-footer { padding: 32px 20px 20px; }
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}

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