:root{
  --bg:#0b1020;
  --card:#121a33;
  --card2:#0f1730;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --border:rgba(255,255,255,.08);
  --shadow:rgba(0,0,0,.4);
  --primary:#60a5fa;
  --danger:#fb7185;

  --topbar-h: 72px;
}


*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% 0%, #1b2a5a 0%, var(--bg) 55%) fixed;
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
  position:sticky;
  top:0;
  z-index:10;
}

.brand{display:flex;align-items:center;gap:12px}
.logo{font-size:26px}
.title{font-weight:800;font-size:18px;line-height:1}
.subtitle{color:var(--muted);font-size:12px;margin-top:2px}

.promo{
  display:flex;align-items:center;gap:10px;
  text-decoration:none;
  color:var(--text);
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(255,255,255,.04);
}
.promo:hover{background:rgba(255,255,255,.06)}
.handle{font-weight:700}
.pill{
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.2);
}
.pill.live{background:rgba(239,68,68,.2); border-color:rgba(239,68,68,.55); color:#fecaca; font-weight:800}
.pill.offline{opacity:.8}

.wrap{
  display:grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap:18px;
  padding:18px;
  max-width: 1320px;
  margin:0 auto;
}

/* Desktop: keep the wheel area fixed and scroll the right-side panels */
@media (min-width: 1051px){
  .wrap{
    min-height: calc(100vh - var(--topbar-h));
    height: auto;
    overflow: visible;
    align-items: start;
  }
  .side{
    max-height: calc(100vh - var(--topbar-h) - 36px);
    overflow-y: auto;
    padding-right: 8px;
  }
}


@media (max-width: 1050px){
  .wrap{grid-template-columns: 1fr; }
  .side{order:-1}
}

.wheel-card{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border-radius:18px;
  box-shadow:0 20px 60px var(--shadow);
  padding:16px;
}

.wheel-stage{
  position:relative;
  width:min(720px, 100%);
  margin:0 auto;
}
#wheel{
  width:100%;
  height:auto;
  display:block;
  border-radius:50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.06), rgba(0,0,0,.18));
  border:1px solid var(--border);
}

.pointer{
  position:absolute;
  top:10px;
  left:50%;
  transform: translateX(-50%);
  width:0;height:0;
  border-left:16px solid transparent;
  border-right:16px solid transparent;
  border-top:28px solid #fff;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.6));
}

.controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:14px;
  align-items:center;
  justify-content:space-between;
}

