:root {
  --plum: #531840;
  --plum-deep: #311329;
  --rose: #a32461;
  --rose-dark: #7c1647;
  --rose-soft: #efcfdf;
  --blush: #fff0f5;
  --white: #ffffff;
  --muted: #6a425e;
  --danger: #9b1c31;
  --radius: 26px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable both-edges;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--plum);
  background:
    url("crosses.svg") left top repeat,
    radial-gradient(ellipse at 3% 2%, #ffd3e3 0, transparent 58%),
    radial-gradient(ellipse at 97% 32%, #eadbff 0, transparent 58%),
    #fff8f5;
  isolation: isolate;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 7px;
  height: 7px;
  pointer-events: none;
  background: #a32461;
  opacity: .05;
  clip-path: polygon(43% 0, 57% 0, 57% 43%, 100% 43%, 100% 57%, 57% 57%, 57% 100%, 43% 100%, 43% 57%, 0 57%, 0 43%, 43% 43%);
  animation: background-twinkle 3.2s ease-in-out;
}

body::before { top: 20%; left: 11%; }
body::after { bottom: 23%; right: 10%; animation-delay: 1.2s; }

@keyframes background-twinkle {
  55% { opacity: .18; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */

.shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(36px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 24px;
}

.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
}

.brand-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.card {
  background: var(--white);
  border: 1px solid var(--rose-soft);
  border-radius: var(--radius);
  box-shadow: 0 24px 72px -48px #9b538b;
  padding: clamp(22px, 6vw, 48px);
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4vw, 28px);
}

.hero-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 158px;
  max-height: 258px;
  overflow: hidden;
  isolation: isolate;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 14% 20%, #98275b, transparent 64%),
    radial-gradient(ellipse at 94% 70%, #6d3ccd, transparent 66%),
    #421343;
}

.hero-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 258px;
  object-fit: contain;
  animation: ribbon-drift 4.4s ease-in-out;
}

.hero-spark {
  position: absolute;
  width: clamp(10px, 3vw, 19px);
  aspect-ratio: 1;
  background: #ffd99d;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: sparkle 4s ease-in-out;
}

.spark-a { top: 22%; right: 15%; }
.spark-b { bottom: 19%; left: 14%; background: #ebd3ff; animation-delay: 160ms; }

@keyframes ribbon-drift {
  45% { transform: translateY(-7px) rotate(-1.6deg); }
  75% { transform: translateY(2px) rotate(0.5deg); }
}

@keyframes sparkle {
  35%, 75% { transform: scale(.44) rotate(28deg); opacity: .42; }
  55% { transform: scale(1.28); }
}

.title.hero-title {
  font-size: clamp(2.35rem, 7.8vw, 3.65rem);
  line-height: 1.01;
}

.hero-title span {
  color: var(--rose);
}

/* ---------- Text ---------- */

.title {
  margin: 0;
  font-size: clamp(2rem, 6.8vw, 3rem);
  line-height: 1.05;
  font-weight: 780;
  color: var(--plum-deep);
  outline: none;
  letter-spacing: -0.055em;
}

.title.question {
  font-size: clamp(1.65rem, 5.4vw, 2.3rem);
  line-height: 1.12;
  text-wrap: balance;
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rose);
}

.lead {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 0.98rem;
  color: var(--muted);
}

.loading {
  margin: auto;
  color: var(--muted);
}

.notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--blush);
  font-weight: 600;
}

.error {
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  border-left: 5px solid var(--danger);
  background: #fbe9ec;
  color: var(--danger);
  font-weight: 600;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
}

.actions > .btn {
  flex: 1 1 140px;
}

.btn {
  min-height: 48px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms, border-color 160ms, box-shadow 160ms;
}

.btn:focus-visible,
.text-input:focus-visible,
.slider:focus-visible {
  outline: 3px solid var(--plum);
  outline-offset: 3px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  color: var(--white);
  background-color: var(--rose);
  box-shadow: 0 5px 12px -8px #780e46;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--rose-dark);
}

.btn-hero {
  min-height: 56px;
  font-size: 1.08rem;
}

.btn-secondary {
  color: var(--plum);
  background: var(--white);
  border-color: var(--rose-soft);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--rose);
}

