:root {
  color-scheme: dark;
  --ink: #fbf9ff;
  --muted: #b8b7d4;
  --night: #0b0920;
  --panel: #15122d;
  --panel-2: #1c1839;
  --line: rgba(174, 175, 235, .18);
  --lavender: #b49aff;
  --purple: #786cff;
  --blue: #69c7ff;
  --wine: #9c3d6b;
  --pink: #ff8fbb;
  --orange: #f59a4a;
  --green: #63dfbd;
  --red: #ff719d;
  --radius: 24px;
  font-family: "Nunito", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--night); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 7%, rgba(120, 108, 255, .23), transparent 28%),
    radial-gradient(circle at 5% 72%, rgba(156, 61, 107, .2), transparent 29%),
    radial-gradient(circle at 55% 105%, rgba(105, 199, 255, .1), transparent 33%),
    var(--night);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image: radial-gradient(rgba(255,255,255,.14) .7px, transparent .7px);
  background-size: 25px 25px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}
::selection { background: var(--pink); color: var(--night); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.topbar { width: min(1400px, calc(100% - 48px)); min-height: 92px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; font-family: "Fredoka", sans-serif; font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.brand b { color: var(--pink); font-weight: inherit; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 18px 18px 12px 18px; color: var(--night); background: linear-gradient(145deg, var(--blue), var(--lavender)); transform: rotate(-3deg); box-shadow: 0 8px 16px rgba(0,0,0,.2); }
.brand-mark img { width: 39px; height: 39px; }
.account { display: flex; align-items: center; gap: 10px; padding: 7px 7px 7px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(21,18,45,.72); font-size: .86rem; font-weight: 800; backdrop-filter: blur(14px); }
.signal { width: 9px; height: 9px; border-radius: 50%; background: var(--wine); }
.signal.online { background: var(--green); }
.connect { padding: 10px 15px; border-radius: 999px; color: var(--ink); background: rgba(120,108,255,.18); text-decoration: none; transition: background .2s ease, transform .2s ease; }
.connect:hover { background: rgba(120,108,255,.3); transform: translateY(-1px); }

main { width: min(1400px, calc(100% - 48px)); margin: 0 auto 34px; display: grid; grid-template-columns: minmax(430px, .86fr) minmax(560px, 1.14fr); overflow: hidden; border: 1px solid var(--line); border-radius: 34px; background: rgba(14, 12, 35, .72); box-shadow: 0 28px 70px rgba(0,0,0,.3); backdrop-filter: blur(20px); }
.setup { padding: 54px; border-right: 1px solid var(--line); }
.section-heading h1, .stage-head h2 { margin: 0; font-family: "Fredoka", sans-serif; font-weight: 700; letter-spacing: -.04em; }
.section-heading h1 { max-width: 9ch; font-size: clamp(2.8rem, 4.5vw, 5.1rem); line-height: .91; color: #f8f3ff; }
.section-heading p, .stage-head p, .rules p, .field-help, .empty-state p { color: var(--muted); line-height: 1.6; }
.section-heading p { margin: 20px 0 40px; max-width: 45ch; font-size: 1rem; }

.source-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 22px; padding: 0; border: 0; }
.source-picker legend { grid-column: 1 / -1; margin-bottom: 10px; color: var(--ink); font-size: .88rem; font-weight: 900; }
.source-picker label { position: relative; }
.source-picker input { position: absolute; opacity: 0; pointer-events: none; }
.source-picker span { min-height: 78px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(21,18,45,.56); cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.source-picker span:hover { border-color: rgba(180,154,255,.48); transform: translateY(-1px); }
.source-picker b { font-size: .87rem; }
.source-picker small { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.source-picker input:checked + span { border-color: rgba(105,199,255,.72); background: linear-gradient(145deg, rgba(105,199,255,.17), rgba(120,108,255,.15)); }
.source-picker input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }
.official-connect { margin: -8px 0 22px; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid rgba(105,199,255,.25); border-radius: 15px; background: rgba(105,199,255,.08); }
.official-connect div { min-width: 0; }
.official-connect strong, .official-connect small { display: block; }
.official-connect strong { font-size: .84rem; }
.official-connect small { margin-top: 3px; color: #c5c3df; font-size: .8rem; line-height: 1.4; }
.official-connect.connected { border-color: rgba(99,223,189,.32); background: rgba(99,223,189,.08); }
.official-connect.connected .connect { color: #b8f8e6; background: rgba(99,223,189,.13); pointer-events: none; }

.post-form > label, .positions legend { display: block; margin-bottom: 10px; color: var(--ink); font-size: .88rem; font-weight: 900; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
input[type="url"] { width: 100%; min-height: 56px; padding: 0 17px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: rgba(28,24,57,.84); caret-color: var(--pink); transition: border-color .2s ease, background .2s ease; }
input[type="url"]::placeholder { color: #777995; }
input[type="url"]:hover, input[type="url"]:focus { border-color: rgba(105,199,255,.55); background: rgba(31,27,65,.96); }
.url-row button, .draw { border: 0; border-radius: 16px; font-weight: 900; cursor: pointer; }
.url-row button { padding: 0 20px; color: #10102a; background: linear-gradient(135deg, var(--blue), #91dcff); transition: transform .2s ease; }
.url-row button:hover { transform: translateY(-2px); }
.url-row button:disabled, .draw:disabled { cursor: wait; opacity: .6; transform: none; }
.field-help { margin: 9px 0 0; font-size: .85rem; }
.load-progress { width: fit-content; margin: 12px 0 0; padding: 8px 12px; border: 1px solid rgba(121,213,255,.24); border-radius: 999px; color: #bdeaff; background: rgba(82,157,255,.1); font-size: .86rem; font-weight: 900; }
.positions { border: 0; padding: 0; margin: 32px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.positions legend { grid-column: 1 / -1; }
.positions label { position: relative; }
.positions input { position: absolute; opacity: 0; pointer-events: none; }
.positions span { min-height: 46px; display: grid; place-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: rgba(21,18,45,.56); font-size: .8rem; font-weight: 900; cursor: pointer; transition: .2s ease; }
.positions span:hover { border-color: rgba(180,154,255,.48); color: var(--ink); }
.positions input:checked + span { border-color: rgba(180,154,255,.72); color: #fff; background: linear-gradient(145deg, rgba(120,108,255,.34), rgba(156,61,107,.18)); }
.positions input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 3px; }

.rules { padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: rgba(21,18,45,.62); }
.rules h2 { margin: 0; font-family: "Fredoka", sans-serif; font-size: 1.08rem; }
.rules p { margin: 5px 0 17px; font-size: .88rem; }
.rules ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.rules li { min-height: 48px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.rule-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 11px; color: var(--night); background: var(--blue); font-weight: 900; }
.rules li:nth-child(2) .rule-icon { background: var(--lavender); }
.rules li:nth-child(3) .rule-icon { background: var(--pink); }
.rules b { font-size: .85rem; }
.rules small { color: var(--muted); font-size: .82rem; text-align: right; }

.snapshot { margin-top: 27px; display: grid; grid-template-columns: repeat(3, minmax(76px, 1fr)); gap: 12px; align-items: end; }
.snapshot div { min-height: 74px; display: flex; flex-direction: column; justify-content: center; padding: 11px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(21,18,45,.58); }
.snapshot strong { font-family: "Fredoka", sans-serif; color: #fff; font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.snapshot span { color: var(--muted); font-size: .82rem; }
.draw { grid-column: 1 / -1; min-height: 60px; margin-top: 2px; color: var(--night); background: linear-gradient(120deg, #aaa4ff, #f099bc); font-family: "Fredoka", sans-serif; font-size: 1.05rem; box-shadow: 0 14px 30px rgba(0,0,0,.24); transition: transform .2s ease, filter .2s ease; }
.draw span { display: inline-block; margin-left: 6px; color: #ffd4e5; }
.draw:hover { transform: translateY(-2px); filter: brightness(1.08); }
.demo-line { display: flex; align-items: center; gap: 10px; margin-top: 19px; color: var(--muted); font-size: .84rem; }
.demo-line button, #newDraw { padding: 0; border: 0; color: var(--blue); background: none; font-weight: 900; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

.stage { position: relative; min-height: 760px; padding: 54px; overflow: hidden; background: linear-gradient(145deg, rgba(29,25,62,.72), rgba(11,9,32,.3) 58%); }
.stage::before, .stage::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; filter: blur(2px); }
.stage::before { width: 360px; height: 360px; top: -210px; right: -80px; background: rgba(120,108,255,.22); }
.stage::after { width: 250px; height: 250px; bottom: -150px; left: -80px; background: rgba(156,61,107,.18); }
.stage-head { position: relative; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.stage-head h2 { font-size: clamp(2rem, 3vw, 3.3rem); }
.stage-head p { margin: 8px 0 0; font-size: .84rem; }
.cat-peek { width: 76px; height: 76px; margin: -8px 5px 0 auto; object-fit: contain; animation: heartBob 2.6s ease-in-out infinite; }

.empty-state { min-height: 540px; position: relative; z-index: 1; display: grid; align-content: center; justify-items: center; text-align: center; }
.empty-state strong { margin-top: 15px; font-family: "Fredoka", sans-serif; font-size: 1.55rem; }
.empty-state p { max-width: 42ch; margin: 8px 0 0; font-size: .87rem; }
.cat-mascot { width: 240px; height: 210px; position: relative; }
.cat-mascot svg { width: 100%; height: 100%; overflow: visible; animation: catFloat 4s ease-in-out infinite; }
.cat-mascot .fur { fill: var(--orange); stroke: #ffc27d; stroke-width: 4; stroke-linejoin: round; }
.cat-mascot .tail { fill: none; stroke: var(--orange); stroke-width: 12; stroke-linecap: round; }
.cat-mascot .ear-inner { fill: #d96b56; }
.cat-mascot .eye { fill: #211535; }
.cat-mascot .eye-shine { fill: #fff; }
.cat-mascot .nose { fill: #9c3d6b; }
.cat-mascot .details, .cat-mascot .paws { fill: none; stroke: #38203e; stroke-width: 3.5; stroke-linecap: round; }
.cat-mascot .belly { fill: #ffd4a8; opacity: .92; }
.spark { position: absolute; z-index: 3; color: var(--blue); font-family: "Fredoka", sans-serif; animation: sparkle 2.5s ease-in-out infinite; }
.spark.s1 { left: 19px; top: 42px; font-size: 1.2rem; }
.spark.s2 { right: 15px; top: 17px; color: var(--lavender); animation-delay: -.8s; }
.spark.s3 { right: 0; top: 91px; color: var(--pink); animation-delay: -1.5s; }
.paw-dots { height: 28px; display: flex; align-items: center; gap: 1px; color: var(--pink); transform: rotate(-8deg); }
.paw-dots img { width: 31px; height: 31px; object-fit: contain; filter: sepia(.2) saturate(1.4); }
.paw-dots i { margin-left: -3px; font-style: normal; font-size: .8rem; }

.drawing-state { min-height: 540px; position: relative; z-index: 2; display: grid; place-content: center; gap: 24px; text-align: center; color: var(--muted); font-weight: 900; }
.ticker { width: min(560px, 65vw); height: 90px; position: relative; overflow: hidden; border: 1px solid rgba(105,199,255,.28); border-radius: 22px; background: rgba(21,18,45,.74); }
.ticker strong { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; font-family: "Fredoka", sans-serif; font-size: clamp(1.4rem, 4vw, 3rem); color: var(--ink); transition: opacity .07s ease, transform .07s ease; }
.ticker strong.swap { opacity: .12; transform: translateY(-8px); }

.results { position: relative; z-index: 2; margin-top: 34px; display: grid; gap: 14px; }
.winner { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(300px, 1.2fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(18,15,42,.86); box-shadow: 0 20px 44px rgba(0,0,0,.24); }
.winner-main { min-height: 244px; padding: 26px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(150deg, rgba(105,199,255,.13), transparent 60%); }
.winner:first-child .winner-main { background: linear-gradient(150deg, rgba(120,108,255,.24), rgba(156,61,107,.13) 55%, transparent); }
.rank { display: inline-flex; align-items: center; gap: 7px; color: var(--pink); font-size: .75rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.rank svg { width: 16px; height: 16px; fill: currentColor; }
.handle { margin: 10px 0 0; font-family: "Fredoka", sans-serif; font-size: clamp(1.3rem, 2.2vw, 2.2rem); letter-spacing: -.03em; overflow-wrap: anywhere; }
.odds { color: var(--muted); font-size: .8rem; }
.comment { margin: 12px 0 0; color: var(--ink); font-size: .84rem; line-height: 1.5; }
.winner-checks { padding: 22px; display: grid; align-content: center; gap: 8px; border-left: 1px solid var(--line); }
.check { min-height: 50px; padding: 9px 10px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; border-radius: 13px; background: var(--panel-2); }
.check-mark { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; color: var(--night); background: #85879b; font-weight: 900; }
.check.pass .check-mark { background: var(--green); }
.check.fail .check-mark { background: var(--red); }
.check strong { font-size: .77rem; }
.check small { display: block; margin-top: 2px; color: var(--muted); font-size: .75rem; }
.check-actions { display: flex; gap: 5px; }
.mini { min-width: 31px; min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: transparent; font-size: .75rem; font-weight: 900; cursor: pointer; }
.mini:hover { border-color: var(--blue); }
.mini.auto { color: var(--blue); }
.disqualify { min-height: 40px; margin-top: 4px; border: 0; border-radius: 11px; color: #ffc0d3; background: rgba(156,61,107,.18); font-size: .78rem; font-weight: 900; cursor: pointer; }
.disqualify:hover { background: rgba(156,61,107,.28); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(420px, calc(100vw - 48px)); padding: 15px 18px; border-radius: 15px; color: var(--night); background: var(--blue); box-shadow: 0 16px 38px rgba(0,0,0,.3); font-size: .84rem; font-weight: 900; }
.toast.error { background: var(--red); }
footer { width: min(1400px, calc(100% - 48px)); min-height: 62px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .8rem; }
footer a { color: #9291b0; text-decoration: none; }
footer a:hover { color: var(--blue); text-decoration: underline; }

@keyframes catFloat { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-9px) rotate(1deg); } }
@keyframes sparkle { 0%,100% { opacity: .35; transform: scale(.75) rotate(0); } 50% { opacity: 1; transform: scale(1.15) rotate(12deg); } }
@keyframes heartBob { 0%,100% { transform: translateY(0) scale(.9); } 50% { transform: translateY(-4px) scale(1.05); } }

@media (max-width: 1080px) {
  main { grid-template-columns: 1fr; }
  .setup { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { min-height: 680px; }
}
@media (max-width: 680px) {
  .topbar, main, footer { width: min(100% - 24px, 1400px); }
  .topbar { min-height: 92px; align-items: center; gap: 14px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 40px; height: 40px; border-radius: 15px; }
  .brand-mark svg { width: 30px; }
  .account { align-items: flex-end; flex-direction: column; gap: 4px; padding: 6px; border: 0; border-radius: 14px; text-align: right; font-size: .78rem; }
  .account .signal { display: none; }
  .connect { padding: 7px 10px; }
  main { border-radius: 25px; }
  .setup, .stage { padding: 34px 22px; }
  .section-heading h1 { font-size: 3.15rem; }
  .url-row { grid-template-columns: 1fr; }
  .url-row button { min-height: 52px; }
  .source-picker { grid-template-columns: 1fr; }
  .official-connect { align-items: stretch; flex-direction: column; }
  .official-connect .connect { text-align: center; }
  .positions { grid-template-columns: 1fr; }
  .positions span { justify-content: start; padding-left: 15px; }
  .rules { padding: 20px 16px; }
  .rules li { grid-template-columns: 34px 1fr; }
  .rules small { grid-column: 2; text-align: left; margin-top: -8px; }
  .snapshot { grid-template-columns: 1fr 1fr; }
  .snapshot div:nth-child(3) { grid-column: 1 / -1; }
  .stage-head { align-items: center; }
  .cat-peek { width: 64px; }
  .cat-mascot { width: 205px; height: 180px; }
  .winner { grid-template-columns: 1fr; }
  .winner-main { min-height: 190px; }
  .winner-checks { border-left: 0; border-top: 1px solid var(--line); }
  .check { grid-template-columns: 28px 1fr; }
  .check-actions { grid-column: 2; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 18px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