.btn{
  appearance:none;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{background:rgba(255,255,255,.06)}
.btn:disabled{opacity:.45; cursor:not-allowed}

/* Used for the "Logged in with ..." banners. Keep it sized like buttons. */
.btn.status{cursor:default}

.btn.primary{
  background:rgba(96,165,250,.18);
  border-color:rgba(96,165,250,.6);
}
.btn.danger{
  background:rgba(251,113,133,.16);
  border-color:rgba(251,113,133,.65);
}


.btn.youtube{
  background: rgba(255, 0, 0, .18);
  border-color: rgba(255, 0, 0, .75);
}
.btn.youtube:hover{background: rgba(255, 0, 0, .24)}

/* Twitch variant (brighter + slightly thicker stroke like YouTube) */
.btn.twitch{
  background: rgba(168, 85, 247, .14);
  border-color: rgba(168, 85, 247, .72);
  border-width: 2px;
}
.btn.twitch:hover{background: rgba(168, 85, 247, .22)}

/* Logged in banner should match other buttons in size, but stay non-clickable */
.btn.status{
  cursor: default;
  text-align: left;
}

/* When OAuth is linked, show a positive state */
.btn.yt-linked{
  background: rgba(34, 197, 94, .16);
  border-color: rgba(34, 197, 94, .70);
}
.btn.yt-linked:hover{background: rgba(34, 197, 94, .22)}
.meta{display:flex;gap:16px;flex-wrap:wrap;color:var(--muted);font-size:13px}
.label{color:var(--text);font-weight:800;margin-right:6px}

.help{
  margin-top:14px;
  border-top:1px solid var(--border);
  padding-top:14px;
}
.help-title{font-weight:900; margin-bottom:8px}
.help ul{margin:8px 0 0 18px; color:var(--muted)}
.help code{
  background:rgba(0,0,0,.25);
  border:1px solid var(--border);
  padding:2px 6px;
  border-radius:8px;
  color:var(--text);
  font-weight:800;
}
.note{color:var(--muted); margin-top:10px}

.side{display:flex;flex-direction:column;gap:14px}
.panel{
  border:1px solid var(--border);
  background: rgba(18,26,51,.75);
  border-radius:18px;
  padding:14px;
  box-shadow:0 16px 40px var(--shadow);
}
.panel-title{font-weight:900; margin-bottom:10px}
.muted{color:var(--muted)}
.tiny{font-size:12px}
.row{display:flex;gap:10px;align-items:center;margin:10px 0}

/* Host controls grouping */
.hc-section{
  margin-top:12px;
  padding:12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
}
.hc-title{
  font-weight:900;
  font-size:12px;
  letter-spacing:.10em;
  text-transform:uppercase;
  color: rgba(255,255,255,.78);
  margin-bottom:8px;
}
.hc-section .row{flex-wrap:wrap; margin:8px 0}
.hc-wheel{background: rgba(30,58,138,.18)}
.hc-youtube{background: rgba(127,29,29,.22); border-color: rgba(239,68,68,.22)}
.hc-twitch{background: rgba(88,28,135,.18); border-color: rgba(168,85,247,.18)}

/* Make Twitch panel buttons match YouTube's stronger stroke */
.hc-twitch .btn{ border-width: 2px; }
.hc-twitch .btn.subtle{ border-color: rgba(168,85,247,.55); background: rgba(168,85,247,.08); }
.hc-images{background: rgba(0,0,0,.18)}
.hc-list{background: rgba(2,6,23,.22)}
.input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.25);
  color:var(--text);
}
.textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.25);
  color:var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  resize: vertical;
}

/*
  Utility: hide any element.
  NOTE: Some components (like .winner-overlay) are declared later with their own
  display rules. Without !important, those later rules can override .hidden when an
  element has both classes (e.g. "winner-overlay hidden"), causing overlays to show
  on initial load.
*/
.hidden{display:none !important}

/* Landing overlay (shown on / when no channel is selected) */
.landing{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.65);
  display:grid;
  place-items:center;
  z-index:50;
  padding:20px;
}

.landing-card{
  width:min(520px,100%);
  background:rgba(15,23,42,.92);
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  padding:18px;
  box-shadow:0 20px 60px rgba(0,0,0,.55);
}

.landing-title{
  font-weight:800;
  font-size:18px;
  margin-bottom:6px;
}

.landing-divider{
  height:1px;
  background:rgba(255,255,255,.10);
  margin:12px 0;
}