.btn-ghost {
  color: var(--plum);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-quiet {
  min-height: 48px;
  color: var(--danger);
  background: transparent;
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-danger {
  color: var(--white);
  background: var(--danger);
}

/* One-tap answer buttons */

.choices {
  display: grid;
  gap: 12px;
}

.btn-choice {
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 14px 45px 14px 18px;
  border-radius: 14px;
  border-color: var(--rose-soft);
  background: #fffafd;
  color: var(--plum-deep);
  text-align: left;
}

.btn-choice:hover {
  border-color: var(--rose);
  background: var(--blush);
}

.btn-choice[aria-pressed="true"] {
  color: var(--white);
  background: var(--rose);
  border-color: var(--rose);
}

.btn-choice[aria-pressed="true"]::after {
  content: "✓" / "";
  position: absolute;
  right: 17px;
  top: 50%;
  translate: 0 -50%;
  font-size: 1.3rem;
  animation: pop 260ms var(--ease);
}

@keyframes pop {
  from { scale: 0.3; opacity: 0; }
  to { scale: 1; opacity: 1; }
}

.range-form {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--rose-soft);
  border-radius: 16px;
  background: #fff8fb;
}

.range-value {
  justify-self: center;
  color: var(--plum-deep);
  font-size: clamp(1.45rem, 5vw, 2.1rem);
  font-weight: 760;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.slider {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--rose);
  cursor: pointer;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.actions-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 6px;
}

.actions-nav .btn {
  padding-inline: 6px;
  font-size: clamp(0.8rem, 4vw, 1rem);
}

/* Progress */

.progress { --part-color: #9d245e; }
.progress[data-part="2"] { --part-color: #6737ac; }
.progress[data-part="3"] { --part-color: #a33a48; }

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--part-color);
}

.progress-label > :last-child {
  white-space: nowrap;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--blush);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ed755b, var(--part-color) 42%, #9c56d9);
  transform: scaleX(var(--progress));
  transform-origin: left center;
  animation: progress-motion 310ms var(--ease);
}

@keyframes progress-motion {
  from { transform: scaleX(var(--progress-from)); }
}

/* Form */

.alias-form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.alias-form .actions {
  margin-top: 8px;
}

.field-label {
  font-weight: 700;
}

.text-input {
  width: 100%;
  height: 46px;
  padding: 8px 13px;
  border: 1px solid #dbadbf;
  border-radius: 11px;
  font: inherit;
  font-size: 1rem;
  color: var(--plum-deep);
  background: var(--white);
}

.text-input[aria-invalid="true"] {
  border-color: var(--danger);
}

.inline-feedback:empty {
  display: none;
}

.inline-feedback {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.finish-actions > :first-child {
  flex: 0 0 auto;
}

.location-picker,
.location-results {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.location-results:empty {
  display: none;
}

.location-results .btn {
  text-align: start;
}

.map-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.map-search .text-input {
  height: 48px;
}

.map {
  height: clamp(200px, 44vw, 300px);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--rose-soft);
  border-radius: 12px;
  background: var(--blush);
}

.map:not(.leaflet-container) {
  display: grid;
  place-items: center;
  text-align: center;
}

.map-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.map-tools .btn {
  flex: 1 1 auto;
  font-size: 0.88rem;
}

/* ---------- Leaderboard ---------- */

.board-meta,
.board-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.board-actions {
  margin-top: 4px;
}

.board-actions > .btn {
  flex: 0 1 auto;
  font-size: 0.91rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #d5e8dc;
  border-radius: 999px;
  background: #edf7f1;
  color: #22553d;
  font-size: 0.78rem;
  font-weight: 700;
}

.live-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.board-stage {
  display: grid;
  align-items: start;
}

.board-stage > * {
  grid-area: 1 / 1;
  min-width: 0;
}

.board {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 15px;
  background: #fffafd;
  border: 1px solid var(--rose-soft);
}

.row:nth-child(1 of [data-id]) {
  background: linear-gradient(120deg, #ffedf3, #f3eaff);
  border-color: var(--rose-soft);
}

.row-leaving {
  position: absolute;
  inset-inline: 0;
  z-index: 1;
  pointer-events: none;
}

.board-stage .empty:not([hidden]) {
  animation: row-in 260ms var(--ease);
}

@keyframes row-in {
  from { opacity: 0; translate: 0 6px; }
  to { opacity: 1; translate: none; }
}

.rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--plum);
  color: var(--white);
  font-weight: 800;
}

.row:nth-child(1 of [data-id]) .rank {
  background: var(--rose);
}

.row-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.row-top {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.row-alias {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-score {
  flex: none;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--rose);
}

.meter {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: #f6e8ef;
  overflow: hidden;
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--plum), var(--rose));
  transform-origin: left center;
  transform: scaleX(var(--score, 0));
  transition: transform 520ms var(--ease);
}


.empty {
  padding: 24px;
  border-radius: 18px;
  background: var(--blush);
  text-align: center;
}

.empty p {
  margin: 0;
}

.empty-title {
  margin-bottom: 6px !important;
  font-size: 1.25rem;
  font-weight: 800;
}


.confirm {
  padding: 18px;
  border-radius: 18px;
  background: #fbe9ec;
}

.confirm p {
  margin: 0 0 14px;
  font-weight: 600;
}

/* Laptop kiosk */

@media (min-width: 900px) {
  .shell {
    padding-top: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
