:root {
  --bg: #fbf6f4;
  --surface: #ffffff;
  --text: #241a1e;
  --muted: #7a6a70;
  --line: #ecdfe2;
  --accent: #b0244f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe5ec;
  --yes: #1f8a5b;
  --yes-soft: #e1f4ea;
  --no: #6f6a6c;
  --no-soft: #efeced;
  --warn: #b25b00;
  --vote-yes: #2e9e6a;
  --vote-no: #e0564f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 20, 35, .06), 0 6px 24px rgba(60, 20, 35, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161114;
    --surface: #211a1e;
    --text: #f4ecef;
    --muted: #a8979e;
    --line: #362b30;
    --accent: #e8507e;
    --accent-ink: #1a0910;
    --accent-soft: #3a1c27;
    --yes: #4cc98f;
    --yes-soft: #17352a;
    --no: #b3a9ad;
    --no-soft: #2c2427;
    --warn: #f0a050;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  min-height: 100dvh;
}
main.wide { max-width: 980px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 28px; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 20px; border-radius: 20px; }
.btn.danger { color: #c0392b; border-color: currentColor; background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.link { border: 0; background: none; color: var(--muted); font-weight: 500; text-decoration: underline; min-height: 40px; }

/* Home */
.hero { min-height: calc(100dvh - 48px); display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 20px; }
.hero .logo { font-size: 64px; line-height: 1; }
.hero h1 { font-size: 36px; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 14px; font-weight: 600; background: var(--no-soft); color: var(--muted); }
.pill.live { background: var(--yes-soft); color: var(--yes); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 4px; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=password] {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 48px;
}
input:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  margin: 0; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); cursor: pointer; font-weight: 600; min-height: 48px;
}
.seg input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + label { outline: 3px solid var(--accent-soft); }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.error { color: #c0392b; font-weight: 600; font-size: 14px; min-height: 1em; margin-bottom: 8px; }

.selfie { display: flex; align-items: center; gap: 14px; }
.selfie .preview {
  width: 88px; height: 88px; border-radius: 50%; flex: none; background: var(--bg) center/cover;
  border: 2px dashed var(--line); display: grid; place-items: center; font-size: 30px; color: var(--muted);
}
.selfie .preview.has { border-style: solid; border-color: var(--accent); font-size: 0; }
.selfie input[type=file] { display: none; }

/* Avatars & people */
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--no-soft); flex: none; }
.avatar.lg { width: 120px; height: 120px; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.avatar.xl { width: 160px; height: 160px; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; } /* min-width: 0 lets long names end in “…” */
.person .who { min-width: 0; flex: 1; }
.person .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Round screen */
.round { text-align: center; }
.round .table-no { font-size: 15px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.round .partner-name { font-size: 32px; font-weight: 800; margin: 10px 0 4px; }
.timer { font-variant-numeric: tabular-nums; font-size: 44px; font-weight: 800; letter-spacing: -.02em; }
.timer.urgent { color: var(--accent); }
.vote { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.vote .btn { min-height: 72px; font-size: 22px; border-width: 2px; }
/* Vote buttons: both neutral until you vote; then the chosen one is filled
   (green YES / red NO, white text) and the other one looks inactive. */
.vote .btn { transition: background .15s, opacity .15s, border-color .15s; }
.vote .yes.on { background: var(--vote-yes); border-color: var(--vote-yes); color: #fff; }
.vote .no.on { background: var(--vote-no); border-color: var(--vote-no); color: #fff; }
.vote.has-vote .btn:not(.on) { opacity: .4; background: var(--no-soft); border-color: var(--no-soft); color: var(--muted); }

/* Dashboard */
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); }
.hist-item.match { border-color: var(--yes); background: var(--yes-soft); }
.tag { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--no-soft); color: var(--muted); white-space: nowrap; }
.tag.yes { background: var(--yes-soft); color: var(--yes); }
.tag.no { background: var(--no-soft); color: var(--no); }
.votes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.contact { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--yes); display: grid; gap: 4px; font-size: 15px; }
.contact a { color: inherit; font-weight: 700; word-break: break-all; }

/* Admin */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid2 { display: grid; gap: 14px; }
.grid2 > * { min-width: 0; } /* columns may shrink below their content (long names) */
@media (min-width: 820px) { .grid2 { grid-template-columns: 1.1fr .9fr; align-items: start; } }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--bg); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat.hl { background: var(--accent-soft); }
.stat.hl .v { color: var(--accent); }
.pairs { display: grid; gap: 8px; }
.pair { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 15px; }
.pair .t { font-weight: 800; color: var(--accent); min-width: 34px; }
.plist { display: grid; gap: 8px; }
.plist .person { padding: 8px; border-radius: 12px; background: var(--bg); }
.gender { font-size: 12px; font-weight: 700; color: var(--muted); }
details summary { cursor: pointer; font-weight: 700; padding: 4px 0; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600;
  transition: transform .25s ease, visibility .25s; visibility: hidden; max-width: calc(100% - 32px); z-index: 10; text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }

