:root {
  --bg: #0a0a1a;
  --bg2: #15153a;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.3);
  --coral: #ff6b6b;
  --coral2: #ee5a24;
  --teal: #4ecdc4;
  --teal2: #3fb3a3;
  --gold: #ffe66d;
  --radius: 22px;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 55%, var(--bg) 100%) fixed;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
.bg-glow {
  position: fixed; inset: -20%; pointer-events: none; z-index: -1;
  background:
    radial-gradient(40% 30% at 20% 15%, rgba(255, 107, 107, 0.16), transparent 70%),
    radial-gradient(35% 30% at 85% 80%, rgba(78, 205, 196, 0.14), transparent 70%);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(3%, -2%) scale(1.05); } }

#app {
  max-width: 480px; margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.center-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; }
.brand { text-align: center; margin: 24px 0 28px; }
.brand .logo { font-size: 56px; animation: bob 3s ease-in-out infinite; display: inline-block; }
.brand h1 {
  font-size: 44px; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--gold), var(--coral));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand p { color: var(--muted); letter-spacing: 1px; margin-top: 6px; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }

.panel {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 22px 20px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both;
}
.panel + .panel { margin-top: 14px; }
.panel.teal { background: rgba(78, 205, 196, .06); border-color: rgba(78, 205, 196, .2); }
.panel.coral { background: rgba(255, 107, 107, .06); border-color: rgba(255, 107, 107, .2); }
.panel h3 { font-size: 19px; margin-bottom: 4px; }
.panel.teal h3 { color: var(--teal); }
.panel.coral h3 { color: var(--coral); }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; line-height: 1.45; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 11px; color: var(--muted); letter-spacing: 1.2px;
  text-transform: uppercase; margin-bottom: 7px;
}
input[type=text], input[type=url] {
  width: 100%; padding: 14px 16px; border-radius: 14px; font: inherit;
  font-size: 16px; /* 16px prevents iOS zoom */
  color: var(--text); background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .12);
  transition: border-color .2s, box-shadow .2s;
}
input:focus { outline: none; border-color: rgba(78, 205, 196, .6); box-shadow: 0 0 0 3px rgba(78, 205, 196, .15); }
input::placeholder { color: var(--faint); }
input.code { text-align: center; letter-spacing: 8px; text-transform: uppercase; font-size: 20px; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 14px 18px; border: none; border-radius: 16px;
  font: 600 16px var(--sans); color: #fff; cursor: pointer; text-decoration: none;
  transition: transform .15s, filter .2s, opacity .2s, box-shadow .2s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.teal { background: linear-gradient(135deg, var(--teal), var(--teal2)); box-shadow: 0 6px 22px rgba(78, 205, 196, .25); }
.btn.coral { background: linear-gradient(135deg, var(--coral), var(--coral2)); box-shadow: 0 6px 22px rgba(255, 107, 107, .25); }
.btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--card-border); color: var(--muted); }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 12px; }
.btn + .btn { margin-top: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row .btn + .btn { margin-top: 0; }

.divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; color: var(--faint); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255, 255, 255, .08); }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.topbar .mini-brand { font-family: var(--serif); font-size: 20px; background: linear-gradient(135deg, var(--gold), var(--coral)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.code-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .06); border: 1px solid var(--card-border); padding: 6px 12px; border-radius: 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.code-pill b { color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; font-size: 15px; }
.sub { color: var(--muted); font-size: 12px; }

/* Lobby */
.big-code { text-align: center; margin: 6px 0 14px; }
.big-code b { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 40px; letter-spacing: 10px; color: var(--gold); text-shadow: 0 0 24px rgba(255, 230, 109, .3); }
.members { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid var(--card-border); font-size: 13px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.chip.voted { border-color: rgba(78, 205, 196, .5); }
.chip.waiting { opacity: .55; }
.chip.waiting .dot { background: var(--faint); box-shadow: none; animation: pulse 1.2s infinite; }
.chip .crown { font-size: 12px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes pulse { 50% { opacity: .3; } }

.seg { display: flex; background: rgba(0, 0, 0, .3); border-radius: 14px; padding: 4px; border: 1px solid var(--card-border); }
.seg button { flex: 1; min-height: 44px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font: 600 14px var(--sans); cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: linear-gradient(135deg, var(--teal), var(--teal2)); color: #fff; }

/* Swipe card */
.progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--faint); margin-bottom: 12px; }
.progress .bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .4s; }

.card-stage { position: relative; flex: 1; min-height: 360px; display: flex; flex-direction: column; }
.rcard {
  position: relative; background: linear-gradient(160deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .025));
  border: 1px solid var(--card-border); border-radius: 26px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4); touch-action: pan-y; user-select: none; -webkit-user-select: none;
  animation: cardIn .45s cubic-bezier(.2, .9, .3, 1.1) both; will-change: transform;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(.94); } }