.kv{
  display:flex;
  justify-content:space-between;
  padding:8px 0;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.kv:last-child{border-bottom:none}
.k{color:var(--muted)}
.v{font-weight:800}

.footer{
  padding:14px 18px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
  border-top:1px solid var(--border);
  background:rgba(0,0,0,.18);
}


/* Winner popup */
.winner-overlay{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  z-index: 50;
}
.winner-card{
  width: min(520px, 92vw);
  border-radius: 18px;
  padding: 22px 22px 18px;
  background: rgba(8,12,24,.85);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 70px rgba(0,0,0,.55);
  text-align: center;
}
.winner-title{
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .85;
  font-size: 12px;
  margin-bottom: 10px;
}
.winner-name{
  font-size: 40px;
  font-weight: 900;
  line-height: 1.05;
  margin: 0 0 14px;
}
.winner-img{
  width: 120px;
  height: 120px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
  display: block;
  margin: 0 auto;
}

.winner-actions{
  display:flex;
  gap:12px;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
  margin-top:18px;
}
.winner-actions .btn{
  min-width:120px;
}

.error{
  color: #fca5a5;
  margin-top: 6px;
  line-height: 1.2;
}

.confetti{
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece{
  position: absolute;
  top: -12px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  background: rgba(255,255,255,.8);
  animation: confettiFall 1.9s ease-in forwards;
}
@keyframes confettiFall{
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* === StreamWheel header: slimmer + centered brand + By GopGang left === */
.topbar.topbar-slim{
  padding: 8px 14px;
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.topbar.topbar-slim .top-left{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  min-width: 0;
}

.topbar.topbar-slim .brand-center{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  min-width: 0;
}

.topbar.topbar-slim .brand-row{
  display:flex;
  align-items:center;
  gap:8px;
}

.topbar.topbar-slim .logo{
  font-size: 18px;
  line-height: 1;
}

.topbar.topbar-slim .title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
  line-height: 1;
}

.topbar.topbar-slim .subtitle{
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.1;
  opacity: .85;
  white-space: nowrap;
}

/* Byline (bigger, replaces old left brand) */
.byline{
  display:flex;
  align-items:center;
  gap:10px;
  color: rgba(229,231,235,.92);
  font-weight: 900;
}

.byline-icon{
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.04);
}

.byline-big .byline-icon-big{
  width:34px;
  height:34px;
  border-radius:12px;
}

.byline-big .byline-text{
  display:flex;
  flex-direction:column;
  line-height:1.05;
}

.byline-big .byline-label{
  font-size: 11px;
  opacity:.8;
  font-weight:800;
}

.byline-big .byline-name{
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: .2px;
}

/* Right side links */
.top-links{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  min-width: 0;
}

.topbtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:7px 10px;
  border-radius:999px;
  text-decoration:none;
  font-weight:900;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  white-space:nowrap;
  font-size: 12px;
}
.topbtn:hover{background:rgba(255,255,255,.06)}

/* Green Tip button */
.topbtn.tip-btn{
  background: rgba(80, 200, 120, .18);
  border-color: rgba(80, 200, 120, .35);
}
.topbtn.tip-btn:hover{ background: rgba(80, 200, 120, .24); }


/* Purple Discord button */
.topbtn.discord-btn{
  background: rgba(88, 101, 242, .22);
  border-color: rgba(88, 101, 242, .40);
}
.topbtn.discord-btn:hover{
  background: rgba(88, 101, 242, .30);
}

/* Keep promo compact so header stays slim */
.topbar.topbar-slim .promo{
  padding: 6px 10px;
}

/* Mobile: stack header */
@media (max-width: 760px){
  .topbar.topbar-slim{
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }
  .topbar.topbar-slim .top-left{ justify-content:center; }
  .topbar.topbar-slim .top-links{ justify-content:center; }
  .topbar.topbar-slim .subtitle{ white-space: normal; }

  /* Prevent handle/pill overlap on small screens */
  .topbar.topbar-slim .promo{
    width: 100%;
    justify-content: space-between;
  }
  .topbar.topbar-slim .promo .handle{
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}


/* --- Viewer Join Modal (Option 2: join via link) --- */
.sw-modal.hidden {
  display: none;
}

.sw-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.sw-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.sw-modal__card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  margin: 12vh auto 0 auto;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: rgba(14, 24, 56, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.sw-modal__title {
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 6px;
}

.sw-modal__subtitle {
  opacity: 0.85;
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.35;
}

.sw-modal__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: inherit;
  outline: none;
}

.sw-modal__input:focus {
  border-color: rgba(120, 170, 255, 0.65);
}

.sw-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.sw-modal__status {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.9;
  min-height: 18px;
}

@media (max-width: 520px) {
  .sw-modal__card {
    margin-top: 10vh;
  }
}


/* Player source badges (Twitch/YouTube) */
.player-source-list{
  margin: 8px 0 10px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.14);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow: auto;
}
.player-source-list .ps-item{
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.18);
  white-space: nowrap;
}
.player-source-list .ps-ttv{ background: rgba(180, 120, 255, .38);
  border-color: rgba(180, 120, 255, .55); }
