:root {
  --bg: #121016;
  --panel: #1c1922;
  --panel2: #252130;
  --line: #34303f;
  --text: #f1edf5;
  --muted: #9a93a6;
  --gold: #e9b949;
  --red: #e8615a;
  --green: #7fd17b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-image: radial-gradient(1200px 500px at 50% -200px, #2a1f38 0%, transparent 70%);
  min-height: 100vh;
}
#app { max-width: 760px; margin: 0 auto; padding: 12px 14px calc(120px + env(safe-area-inset-bottom)); }
a { color: var(--gold); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 10px; }
[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; transition: background .15s, transform .05s, border-color .15s;
}
button:hover:not(:disabled) { border-color: #4a4458; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 650; }
button.ghost { background: transparent; }
button.wide { width: 100%; padding: 14px; }
button.armed { background: var(--red); border-color: var(--red); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; }
input[type=text], input:not([type]), input[type=search] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none;
}
input:focus { border-color: var(--gold); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }

/* home */
.home { padding-top: 6vh; }
.logo { font-size: 2.6rem; letter-spacing: -.02em; text-align: center; margin-bottom: .2em; }
.logo.small { font-size: 1.15rem; text-decoration: none; color: var(--text); font-weight: 700; }
.tagline { text-align: center; color: var(--muted); max-width: 30em; margin: 0 auto 18px; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
label input { margin-top: 6px; color: var(--text); font-size: 1rem; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.mode { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; color: var(--text); font-size: 1rem; cursor: pointer; }
.mode:has(input:checked) { border-color: var(--gold); }
.mode input { margin-top: 4px; accent-color: var(--gold); }
.mode small { display: block; color: var(--muted); font-size: .85rem; }
#create button.primary { width: 100%; padding: 13px; }
.row { display: flex; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; text-align: center; }
.how summary { cursor: pointer; font-weight: 600; }
.how ol { padding-left: 1.2em; color: #d8d2df; }
.how li { margin: 8px 0; }

/* room header */
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.code-chip { letter-spacing: .18em; font-weight: 700; display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.share-ico { letter-spacing: 0; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.dot.off { background: var(--red); }

.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 8px; font-size: .8rem; }
.steps li { flex: 1; text-align: center; padding: 6px 4px; border-radius: 8px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.steps li.on { color: #1a1408; background: var(--gold); border-color: var(--gold); font-weight: 650; }
.hint { margin: 6px 0 4px; color: #d8d2df; }
.settings { margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.settings summary { cursor: pointer; color: var(--muted); }
.setrow { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.setrow:first-of-type { margin-top: 8px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; padding: 6px 12px; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.seg button.on { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 34px; height: 34px; padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; font-size: .9rem; }
.chip.me { border-color: var(--gold); }
.chip .x { padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 1rem; line-height: 1; }
.chip .x.armed { color: #fff; background: var(--red); padding: 0 6px; font-size: .75rem; }

/* search */
#search { padding: 10px; position: sticky; top: 6px; z-index: 5; box-shadow: 0 8px 20px #0008; }
#results:not(:empty) { margin-top: 8px; max-height: 50vh; overflow: auto; }
.hit { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 6px; }
.hit:hover:not(:disabled) { background: var(--panel2); }
.hit img, .noposter.sm { width: 34px; height: 51px; object-fit: cover; border-radius: 4px; flex: none; }
.hit > span:nth-child(2) { flex: 1; }
.hit .add { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #1a1408; display: grid; place-items: center; font-weight: 700; flex: none; font-size: .9rem; }
.hit:disabled .add { background: var(--line); color: var(--muted); }

/* movie cards */
.cards { display: grid; gap: 12px; margin-top: 12px; }
.card { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; transition: border-color .2s, opacity .2s; }
.card.is-approve { border-color: var(--green); }
.card.is-veto { border-color: var(--red); }
.card.is-veto .poster { filter: grayscale(1) brightness(.6); }
.poster { width: 96px; height: 144px; object-fit: cover; border-radius: 8px; flex: none; background: var(--panel2); }
.noposter { display: grid; place-items: center; font-size: 2rem; background: var(--panel2); border-radius: 8px; }
.body { flex: 1; min-width: 0; }
.body h3 { margin-bottom: 2px; }
.year { color: var(--muted); font-weight: 400; }
.meta { color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { font-size: .8rem; padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.badge.imdb { background: #f5c518; color: #000; border-color: #f5c518; }
.badge.rt.fresh { border-color: #fa320a; }
.badge.rt.rotten { border-color: #6b8e23; }
.badge.mc.good { background: #00ce7a; color: #000; border-color: #00ce7a; }
.badge.mc.mixed { background: #ffbd3f; color: #000; border-color: #ffbd3f; }
.badge.mc.bad { background: #ff6874; color: #000; border-color: #ff6874; }
.providers { display: flex; gap: 6px; margin: 6px 0; }
.providers img { width: 28px; height: 28px; border-radius: 6px; }
.providers.none { font-size: .8rem; color: var(--muted); }
.plot summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.plot p { font-size: .9rem; margin: 6px 0; color: #d8d2df; }
.links { font-size: .85rem; margin-top: 4px; }
.by { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.vote { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.vbtn { flex: 1; min-width: 120px; padding: 10px; }
.vbtn.approve.on { background: var(--green); border-color: var(--green); color: #0b1a0a; font-weight: 650; }
.vbtn.veto.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 650; }

/* bottom bar */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px max(14px, calc((100vw - 760px) / 2 + 14px)) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent); display: grid; gap: 8px;
}
.wait { margin: 0; text-align: center; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

/* reveal */
.tallies { list-style: none; padding: 0; margin: 0; }
.tally { display: grid; grid-template-columns: 1fr 90px 52px; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); position: relative; transition: opacity .4s; }
.tally:first-child { border-top: 0; }
.t-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.t-bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .8s ease; }
.t-num { text-align: right; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .4s; }
.tally.counted .t-bar i { width: var(--w); }
.tally.counted .t-num { opacity: 1; }
.stamp {
  position: absolute; left: 40%; top: 50%; transform: translate(-50%, -50%) rotate(-8deg) scale(2.2); opacity: 0;
  color: var(--red); border: 2px solid var(--red); border-radius: 6px; padding: 0 8px; font-weight: 800; letter-spacing: .1em; font-size: .85rem;
  transition: transform .25s cubic-bezier(.3,1.6,.6,1), opacity .2s; pointer-events: none; background: #1c1922e0;
}
.tally.vetoed .stamp { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
.tally.vetoed .t-title, .tally.vetoed .t-bar, .tally.vetoed .t-num { opacity: .35; text-decoration: line-through; }
.tally.won .t-title { color: var(--gold); font-weight: 700; }

.wheel-wrap { text-align: center; }
.wheel-stage { position: relative; width: min(280px, 75vw); aspect-ratio: 1; margin: 10px auto 14px; }
.wheel { width: 100%; height: 100%; border-radius: 50%; border: 4px solid var(--panel2); box-shadow: 0 0 0 2px var(--line), 0 10px 30px #0009; }
.pointer { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); z-index: 2; color: var(--text); font-size: 1.6rem; text-shadow: 0 2px 6px #000; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; text-align: left; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.winner { animation: pop .6s cubic-bezier(.3,1.4,.6,1); margin: 6px 0 4px; }
.kicker { text-align: center; color: var(--gold); text-transform: uppercase; letter-spacing: .15em; font-size: .8rem; font-weight: 700; margin: 4px 0 8px; }
.card.hero { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 40px #e9b94933; }
.card.hero .poster { width: 120px; height: 180px; }
.card.hero h3 { font-size: 1.3rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: #000d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; transition: all .25s; pointer-events: none; z-index: 20; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .poster { width: 78px; height: 117px; }
  .tally { grid-template-columns: 1fr 60px 46px; }
}
