:root {
  color-scheme: dark;
  --bg: #212428;
  --panel: #2a2e33;
  --panel-soft: #30353b;
  --line: rgba(255, 255, 255, .1);
  --text: #fff;
  --muted: rgba(255, 255, 255, .66);
  --blue: #00bcff;
  --blue-dark: #008fd1;
  --danger: #ff5173;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 80% 0%, rgba(0, 188, 255, .16), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
main, .persistent-stream { width: min(1480px, calc(100% - 40px)); margin: 0 auto; }
main { padding: 28px 0 56px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; justify-content: space-between;
  padding: 12px max(20px, calc((100vw - 1480px) / 2));
  background: rgba(33, 36, 40, .9); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.brand, nav, .account, .card-actions, .row, .section-title { display: flex; align-items: center; gap: 14px; }
.brand img, .account img { width: 36px; height: 36px; object-fit: contain; }
.account img { border-radius: 50%; object-fit: cover; }
.brand span { font-size: 20px; font-weight: 900; letter-spacing: 0; }
.menu-toggle { display: none; }
nav { flex: 1; }
nav a, .account a { color: var(--muted); font-weight: 700; font-size: 14px; }
nav a:hover, .account a:hover { color: var(--blue); }
body[data-page="home"] nav a[data-nav="home"],
body[data-page="shop"] nav a[data-nav="shop"],
body[data-page="messages"] nav a[data-nav="messages"],
body[data-page="admin"] nav a[data-nav="admin"] { color: var(--blue); }
.mobile-logout-link { display: none; }
.account strong { color: var(--blue); }
.account span { color: var(--muted); }
.logout-link {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: rgba(255, 81, 115, .12); border: 1px solid rgba(255, 81, 115, .35);
}
.logout-link svg { width: 20px; height: 20px; fill: var(--danger); }
.logout-link:hover { background: rgba(255, 81, 115, .22); border-color: var(--danger); }

.login-panel {
  width: min(460px, 100%);
  margin: 8vh auto;
  padding: 34px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.login-panel img { width: 92px; height: 92px; }
.login-benefits {
  display: grid; gap: 8px; margin: 0 0 28px; padding: 0; list-style: none; text-align: left;
}
.login-benefits li {
  position: relative; padding-left: 18px; color: #fff; font-weight: 700;
}
.login-benefits li::before {
  content: ""; position: absolute; left: 0; top: .65em; width: 7px; height: 7px;
  border-radius: 50%; background: var(--blue);
}
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(34px, 6vw, 64px); line-height: 1; letter-spacing: 0; }
h2 { font-size: 20px; }
p, small, .notice, .empty { color: var(--muted); }
.notice { padding: 12px; border: 1px solid rgba(0,188,255,.35); border-radius: 8px; margin-bottom: 16px; }
.button, button {
  border: 0; border-radius: 6px; padding: 10px 14px; cursor: pointer;
  color: #fff; background: var(--panel-soft); font-weight: 900;
}
.button.primary, button.primary { background: var(--blue); color: #04151d; }
.button.primary:hover, button.primary:hover { background: #40ccff; }
.twitch-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: #9146ff; color: #fff; padding: 12px 18px;
}
.twitch-button:hover { background: #7f35ee; }
.twitch-button svg { width: 22px; height: 22px; fill: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
.danger { background: rgba(255,81,115,.16); color: var(--danger); }

.persistent-stream { display: none; padding-top: 24px; }
body[data-page="home"] .persistent-stream,
body[data-page="shop"] .persistent-stream,
body[data-page="messages"] .persistent-stream { display: block; }
body[data-page="home"] .persistent-stream {
  position: sticky;
  top: 62px;
  z-index: 4;
  background: rgba(33, 36, 40, .96);
  backdrop-filter: blur(14px);
}
body.stream-compact[data-page="home"] .persistent-stream {
  position: fixed;
  top: auto;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  width: min(420px, calc(100vw - 36px));
  margin: 0;
  padding-top: 10px;
  background: transparent;
  backdrop-filter: none;
}
body.stream-compact[data-page="home"] .stream-zone {
  display: block;
  padding: 0;
  border: 1px solid rgba(0, 188, 255, .35);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .45);
}
body.stream-compact[data-page="home"] .stream-left {
  display: block;
  height: auto;
}
body.stream-compact[data-page="home"] .stream-player {
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0;
}
body.stream-compact[data-page="home"] .stream-chat,
body.stream-compact[data-page="home"] .stream-balance {
  display: none;
}
body[data-page="admin"] .persistent-stream,
body[data-page="login"] .persistent-stream { display: none; }
.stream-zone { display: grid; grid-template-columns: minmax(0, 1fr) 390px; align-items: start; gap: 18px; padding: 0 0 8px; }
.stream-left { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; height: 680px; min-width: 0; }
.stream-player, .stream-chat { position: relative; background: #111418; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; height: 680px; }
.stream-player { height: 100%; min-height: 0; }
.stream-player iframe, .stream-chat iframe { display: block; width: 100%; height: 100%; border: 0; }
.stream-balance {
  justify-self: start; display: flex; align-items: center; gap: 8px;
  max-width: 100%; padding: 10px 14px; border-radius: 8px;
  background: #2a2e33;
  color: var(--muted); font-size: 15px; font-weight: 800;
}
.stream-balance b { color: #fff; font-size: 1em; line-height: inherit; }
.coin-stack {
  position: relative; display: inline-block; flex: 0 0 18px; width: 18px; height: 16px;
}
.coin-stack i {
  position: absolute; left: 1px; width: 16px; height: 7px; border-radius: 50%;
  background: linear-gradient(180deg, #ffe27a, #f3aa25);
  box-shadow: inset 0 -1px 0 rgba(120, 72, 0, .35);
}
.coin-stack i:nth-child(1) { bottom: 0; }
.coin-stack i:nth-child(2) { bottom: 4px; }
.coin-stack i:nth-child(3) { bottom: 8px; }
.coin-stack i::after {
  content: ""; position: absolute; inset: 1px 3px auto; height: 2px; border-radius: 50%;
  background: rgba(255, 255, 255, .45);
}
.separator { color: rgba(255,255,255,.28); }
.eyebrow, .section-title span { color: var(--blue); font-weight: 900; text-transform: uppercase; font-size: 12px; }
.event-title { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.event-logo { width: 1em; height: 1em; object-fit: contain; flex: 0 0 1em; }
.event-link {
  display: inline-grid; place-items: center; width: 1.35em; height: 1.35em; border-radius: 4px;
  color: var(--blue); background: rgba(0, 188, 255, .12); text-decoration: none;
}
.event-link svg { width: .95em; height: .95em; fill: currentColor; }
.event-link:hover { background: rgba(0, 188, 255, .22); }
.hero aside, .panel, .card, .match-card, .leaderboard-item {
  background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 8px;
}
.hero aside { padding: 22px; display: grid; gap: 4px; }
.hero aside strong { color: var(--blue); font-size: 48px; line-height: 1; }
.grid.two { display: grid; grid-template-columns: 1.5fr .8fr; gap: 22px; margin-top: 26px; }
.section-title { justify-content: space-between; margin: 10px 0 16px; }
.section-title h1, .section-title h2 { margin: 0; }
.match-list, .leaderboard, .cards { display: grid; gap: 14px; }
.match-card { padding: 16px; display: grid; gap: 14px; }
.match-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.versus { display: grid; grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr); align-items: stretch; gap: 12px; }
.team-pick {
  display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 12px;
  width: 100%; min-height: 92px; padding: 10px; text-align: left;
  background: rgba(255, 255, 255, .025); border: 1px solid transparent; border-radius: 8px;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.team-pick:hover:not(:disabled) { background: rgba(0, 188, 255, .11); border-color: rgba(0, 188, 255, .42); transform: translateY(-1px); }
.team-pick.selected { background: rgba(0, 188, 255, .16); border-color: var(--blue); box-shadow: inset 0 0 0 1px rgba(0, 188, 255, .4); }
.team-pick.won { background: rgba(65, 214, 132, .17); border-color: #41d684; }
.team-pick.lost { background: rgba(255, 81, 115, .13); border-color: var(--danger); }
.team-pick:disabled { cursor: default; opacity: 1; }
.team-logo-box {
  display: flex; align-items: center; justify-content: center;
  width: 78px; height: 72px; min-width: 78px; max-width: 78px;
  padding: 6px;
  background: rgba(0, 0, 0, .18); border-radius: 8px; overflow: hidden;
}
.team-logo-box img {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
}
.team-copy { display: grid; gap: 3px; min-width: 0; }
.team-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-item img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; background: var(--panel); }
.tag { color: var(--blue); font-weight: 900; }
.vote-share {
  position: relative; display: block; width: min(180px, 100%); height: 18px;
  overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08);
}
.vote-share span {
  position: absolute; inset: 0 auto 0 0; background: rgba(0, 188, 255, .48);
}
.vote-share b {
  position: relative; z-index: 1; display: block; padding: 0 7px;
  color: #fff; font-size: 12px; line-height: 18px; font-weight: 900;
}
.vs { display: grid; place-items: center; color: var(--muted); font-weight: 900; min-height: 92px; }
.bet-result { width: max-content; padding: 3px 7px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.bet-result.won { color: #062113; background: #41d684; }
.bet-result.lost { color: #fff; background: var(--danger); }
.supporters { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.supporters img, .supporter-fallback {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25);
}
.supporters img { object-fit: cover; }
.supporter-fallback {
  display: inline-grid; place-items: center; background: rgba(0, 188, 255, .18);
  color: #fff; font-size: 11px; font-weight: 900;
}
.status { color: var(--muted); font-size: 13px; font-weight: 900; }
.leaderboard-item { padding: 12px; display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; }
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { padding: 16px; }
.product > img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 6px; background: var(--panel); margin-bottom: 12px; }
.card-actions { justify-content: space-between; margin-top: 18px; }

.messages { max-width: 820px; margin: 0 auto; }
.thread { display: grid; gap: 12px; margin-bottom: 18px; }
.bubble { max-width: 76%; padding: 12px 14px; border-radius: 8px; background: var(--panel); }
.bubble.user { justify-self: end; background: rgba(0,188,255,.15); border: 1px solid rgba(0,188,255,.25); }
.bubble p { margin-bottom: 6px; color: #fff; }
.reply { display: grid; gap: 10px; }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.admin-tabs a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 8px; background: var(--panel); color: var(--muted); font-weight: 900;
}
.admin-tabs a.active, .admin-tabs a:hover { background: rgba(0, 188, 255, .14); color: var(--blue); }
.panel { padding: 16px; margin-bottom: 16px; }
.panel form, .panel { min-width: 0; }
.wide { width: 100%; overflow-x: auto; }
input, select, textarea {
  width: 100%; margin-bottom: 10px; padding: 11px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: #1b1e22; color: #fff;
}
textarea { resize: vertical; min-height: 88px; }
.row { justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.row span { min-width: 220px; }
.row form { display: flex; gap: 8px; align-items: center; margin: 0; }
.row select { margin: 0; min-width: 160px; }
.inline-form { display: grid; grid-template-columns: 220px 1fr auto; gap: 10px; align-items: start; }
.edit-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) 120px;
  gap: 10px;
  align-items: start;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.product-edit { grid-template-columns: repeat(3, minmax(140px, 1fr)) 110px 110px; }
.edit-row input, .edit-row select, .edit-row textarea { margin-bottom: 0; }
.mini-delete { margin: 8px 0 14px; }
.admin-list-panel { display: grid; gap: 10px; overflow: visible; }
.admin-list-head {
  display: grid; grid-template-columns: 1fr minmax(220px, 360px); gap: 12px; align-items: center;
}
.admin-list-head h2 { margin: 0; }
.admin-list-head input { margin: 0; }
.admin-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: start;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.admin-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.admin-row-main img {
  width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: rgba(0,0,0,.18); padding: 4px;
}
.admin-row-main strong { min-width: 180px; }
.admin-row-main p { flex-basis: 100%; margin: 0; color: var(--text); }
.badge {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px;
  background: rgba(0, 188, 255, .14); color: var(--blue); font-size: 12px; font-weight: 900;
}
.admin-row details { min-width: 100px; position: static; }
.admin-row summary { cursor: pointer; color: var(--blue); font-weight: 900; }
.admin-row details[open] {
  grid-column: 1 / -1;
  order: 5;
  width: 100%;
  padding-top: 10px;
}
.admin-row details[open] summary { margin-bottom: 10px; }
.admin-row details[open] .edit-row {
  width: 100%;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .12);
}
.admin-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.admin-pagination span { color: var(--muted); font-weight: 800; }
.toast {
  position: fixed; right: 18px; bottom: 18px; transform: translateY(20px); opacity: 0;
  background: #111418; color: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
  transition: .2s ease; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .brand span { display: none; }
  .menu-toggle {
    display: grid; gap: 4px; place-content: center;
    width: 40px; height: 40px; padding: 0; margin-left: auto;
    background: rgba(255,255,255,.06); border: 1px solid var(--line);
  }
  .menu-toggle span { display: block; width: 18px; height: 2px; border-radius: 999px; background: #fff; }
  nav {
    order: 4; display: none; flex: 0 0 100%; width: 100%; flex-direction: column; align-items: stretch; gap: 4px;
    padding-top: 10px; border-top: 1px solid var(--line);
  }
  .mobile-logout-link { display: block; color: var(--danger); }
  body.menu-open nav { display: flex; }
  nav a { display: block; width: 100%; padding: 10px 0; }
  .account { order: 2; width: auto; margin-left: auto; justify-content: flex-end; }
  .account .logout-link { display: none; }
  .account strong { font-size: 16px; }
  .account span { font-size: 13px; }
  .menu-toggle { order: 3; margin-left: 0; }
  .persistent-stream {
    position: sticky;
    top: 92px;
    z-index: 4;
    padding-top: 10px;
    padding-bottom: 8px;
    background: rgba(33, 36, 40, .96);
    backdrop-filter: blur(14px);
  }
  body.stream-compact[data-page="home"] .persistent-stream {
    width: min(260px, calc(100vw - 28px));
    right: 14px;
    bottom: 14px;
  }
  .stream-zone, .hero, .grid.two, .admin-grid { grid-template-columns: 1fr; }
  .stream-left { height: auto; }
  .stream-player { height: auto; aspect-ratio: 16 / 9; }
  .stream-chat { display: none; }
  .stream-balance { flex-wrap: wrap; }
  .versus { grid-template-columns: 1fr; }
  .vs { min-height: 28px; }
  .match-head, .row, .inline-form, .edit-row, .product-edit, .admin-list-head, .admin-row { align-items: stretch; flex-direction: column; grid-template-columns: 1fr; }
  .admin-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-row-main strong { min-width: 0; }
  .admin-pagination { justify-content: stretch; }
  .admin-pagination button { flex: 1; }
  .bubble { max-width: 92%; }
}
