:root {
  --bg: #0e0b16;
  --bg-2: #171126;
  --card: rgba(255, 255, 255, 0.055);
  --stroke: rgba(255, 255, 255, 0.11);
  --stroke-strong: rgba(255, 255, 255, 0.22);
  --text: #f2eefb;
  --muted: #a79fc0;
  --p1: #ff7ab8;
  --p2: #6fd6ff;
  --accent: #b98bff;
  --danger: #ff8a8a;
  --radius: 18px;
  --pad: clamp(18px, 5vw, 34px);
}

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

html, body {
  margin: 0;
  height: 100%;        /* lets #app's min-height:100% resolve inside an iframe */
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Painted on a fixed layer rather than the body: background-attachment:fixed
   is not honoured beneath backdrop-filter elements on tall pages. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(90vw 60vh at 12% -10%, rgba(185, 139, 255, 0.20), transparent 60%),
    radial-gradient(80vw 55vh at 100% 5%, rgba(255, 122, 184, 0.16), transparent 60%),
    radial-gradient(70vw 50vh at 50% 110%, rgba(111, 214, 255, 0.14), transparent 60%),
    linear-gradient(170deg, var(--bg), var(--bg-2));
}

#app {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) clamp(14px, 4vw, 24px) 48px;
  /* 100% keeps this correct inside an iframe, where dvh tracks the outer
     viewport rather than the frame; dvh then refines it for real browsers. */
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* centers short screens without clipping the top of tall ones */
  justify-content: safe center;
}

/* ---------- shared blocks ---------- */
.screen {
  animation: rise 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: var(--pad);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

h1 {
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  line-height: 1.12;
  text-align: center;
}

h2 {
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  text-align: center;
}

.sub {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 0.96rem;
  text-align: center;
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- buttons ---------- */
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  padding: 15px 18px;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
  width: 100%;
  text-align: left;
}

button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); border-color: var(--stroke-strong); }
button:active:not(:disabled) { transform: scale(0.985); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  text-align: center;
  font-weight: 600;
  border: none;
  background: linear-gradient(100deg, var(--accent), var(--p1));
  color: #17101f;
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(100deg, var(--accent), var(--p1)); }

.btn-ghost {
  text-align: center;
  background: transparent;
  color: var(--muted);
}

.choice {
  display: flex;
  align-items: center;
  gap: 13px;
  font-weight: 500;
}

.choice .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--accent);
}
.choice .dot.mf { background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%); }
.choice .dot.ff { background: var(--p1); }
.choice .dot.mm { background: var(--p2); }

.choice.selected {
  border-color: var(--accent);
  background: rgba(185, 139, 255, 0.16);
}

/* ---------- radio options (secret survey) ---------- */
.opt {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 17px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
  /* reset inherited <label> styling */
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--text);
  margin: 0;
}

.opt:hover { background: rgba(255, 255, 255, 0.09); }

.opt input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--stroke-strong);
  background: transparent;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease;
}

/* the filled centre dot */
.opt input[type="radio"]::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(100deg, var(--accent), var(--p1));
  transform: scale(0);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.opt input[type="radio"]:checked { border-color: var(--accent); }
.opt input[type="radio"]:checked::after { transform: scale(1); }

.opt.selected {
  border-color: var(--accent);
  background: rgba(185, 139, 255, 0.16);
}

.opt-txt { flex: 1 1 auto; }

/* ---------- multi-player input groups ---------- */
.in-group {
  padding: 18px 0 2px;
  border-top: 1px solid var(--stroke);
  margin-top: 6px;
}
.in-group:first-of-type { border-top: none; margin-top: 0; padding-top: 4px; }

/* ---------- forms ---------- */
label {
  display: block;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

input {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 14px 15px;
}

input::placeholder { color: rgba(255, 255, 255, 0.28); }
input:focus { border-color: var(--accent); }

.field { margin-bottom: 16px; }
.error { color: var(--danger); font-size: 0.88rem; min-height: 1.25em; margin: 0 0 12px; }

/* ---------- badges / meta ---------- */
.badge {
  display: block;
  width: fit-content;
  margin-inline: auto;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  color: var(--muted);
  margin-bottom: 14px;
}
.badge.p1 { color: var(--p1); border-color: rgba(255, 122, 184, 0.45); background: rgba(255, 122, 184, 0.10); }
.badge.p2 { color: var(--p2); border-color: rgba(111, 214, 255, 0.45); background: rgba(111, 214, 255, 0.10); }
.badge.both { color: var(--accent); border-color: rgba(185, 139, 255, 0.45); background: rgba(185, 139, 255, 0.10); }

.note {
  border-left: 3px solid var(--accent);
  background: rgba(185, 139, 255, 0.09);
  border-radius: 0 12px 12px 0;
  padding: 15px 17px;
  margin: 0 0 20px;
  color: #e6dcff;
}

.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.94rem;
  margin-bottom: 20px;
  text-transform: none;
  letter-spacing: 0;
}
.check input { width: 20px; height: 20px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--accent); }

