:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --card2: #F2F2F7;
  --fill: rgba(120, 120, 128, .12);
  --label: #000000;
  --label2: rgba(60, 60, 67, .62);
  --label3: rgba(60, 60, 67, .35);
  --sep: rgba(60, 60, 67, .18);
  --blue: #007AFF;
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --purple: #AF52DE;
  --pink: #FF2D55;
  --glass: rgba(255, 255, 255, .72);
  --shadow: 0 8px 30px rgba(0, 0, 0, .08);
  --truth: linear-gradient(140deg, #5E5CE6 0%, #0A84FF 100%);
  --dare: linear-gradient(140deg, #FF2D55 0%, #FF9500 100%);
  --blob1: #c7b8ff;
  --blob2: #ffc2d6;
  --blob3: #b5e3ff;
  --r: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1C1C1E;
    --card2: #2C2C2E;
    --fill: rgba(120, 120, 128, .24);
    --label: #FFFFFF;
    --label2: rgba(235, 235, 245, .62);
    --label3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .55);
    --blue: #0A84FF;
    --green: #30D158;
    --red: #FF453A;
    --orange: #FF9F0A;
    --yellow: #FFD60A;
    --purple: #BF5AF2;
    --pink: #FF375F;
    --glass: rgba(28, 28, 30, .72);
    --shadow: 0 10px 40px rgba(0, 0, 0, .5);
    --blob1: #3b1f8f;
    --blob2: #7a1240;
    --blob3: #0d3d73;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1C1C1E; --card2: #2C2C2E; --fill: rgba(120,120,128,.24);
  --label: #FFFFFF; --label2: rgba(235,235,245,.62); --label3: rgba(235,235,245,.3); --sep: rgba(84,84,88,.55);
  --blue: #0A84FF; --green: #30D158; --red: #FF453A; --orange: #FF9F0A; --yellow: #FFD60A; --purple: #BF5AF2; --pink: #FF375F;
  --glass: rgba(28,28,30,.72); --shadow: 0 10px 40px rgba(0,0,0,.5); --blob1: #3b1f8f; --blob2: #7a1240; --blob3: #0d3d73;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Hebrew", "Segoe UI", Rubik, Heebo, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* soft party background */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg i { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(80px); opacity: .55; animation: drift 22s ease-in-out infinite alternate; }
.bg i:nth-child(1) { background: var(--blob1); top: -30vmax; right: -20vmax; }
.bg i:nth-child(2) { background: var(--blob2); bottom: -35vmax; left: -25vmax; animation-delay: -7s; }
.bg i:nth-child(3) { background: var(--blob3); top: 30%; right: -40vmax; width: 50vmax; height: 50vmax; animation-delay: -14s; opacity: .35; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .bg i { animation: none; } }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 96px);
}

/* typography */
.large-title { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 6px 4px 4px; }
.subtitle { color: var(--label2); margin: 0 4px 20px; font-size: 16px; }
.section-h { font-size: 13px; text-transform: uppercase; color: var(--label2); margin: 22px 16px 7px; font-weight: 500; letter-spacing: .2px; }
.foot { color: var(--label2); font-size: 13px; margin: 8px 16px 0; }
.center { text-align: center; }

/* grouped lists */
.group { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 0; right: 16px; height: .5px; background: var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--label); font-size: 17px; padding: 6px 0; }
.row input::placeholder { color: var(--label3); }
.row.tap:active { background: var(--fill); }
.chev { color: var(--label3); font-size: 20px; }

/* buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; border-radius: 16px; font-weight: 700; font-size: 17px;
  background: var(--blue); color: #fff; transition: transform .12s ease, opacity .2s;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn:disabled { opacity: .4; }
.btn.gray { background: var(--fill); color: var(--label); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.wa { background: #25D366; }
.btn.small { min-height: 44px; font-size: 15px; border-radius: 13px; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row > * { flex: 1; }
.link { color: var(--blue); font-weight: 600; }
.stack > * + * { margin-top: 10px; }

/* home */
.hero { text-align: center; padding: 26px 0 8px; }
.hero .logo { font-size: 74px; line-height: 1; filter: drop-shadow(0 10px 22px rgba(0,0,0,.25)); animation: bob 3s ease-in-out infinite; }
.hero h1 { font-size: 40px; font-weight: 900; margin: 12px 0 4px; letter-spacing: -1px; }
.hero h1 span { background: var(--dare); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero h1 b { background: var(--truth); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--label2); margin: 0; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }
.code-input { text-align: center; letter-spacing: 8px; font-weight: 800; text-transform: uppercase; direction: ltr; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.how div { background: var(--card); border-radius: 18px; padding: 14px 8px; text-align: center; font-size: 13px; color: var(--label2); box-shadow: var(--shadow); }
.how div b { display: block; font-size: 26px; margin-bottom: 4px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; }
.topbar .title { flex: 1; font-weight: 800; font-size: 22px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); }
.chip.code { direction: ltr; letter-spacing: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); display: grid; place-items: center; font-size: 19px; box-shadow: var(--shadow); }
.icon-btn:active { transform: scale(.92); }