.player-source-list .ps-yt{ background: rgba(255, 120, 120, .38);
  border-color: rgba(255, 120, 120, .55); }

.ps-item.ps-ttv{ background: rgba(180,120,255,.18); }
.ps-item.ps-yt{ background: rgba(255,120,120,.18); }

/* Site visitor count (bottom-left) */
.visitor-count {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.2px;
}

/* Winner history */
.winner-history{
  margin-top: 6px;
}
.winner-history-list{
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.winner-history-list li{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.12);
}
.wh-src{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 22px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.18);
}
.wh-ttv{ background: rgba(180, 120, 255, .28); border-color: rgba(180, 120, 255, .55); }
.wh-yt{ background: rgba(255, 120, 120, .28); border-color: rgba(255, 120, 120, .55); }
.wh-name{
  flex: 1;
  font-weight: 900;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wh-count{
  font-size: 12px;
  font-weight: 800;
  opacity: .9;
  white-space: nowrap;
}

/* Toast notifications (e.g., "<mod> spun the wheel!") */
.toast-container {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 200ms ease, transform 200ms ease;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  text-align: center;
  max-width: min(520px, calc(100vw - 24px));
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.topbtn.info-btn{
  cursor:pointer;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.08);
  color:rgba(255,255,255,.92);
}
.topbtn.info-btn:hover{background:rgba(255,255,255,.12)}

.info-overlay{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(0,0,0,.55);
  z-index:80;
}
.info-card{
  width:min(760px, 96vw);
  max-height:min(82vh, 760px);
  overflow:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(18,24,40,.96);
  box-shadow:0 18px 60px rgba(0,0,0,.45);
  padding:16px 16px 8px;
}
.info-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding-bottom:10px;
  border-bottom:1px solid rgba(255,255,255,.10);
  margin-bottom:12px;
}
.info-title{font-weight:800;font-size:18px}
.info-body h3{margin:14px 0 8px 0}
.info-body ul{margin:8px 0 12px 18px}
.info-body code{
  padding:2px 6px;
  border-radius:8px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.10);
}

/* YouTube auth buttons */
.btn.youtube-auth{
  background:rgba(255,0,0,.14);
  border-color:rgba(255,0,0,.72);
}
.btn.youtube-auth:hover{background:rgba(255,0,0,.20)}
.btn.youtube-logout{
  background:rgba(255,0,0,.10);
  border-color:rgba(255,0,0,.55);
}
.btn.youtube-logout:hover{background:rgba(255,0,0,.16)}
.btn.success{
  background:rgba(34,197,94,.16);
  border-color:rgba(34,197,94,.65);
}
.btn.success:hover{background:rgba(34,197,94,.22)}



/* --- v0.3.5: Ensure platform sections keep their color tints --- */
.section.youtube, .card.youtube, .panel.youtube, [data-platform="youtube"]{
  background: linear-gradient(180deg, rgba(255,0,0,0.14), rgba(0,0,0,0.08));
  border: 1px solid rgba(255,0,0,0.25);
}
.section.twitch, .card.twitch, .panel.twitch, [data-platform="twitch"]{
  background: linear-gradient(180deg, rgba(120,90,255,0.16), rgba(0,0,0,0.08));
  border: 1px solid rgba(120,90,255,0.25);
}


/* Keep wheel centered while scrolling (toggle) */
.wheel-stage.centered-sticky{
  position: sticky;
  top: 50vh;
  transform: translateY(-50%);
  z-index: 3;
}

@media (max-width: 900px){
  .wheel-stage.centered-sticky{
    top: 44vh;
  }
}

/* v0.4.3.17: allow main page scroll again, keep right sidebar independently scrollable */
@media (min-width: 1051px) {
  /* Keep normal document scrolling */
  html, body { overflow-y: auto; }

  /* Right sidebar: sticky within viewport and scroll its own contents */
  aside.side {
    position: sticky;
    top: 16px; /* below topbar padding */
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
