:root {
  --bg: #f7f2ea;
  --card: #fffdf9;
  --ink: #4b4a54;
  --muted: #8d8996;
  --line: #ebe4d8;
  --past: #dcd5ef;   --past-ink: #5b5082;
  --present: #d2e5d5; --present-ink: #3f6450;
  --future: #f6dfca; --future-ink: #8a5a38;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(60rem 40rem at 10% -10%, #fbe9e4 0%, transparent 60%),
    radial-gradient(50rem 40rem at 110% 10%, #e5eef3 0%, transparent 55%),
    radial-gradient(50rem 40rem at 50% 120%, #ecf2e6 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: .01em; margin: 0; }
.dots { color: var(--muted); padding: 0 .35em; }
button { font: inherit; color: inherit; }

.avatar {
  --size: 3rem;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: calc(var(--size) * .46);
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 4px 12px rgba(90, 80, 70, .10);
  user-select: none;
  flex: none;
}

.icon { width: 1.6rem; height: 1.6rem; flex: none; }
.past { --tint: var(--past); --tint-ink: var(--past-ink); }
.present { --tint: var(--present); --tint-ink: var(--present-ink); }
.future { --tint: var(--future); --tint-ink: var(--future-ink); }

@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Join (phone) ---------- */
.join { min-height: 100%; display: grid; place-items: center; padding: 1.5rem 1.1rem 2.5rem; }
.sheet {
  width: min(26rem, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  padding: 2rem 1.5rem 1.6rem;
  box-shadow: 0 18px 50px -20px rgba(90, 80, 70, .25);
  animation: fade .4s ease;
}
.sheet h1 { font-size: 1.55rem; text-align: center; }
.sub { text-align: center; color: var(--muted); margin: .5rem 0 1.6rem; font-size: .98rem; }
.step[hidden] { display: none; }
label.field { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .45rem; }
input.name {
  width: 100%; font: inherit; font-size: 1.15rem;
  padding: .85rem 1rem; border-radius: .9rem;
  border: 1px solid var(--line); background: #fbf8f3; color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
input.name:focus { border-color: #d8cdbd; box-shadow: 0 0 0 4px #f1ebe1; }
.primary {
  width: 100%; margin-top: 1rem; padding: .9rem 1rem;
  border: 0; border-radius: .9rem; cursor: pointer;
  background: #5d5a66; color: #fdfbf7; font-size: 1.05rem;
  transition: transform .15s, opacity .2s;
}
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .5; cursor: default; }
.error { color: #a0574e; font-size: .9rem; min-height: 1.3em; margin: .6rem 0 0; text-align: center; }

.me { display: flex; flex-direction: column; align-items: center; gap: .7rem; margin-bottom: 1.4rem; }
.me .avatar { --size: 5.2rem; animation: rise .5s ease, breathe 5s ease-in-out 1s infinite; }
.me h2 { font-size: 1.35rem; }
.prompt { text-align: center; color: var(--muted); margin: 0 0 1rem; }
.choices { display: grid; gap: .7rem; }
.choice {
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.1rem; border-radius: 1.1rem; cursor: pointer;
  border: 1.5px solid transparent; background: color-mix(in srgb, var(--tint) 55%, white);
  color: var(--tint-ink); text-align: left;
  transition: transform .15s, border-color .2s, background .2s, box-shadow .2s;
}
.choice:active { transform: scale(.985); }
.choice .label { font-family: var(--serif); font-size: 1.2rem; }
.choice .hint { display: block; font-size: .85rem; opacity: .75; margin-top: .1rem; font-family: var(--sans); }
.choice .tick { margin-left: auto; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1.5px solid currentColor; opacity: .35; display: grid; place-items: center; transition: opacity .2s, background .2s; }
.choice[aria-pressed="true"] { background: var(--tint); border-color: color-mix(in srgb, var(--tint-ink) 35%, transparent); box-shadow: 0 8px 22px -12px var(--tint-ink); }
.choice[aria-pressed="true"] .tick { opacity: 1; background: var(--tint-ink); color: var(--card); }
.note { text-align: center; color: var(--muted); font-size: .88rem; margin: 1.1rem 0 0; min-height: 1.3em; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; display: block; margin: 1.2rem auto 0; font-size: .85rem; }

/* ---------- Presenter ---------- */
.stage { min-height: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2rem; padding: 2.2rem 2.6rem 2rem; }
.stage.no-qr { grid-template-columns: 1fr; }
.stage.no-qr .qr { display: none; }
.main { display: flex; flex-direction: column; gap: 1.4rem; min-width: 0; }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.top h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.counts { color: var(--muted); font-size: 1.05rem; }
.question { margin: -.6rem 0 0; font-family: var(--serif); font-size: clamp(1.1rem, 1.8vw, 1.5rem); color: var(--muted); font-style: italic; }
.columns { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; min-height: 14rem; }
.column {
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--tint) 45%, var(--card));
  border: 1px solid color-mix(in srgb, var(--tint) 80%, white);
  border-radius: 1.6rem; padding: 1.3rem 1.2rem 1.2rem;
  color: var(--tint-ink);
}
.column header { display: flex; align-items: center; gap: .6rem; }
.column h2 { font-size: clamp(1.3rem, 2vw, 1.8rem); }
.column .num { margin-left: auto; font-family: var(--serif); font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1; }
.column .pct { font-size: .9rem; opacity: .7; margin: .15rem 0 0; text-align: right; min-height: 1.2em; }
.crowd { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .9rem .7rem; margin-top: 1rem; }
.person { display: flex; flex-direction: column; align-items: center; gap: .3rem; width: 4.4rem; animation: rise .45s ease both; }
.person .avatar { --size: 3.2rem; }
.person span { font-size: .78rem; color: var(--ink); opacity: .75; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: currentColor; opacity: .45; font-size: .95rem; font-style: italic; margin: auto; text-align: center; }

.bar { position: relative; display: flex; height: clamp(5rem, 13vh, 8rem); border-radius: 1.6rem; overflow: hidden; background: #efe9df; box-shadow: 0 14px 40px -24px rgba(90, 80, 70, .35); flex: none; }
.bar > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; overflow: hidden; white-space: nowrap; width: 0; color: var(--tint-ink); transition: width .8s cubic-bezier(.2,.7,.2,1); }
.bar .past { background: var(--past); } .bar .present { background: var(--present); } .bar .future { background: var(--future); }
.seg-pct { font-family: var(--serif); font-size: clamp(1.8rem, 3.6vw, 3.2rem); line-height: 1; }
.seg-label { font-size: clamp(.8rem, 1.1vw, 1rem); letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.bar > div.narrow .seg-label { display: none; }
.bar > div.narrow .seg-pct { font-size: clamp(1rem, 1.6vw, 1.4rem); }
.bar-empty { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; color: var(--muted); font-style: italic; }
.bar-empty[hidden] { display: none; }
.waiting { display: flex; align-items: center; gap: .8rem; min-height: 2.6rem; color: var(--muted); font-size: .95rem; }
.waiting .crowd { flex: none; margin: 0; gap: .4rem; }
.waiting .person { width: auto; }
.waiting .person .avatar { --size: 2.1rem; opacity: .8; }
.waiting .person span { display: none; }

.qr {
  align-self: start; width: 17rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 1.6rem;
  padding: 1.4rem 1.4rem 1.2rem; text-align: center;
  box-shadow: 0 18px 50px -24px rgba(90, 80, 70, .3);
}
.qr h3 { font-size: 1.3rem; }
.qr img { display: block; width: 100%; aspect-ratio: 1; margin: 1rem 0 .2rem; background: #fff; border-radius: 1rem; padding: .6rem; }
.tools { position: fixed; right: 1rem; bottom: .8rem; display: flex; gap: .4rem; opacity: .35; transition: opacity .2s; }
.tools:hover { opacity: 1; }
.tools button { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-size: .8rem; cursor: pointer; color: var(--muted); }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; padding: 1.4rem; }
  .qr { order: -1; width: 100%; max-width: 20rem; justify-self: center; }
  .columns { grid-template-columns: 1fr; }
}
