:root {
  --bg1: #3a0f7a;
  --bg2: #12032b;
  --ink: #fff;
  --muted: #c9b8ef;
  --yellow: #ffd23f;
  --yellow-d: #c99a00;
  --pink: #ff4f9a;
  --pink-d: #b8236a;
  --teal: #2ee6c5;
  --red: #ff4757;
  --panel: rgba(255, 255, 255, .08);
  --radius: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg2); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 600 17px/1.4 ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg1), var(--bg2)) fixed;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, h3 { margin: 0; font-weight: 900; }
h1 { font-size: 56px; letter-spacing: -1px; text-shadow: 0 4px 0 var(--pink-d); }
h2 { font-size: 26px; }
h3 { font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
p { margin: 0; }

.center { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.label { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: .5px; }

header { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.back {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--panel); color: var(--ink); font-size: 22px; font-weight: 900;
}
.step { margin-inline-start: auto; color: var(--muted); }
.step b { color: var(--yellow); letter-spacing: 2px; }

.hero { text-align: center; padding: 32px 0 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.hero p { color: var(--muted); max-width: 320px; }
.logo { font-size: 84px; line-height: 1; animation: bob 3s ease-in-out infinite; }

.btn {
  width: 100%; border: 0; border-radius: var(--radius);
  padding: 18px; font: inherit; font-size: 20px; font-weight: 900;
  color: #2a0b4d; background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-d);
  transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--yellow-d); }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 6px 0 var(--pink-d); }
.btn.pink:active:not(:disabled) { box-shadow: 0 2px 0 var(--pink-d); }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: none; }
.btn.small { width: auto; padding: 10px 18px; font-size: 16px; }
.btn:disabled { opacity: .4; }
.btn.danger { color: var(--red); }
.invisible { visibility: hidden; }

.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.how summary { font-weight: 900; cursor: pointer; }
.how p { color: var(--muted); margin-top: 8px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid rgba(255, 255, 255, .2); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 15px;
}
.chip.on { background: var(--teal); border-color: var(--teal); color: #08332c; }
.chip:disabled { opacity: .7; }
.chip.edit { border-style: dashed; }
.langs { display: flex; justify-content: center; gap: 8px; }

.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--yellow); color: #2a0b4d; font-size: 22px; font-weight: 900;
}
.stepper button:disabled { opacity: .4; }
.stepper b { font-size: 24px; min-width: 1ch; text-align: center; }

.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 54px; height: 32px; border-radius: 99px; background: rgba(255, 255, 255, .2); position: relative; flex: none; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--teal); }
.toggle input:checked + span::after { transform: translateX(22px); }
.toggle input:focus-visible + span { outline: 3px solid var(--yellow); }
.toggle input:disabled + span { opacity: .6; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plist li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-radius: 14px; padding: 10px 10px 10px 16px; min-height: 52px;
}
.plist li.away { opacity: .45; }
.plist em { font-style: normal; font-size: 13px; color: var(--yellow); margin-inline-start: 8px; }
.plist button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: var(--ink); font-size: 16px; }

.add { display: flex; gap: 8px; }
.plist .link { flex: 1; width: auto; height: auto; border-radius: 0; background: none; text-align: start; font: inherit; display: flex; justify-content: space-between; }
.emoji-lg { font-size: 32px; }
.title-input { font-weight: 900; font-size: 22px !important; padding: 8px 12px !important; }
[dir=rtl] .back, [dir=rtl] .plist .link span:last-child { transform: scaleX(-1); }
input:not([type=checkbox]) {
  width: 100%; font: inherit; font-size: 18px; color: var(--ink);
  background: rgba(0, 0, 0, .25); border: 2px solid rgba(255, 255, 255, .15); border-radius: 14px; padding: 14px;
}
input:focus { outline: none; border-color: var(--teal); }
.stack label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 26px !important; text-align: center; }

.big-name { font-size: 40px; font-weight: 900; color: var(--yellow); word-break: break-word; }

/* Role card: a 3D flip so the word is hidden until tapped. */
.card {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 52dvh;
  border: 0; padding: 0; background: none; font: inherit; color: inherit;
  perspective: 1200px;
}
.face {
  position: absolute; inset: 0; border-radius: 28px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px;
  transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); box-shadow: 0 10px 0 rgba(0, 0, 0, .3);
}
.front { background: linear-gradient(145deg, var(--pink), #7b2ff7); font-size: 20px; }
.front .q { font-size: 120px; font-weight: 900; line-height: 1; text-shadow: 0 6px 0 rgba(0, 0, 0, .2); }
.backface { background: #fff; color: #2a0b4d; transform: rotateY(180deg); text-align: center; }
.backface.imp { background: var(--red); color: #fff; }
.card.open .front { transform: rotateY(-180deg); }
.card.open .backface { transform: rotateY(0); }
.backface strong { font-size: 30px; font-weight: 900; }
.backface .word { font-size: 44px; word-break: break-word; }
.backface .emoji { font-size: 64px; }
.backface small { opacity: .7; font-size: 15px; }
.backface .hide { position: absolute; bottom: 16px; }
.pill { background: rgba(0, 0, 0, .1); border-radius: 999px; padding: 6px 14px; font-size: 15px; }
.imp .pill { background: rgba(0, 0, 0, .2); }

.imp-names { display: flex; flex-direction: column; gap: 6px; font-size: 34px; font-weight: 900; color: var(--red); text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.big-word { font-size: 40px; font-weight: 900; color: var(--teal); }

.invite { flex-direction: row; align-items: center; }
.qr { width: 140px; flex: none; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
.invite > div:last-child { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.code { font-size: 36px; font-weight: 900; letter-spacing: 4px; color: var(--yellow); }

.banner { background: var(--pink); border-radius: 12px; padding: 8px; text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 120px);
  background: var(--teal); color: #08332c; padding: 12px 20px; border-radius: 999px; font-weight: 900; transition: transform .3s, opacity .3s; opacity: 0; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

.pop { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.center .chips { justify-content: center; }
.timer { font-size: 72px; font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; }
.plist li.on { outline: 3px solid var(--teal); }
