:root {
  --bg: #07080c;
  --panel: #10121a;
  --panel-2: #161926;
  --line: #232738;
  --text: #e8eaf2;
  --muted: #8a90a8;
  --dim: #5b6079;
  --a: #22d3ee;
  --a-soft: rgba(34, 211, 238, 0.14);
  --b: #f472b6;
  --b-soft: rgba(244, 114, 182, 0.14);
  --both: #c4b5fd;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: "Inter", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(1200px 500px at 90% -10%, rgba(244, 114, 182, 0.10), transparent 60%),
    var(--bg);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.a { color: var(--a); }
.b { color: var(--b); }
.hidden { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgba(7, 8, 12, 0.7); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: 0.08em; font-size: 18px; }
.brand svg { width: 44px; height: 24px; }
.c-a { fill: var(--a); }
.c-b { fill: var(--b); fill-opacity: 0.85; mix-blend-mode: screen; }
.boothbar { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
.chip strong { color: var(--text); font-family: var(--mono); letter-spacing: 0.12em; }
.chip.env { text-transform: uppercase; font-size: 11px; letter-spacing: 0.1em; }

main { max-width: 1320px; margin: 0 auto; padding: 26px 28px 60px; }
.foot { text-align: center; color: var(--dim); font-size: 13px; padding: 20px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; text-decoration: none; font-weight: 600; transition: transform 0.08s, background 0.15s, border-color 0.15s; }
.btn:hover { border-color: #3a4058; background: #1c2030; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, var(--a), var(--b)); color: #07080c; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.a { border-color: rgba(34, 211, 238, 0.5); color: var(--a); background: var(--a-soft); }
.btn.b { border-color: rgba(244, 114, 182, 0.5); color: var(--b); background: var(--b-soft); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.iconbtn { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--muted); }
.iconbtn:hover { color: var(--text); border-color: #3a4058; }
.iconbtn.on { color: var(--warn); border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.1); }

/* landing */
.hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center; padding: 40px 0 30px; }
.hero h1 { font-size: 54px; line-height: 1.02; margin: 0 0 18px; letter-spacing: -0.02em; }
.hero h1 .grad { background: linear-gradient(90deg, var(--a), var(--b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 18px; color: var(--muted); max-width: 560px; }
.hero .actions { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.hero-art { position: relative; height: 320px; }
.hero-art .vinyl { position: absolute; width: 260px; height: 260px; top: 30px; }
.hero-art .vinyl.left { left: 0; }
.hero-art .vinyl.right { right: 0; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.step .n { font-family: var(--mono); color: var(--dim); font-size: 12px; letter-spacing: 0.12em; }
.step h3 { margin: 6px 0 6px; font-size: 16px; }
.step p { margin: 0; color: var(--muted); font-size: 14px; }

/* vinyl */
.vinyl { border-radius: 50%; background: repeating-radial-gradient(circle at 50% 50%, #111 0 2px, #191919 2px 4px); box-shadow: 0 0 0 2px #1d1f2a, 0 20px 60px rgba(0, 0, 0, 0.6); display: grid; place-items: center; }
.vinyl .label { width: 36%; height: 36%; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #07080c; letter-spacing: 0.1em; }
.vinyl.spin { animation: spin 3.2s linear infinite; }
.vinyl .label::after { content: ""; width: 9%; height: 9%; border-radius: 50%; background: #07080c; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vinyl.spin { animation: none; } }

/* booth */
.decks { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.decks.solo { grid-template-columns: 1fr; }
.deck { position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 20px; align-items: center; padding: 20px 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.deck::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--deck); }
.deck.a { --deck: var(--a); --deck-soft: var(--a-soft); }
.deck.b { --deck: var(--b); --deck-soft: var(--b-soft); }
.deck .vinyl { width: 112px; height: 112px; }
.deck .vinyl .label { background: var(--deck); }
.deck .who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.deck .seat { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; color: var(--deck); text-transform: uppercase; }
.deck .handle { font-size: 22px; font-weight: 750; letter-spacing: -0.01em; }
.deck .handle input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: 20px; font-weight: 700; width: 220px; }
.deck .status { margin-top: 4px; color: var(--muted); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.deck .actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.deck .you { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--deck-soft); color: var(--deck); font-weight: 700; letter-spacing: 0.06em; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.live.polling { color: var(--warn); }
.live.polling::before { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.progress { height: 4px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--deck); width: 30%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.alert { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.alert.warn { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); color: #fde68a; }
.alert.bad { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); color: #fecaca; }
.alert.info { border-color: var(--line); background: var(--panel-2); color: var(--muted); }
.alert .rid { font-family: var(--mono); font-size: 12px; opacity: 0.75; }

.privacy { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 6px; padding: 12px 16px; border-radius: 12px; background: linear-gradient(90deg, var(--a-soft), var(--b-soft)); border: 1px solid var(--line); font-size: 14px; color: #cfd3e3; }
.privacy svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }

.invite { margin-top: 18px; padding: 22px; border-radius: var(--radius); border: 1px dashed #3a4058; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.invite .link { font-family: var(--mono); background: var(--panel-2); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); flex: 1; min-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

section.panel { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
section.panel > h2 { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 12px; }
section.panel > h2 .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.sub { color: var(--dim); font-size: 13px; margin: 0 0 14px; }

.grid-analysis { display: grid; grid-template-columns: 0.8fr 1.3fr 1fr; gap: 18px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 650; display: flex; align-items: baseline; gap: 8px; }
.card h3 .count { margin-left: auto; font-family: var(--mono); color: var(--muted); font-weight: 500; font-size: 12px; }
.bignum { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; background: linear-gradient(90deg, var(--a), var(--b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.overlap-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 220px; overflow: auto; font-size: 13px; }
.overlap-list li { padding: 5px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.overlap-list li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
svg text { fill: var(--muted); font-family: var(--mono); font-size: 10px; }
.wheel-wrap { display: grid; grid-template-columns: 1fr; justify-items: center; }
.bridges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.bridge { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.bridge .side { min-width: 0; }
.bridge .side .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bridge .side.masked .t { color: var(--muted); font-weight: 500; font-style: italic; }
.bridge .arrow { color: var(--dim); font-family: var(--mono); font-size: 11px; text-align: center; }
.bridge .side.a { border-left: 2px solid var(--a); padding-left: 8px; }
.bridge .side.b { border-left: 2px solid var(--b); padding-left: 8px; }

/* builder */
.controls { display: grid; grid-template-columns: 1fr 1.3fr auto 1.2fr auto; gap: 16px; align-items: end; }
.field label { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field .row { display: flex; gap: 6px; align-items: center; }
.field input[type="number"], .field input[type="search"], .field select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.field input[type="number"] { width: 64px; text-align: center; font-family: var(--mono); }
.field input[type="range"] { width: 100%; accent-color: var(--a); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { white-space: nowrap; padding: 7px 11px; background: var(--panel-2); border: 0; border-right: 1px solid var(--line); cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: #262b40; color: var(--text); }
.startpick { position: relative; }
.startpick .results { position: absolute; z-index: 10; top: 100%; left: 0; right: 0; background: #1a1d2b; border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; max-height: 260px; overflow: auto; box-shadow: 0 20px 40px rgba(0,0,0,.5); }
.startpick .results button { display: flex; width: 100%; text-align: left; gap: 8px; padding: 8px 10px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.startpick .results button:hover { background: #22263a; }
.startchosen { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 7px 10px; border-radius: 8px; background: var(--a-soft); border: 1px solid rgba(34, 211, 238, 0.35); }
.startchosen span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.curve { margin-top: 18px; background: #0b0d14; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 0; }
.curve svg { width: 100%; height: 190px; display: block; }

.timeline { margin-top: 14px; display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x proximity; }
.timeline::-webkit-scrollbar { height: 8px; }
.timeline::-webkit-scrollbar-thumb { background: #262a3c; border-radius: 8px; }
.slot { flex: none; width: 196px; scroll-snap-align: start; }
.tcard { position: relative; background: var(--panel-2); border: 1px solid var(--line); border-top: 3px solid var(--seat); border-radius: 12px; padding: 12px 12px 10px; height: 100%; transition: border-color .2s, transform .2s; }
.tcard.a { --seat: var(--a); }
.tcard.b { --seat: var(--b); }
.tcard.locked { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45); }
.tcard.fresh { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
.tcard .pos { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tcard .pos .who { color: var(--seat); font-weight: 700; letter-spacing: 0.08em; }
.tcard .pos .tools { margin-left: auto; display: flex; gap: 4px; }
.tcard .pos .tools .iconbtn { width: 26px; height: 26px; }
.tcard .title { margin-top: 8px; font-weight: 650; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.tcard .artist { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard .meta { margin-top: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kchip { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; color: #07080c; }
.kchip.none { background: #2a2e40; color: var(--muted); font-weight: 500; }
.bchip { font-family: var(--mono); font-size: 12px; color: var(--text); }
.bchip.none { color: var(--warn); }
.tags { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; min-height: 20px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #22263a; color: var(--muted); }
.tag.fit { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.owners { margin-top: 8px; font-size: 11px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.owners .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.trans { flex: none; width: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-align: center; padding: 0 4px; position: relative; }
.trans::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, var(--from), var(--to)); opacity: .45; z-index: 0; }
.trans span { position: relative; z-index: 1; background: var(--bg); padding: 2px 5px; border-radius: 6px; border: 1px solid var(--line); }
.trans .note { color: var(--dim); font-size: 10px; border: 0; background: transparent; }
.trans.bad span:first-child { border-color: rgba(251, 191, 36, 0.5); color: var(--warn); }
.missing { opacity: .55; border-style: dashed !important; }

.alts { position: absolute; z-index: 30; width: 340px; background: #191c2a; border: 1px solid #343a54; border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.6); padding: 10px; }
.alts h4 { margin: 2px 4px 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.alts button.alt { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px; cursor: pointer; }
.alts button.alt:hover { background: #23273a; }
.alts .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alts .x { font-family: var(--mono); font-size: 10.5px; color: var(--muted); grid-column: 1 / -1; }

.setstats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.setstats b { color: var(--text); font-family: var(--mono); }

/* save */
.savegrid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: stretch; }
.savegrid.solo { grid-template-columns: 1fr auto; }
.savecard { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--seat); border-radius: 12px; padding: 14px 16px; }
.savecard.a { --seat: var(--a); }
.savecard.b { --seat: var(--b); }
.savecard .h { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.savecard .h .st { margin-left: auto; font-size: 12px; font-weight: 600; }
.savecard .line { font-size: 14px; color: var(--muted); margin-top: 6px; }
.savecard .line b { color: var(--text); }
.savecard select { margin-top: 10px; width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.savecard .fine { font-size: 12px; color: var(--dim); margin-top: 6px; }
.saveaction { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 210px; }
.st.ok { color: var(--ok); }
.st.wait { color: var(--warn); }
.st.bad { color: var(--bad); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 10px 0 6px; font-size: 18px; }

.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: 420px; }
.toast { background: #1b1f2e; border: 1px solid #343a54; border-left: 3px solid var(--a); border-radius: 10px; padding: 12px 14px; font-size: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: pop .25s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .rid { font-family: var(--mono); font-size: 11px; color: var(--dim); display: block; margin-top: 3px; }

body.plain main.notice { max-width: 560px; margin: 12vh auto; text-align: center; }
body.plain .logo { font-weight: 800; letter-spacing: .1em; font-size: 22px; background: linear-gradient(90deg, var(--a), var(--b)); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (max-width: 1100px) {
  .grid-analysis { grid-template-columns: 1fr 1fr; }
  .controls { grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 760px) {
  .decks, .grid-analysis, .savegrid, .steps { grid-template-columns: 1fr; }
  main { padding: 18px 14px 40px; }
  .hero h1 { font-size: 38px; }
}
