:root {
  --bg: #0b0c0f; --bg2: #121419; --bg3: #1a1d24; --line: #262a33;
  --text: #eef0f4; --muted: #8b92a1; --accent: #ff5a1f; --accent2: #ffb020;
  --good: #3ddc84; --bad: #ff4d6d; --discord: #5865f2;
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(11,12,15,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 900; letter-spacing: .08em; font-size: 18px; }
.brand-sub { color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--bad); box-shadow: 0 0 0 0 rgba(255,77,109,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(255,77,109,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,109,0); } }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.pill.points { border-color: rgba(255,176,32,.4); color: var(--accent2); }
.btn { border: 1px solid var(--line); background: var(--bg3); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.btn:hover { border-color: #3a404c; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.big { font-size: 17px; padding: 12px 20px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.menu { position: relative; }
.menu-pop { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.menu.open .menu-pop { display: grid; }
.menu-pop button, .menu-pop a { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; text-decoration: none; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--bg3); }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 16px; max-width: 1800px; margin: 0 auto;
  height: calc(100dvh - 57px); }
.stage { overflow-y: auto; min-width: 0; }
.side { display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; overflow: hidden; }

.player-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
video { width: 100%; height: 100%; display: block; background: #000; }
.player-overlay { position: absolute; inset: auto 0 16px 0; display: flex; justify-content: center; pointer-events: none; }
.player-overlay button { pointer-events: auto; }
.offline-badge { position: absolute; left: 12px; top: 12px; background: rgba(0,0,0,.7); padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }

.stream-meta { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 14px 2px; flex-wrap: wrap; }
.stream-meta h1 { display: inline; font-size: 20px; margin: 0; }
.live-tag { background: var(--bad); color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .1em; padding: 3px 7px; border-radius: 5px; margin-right: 8px; vertical-align: 3px; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.goal { min-width: 260px; flex: 0 1 360px; }
.goal-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.goal-head span:first-child { color: var(--text); font-weight: 600; }
.bar { height: 10px; background: var(--bg3); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* Ads: quiet, clearly labeled, never cover content */
.ad { position: relative; display: flex; gap: 12px; align-items: center; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; text-decoration: none; }
.ad::before { content: 'Sponsored'; position: absolute; top: 6px; right: 10px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ad img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.ad b { display: block; }
.ad small { color: var(--muted); }
.ad-below { margin-bottom: 14px; }
.ad-side { margin: 10px 10px 0; padding: 8px 10px; }
.ad-side img { width: 40px; height: 40px; }

.challenges { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.challenges h2 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent2); }
.challenges ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.challenges li { background: var(--bg3); border-radius: 8px; padding: 8px 10px; }
.challenges li small { color: var(--muted); }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 12px 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.panel.active { display: flex; flex-direction: column; }
#tab-chat.panel { padding: 0; }

/* Chat */
.chat { list-style: none; margin: 0; padding: 10px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.chat li { line-height: 1.4; word-wrap: break-word; padding: 3px 6px; border-radius: 6px; position: relative; }
.chat li:hover { background: var(--bg3); }
.chat .name { font-weight: 700; margin-right: 6px; }
.chat .badge { display: inline-block; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.badge.discord { background: var(--discord); color: #fff; }
.badge.mod { background: var(--good); color: #062; }
.badge.admin { background: var(--accent); color: #fff; }
.chat .del { display: none; position: absolute; right: 4px; top: 2px; font-size: 11px; background: var(--bad); border: 0; color: #fff; border-radius: 4px; padding: 1px 6px; }
.chat li:hover .del { display: block; }
.chat .sys { color: var(--accent2); font-size: 13px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; }
input, textarea, select { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; width: 100%; }
input:focus, textarea:focus { outline: 2px solid rgba(255,90,31,.5); border-color: transparent; }

/* Rewards */
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.rewards { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.reward { background: var(--bg3); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.reward-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reward-head b { font-size: 15px; }
.cost { color: var(--accent2); font-weight: 700; white-space: nowrap; }
.reward p { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }
.reward form { display: grid; gap: 8px; }

/* Donate */
.donate { display: grid; gap: 10px; }
.donate label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.donate .check { display: flex; gap: 8px; align-items: center; }
.donate .check input { width: auto; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 8px 0; border-radius: 8px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--bg3); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--bg3); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.chips button.on { border-color: var(--accent); color: var(--accent); }
.merch { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.merch h3 { margin: 0 0 8px; }
.product { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; background: var(--bg3); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.product img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.product .row { display: flex; gap: 6px; margin-top: 6px; }

/* Top */
.panel h3 { margin: 4px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.board { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: r; }
.board li { counter-increment: r; display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; }
.board li:nth-child(odd) { background: var(--bg3); }
.board li::before { content: counter(r); width: 24px; color: var(--muted); font-weight: 700; }
.board li span:first-of-type { flex: 1; }
.big-num { font-size: 26px; font-weight: 800; color: var(--accent2); margin: 0 0 10px; }
.big-num small { font-size: 12px; color: var(--muted); font-weight: 500; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.history .plus { color: var(--good); } .history .minus { color: var(--bad); }

/* Dialog + toasts */
dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
.code { font: 800 32px/1 ui-monospace, monospace; letter-spacing: .2em; text-align: center; padding: 14px; background: var(--bg); border-radius: 10px; margin: 10px 0; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--bg3); border: 1px solid var(--line); border-left: 4px solid var(--accent2); padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toastIn .3s ease-out; }
.toast.err { border-left-color: var(--bad); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* Mobile: video on top, sidebar fills the rest */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 0; gap: 0; }
  .stage { overflow: visible; }
  .player-wrap { border-radius: 0; position: sticky; top: 57px; z-index: 5; }
  .stream-meta, .challenges, .ad-below { margin-left: 12px; margin-right: 12px; }
  .side { border-radius: 0; border-left: 0; border-right: 0; height: 70dvh; }
  .goal { flex-basis: 100%; }
  .pill.viewers { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.btn.cashapp { background: #00d64f; border-color: #00d64f; color: #04220f; }
.steps { padding-left: 20px; } .steps li { margin: 6px 0; }
