/* ===== Top bar =========================================================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, #161729 0%, #11121f 100%);
  border-bottom: 1px solid rgba(160, 170, 255, 0.08);
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.8);
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 138, 0, 0.55) 30%, rgba(255, 138, 0, 0.55) 70%, transparent);
  opacity: 0.5;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.tb-right { margin-left: auto; }
.tb-chat-toggle { display: none; }

.logo { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.logo-mark { width: 31px; height: 34px; }
.logo-text { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: 0.14em; line-height: 1; font-style: normal; text-transform: uppercase; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-text b, .logo-text i { font-weight: inherit; font-style: normal; }

.menu-item.on { background: rgba(255, 174, 26, 0.1); color: #fff; }
.menu-item.on .ic { color: var(--yellow); }

.tb-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--text-2);
  font-family: var(--display); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tb-icon:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tb-free { color: var(--green-1); border-color: rgba(43, 217, 107, 0.3); background: rgba(43, 217, 107, 0.08); }
.tb-free:hover { color: #fff; background: rgba(43, 217, 107, 0.16); }
.tb-badge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 99px; background: var(--red); color: #fff; font: 700 11px var(--font);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px #12131f;
}

.tb-wallet { display: flex; align-items: center; height: 44px; padding: 3px; gap: 3px; background: #0b0c16; border: 1px solid var(--line-2); border-radius: 10px; }
.balance {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 100%; padding: 0 10px;
  font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
  border-radius: 7px; transition: box-shadow 0.3s, background 0.15s;
}
.balance:hover { background: rgba(255, 255, 255, 0.04); }
.balance .coin { width: 20px; height: 20px; }
.bal-v { min-width: 56px; text-align: left; }
.bal-tag { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.balance.up { animation: balUp 0.8s; }
.balance.down { animation: balDown 0.8s; }
@keyframes balUp { 30% { box-shadow: 0 0 0 2px rgba(43, 217, 107, 0.55); color: var(--green-1); } }
@keyframes balDown { 30% { box-shadow: 0 0 0 2px rgba(255, 77, 94, 0.45); } }
.bal-float {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  color: var(--green-1); font-size: 14px; font-weight: 700; pointer-events: none; white-space: nowrap;
  animation: balFloat 1.2s var(--ease) forwards;
}
@keyframes balFloat { from { opacity: 0; transform: translate(-50%, -6px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, 14px); } }

.tb-get { height: 100%; padding: 0 16px; --cut: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px 0 4px;
  border-radius: 10px; color: var(--muted);
  transition: background 0.15s;
}
.user-chip:hover { background: rgba(255, 255, 255, 0.05); }
.uc-av { position: relative; display: block; }
.uc-av .avatar { width: 36px; height: 36px; border-radius: 8px; box-shadow: 0 0 0 2px rgba(255, 138, 0, 0.55); }
.uc-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.uc-name { color: #fff; font-size: 14px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-lvl { display: flex; align-items: center; gap: 6px; }
.uc-lvl .lvl { height: 16px; min-width: 20px; font-size: 10px; }
.uc-xp { width: 60px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.uc-xp i { display: block; height: 100%; background: var(--accent-grad); border-radius: 4px; }

/* ===== Live drops strip ================================================== */
.live-strip {
  position: relative; display: flex; align-items: stretch; height: var(--strip-h); flex: none; padding: 6px;
  background: #0e0f1a; border-bottom: 1px solid var(--line);
}
.ls-feed { flex: 1; min-width: 0; display: flex; gap: 4px; overflow: hidden; }
.live-strip:has(.ls-feed:empty) { display: none; }
/* one drop: rarity bar on top, odds in the corner, the item over a faint brick stud */
.ls-drop {
  position: relative; flex: none; width: 104px; height: 100%; display: grid; place-items: center; border-radius: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='%232a2c40'%3E%3Crect x='8' y='8' width='84' height='84' rx='14' stroke-width='6'/%3E%3Ccircle cx='50' cy='50' r='22' stroke-width='7'/%3E%3C/svg%3E") center / 70px no-repeat, #191a28;
  transition: background-color 0.15s;
}
.ls-drop::before { content: ''; position: absolute; top: 0; left: 50%; width: 46px; height: 3px; margin-left: -23px; border-radius: 0 0 3px 3px; background: var(--rc); box-shadow: 0 0 8px color-mix(in srgb, var(--rc) 60%, transparent); }
.ls-drop img { width: 88%; height: 72%; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6)); transition: transform 0.2s var(--ease); }
.ls-drop:hover { background-color: #202133; }
.ls-drop:hover img { transform: scale(1.08); }
.ls-odds { position: absolute; top: 7px; right: 8px; font-size: 10.5px; font-weight: 600; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.ls-drop.you { box-shadow: inset 0 0 0 1px rgba(255, 150, 20, 0.6); }
.ls-drop.enter { animation: dropIn 0.5s var(--ease); }

/* ===== Shell: game menu | page | chat ===================================== */
.shell { display: flex; align-items: flex-start; }
.main { flex: 1; min-width: 0; min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; }
/* at least a screen tall, so short pages don't pull the footer into view */
.page { width: 100%; max-width: 1960px; min-height: calc(100vh - var(--topbar-h)); margin: 0 auto; padding: 26px 26px 64px; flex: 1; animation: fadeUp 0.25s var(--ease); }

/* ===== Game menu (left) ================================================== */
.gamenav {
  position: sticky; top: var(--topbar-h); z-index: 40; flex: none;
  width: var(--gamenav-w); height: calc(100vh - var(--topbar-h)); overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 14px; padding: 16px 10px;
  background: linear-gradient(180deg, #10111d, #0d0e18); border-right: 1px solid var(--line);
}
.gn-group { display: flex; flex-direction: column; gap: 2px; }
.gn-group + .gn-group { padding-top: 14px; border-top: 1px solid var(--line); }
.gn-title { padding: 0 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.gn-item {
  position: relative; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 9px;
  font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  color: var(--muted); transition: background 0.15s, color 0.15s;
}
.gn-item .ic { width: 20px; height: 20px; flex: none; color: var(--muted-2); transition: color 0.15s; }
.gn-item:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.gn-item:hover .ic { color: var(--yellow); }
.gn-item.on { background: rgba(255, 174, 26, 0.09); color: #fff; }
.gn-item.on .ic { color: var(--yellow); }
.gn-item.on::before { content: ''; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-grad); }
.gn-item .gn-badge { position: static; margin-left: auto; box-shadow: none; }
/* narrower screens: icons only (names stay as tooltips) */
@media (max-width: 1499px) {
  .gamenav { width: var(--gamenav-rail); padding: 14px 10px; }
  .gn-title, .gn-item span { display: none; }
  .gn-item { justify-content: center; padding: 0; }
  .gn-item .ic { width: 22px; height: 22px; }
  .gn-item .gn-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; font-size: 10px; box-shadow: 0 0 0 2px #0f101b; }
}

/* ===== Sidebar / chat ==================================================== */
.sidebar {
  position: sticky; top: var(--topbar-h); z-index: 40;
  width: var(--sidebar-w); height: calc(100vh - var(--topbar-h)); flex: none;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #10111d, #0d0e18); border-left: 1px solid var(--line);
}
body.chat-closed .sidebar { display: none; }

.rain {
  position: relative; margin: 10px 10px 4px; padding: 12px 12px 12px;
  border: 1px solid rgba(255, 150, 20, 0.35); border-radius: 10px; text-align: center; overflow: hidden;
  background:
    radial-gradient(120px 60px at 15% 0%, rgba(255, 150, 20, 0.13), transparent),
    radial-gradient(120px 60px at 85% 100%, rgba(255, 150, 20, 0.08), transparent),
    rgba(255, 150, 20, 0.03);
}
.rain.open { border-color: var(--yellow); animation: glowPulse 2.4s infinite; }
.rain-top { display: flex; align-items: center; justify-content: center; gap: 8px; }
.rain-ic { width: 22px; height: 22px; color: var(--yellow); }
.rain-pot .amt { font-family: var(--display); font-size: 28px; font-weight: 800; color: #fff; }
.rain-pot .coin { width: 20px; height: 20px; }
.rain-title { margin-top: 4px; color: var(--yellow); font-family: var(--display); font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.04em; }
.rain-sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.rain-actions { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.rain-join { min-width: 96px; }

.chat-list { flex: 1; overflow-y: auto; padding: 6px 0 10px; overscroll-behavior: contain; }
.msg { display: flex; gap: 10px; padding: 7px 12px; animation: fadeUp 0.25s var(--ease); }
.msg-you { background: rgba(255, 150, 20, 0.04); }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.msg-head b { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 128px; }
.msg-you .msg-head b { color: var(--yellow); }
.msg-head time { margin-left: auto; font-size: 10.5px; color: var(--muted-2); }
.msg-text { color: var(--text-2); font-size: 14px; margin-top: 3px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-sys { padding: 6px 10px; }
.sys-drop, .sys-rain, .sys-level {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rc, #ffc61a) 16%, transparent), rgba(255, 255, 255, 0.02));
  border-left: 3px solid var(--rc, var(--yellow)); font-size: 12.5px; color: var(--text-2);
}
.sys-drop img { width: 48px; height: 36px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5)); }
.sys-drop b, .sys-level b { color: #fff; }
.sd-item { color: var(--rc); font-weight: 600; }
.sd-meta { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.sys-rain { --rc: #4c8dff; }
.sys-rain .ic, .sys-level .ic { color: var(--rc); width: 22px; height: 22px; }
.sys-level { --rc: #ffc61a; }

.chat-new {
  position: relative; align-self: center; margin-top: -40px; margin-bottom: 8px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
  background: var(--accent-grad); color: #2a1300; font-size: 12px; font-weight: 700; box-shadow: var(--shadow);
}
.chat-form { display: flex; align-items: center; gap: 6px; margin: 0 10px 8px; padding: 6px 6px 6px 12px; background: var(--bg-0); border: 1px solid var(--line); border-radius: 10px; }
.chat-form:focus-within { border-color: rgba(255, 150, 20, 0.4); }
.chat-input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: #fff; font-size: 13px; height: 28px; }
.chat-input::placeholder { color: var(--muted-2); }
.chat-emoji, .chat-send { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); background: var(--bg-4); }
.chat-emoji:hover, .chat-send:hover { color: #fff; background: var(--bg-5); }
.chat-send { color: var(--yellow); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 4px; }
.emoji-grid button { font-size: 18px; height: 30px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--bg-5); }

.side-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sf-btn { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--bg-4); color: var(--muted); }
.sf-btn:hover { color: #fff; }
.sf-btn .ic { width: 16px; height: 16px; }
.sf-lang { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; height: 30px; border-radius: 7px; background: var(--bg-4); font-weight: 600; }
.flag-us { width: 16px; height: 11px; border-radius: 2px; background:
  linear-gradient(#3c3b6e, #3c3b6e) 0 0 / 7px 6px no-repeat,
  repeating-linear-gradient(#b22234 0 1.6px, #fff 1.6px 3.2px); }
.sf-online { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-weight: 600; color: var(--text-2); }
.sf-online i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(36, 198, 97, 0.18); animation: pulse 2s infinite; }

.chat-reopen, .help-bubble {
  position: fixed; z-index: 55; display: grid; place-items: center; border-radius: 50%;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45); transition: transform 0.15s;
}
.chat-reopen { right: 22px; bottom: 84px; width: 46px; height: 46px; background: var(--bg-4); color: var(--text-2); border: 1px solid var(--line-2); display: none; }
body.chat-closed .chat-reopen { display: grid; }
.help-bubble { right: 18px; bottom: 18px; width: 54px; height: 54px; background: var(--accent-grad); color: #2a1300; box-shadow: 0 10px 30px rgba(255, 122, 0, 0.35); }
.help-bubble .ic { width: 24px; height: 24px; }
.chat-reopen:hover, .help-bubble:hover { transform: translateY(-2px); }
@media (min-width: 1101px) {
  body:not(.chat-closed) .help-bubble { right: calc(var(--sidebar-w) + 18px); }
  body:not(.chat-closed) .toasts { right: calc(var(--sidebar-w) + 16px); }
}

/* ===== Footer ============================================================ */
.footer { border-top: 1px solid var(--line); background: #0b0c15; padding: 40px 26px 22px; color: var(--muted); }
.footer-top { max-width: 1908px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; }
.f-brand p { margin-top: 12px; font-size: 13px; max-width: 360px; line-height: 1.6; }
.f-brand .logo-text { font-size: 21px; }
.f-brand .logo-mark { width: 25px; height: 28px; }
.f-col { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.f-col h4 { color: #fff; font-size: 17px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.f-col a:hover { color: var(--yellow); }
.footer-bottom { max-width: 1908px; margin: 26px auto 0; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted-2); }

/* ===== Responsive ======================================================== */
@media (max-width: 1100px) {
  .tb-chat-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; right: 0; top: var(--topbar-h); z-index: 70;
    transform: translateX(102%); transition: transform 0.25s var(--ease);
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.5);
  }
  body.chat-closed .sidebar { display: flex; }
  body.chat-drawer .sidebar { transform: none; }
  body.chat-closed .chat-reopen, .chat-reopen { display: none; }
  .sf-close { display: none; }
  .tb-free span:not(.tb-badge) { display: none; }
}
@media (max-width: 860px) {
  .gamenav { display: none; }
  .footer-top { grid-template-columns: 1fr 1fr; }
  .f-brand { grid-column: 1 / -1; }
  .tb-get span, .tb-race { display: none; }
  .tb-get { width: 38px; padding: 0; }
  .uc-text { display: none; }
  .logo-text { display: none; }
}
@media (max-width: 560px) {
  :root { --topbar-h: 60px; --strip-h: 84px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .tb-right { gap: 6px; }
  .tb-wallet { height: 40px; }
  .balance { font-size: 17px; gap: 6px; padding: 0 6px; }
  .bal-tag { display: none; }
  .tb-free { display: none; }
  .user-chip .ic-sm { display: none; }
  .user-chip { padding: 0 2px; }
  .page { padding: 18px 14px 48px; }
  .help-bubble { width: 46px; height: 46px; right: 12px; bottom: 12px; }
  .live-strip { padding: 5px; }
  .ls-drop { width: 84px; background-size: 50px; }
  .ls-odds { top: 5px; right: 6px; font-size: 9.5px; }
}

/* ===== Mobile bottom navigation ========================================== */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 58;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(16, 17, 29, 0.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line-2);
  }
  .mobile-nav a, .mobile-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-family: var(--display); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  }
  .mobile-nav .ic { width: 21px; height: 21px; }
  .mobile-nav .active { color: var(--yellow); }
  .mobile-nav .mn-badge { top: 6px; right: calc(50% - 22px); box-shadow: 0 0 0 2px #12131f; }
  .help-bubble { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toasts { top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .promo { min-height: 262px; }
  .promo-slide, .promo-dots { width: 86%; }
  .ps-sub { max-width: 72%; }
  .promo-slide .btn { flex-shrink: 0; }
}