/* share */
.share { padding: 18px; text-align: center; }
.share .big-code { font-size: 46px; font-weight: 900; letter-spacing: 10px; direction: ltr; margin: 2px 0 6px; }
.share .qr { width: 168px; height: 168px; margin: 8px auto 6px; background: #fff; border-radius: 18px; padding: 10px; }
.share .qr svg { width: 100%; height: 100%; display: block; }
.share .url { color: var(--label2); font-size: 14px; direction: ltr; }

/* avatars */
.av { --c: var(--blue); width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: color-mix(in srgb, var(--c) 28%, var(--card)); box-shadow: inset 0 0 0 2.5px var(--c); position: relative; flex: none; }
.av.lg { width: 96px; height: 96px; font-size: 54px; box-shadow: inset 0 0 0 4px var(--c), 0 10px 30px color-mix(in srgb, var(--c) 45%, transparent); }
.av .dot { position: absolute; bottom: 1px; left: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--label3); border: 2.5px solid var(--card); }
.av .dot.on { background: var(--green); }
.av .crown { position: absolute; top: -12px; font-size: 18px; transform: rotate(-12deg); right: -4px; }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; padding: 14px; }
.ptile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: 16px; position: relative; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.ptile .nm { font-size: 14px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptile .me { font-size: 11px; color: var(--blue); font-weight: 700; margin-top: -4px; }
.ptile .kick { position: absolute; top: 0; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--fill); font-size: 12px; color: var(--label2); }
.ptile.mine { background: var(--fill); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* segmented control */
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; width: 100%; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 15px; font-weight: 600; color: var(--label); transition: background .2s; }
.seg button.on { background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
:root:not([data-theme="light"]) .seg button.on { background: #636366; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .seg button.on { background: #fff; } }
.seg.disabled { opacity: .6; pointer-events: none; }

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--fill); transition: background .25s; }
.switch span::after { content: ""; position: absolute; top: 2px; right: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15); transition: transform .25s cubic-bezier(.3,1.3,.5,1); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(-20px); }
.switch input:disabled + span { opacity: .5; }

/* players strip (in game) */
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 14px 6px 10px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.sp { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 58px; opacity: .72; transition: opacity .3s, transform .3s; }
.sp .av { width: 46px; height: 46px; font-size: 24px; }
.sp .nm { font-size: 12px; font-weight: 600; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp .sc { position: absolute; top: -6px; left: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--card); color: var(--label); font-size: 12px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.sp.cur { opacity: 1; transform: scale(1.12); }
.sp.cur .av { box-shadow: inset 0 0 0 3px var(--c), 0 0 0 3px var(--bg), 0 0 0 5.5px var(--c); }

/* stage */
.stage { margin-top: 8px; }
.turn-hd { text-align: center; margin: 10px 0 16px; }
.turn-hd .av { margin: 0 auto 10px; }
.turn-hd h2 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.3px; }
.turn-hd p { margin: 4px 0 0; color: var(--label2); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { border-radius: 26px; min-height: 170px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 30px; font-weight: 900; box-shadow: var(--shadow); transition: transform .15s; position: relative; overflow: hidden; }
.choice::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.25), transparent 50%); pointer-events: none; }
.choice small { font-size: 13px; font-weight: 600; opacity: .9; }
.choice .e { font-size: 44px; }
.choice:active { transform: scale(.95); }
.choice.truth { background: var(--truth); }
.choice.dare { background: var(--dare); }
.random-btn { margin-top: 12px; }

.waiting { text-align: center; padding: 22px; color: var(--label2); }
.dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; text-align: right; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }

.tcard { border-radius: 28px; padding: 22px 22px 26px; color: #fff; min-height: 250px; display: flex; flex-direction: column; box-shadow: var(--shadow), 0 20px 50px rgba(0,0,0,.2); position: relative; overflow: hidden; animation: flip .55s cubic-bezier(.2,1.2,.4,1); }
.tcard.truth { background: var(--truth); }
.tcard.dare { background: var(--dare); }
.tcard::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.12); top: -110px; left: -90px; }
.tcard .hd { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 18px; position: relative; }
.tcard .badge { background: rgba(255,255,255,.22); padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.tcard .txt { flex: 1; display: flex; align-items: center; font-size: 27px; font-weight: 800; line-height: 1.3; margin: 18px 0 12px; letter-spacing: -.2px; position: relative; text-wrap: balance; }
.tcard .who { display: flex; align-items: center; gap: 8px; font-weight: 700; opacity: .95; position: relative; }
@keyframes flip { from { transform: perspective(900px) rotateY(80deg) scale(.9); opacity: 0; } }

.actions { margin-top: 14px; }
.actions .btn-row { margin-top: 10px; }
.host-note { text-align: center; color: var(--label2); font-size: 13px; margin-top: 14px; }
.host-note button { color: var(--blue); font-weight: 600; font-size: 13px; }

.last { display: flex; align-items: center; gap: 10px; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 18px; padding: 10px 14px; box-shadow: var(--shadow); margin-bottom: 6px; animation: slide .4s ease; }
.last .grow { flex: 1; font-size: 15px; }
.last b { font-weight: 800; }
.last .pen { color: var(--orange); font-weight: 800; }
@keyframes slide { from { transform: translateY(-10px); opacity: 0; } }

/* reactions */
.reactbar { position: fixed; bottom: calc(var(--safe-b) + 12px); left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: var(--shadow), 0 0 0 .5px var(--sep); z-index: 20; max-width: calc(100vw - 24px); }
.reactbar button { width: 42px; height: 42px; border-radius: 50%; font-size: 24px; transition: transform .1s; }
.reactbar button:active { transform: scale(1.35); background: var(--fill); }
@media (max-width: 370px) { .reactbar button { width: 36px; height: 36px; font-size: 21px; } }
.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.floater { position: absolute; bottom: 70px; font-size: 40px; animation: floatUp 2.4s cubic-bezier(.2,.6,.4,1) forwards; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.4); opacity: 0; } 12% { opacity: 1; transform: translateY(-40px) scale(1.15); } 100% { transform: translateY(-70vh) translateX(var(--dx)) scale(.9) rotate(var(--rot)); opacity: 0; } }

/* spin overlay */
.spin { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); animation: fade .25s ease; padding: 20px; }
.spin.out { animation: fadeOut .35s ease forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: scale(1.04); } }
.ring { position: relative; width: min(84vw, 360px); height: min(84vw, 360px); }
.ring .av { position: absolute; transform: translate(-50%, -50%); transition: transform .3s, box-shadow .3s; }
.ring .av.win { transform: translate(-50%, -50%) scale(1.3); z-index: 2; box-shadow: inset 0 0 0 3px var(--c), 0 0 0 4px var(--bg), 0 0 0 8px var(--c), 0 0 40px var(--c); }
.ring .nm { position: absolute; transform: translate(-50%, 0); font-size: 12px; font-weight: 700; white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.bottle { position: absolute; left: 50%; top: 50%; width: 58px; height: 150px; margin: -75px 0 0 -29px; transition: transform 3s cubic-bezier(.15,.75,.2,1); filter: drop-shadow(0 12px 18px rgba(0,0,0,.35)); }
.spin .caption { margin-top: 26px; font-size: 26px; font-weight: 900; min-height: 36px; text-align: center; }
.spin .caption.pop { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
.spin .last { max-width: 420px; width: 100%; margin-bottom: 22px; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.4); animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 14px 14px 0 0; padding: 8px 16px calc(var(--safe-b) + 20px); animation: up .35s cubic-bezier(.2,1,.3,1); }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--label3); margin: 0 auto 10px; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet .sh h3 { margin: 0; font-size: 20px; font-weight: 800; }
.sheet textarea { width: 100%; min-height: 110px; border: 0; outline: 0; resize: none; background: var(--card); color: var(--label); border-radius: 16px; padding: 14px; font: inherit; font-size: 17px; }
@keyframes up { from { transform: translateY(100%); } }

.score-row .rank { width: 26px; text-align: center; font-weight: 800; color: var(--label2); }
.score-row .pts { font-size: 22px; font-weight: 900; }
.score-row .stats { font-size: 12px; color: var(--label2); }

/* end */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 26px 0 18px; }
.podium .col { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; }
.podium .base { width: 100%; border-radius: 16px 16px 6px 6px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 28px; font-weight: 900; box-shadow: var(--shadow); }
.podium .nm { font-weight: 700; font-size: 14px; }
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.award { background: var(--card); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.award .t { font-size: 13px; color: var(--label2); }
.award .n { font-weight: 800; font-size: 17px; margin-top: 4px; }

/* misc */
.net { position: fixed; top: calc(var(--safe-t) + 8px); left: 50%; transform: translateX(-50%); z-index: 90; background: var(--orange); color: #000; font-weight: 700; font-size: 14px; padding: 6px 14px; border-radius: 99px; box-shadow: var(--shadow); }
.toast { position: fixed; top: calc(var(--safe-t) + 14px); left: 50%; transform: translateX(-50%); z-index: 95; background: var(--glass); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); padding: 12px 18px; border-radius: 16px; font-weight: 600; box-shadow: var(--shadow), 0 0 0 .5px var(--sep); max-width: calc(100vw - 32px); text-align: center; animation: slide .3s ease; }
.err { color: var(--red); font-size: 14px; margin: 8px 16px 0; }
.ios-hint { margin-top: 18px; text-align: center; font-size: 13px; color: var(--label2); }
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 80; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