/* ---------- progress ---------- */
.progress {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  margin-bottom: 22px;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--p1));
  transition: width 0.35s ease;
}

/* ---------- scorebar ---------- */
.scorebar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -8px -6px 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(20, 15, 33, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
}

.scorebar .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  margin-bottom: 9px;
}
.scorebar .who { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.scorebar .nm {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw;
}
.scorebar .sc { font-variant-numeric: tabular-nums; font-weight: 650; }
.scorebar .p1 { color: var(--p1); }
.scorebar .p2 { color: var(--p2); }

.bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  overflow: hidden;
}
.bar > i { display: block; height: 100%; transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
.bar > i.f1 { background: linear-gradient(90deg, var(--p1), #ffa8cf); }
.bar > i.f2 { background: linear-gradient(90deg, #8fe2ff, var(--p2)); }

.qmeta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.qtext {
  font-size: clamp(1.2rem, 5vw, 1.55rem);
  font-weight: 550;
  letter-spacing: -0.015em;
  line-height: 1.35;
  margin: 0 0 22px;
}
.qtext .fill {
  color: var(--accent);
  border-bottom: 2px solid rgba(185, 139, 255, 0.45);
  padding-bottom: 1px;
}

/* ---------- picked inputs display ---------- */
.picks { margin: 0 0 22px; display: grid; gap: 12px; }
.pick-group .pg-title {
  font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  font-size: 0.9rem;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
}
.pick.chosen {
  color: #17101f;
  font-weight: 600;
  border-color: transparent;
  background: linear-gradient(100deg, var(--accent), var(--p1));
}
.pick .idx { opacity: 0.55; margin-right: 6px; font-variant-numeric: tabular-nums; }
.pick.chosen .idx { opacity: 0.7; }

/* ---------- marking ---------- */
.mark-box {
  border-top: 1px solid var(--stroke);
  padding-top: 20px;
}
.mark-head { font-size: 0.94rem; color: var(--muted); margin-bottom: 14px; }
.mark-head b { color: var(--text); font-weight: 600; }

/* ---------- marking slider ---------- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slider-val {
  flex: 0 0 auto;
  min-width: 58px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(100deg, var(--accent), var(--p1));
  color: #17101f;
}

.slider-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 6px 74px 20px 2px;
  font-variant-numeric: tabular-nums;
}

.slider {
  --pct: 0%;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}

/* track — WebKit / Blink */
.slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 99px;
  background:
    linear-gradient(90deg, var(--accent), var(--p1)) 0 / var(--pct) 100% no-repeat,
    rgba(255, 255, 255, 0.10);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -10px;              /* centres the 30px thumb on the 10px track */
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease;
}
.slider:active::-webkit-slider-thumb { transform: scale(1.12); }

/* track — Firefox */
.slider::-moz-range-track {
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.10);
}
.slider::-moz-range-progress {
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--p1));
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* ---------- timer ---------- */
.timer {
  font-size: clamp(3rem, 17vw, 5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 10px 0 6px;
  background: linear-gradient(100deg, var(--accent), var(--p1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.timer-msg { text-align: center; color: var(--muted); margin: 0 0 26px; }

.ring { display: block; margin: 0 auto 8px; }
.ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring .track { stroke: rgba(255, 255, 255, 0.09); }
.ring .fill { stroke: url(#ringgrad); transition: stroke-dashoffset 1s linear; }

/* ---------- results ---------- */
.winner {
  text-align: center;
  font-size: clamp(1.6rem, 6.5vw, 2.2rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 6px 0 26px;
}
.tally { display: grid; gap: 12px; margin-bottom: 26px; }
.tally .t {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.045);
}
.tally .t.lead { border-color: var(--stroke-strong); background: rgba(255, 255, 255, 0.09); }
.tally .t .n { font-weight: 600; }
.tally .t .v { font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 650; }
.tally .t.a .v { color: var(--p1); }
.tally .t.b .v { color: var(--p2); }

/* ---------- dev page ---------- */
.dev-wrap { max-width: 900px; margin: 0 auto; padding: 26px 16px 60px; }
.dev-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.dev-head h1 { margin: 0; font-size: 1.6rem; text-align: left; }
.dev-wrap .sub { text-align: left; }
.dev-actions { display: flex; gap: 10px; }
.dev-actions button { width: auto; padding: 10px 16px; font-size: 0.9rem; }
.resp { margin-bottom: 14px; }
.resp summary {
  cursor: pointer;
  padding: 15px 17px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
}
.resp summary::-webkit-details-marker { display: none; }
.resp summary .t { font-size: 0.82rem; color: var(--muted); margin-left: auto; }
.resp .qa { padding: 8px 4px 0; }
.resp .qa > div { padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.resp .qa > div:last-child { border-bottom: none; }
.resp .qa .q { font-size: 0.86rem; color: var(--muted); margin-bottom: 5px; }
.resp .qa .a { font-weight: 550; overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; padding: 50px 0; }

.mono { font-variant-numeric: tabular-nums; }
