:root {
  --bg: #0d1117;
  --panel: #161b27;
  --panel2: #1d2435;
  --line: #2a3348;
  --text: #e8edf6;
  --dim: #8b96ad;
  --accent: #f5b429;      /* auction gold */
  --green: #3fb96b;
  --red: #e05555;
  --blue: #4d8fe8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #201700; font-weight: 700;
  padding: 12px 18px;
}
button:disabled { opacity: .35; cursor: default; }
button.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--red); color: #fff; }
input, select {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  width: 100%;
}
.loading { display: grid; place-items: center; height: 100vh; color: var(--dim); }

/* ------------------------------------------------ mobile shell */
.shell { max-width: 480px; margin: 0 auto; padding: 16px; min-height: 100vh;
         display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 26px; letter-spacing: .5px; }
h1 .gold { color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row .grow { flex: 1; }
.muted { color: var(--dim); font-size: 13px; }
.small { font-size: 13px; }
.err { color: var(--red); font-size: 14px; min-height: 18px; }
label { font-size: 13px; color: var(--dim); display: block; margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details.adv summary { color: var(--dim); cursor: pointer; font-size: 14px; margin: 4px 0; }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text);
              margin: 0; cursor: pointer; }
label.check input { width: auto; margin-top: 3px; }

/* ------------------------------------------------ draft wheel */
.wheelwrap { width: 100%; max-width: 340px; margin: 10px auto 4px; }
.wheelsvg { width: 100%; height: auto; display: block;
            filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
#wheelspin { transform-origin: 50% 50%;
             transition: transform 3.6s cubic-bezier(.18,.75,.15,1); }
.draftbanner { font-size: 22px; font-weight: 800; color: var(--accent); margin-top: 6px;
               min-height: 28px; }
.plist .p.turn { background: rgba(245,180,41,.08); border-radius: 8px; }
.scr-wallets .w.turn b, .scr-wallets .w.turn { color: var(--accent); }
.wheelwrap.big { max-width: none; width: 46vh; margin: 1vh auto; }

/* Captain (2x) */
.cbadge {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent); color: #201700;
  font-size: 11px; font-weight: 800; vertical-align: middle;
}
.plist .p.iscap { background: rgba(245,180,41,.10); border-radius: 8px; }
.plist .p[role=button] { cursor: pointer; }
.plist .p[role=button]:active { background: rgba(245,180,41,.16); }
.capset { color: var(--accent); }
.score .x2 { color: var(--accent); font-size: 12px; font-weight: 800; margin-left: 3px; }
.scr-cap { font-size: 1.9vh; color: var(--accent); font-weight: 600; margin-top: .3vh; }
.scr-cap .cbadge { width: 2.2vh; height: 2.2vh; font-size: 1.3vh; }

/* ------------------------------------------------ lobby */
.code-big { font-size: 44px; font-weight: 800; letter-spacing: 10px; color: var(--accent); text-align: center; }
.member { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.tag { font-size: 11px; background: var(--panel2); border: 1px solid var(--line);
       padding: 2px 8px; border-radius: 20px; color: var(--dim); }
.tag.host { color: var(--accent); border-color: var(--accent); }
.tag.warn { color: var(--red); border-color: var(--red); vertical-align: middle;
            font-weight: 700; letter-spacing: .5px; }
code { background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
       padding: 1px 5px; font-size: 12px; }

/* ------------------------------------------------ auction (mobile) */
.walletbar { display: flex; justify-content: space-between; align-items: baseline; }
.walletbar .bal { font-size: 24px; font-weight: 800; color: var(--green); }
.pot { color: var(--accent); font-weight: 700; }
.lotcard { text-align: center; position: relative; overflow: hidden; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--panel2);
  border: 2px solid var(--line); display: inline-grid; place-items: center;
  font-size: 22px; font-weight: 800; color: var(--accent); margin-bottom: 6px;
  position: relative; overflow: hidden; vertical-align: middle;
  /* Never let a flex parent distort the circle: hold a square and don't flex. */
  aspect-ratio: 1 / 1; flex: 0 0 auto;
}
/* Initials sit underneath; the headshot (if it loads) covers them. */
.avatar::after { content: attr(data-i); }
.avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: var(--panel2);
}
.avatar.thumb {
  width: 38px; height: 38px; font-size: 13px; border-width: 1px;
  margin-bottom: 0; flex: 0 0 auto;
}
/* Participants (humans) get a faint gold ring to distinguish them from
   NRL player headshots. */
