/* True Sync — "Aurora" theme
   Deep midnight-blue base (trust) with slow-drifting washes of color
   (warm gold, teal, violet) behind everything. Every tappable choice sits
   on a solid, constant surface so text stays readable while the
   background breathes. Respects prefers-reduced-motion. */
:root {
  --bg0: #070b16;
  --bg: #0b1120;
  --surface: rgba(15, 22, 40, 0.96);   /* constant card surface */
  --surface2: #141c33;                 /* constant input surface */
  --ink: #f4efe6;                      /* warm white */
  --muted: #9aa3b8;
  --gold: #d9a441;
  --gold-deep: #b97f2e;
  --gold-ink: #241a06;
  --trust: #5b8def;
  --teal: #3fa796;
  --violet: #8a6fd1;
  --line: rgba(150, 170, 220, 0.16);
  --l1: #6fa8dc;
  --l2: #58b368;
  --l3: #e8a13c;
  --l4: #e0586a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg0);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
/* --- aurora layer 1: slow drift --- */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(42% 38% at 18% 22%, rgba(91, 141, 239, 0.30), transparent 70%),
    radial-gradient(46% 42% at 82% 18%, rgba(138, 111, 209, 0.26), transparent 70%),
    radial-gradient(50% 44% at 72% 82%, rgba(217, 164, 65, 0.22), transparent 70%),
    radial-gradient(44% 40% at 22% 78%, rgba(63, 167, 150, 0.26), transparent 70%),
    var(--bg0);
  filter: blur(12px) saturate(1.08);
  animation: aurora-drift 80s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes aurora-drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%  { transform: translate3d(2%, 2%, 0) scale(1.06); }
  100% { transform: translate3d(-1%, 2%, 0) scale(1.03); }
}
/* --- aurora layer 2: slow breathe, independent timing --- */
body::after {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(36% 32% at 60% 40%, rgba(217, 164, 65, 0.14), transparent 70%),
    radial-gradient(40% 36% at 35% 62%, rgba(91, 141, 239, 0.16), transparent 70%);
  filter: blur(26px);
  animation: aurora-breathe 58s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes aurora-breathe {
  from { opacity: 0.5; transform: translate3d(1%, -1%, 0) scale(1); }
  to   { opacity: 1;   transform: translate3d(-2%, 2%, 0) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}
#app { min-height: 100vh; position: relative; }
.screen { display: block; }
.hidden { display: none !important; }
.wrap { max-width: 560px; margin: 0 auto; padding: 24px 18px 48px; }
.wrap.wide { max-width: 760px; }
h1.logo {
  font-size: 2.6rem;
  margin: 1.4rem 0 0.2rem;
  letter-spacing: 0.5px;
  background: linear-gradient(115deg, #f7f2e6 20%, #eecf87 55%, #d9a441 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
h2 { font-size: 1.5rem; margin: 0.6rem 0 0.8rem; color: var(--ink); }
h2.tight { margin-bottom: 0; }
p.tight { margin-top: 0; }
.tagline { color: var(--muted); margin-bottom: 2rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.fineprint { color: var(--muted); font-size: 0.8rem; margin-top: 2rem; }

.mode-cards { display: grid; gap: 14px; margin: 1.5rem 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  display: block;
  width: 100%;
  font-size: 1rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}
.card:active { transform: scale(0.99); }
.card-title { display: block; font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.card-sub { color: var(--muted); font-size: 0.9rem; }

button.primary, button.secondary {
  border: none; border-radius: var(--radius);
  padding: 14px 18px; font-size: 1rem; font-weight: 700;
  cursor: pointer; width: 100%; margin: 8px 0;
}
button.primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: var(--gold-ink);
  box-shadow: 0 4px 18px rgba(217, 164, 65, 0.28);
}
button.primary.big { padding: 17px 18px; font-size: 1.1rem; }
button.secondary {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); width: auto; padding: 10px 16px;
}
button.linklike {
  background: none; border: none; color: var(--muted);
  padding: 10px; font-size: 0.95rem; cursor: pointer; width: 100%; margin-top: 6px;
}
button.linklike.danger { color: var(--l4); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible, .card:focus-visible, .cat-head:focus-visible, .pill:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.field { display: block; margin: 14px 0; }
.field > span { display: block; margin-bottom: 6px; font-weight: 600; }
.field em { font-style: normal; color: var(--muted); font-weight: 400; }
.field input {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--ink); font-size: 1rem;
}
.divider { text-align: center; color: var(--muted); margin: 18px 0; position: relative; }
.divider span { background: var(--bg); padding: 0 12px; position: relative; }
.divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--line); }

.conceal { text-align: center; padding-top: 18vh; }
.code-row { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.room-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.9rem; letter-spacing: 4px;
  background: var(--surface2); border: 1px dashed rgba(217, 164, 65, 0.55);
  border-radius: var(--radius); padding: 12px 18px; flex: 1; text-align: center;
  color: var(--gold);
}
.members { margin: 14px 0; display: grid; gap: 8px; }
.member {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.member .presence { font-size: 0.8rem; color: var(--muted); }
.member .presence.here { color: var(--l2); }

/* selection UI — pills sit on constant surfaces */
.sel-toolbar { position: sticky; top: 0; background: rgba(7, 11, 22, 0.9); padding: 8px 0; z-index: 5; }
.sel-toolbar input {
  width: 100%; padding: 11px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--ink); font-size: 1rem;
}
.cat { margin: 10px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cat-head {
  width: 100%; background: transparent; color: var(--ink); border: none;
  padding: 13px 14px; font-size: 1rem; font-weight: 700; text-align: left;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.cat-head .cnt { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.cat-items { display: none; padding: 10px; gap: 8px; flex-wrap: wrap; }
.cat.open .cat-items { display: flex; }
.pill {
  border: 1px solid rgba(150, 170, 220, 0.28); background: var(--surface2); color: var(--ink);
  border-radius: 999px; padding: 9px 12px; font-size: 0.88rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
}
.pill .dots { display: inline-flex; gap: 3px; }
.pill .dots i { width: 8px; height: 8px; border-radius: 50%; background: #3d4a6b; display: block; }
.pill[data-level="1"] { border-color: var(--l1); } .pill[data-level="1"] .dots i:nth-child(-n+1) { background: var(--l1); }
.pill[data-level="2"] { border-color: var(--l2); } .pill[data-level="2"] .dots i:nth-child(-n+2) { background: var(--l2); }
.pill[data-level="3"] { border-color: var(--l3); } .pill[data-level="3"] .dots i:nth-child(-n+3) { background: var(--l3); }
.pill[data-level="4"] { border-color: var(--l4); } .pill[data-level="4"] .dots i:nth-child(-n+4) { background: var(--l4); }
.pill .lvl-name { font-size: 0.72rem; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; font-size: 0.78rem; color: var(--muted); }
.legend b { font-weight: 700; }
.l1c { color: var(--l1); } .l2c { color: var(--l2); } .l3c { color: var(--l3); } .l4c { color: var(--l4); }

.custom-sec { margin: 18px 0; }
.custom-row { display: flex; gap: 8px; margin: 8px 0; }
.custom-row input {
  flex: 1; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--ink); font-size: 1rem;
}
.custom-list { display: grid; gap: 8px; margin-top: 10px; }
.custom-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px;
}
.custom-item span.txt { flex: 1; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; }
.custom-item .del { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }

.room-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.count-badge {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 0.9rem; font-weight: 700; color: var(--ink);
}
.count-badge.over { border-color: var(--l4); color: var(--l4); }
.lockin-box { margin: 22px 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* results */
.tier { margin: 18px 0; }
.tier h3 { margin: 0 0 8px; font-size: 1.1rem; }
.tier-4 h3 { color: var(--l4); } .tier-3 h3 { color: var(--l3); }
.tier-2 h3 { color: var(--l2); } .tier-1 h3 { color: var(--l1); }
.match-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.match-list li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; font-size: 0.95rem;
}
.match-list li .own { color: var(--muted); font-size: 0.78rem; display: block; margin-top: 2px; }
.unusual-note {
  background: rgba(40, 28, 58, 0.96); border: 1px solid var(--violet); border-radius: var(--radius);
  padding: 12px 16px; margin: 16px 0; font-size: 0.92rem;
}
.no-match { text-align: center; color: var(--muted); padding: 30px 10px; }

.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 20px; align-items: center; }
.file-label { cursor: pointer; }

/* progress overlay */
#progress {
  position: fixed; inset: 0; background: rgba(7, 11, 22, 0.86);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.progress-box { text-align: center; padding: 30px; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border: 4px solid #2a3550; border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--surface2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 18px; max-width: 88vw; z-index: 60;
  font-size: 0.92rem; text-align: center;
}

@media (min-width: 700px) {
  .cat-items { gap: 10px; }
  .pill { font-size: 0.95rem; }
}
