:root {
  --bg: #0e0e13;
  --panel: #17171f;
  --panel-2: #20202b;
  --line: #2c2c3a;
  --text: #f3f3f7;
  --muted: #9a9aad;
  --accent: #ff4d6d;
  --accent-2: #ff8a5b;
  --like: #2fd08a;
  --nope: #ff4d6d;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
input { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85em; }
.center { text-align: center; }

#app { max-width: 480px; margin: 0 auto; min-height: 100%; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.screen { display: flex; flex-direction: column; gap: 14px; min-height: calc(100dvh - 28px); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 16px; font-weight: 600; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; }
.btn.big { padding: 15px; font-size: 1.05rem; width: 100%; border-radius: 14px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.danger { color: var(--nope); }

/* home */
#home { justify-content: center; }
.brand { text-align: center; margin-bottom: 18px; }
.logo { font-size: 64px; line-height: 1; filter: drop-shadow(0 8px 24px #ff4d6d55); }
.brand h1 { margin: 8px 0 4px; font-size: 2.4rem; letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { color: var(--muted); margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.field input, .join-row input { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; font-size: 1rem; outline: none; }
.field input:focus, .join-row input:focus { border-color: var(--accent); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#normal-actions, #invite-actions { display: flex; flex-direction: column; gap: 14px; }
.invite { text-align: center; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.invite span { color: var(--muted); font-size: .85rem; }
.invite strong { font-size: 2.2rem; letter-spacing: .3em; margin-right: -.3em; }
.create-own { align-self: center; color: var(--muted); }
.invite-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #ff4d6d1a; border: 1px solid var(--accent);
  border-radius: 14px; padding: 10px 12px; font-size: .9rem; }
.join-row { display: flex; gap: 8px; }
.credit { text-align: center; font-size: .72rem; color: var(--muted); margin: 18px 0 0; opacity: .7; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .35em; font-weight: 700; text-align: center; }

/* lobby */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code-box { text-align: center; display: flex; flex-direction: column; line-height: 1.1; background: none; border: 0; padding: 0; }
.code-chip { background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; padding: 6px 9px; font-weight: 700; letter-spacing: .12em; font-size: .85rem; color: var(--text); flex: none; }
.code-chip:active, .code-box:active { transform: scale(.95); }
.code-box span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.code-box strong { font-size: 1.9rem; letter-spacing: .25em; margin-right: -.25em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel h2 { font-size: 1rem; margin: 0 0 10px; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li { display: flex; align-items: center; gap: 10px; }
.players li.off { opacity: .5; }
.pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname em { color: var(--muted); font-style: normal; font-size: .85em; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: hsl(var(--h) 65% 45%); color: #fff; flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: .65rem; }
.kick { background: none; border: 0; color: var(--muted); padding: 4px 8px; }
.kick:hover { color: var(--nope); }

.set { padding: 10px 0; border-top: 1px solid var(--line); }
.set:first-child { border-top: 0; padding-top: 0; }
.set-label { font-size: .85rem; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.set-label small { opacity: .8; }
.set-label strong { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 6px 11px; font-size: .85rem; }
.chip.on, .chip.include { background: #2fd08a22; border-color: var(--like); color: #8ff0c3; }
.chip.include::before { content: "✓ "; }
.chip.exclude { background: #ff4d6d1f; border-color: var(--nope); color: #ff9aac; text-decoration: line-through; }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-size: .85rem; color: var(--muted); }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.genre-mode { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.genre-mode .seg { flex: 1; }
.years { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.years input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.presets { margin-top: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
#settings.readonly button, #settings.readonly input { pointer-events: none; }
.deck-row { display: flex; gap: 8px; align-items: stretch; }
.deck-row .seg { flex: 1; }
.deck-row input { width: 72px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; text-align: center; outline: none; }
.deck-row input:focus { border-color: var(--accent); }
#settings.readonly .seg button:not(.on), #settings.readonly .chip:not(.on):not(.include):not(.exclude) { opacity: .45; }

.start-bar { position: sticky; bottom: 0; margin-top: auto; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%);
  display: flex; flex-direction: column; gap: 8px; }
#pool-count { text-align: center; color: var(--muted); font-size: .9rem; }
#pool-count strong { color: var(--text); }

.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topic { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.topic .t-emoji { font-size: 1.6rem; line-height: 1.2; }
.topic strong { font-size: .95rem; }
.topic span.muted { font-size: .75rem; }
.topic.on { border-color: var(--accent); background: #ff4d6d1a; box-shadow: inset 0 0 0 1px var(--accent); }
.topics.readonly .topic { pointer-events: none; }
.topics.readonly .topic:not(.on) { opacity: .4; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; }
.add-row input:focus { border-color: var(--accent); }
#custom-hint { margin: -4px 0 10px; }
.custom-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.custom-list li { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 10px; padding: 7px 6px 7px 12px; }
.custom-list .c-title { flex: 1; overflow-wrap: anywhere; }
.custom-list .c-by { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.library { margin: 0 0 12px; }
.lib-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font-size: .8rem; text-decoration: underline; }
.linkish.on { color: var(--accent); }
.lib-item { display: inline-flex; align-items: center; gap: 2px; }
.chip.lib.on { border-color: var(--accent); background: #ff4d6d1a; color: #ffb3c1; }
.lib-del { background: none; border: 0; padding: 4px 6px; font-size: .9rem; }
.lib-empty { font-size: .8rem; color: var(--muted); margin: 0; }
.list-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.list-actions .from { flex-basis: 100%; font-size: .8rem; color: var(--muted); }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 18px; width: min(360px, 90vw); }
.dialog::backdrop { background: #000a; }
.dialog h3 { margin: 0 0 6px; }
.dialog p { margin: 0 0 12px; }
.dialog input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }
.dialog input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* swipe */
#swipe { gap: 10px; }
.sheet-lobby { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; margin: 0 40px 6px 0; }
.sheet-lobby strong { color: var(--text); letter-spacing: .15em; }
.progress { display: flex; gap: 6px; overflow-x: auto; flex: 1; justify-content: safe center; scrollbar-width: none; }
.pchip { display: flex; align-items: center; gap: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 8px 3px 3px; font-size: .75rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pchip.me { border-color: #ffffff55; }
.pchip.off { opacity: .45; }
.match-btn { background: #ff4d6d22; border-color: var(--accent); color: #ffb3c1; }
.match-btn.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.25); } }

.stack-wrap { position: relative; flex: 1; min-height: 380px; }
.stack { position: absolute; inset: 0; }
.card { position: absolute; inset: 0; border-radius: 20px; overflow: hidden; background: var(--panel-2); box-shadow: 0 12px 40px #0009;
  touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .25s ease; will-change: transform;
  --like: 0; --nope: 0; }
.card[data-pos="1"] { transform: scale(.95) translateY(14px); filter: brightness(.7); }
.card[data-pos="2"] { transform: scale(.9) translateY(28px); filter: brightness(.5); }
.card.enter { animation: enter .3s ease-out; }
@keyframes enter { from { transform: translateY(-40px) scale(1.05); opacity: 0; } }
.poster { position: absolute; inset: 0; background: center / cover no-repeat; }
.noposter { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; font-size: 1.8rem; font-weight: 800;
  background: linear-gradient(160deg, hsl(var(--h) 55% 30%), hsl(calc(var(--h) + 60) 50% 14%)); }
.emoji-art { position: absolute; inset: 0; padding-bottom: 35%; display: grid; place-items: center; font-size: 120px;
  background: radial-gradient(circle at 50% 45%, hsl(var(--h) 60% 38%), hsl(calc(var(--h) + 50) 55% 12%) 75%); }
.card-info .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.card-info .tags span { font-size: .72rem; background: #ffffff1f; border-radius: 999px; padding: 2px 8px; }
.row .thumb.emoji { display: grid; place-items: center; font-size: 26px; background: hsl(var(--h) 45% 25%); }
.stamp { position: absolute; top: 26px; padding: 4px 12px; border: 4px solid; border-radius: 10px; font-weight: 900; font-size: 2rem; letter-spacing: .08em; }
.stamp.like { left: 22px; color: var(--like); transform: rotate(-14deg); opacity: var(--like); }
.stamp.nope { right: 22px; color: var(--nope); transform: rotate(14deg); opacity: var(--nope); }
.card-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 18px 18px; background: linear-gradient(transparent, #000d 45%); }
.card-info h3 { margin: 0; font-size: 1.5rem; line-height: 1.15; }
.card-info .year { color: #ffffffaa; font-weight: 400; font-size: 1.1rem; }
.card-info .meta { font-size: .9rem; color: #ffffffcc; margin-top: 4px; }
.card-info .genres { font-size: .8rem; color: #ffffff99; margin-top: 2px; }
.overview { display: none; font-size: .9rem; color: #ffffffdd; margin: 10px 0 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card.expanded .card-info { background: linear-gradient(transparent, #000e 20%); padding-top: 80px; }
.card.expanded .overview { -webkit-line-clamp: 12; }
.card .tmdb { display: none; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.card.expanded .tmdb { display: inline-block; }

.done { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 20px; padding: 24px; }
.done h2 { margin: 0; }
.done p { margin: 0; color: var(--muted); }
.done .btn { min-width: 200px; }

.controls { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 6px 0; }
.round { width: 68px; height: 68px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 1.8rem; display: grid; place-items: center;
  box-shadow: 0 6px 20px #0006; transition: transform .1s; }
.round:active { transform: scale(.9); }
.round.small { width: 46px; height: 46px; font-size: 1.15rem; color: var(--muted); }
.round.nope { color: var(--nope); }
.round.like { color: var(--like); }

/* sheet */
.sheet { position: fixed; inset: 0; background: #000a; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { position: relative; background: var(--panel); width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px max(20px, env(safe-area-inset-bottom)); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet-close { position: absolute; top: 12px; right: 12px; }
.sheet h2 { font-size: 1.05rem; margin: 18px 0 8px; }
.sheet h2:first-of-type { margin-top: 4px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; text-decoration: none; background: var(--panel-2); border-radius: 12px; padding: 6px; }
.row img, .row .thumb { width: 46px; height: 69px; border-radius: 8px; object-fit: cover; flex: none; background: var(--line); }
.row.picked { outline: 2px solid var(--accent); }
.picked-banner { background: linear-gradient(135deg, #ff4d6d33, #ff8a5b33); border: 1px solid var(--accent); border-radius: 14px; padding: 12px; margin-bottom: 6px; }
.host-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sheet-foot { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* overlay */
.overlay { position: fixed; inset: 0; z-index: 50; background: #000c; display: grid; place-items: center; padding: 24px; backdrop-filter: blur(6px); }
.overlay-body { text-align: center; max-width: 340px; width: 100%; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.ov-title { font-size: 2.2rem; font-weight: 900; letter-spacing: -.02em; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ov-poster.emoji { font-size: 90px; background: radial-gradient(circle, hsl(var(--h) 60% 38%), hsl(calc(var(--h) + 50) 55% 12%)); }
.ov-poster { width: 200px; aspect-ratio: 2/3; margin: 0 auto; border-radius: 14px; background: center / cover var(--panel-2); box-shadow: 0 16px 50px #ff4d6d55;
  display: grid; place-items: center; font-weight: 800; padding: 12px; }
.overlay h3 { margin: 14px 0 18px; font-size: 1.3rem; }
.overlay h3 span { color: var(--muted); font-weight: 400; }
.ov-actions { display: flex; gap: 10px; justify-content: center; }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: #fff; color: #111; padding: 10px 16px; border-radius: 12px;
  font-size: .9rem; z-index: 60; box-shadow: 0 8px 30px #0008; max-width: 90vw; text-align: center; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: #b8860b; color: #fff; text-align: center; padding: 6px; font-size: .85rem; z-index: 70; }