.avatar.user { border-color: rgba(245,180,41,.55); }
.avatar.inline {
  width: 20px; height: 20px; font-size: 9px; border-width: 1px;
  margin: 0 4px -5px 2px; display: inline-grid;
}
/* Big-screen participant avatar. NB: the size class must NOT be "scr" — that
   token collides with the big-screen container `.scr` and inherits its flex
   layout, stretching the avatar. Kept higher-specificity than the `.scr .avatar`
   lot-card rule (14vh) below. */
.scr .avatar.uscr, .avatar.uscr {
  width: 4.6vh; height: 4.6vh; font-size: 1.7vh; margin-bottom: 0;
  border-width: .25vh; flex: 0 0 auto; }
.scr .avatar.uscr-inline, .avatar.uscr-inline {
  width: 3.4vh; height: 3.4vh; font-size: 1.3vh; border-width: .2vh;
  margin: 0 .5vw -0.7vh .3vw; display: inline-grid; }
.photorow { align-items: center; }
.photorow input[type=file] { padding: 8px; font-size: 12px; margin-top: 3px; }
.member { gap: 10px; align-items: center; }
.member .grow { flex: 1; }
.pname { font-size: 22px; font-weight: 800; }
.pmeta { color: var(--dim); font-size: 14px; margin-top: 2px; }
.statrow { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }
.stat { text-align: center; }
.stat .v { font-size: 18px; font-weight: 700; }
.stat .k { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }
.timerwrap { height: 8px; background: var(--panel2); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.timerbar { height: 100%; background: var(--green); border-radius: 4px; transition: width .2s linear; }
.timerbar.low { background: var(--red); }
.tstate { margin-top: 6px; font-size: 13px; color: var(--dim); min-height: 17px; }
.going { color: var(--accent); font-weight: 800; animation: pulse .6s infinite alternate; }
@keyframes pulse { from { opacity: .5; } to { opacity: 1; } }
.highbid { margin-top: 10px; font-size: 16px; }
.highbid b { color: var(--accent); }
.ownerline { font-size: 13px; color: var(--dim); margin-top: 4px; }
.bidbtns { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.bidbtns .big { font-size: 20px; padding: 16px; }
.custom { display: flex; gap: 8px; }
.hist { max-height: 110px; overflow-y: auto; font-size: 13px; color: var(--dim); }
.hist div { padding: 3px 0; border-bottom: 1px dashed var(--line); }

/* squads / team list */
.plist .p { display: flex; gap: 10px; justify-content: space-between; align-items: center;
            padding: 9px 4px; border-bottom: 1px solid var(--line); }
.plist .p:last-child { border-bottom: 0; }
.p .nm { font-weight: 600; }
.p .sub { font-size: 12px; color: var(--dim); }
.p .avg { font-weight: 700; color: var(--blue); }
.p .score { font-weight: 800; font-size: 18px; }
.p .dnp { color: var(--red); font-size: 12px; font-weight: 700; }

/* trade modal */
.modal-back { position: fixed; inset: 0; background: rgba(5,8,14,.82); display: grid;
              place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; }
.pick { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; gap: 10px;
        display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; cursor: pointer; }
.pick.sel { border-color: var(--accent); background: rgba(245,180,41,.08); }

/* host controls */
.hostbar { display: flex; flex-wrap: wrap; gap: 8px; }
.hostbar button { padding: 9px 12px; font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; background: var(--panel2); color: var(--dim); border: 1px solid var(--line); }
.tabs button.on { background: var(--accent); color: #201700; }

/* leaderboard */
.lb .r { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.lb .rank { width: 30px; font-size: 20px; font-weight: 800; color: var(--dim); }
.lb .r.first .rank, .lb .r.first .tot { color: var(--accent); }
.lb .tot { margin-left: auto; font-size: 22px; font-weight: 800; }
.chip { font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 3px 10px; border-radius: 20px; }
.chip.LIVE { background: var(--red); color: #fff; animation: pulse 1s infinite alternate; }
.chip.PROVISIONAL { background: var(--accent); color: #201700; }
.chip.FINAL { background: var(--green); color: #fff; }
.chip.UPCOMING { background: var(--panel2); color: var(--dim); border: 1px solid var(--line); }

/* ------------------------------------------------ big screen view (FR-42) */
body.screen { overflow: hidden; }
.scr { display: flex; flex-direction: column; height: 100vh; padding: 3vh 4vw; gap: 2vh; }
.scr header { display: flex; justify-content: space-between; align-items: baseline; }
.scr header .ttl { font-size: 3.4vh; font-weight: 800; letter-spacing: 1px; }
.scr header .pot { font-size: 4.2vh; }
.scr header .code { font-size: 2.6vh; color: var(--dim); letter-spacing: 4px; }
.scr-main { flex: 1; display: flex; gap: 3vw; min-height: 0; }
.scr-lot { flex: 3; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.scr-side { flex: 1.2; display: flex; flex-direction: column; gap: 2vh; min-width: 26vw; }
.scr .avatar { width: 14vh; height: 14vh; font-size: 5vh; }
.scr .pname { font-size: 7vh; }
.scr .pmeta { font-size: 2.6vh; }
.scr .statrow { gap: 4vw; margin-top: 2vh; }
.scr .stat .v { font-size: 4.5vh; }
.scr .stat .k { font-size: 1.7vh; }
.scr .highbid { font-size: 4vh; margin-top: 2.5vh; }
.scr .ownerline { font-size: 2.4vh; }
.scr .timerwrap { height: 2.2vh; margin-top: 3vh; }
.scr .tstate { font-size: 3.4vh; min-height: 4vh; margin-top: 1.2vh; }
.scr .panelh { font-size: 1.9vh; color: var(--dim); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 1vh; }
.scr-wallets .w { display: flex; justify-content: space-between; font-size: 2.5vh; padding: .7vh 0; }
.scr-wallets .w b { color: var(--green); }
.scr-hist { flex: 1; overflow: hidden; font-size: 2.2vh; color: var(--dim); }
.scr-hist div { padding: .5vh 0; }
.scr-results div { font-size: 2vh; color: var(--dim); padding: .4vh 0; }
.scr .lb .r { padding: 1.6vh 1vw; }
.scr .lb .rank { font-size: 4vh; width: 6vw; }
.scr .lb .nm { font-size: 3.4vh; font-weight: 700; }
.scr .lb .tot { font-size: 4.6vh; }
.scr .code-big { font-size: 12vh; letter-spacing: 3vh; }
.scr .qr { background: #fff; border-radius: 2vh; padding: 2vh; width: 34vh; height: 34vh; }
.scr .qr svg, .scr .qr img { width: 100%; height: 100%; }
.scr-lobby { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6vw; }
.scr-lobby .members { font-size: 3.2vh; line-height: 1.9; }
.flash {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 99;
  font-size: 11vh; font-weight: 900; letter-spacing: 1vh; pointer-events: none;
  animation: flashin 2.6s ease forwards; text-align: center;
}
@keyframes flashin { 0% { opacity: 0; transform: scale(.7); } 12% { opacity: 1; transform: scale(1.02); }
                     80% { opacity: 1; } 100% { opacity: 0; } }
.flash.protect { color: var(--accent); background: rgba(245,180,41,.14); }
.flash.sold { color: var(--green); background: rgba(63,185,107,.12); }
.flash.passed { color: var(--dim); background: rgba(13,17,23,.5); }
.flash .sub { font-size: 3.4vh; font-weight: 600; letter-spacing: .3vh; color: var(--text); margin-top: 2vh; }