.rcard.fly-right { transition: transform .4s ease-in, opacity .4s; transform: translateX(140%) rotate(22deg) !important; opacity: 0; }
.rcard.fly-left { transition: transform .4s ease-in, opacity .4s; transform: translateX(-140%) rotate(-22deg) !important; opacity: 0; }
.rcard .hero { height: 170px; display: flex; align-items: center; justify-content: center; font-size: 88px; position: relative; }
.rcard .hero::after { content: ''; position: absolute; inset: auto 0 0 0; height: 60px; background: linear-gradient(transparent, rgba(10, 10, 26, .35)); }
.rcard .body { padding: 18px 22px 22px; }
.rcard h2 { font-size: 27px; margin-bottom: 4px; }
.rcard .cuisine { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 13px; padding: 6px 12px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: rgba(255, 255, 255, .8); }
.tag.gold { color: var(--gold); }
.tag.teal { color: var(--teal); }
.rcard .addr { color: var(--faint); font-size: 12px; margin-top: 14px; line-height: 1.4; }
.stamp { position: absolute; top: 22px; padding: 6px 14px; border: 3px solid; border-radius: 10px; font: 800 26px var(--sans); letter-spacing: 2px; opacity: 0; transform: rotate(-14deg); z-index: 2; pointer-events: none; }
.stamp.yes { left: 18px; color: var(--teal); border-color: var(--teal); }
.stamp.no { right: 18px; color: var(--coral); border-color: var(--coral); transform: rotate(14deg); }

.vote-row { display: flex; gap: 14px; margin-top: 18px; }
.vote-btn { flex: 1; min-height: 62px; border-radius: 20px; font: 700 17px var(--sans); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s, background .2s; touch-action: manipulation; }
.vote-btn:active { transform: scale(.94); }
.vote-btn.no { background: rgba(255, 107, 107, .1); border: 1.5px solid rgba(255, 107, 107, .4); color: var(--coral); }
.vote-btn.yes { background: rgba(78, 205, 196, .1); border: 1.5px solid rgba(78, 205, 196, .4); color: var(--teal); }
.vote-btn span { font-size: 24px; }

.waiting-box { text-align: center; padding: 18px; margin-top: 16px; border-radius: 18px; background: rgba(255, 255, 255, .04); border: 1px dashed var(--card-border); color: var(--muted); font-size: 14px; }
.waiting-box .members { justify-content: center; }
.rule-note { text-align: center; font-size: 12px; color: var(--faint); margin-top: 12px; }

/* Match */
.match-title { text-align: center; margin: 10px 0 18px; }
.match-title .big { font-size: 64px; display: block; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.match-title h2 { font-size: 32px; color: var(--gold); letter-spacing: 2px; text-shadow: 0 0 30px rgba(255, 230, 109, .35); }
.match-title p { color: var(--muted); margin-top: 6px; }
.order-links { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 6px 0 4px; }
.order-link { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid var(--card-border); color: #fff; text-decoration: none; font-weight: 600; transition: background .2s, transform .15s; }
.order-link:active { transform: scale(.98); }
.order-link:hover { background: rgba(255, 255, 255, .1); }
.order-link.doordash { border-left: 4px solid #ff3008; }
.order-link.ubereats { border-left: 4px solid #06c167; }
.order-link.grubhub { border-left: 4px solid #f63440; }
.steps { color: var(--muted); font-size: 13px; line-height: 1.6; padding-left: 18px; margin-bottom: 14px; }
.group-link { display: block; text-align: center; padding: 18px; border-radius: 18px; background: linear-gradient(135deg, rgba(78, 205, 196, .2), rgba(255, 230, 109, .15)); border: 1px solid rgba(78, 205, 196, .5); color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 28px rgba(78, 205, 196, .35); } }

.picks .pick { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border); margin-bottom: 8px; }
.picks .pick .e { font-size: 28px; }
.picks .pick .n { flex: 1; min-width: 0; }
.picks .pick .n b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picks .pick .n small { color: var(--muted); }

.banner { font-size: 12px; text-align: center; padding: 8px 12px; border-radius: 12px; margin-bottom: 12px; background: rgba(255, 230, 109, .08); color: var(--gold); border: 1px solid rgba(255, 230, 109, .2); }
.error { color: var(--coral); font-size: 13px; margin: -4px 0 12px; }
.footer { text-align: center; color: var(--faint); font-size: 11px; margin-top: auto; padding-top: 24px; }
.footer a { color: var(--muted); }
.linklike { background: none; border: none; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 120px); background: rgba(20, 20, 45, .95); border: 1px solid var(--card-border); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2); z-index: 1000; max-width: 90vw; text-align: center; }
#toast.show { transform: translate(-50%, 0); }

.spinner { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .1); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti i { position: absolute; top: -12px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

@media (min-width: 520px) { #app { padding-top: 40px; } }
@media (max-height: 680px) { .rcard .hero { height: 120px; font-size: 64px; } .brand { margin: 8px 0 16px; } .brand .logo { font-size: 42px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