/* Sign-up notice */
.notice { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.notice.strong { border: 2px solid var(--accent); }

/* Social network picker inside the input */
.social-input {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; min-height: 48px;
}
.social-input:focus-within { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.social-input input[type=text] { border: 0; background: transparent; padding: 8px 6px 8px 0; min-height: 38px; min-width: 0; flex: 1; outline: none; }
.social-input .at { color: var(--muted); font-weight: 600; padding-left: 6px; }
.net { display: flex; gap: 4px; flex: none; }
.net input { position: absolute; opacity: 0; pointer-events: none; }
.net label { margin: 0; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; cursor: pointer; opacity: .35; filter: grayscale(1); transition: opacity .15s, filter .15s; }
.net input:checked + label { opacity: 1; filter: none; background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.net input:focus-visible + label { outline: 3px solid var(--accent-soft); }
.net-icon { display: inline-block; vertical-align: -3px; flex: none; }
.social-link { display: inline-flex; align-items: center; gap: 5px; color: inherit; font-weight: 700; text-decoration: none; }
.social-link span { text-decoration: underline; }
.tag.na { background: transparent; border: 1px dashed var(--line); }

/* QR dialog */
.qr-dialog { border: 0; border-radius: 22px; padding: 22px; width: min(380px, calc(100% - 32px)); background: var(--surface); color: var(--text); }
.qr-dialog::backdrop { background: rgba(20, 8, 14, .55); }
.qr { background: #fff; padding: 12px; border-radius: 16px; width: min(260px, 100%); margin: 8px auto 10px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-url { display: block; word-break: break-all; color: var(--muted); }

/* Missing votes */
.pending-list { display: grid; gap: 10px; }
.pending-item { border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: grid; gap: 8px; }
.pending-item .person { gap: 10px; }
.mini-vote { display: flex; gap: 6px; flex: none; }
.mini-vote .btn.small { min-height: 38px; padding: 6px 10px; }
.mini-vote .on-yes { background: var(--yes); border-color: var(--yes); color: #fff; }
.mini-vote .on-yes { background: var(--vote-yes); border-color: var(--vote-yes); }
.mini-vote .on-no { background: var(--vote-no); border-color: var(--vote-no); color: #fff; }

/* Results table */
.votes-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.votes-table th, .votes-table td { padding: 8px; text-align: center; border-bottom: 1px solid var(--line); }
.votes-table thead th { font-size: 13px; color: var(--muted); }
.votes-table tbody th { text-align: left; font-weight: 600; }
.votes-table td { font-size: 20px; font-weight: 800; }

/* Paused round */
.pill.paused { background: #fff1d6; color: #8a5300; margin: 8px 0 4px; }
@media (prefers-color-scheme: dark) { .pill.paused { background: #3a2a10; color: #f0b050; } }
.frozen { opacity: .55; }
.sound-toggle { font-size: 18px; min-width: 44px; }

/* Phone number with country code */
.phone-input { display: flex; gap: 8px; }
.phone-input input { flex: 1; min-width: 0; }
.cc-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 48px; cursor: pointer;
}
.cc-btn:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.cc-flag { font-size: 22px; line-height: 1; }
.cc-caret { color: var(--muted); font-size: 12px; }
.cc-dialog {
  border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text);
  width: min(440px, calc(100% - 24px)); height: min(640px, 85dvh); overflow: hidden;
}
.cc-dialog[open] { display: flex; flex-direction: column; }
.cc-dialog::backdrop { background: rgba(20, 8, 14, .55); }
.cc-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.cc-head input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px;
}
.cc-list { overflow-y: auto; flex: 1; padding: 6px; -webkit-overflow-scrolling: touch; }
.cc-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: none; border: 0; border-radius: 10px; padding: 10px 12px; min-height: 48px; cursor: pointer;
}
.cc-item:hover, .cc-item:focus-visible { background: var(--bg); outline: none; }
.cc-item.on { background: var(--accent-soft); }
.cc-name { flex: 1; }
.cc-dial { color: var(--muted); font-variant-numeric: tabular-nums; }
.wa-link { color: #1a9e55 !important; }

/* Language switch (EN | ES) */
.lang-switch { display: inline-flex; flex: none; background: var(--no-soft); border-radius: 99px; padding: 3px; gap: 2px; }
.lang-switch button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  min-width: 40px; min-height: 32px; padding: 0 10px; border-radius: 99px; cursor: pointer; letter-spacing: .03em;
}
.lang-switch button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.lang-switch button:focus-visible { outline: 3px solid var(--accent-soft); }
.lang-corner { display: flex; justify-content: flex-end; }
.lang-corner + .hero { min-height: calc(100dvh - 92px); }

/* Long names: show them in full (wrapping) in the participant's top bar and the organizer's list;
   on narrow phones the language/sound buttons move below the name. */
.topbar .me-card { flex: 1 1 200px; }
.me-card .who b, .plist .who b { white-space: normal; overflow-wrap: break-word; }
.plist .person { flex-wrap: wrap; }
.plist .person .who { flex: 1 1 150px; }
.plist .actions { display: flex; gap: 8px; margin-left: auto; }

/* Round phases */
.go-to-table { font-size: 26px; margin: 14px 0 12px; }
.result-match { border-color: var(--yes); background: var(--yes-soft); }

/* Event settings form */
.settings-row { align-items: flex-start; }
.settings-row .field { flex: 1 1 120px; margin-bottom: 12px; }
