/* Guest phone. Mobile first; one primary action per screen; big, calm, readable. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--moss-100) 0%, rgba(226, 235, 230, 0) 70%),
    radial-gradient(90% 60% at 50% 100%, var(--beige-100) 0%, rgba(239, 229, 212, 0) 75%),
    var(--moss-50);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- backdrop flowers ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.decor {
  position: absolute;
  left: 50%;
  width: min(560px, 118vw);
  transform: translateX(-50%);
  opacity: 0.9;
}

.decor-top {
  top: calc(-10px + env(safe-area-inset-top));
}

.decor-bottom {
  bottom: calc(-14px + env(safe-area-inset-bottom));
}

.decor svg {
  display: block;
  width: 100%;
  height: auto;
}

.bouquet .flower,
.decor svg {
  overflow: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .decor-top svg {
    animation: sway 9s var(--ease-in-out) infinite alternate;
    transform-origin: 50% 0%;
  }
  .decor-bottom svg {
    animation: sway 11s var(--ease-in-out) infinite alternate-reverse;
    transform-origin: 50% 100%;
  }
}

@keyframes sway {
  from {
    transform: rotate(-0.8deg) translateY(0);
  }
  to {
    transform: rotate(0.8deg) translateY(2px);
  }
}

/* ---------- chrome ---------- */

.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: calc(52px + env(safe-area-inset-top));
  padding: calc(14px + env(safe-area-inset-top)) 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.result-dot {
  width: 14px;
  height: 14px;
  margin-top: 4px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 0 transparent;
  transition:
    background-color 600ms var(--ease-out),
    box-shadow 600ms var(--ease-out),
    opacity 400ms;
  opacity: 0;
}

.result-dot[data-state='good'] {
  opacity: 1;
  background: var(--good);
  box-shadow:
    0 0 0 4px var(--good-soft),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.result-dot[data-state='bad'] {
  opacity: 1;
  background: var(--bad);
  box-shadow:
    0 0 0 4px var(--bad-soft),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.who {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(251, 248, 242, 0.7);
  max-width: 50vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conn {
  position: absolute;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top));
  transform: translate(-50%, -8px);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--brown-700);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transition:
    opacity 400ms var(--ease-out),
    transform 400ms var(--ease-out);
}

.conn[data-show='true'] {
  opacity: 1;
  transform: translate(-50%, 0);
}

.conn[data-tone='ok'] {
  color: var(--good);
}

/* ---------- stage & screens ---------- */

.stage {
  position: relative;
  z-index: 10;
  height: 100vh;
  height: 100dvh;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(72px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.leaving {
  pointer-events: none;
}

.center {
  display: flex;
  justify-content: center;
}

.muted {
  color: var(--ink-soft);
  margin: 0;
  max-width: 22em;
}

.eyebrow {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brown-500);
}

.h2 {
  display: block;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1.08;
  color: var(--ink);
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.actions > div {
  width: 100%;
}

.actions.small {
  gap: 6px;
}

.form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.form .muted {
  margin: -6px auto 4px;
}

.hint {
  margin: -4px 0 0;
  font-size: 16px;
  color: var(--brown-700);
  background: var(--beige-100);
  border-radius: var(--r-sm);
  padding: 10px 14px;
}

.notice {
  margin: 8px auto 0;
  font-size: 16px;
  color: var(--brown-700);
  max-width: 20em;
}

/* ---------- buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  width: 100%;
  padding: 0 28px;
  border: 0;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition:
    transform 160ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    filter 220ms;
}

.btn:focus-visible {
  outline: 3px solid var(--moss-400);
  outline-offset: 3px;
}

.btn-primary {
  color: #fbf8f2;
  background: linear-gradient(180deg, var(--moss-500) 0%, var(--moss-600) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(20, 40, 32, 0.22),
    0 1px 2px rgba(35, 56, 48, 0.25),
    0 10px 24px -8px rgba(35, 56, 48, 0.45);
}

/* Lit from above: a soft top light, a crisp highlight edge and a darker lip at the bottom. */
.btn-lit {
  background:
    radial-gradient(120% 90% at 50% -30%, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, #7a9f90 0%, var(--moss-600) 58%, #4b6a5c 100%);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -3px 0 rgba(20, 40, 32, 0.28),
    0 1px 1px rgba(35, 56, 48, 0.3),
    0 4px 8px -2px rgba(35, 56, 48, 0.25),
    0 18px 32px -14px rgba(35, 56, 48, 0.55);
  text-shadow: 0 1px 0 rgba(20, 40, 32, 0.35);
}

.btn-lit::after {
  content: '';
  position: absolute;
  inset: 1px 12px auto;
  height: 42%;
  border-radius: 16px 16px 40% 40% / 16px 16px 12px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.btn-primary:active,
.btn-lit:active {
  transform: translateY(1px) scale(0.99);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(20, 40, 32, 0.22),
    0 1px 1px rgba(35, 56, 48, 0.3),
    0 6px 14px -8px rgba(35, 56, 48, 0.45);
  filter: brightness(0.97);
}

.btn-quiet {
  min-height: 52px;
  width: auto;
  font-size: 17px;
  font-weight: 600;
  color: var(--moss-700);
  background: rgba(251, 248, 242, 0.75);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(35, 56, 48, 0.06);
}

.btn-quiet:active {
  transform: scale(0.98);
  background: var(--surface);
}

.btn-icon {
  width: 22px;
  height: 22px;
}

.btn.is-busy {
  opacity: 0.75;
  cursor: progress;
}

.btn:disabled {
  cursor: default;
}

.link {
  background: none;
  border: 0;
  padding: 10px 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--moss-700);
  text-decoration: underline;
  text-decoration-color: rgba(63, 90, 79, 0.35);
  text-underline-offset: 4px;
  cursor: pointer;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--moss-50);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* ---------- inputs ---------- */

.field {
  width: 100%;
  min-height: 64px;
  padding: 0 20px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1.5px var(--moss-200),
    inset 0 2px 4px rgba(35, 56, 48, 0.06);
  text-align: center;
  caret-color: var(--moss-600);
  transition: box-shadow 220ms var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
}

.field::placeholder {
  color: rgba(75, 97, 88, 0.45);
  font-weight: 500;
}

.field:focus {
  outline: none;
  box-shadow:
    inset 0 0 0 2px var(--moss-500),
    0 0 0 5px rgba(107, 144, 129, 0.18);
}

/* ---------- welcome: a book cover ---------- */

.screen-welcome {
  justify-content: space-between;
  padding-top: calc(16vh + env(safe-area-inset-top));
  padding-bottom: calc(15vh + env(safe-area-inset-bottom));
}

.cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.cover-ornament .flower {
  width: 54px;
  height: 54px;
}

.cover-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(44px, 12.5vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.005em;
  color: var(--ink);
  max-width: 7.4em;
  text-wrap: balance;
}

.cover-rule,
.reveal-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(220px, 60vw);
}

.cover-rule span,
.reveal-rule span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(140, 108, 79, 0), rgba(140, 108, 79, 0.55), rgba(140, 108, 79, 0));
}

.flower.tiny {
  width: 22px;
  height: 22px;
  flex: none;
}

/* ---------- lobby ---------- */

.screen-lobby {
  justify-content: space-between;
  padding-top: calc(13vh + env(safe-area-inset-top));
}

.lobby-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.display-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(44px, 13vw, 64px);
  line-height: 1.02;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.guestbook {
  width: 100%;
  max-width: 420px;
}

.guestbook-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--brown-500);
  letter-spacing: 0.04em;
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-height: 30vh;
  overflow-y: auto;
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  color: var(--moss-700);
  background: rgba(251, 248, 242, 0.85);
  box-shadow: inset 0 0 0 1px var(--line);
}

.chip.is-you {
  color: #fbf8f2;
  background: var(--moss-500);
  box-shadow: none;
}

/* ---------- pick / confirm ---------- */

.claim-name {
  margin: -4px 0 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(40px, 12vw, 56px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.pick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px;
}

.pick-item {
  min-height: 58px;
  border: 0;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 600;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(35, 56, 48, 0.06);
  cursor: pointer;
}

.pick-item:active {
  background: var(--moss-100);
}

/* ---------- question ---------- */

.medallion {
  --size: 132px;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  color: var(--moss-700);
  background:
    radial-gradient(circle at 50% 30%, #fffdf8 0%, var(--cream) 60%, var(--beige-100) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(140, 108, 79, 0.18),
    0 0 0 8px rgba(251, 248, 242, 0.55),
    0 0 0 9px rgba(140, 108, 79, 0.12),
    0 18px 40px -18px rgba(35, 56, 48, 0.45);
}

.medallion .glyph {
  width: 58%;
  height: 58%;
}

.medallion.small {
  --size: 52px;
  box-shadow:
    inset 0 0 0 1px rgba(140, 108, 79, 0.18),
    0 0 0 4px rgba(251, 248, 242, 0.55),
    0 8px 16px -10px rgba(35, 56, 48, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  .glyph.bob {
    animation: bob 4.2s var(--ease-in-out) infinite alternate;
  }
}

@keyframes bob {
  from {
    transform: translateY(2px) rotate(-3deg);
  }
  to {
    transform: translateY(-3px) rotate(3deg);
  }
}

.q-title {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 14vw, 68px);
  line-height: 1;
  color: var(--ink);
}

.q-title.small {
  margin: 0;
  font-size: 26px;
}

.q-progress {
  margin: 4px 0 0;
}

.dots {
  display: inline-flex;
  gap: 7px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss-200);
}

.dots i.done {
  background: var(--moss-400);
}

.dots i.now {
  background: var(--brown-500);
  transform: scale(1.25);
}

.intro-wait {
  margin-top: 10px;
  font-size: 16px;
}

.screen-question,
.screen-locked {
  justify-content: flex-start;
  gap: 0;
}

.q-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 2vh;
}

.q-head.faded {
  opacity: 0.8;
}

.q-body {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: flex-grow 0s;
}

.q-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: clamp(30px, 8.6vw, 40px);
  transform-origin: 50% 50%;
}

.q-target {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.42em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brown-500);
}

.q-text {
  margin: 0;
  max-width: 11.5em;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1em;
  line-height: 1.16;
  color: var(--ink);
  text-wrap: balance;
}

/* When the answer button arrives the question gets a little smaller and rises.
   Sizes are in em with the width in em too, so the lines break the same way at both sizes. */
.screen-question.is-open .q-body {
  flex: 0 0 auto;
  margin-top: 6vh;
}

.screen-question.is-open .q-block {
  font-size: clamp(26px, 7.2vw, 34px);
}

.answer-zone {
  position: relative;
  width: 100%;
  max-width: 380px;
  min-height: 0;
  display: flex;
  justify-content: center;
  margin: 0 auto;
}

.screen-question.is-open .answer-zone {
  flex: 1;
  align-items: center;
  min-height: 160px;
}

.btn-answer {
  min-height: 72px;
  font-size: 23px;
  border-radius: 22px;
}

.answer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 16px 22px 14px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1.5px var(--moss-200),
    0 1px 2px rgba(35, 56, 48, 0.06),
    0 14px 30px -18px rgba(35, 56, 48, 0.4);
  cursor: pointer;
  text-align: center;
}

.answer-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brown-500);
}

.answer-text {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.answer-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--moss-600);
}

.pencil {
  width: 16px;
  height: 16px;
}

/* ---------- answer sheet ---------- */

.overlay-root {
  position: relative;
  z-index: 50;
}

.sheet-wrap,
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(12vh + env(safe-area-inset-top)) 18px 18px;
}

.sheet-scrim,
.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(35, 56, 48, 0.32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet,
.qr-card,
.confirm-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 26px 22px 20px;
  border-radius: 28px;
  background: var(--surface);
  box-shadow:
    0 1px 2px rgba(35, 56, 48, 0.1),
    0 30px 60px -20px rgba(35, 56, 48, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.sheet-close,
.qr-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.sheet-label {
  margin: 4px 44px 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}

.answer-input {
  font-family: var(--font-display);
  font-size: 32px;
  min-height: 70px;
}

.sheet-hint {
  margin: -4px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.overlay {
  align-items: center;
}

.qr-card {
  background: #fff;
  align-items: center;
  padding-top: 30px;
}

.qr-title {
  margin: 0 44px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.qr-frame {
  width: min(300px, 74vw);
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 20px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(35, 56, 48, 0.08);
}

.qr-frame img {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-url {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  word-break: break-all;
}

.confirm-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}

.confirm-text {
  margin: -4px 0 4px;
  color: var(--ink-soft);
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-actions .btn-quiet {
  width: 100%;
}

/* ---------- locked: the check ---------- */

.check-stage {
  --ring-r: -112px;
  position: relative;
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
  min-height: 300px;
}

.check-stage .answer-card {
  width: min(250px, 70vw);
  cursor: default;
  z-index: 2;
}

.answer-card.is-empty .answer-text {
  color: var(--ink-soft);
}

.petal-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 1;
}

.ring-petal {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  opacity: 0;
  transform: rotate(calc(var(--i) * 36deg)) translateY(var(--ring-r)) scale(0.2);
}

.ring-petal svg {
  width: 100%;
  height: 100%;
  display: block;
}

@media (prefers-reduced-motion: no-preference) {
  .is-checking .petal-ring {
    animation: ring-turn 2.4s linear infinite;
  }
  .is-checking .ring-petal svg {
    animation: petal-breathe 1.2s var(--ease-in-out) infinite alternate;
    animation-delay: calc(var(--i) * -0.12s);
  }
}

@keyframes ring-turn {
  to {
    transform: rotate(360deg);
  }
}

@keyframes petal-breathe {
  from {
    transform: scale(0.75);
    opacity: 0.65;
  }
  to {
    transform: scale(1.1);
    opacity: 1;
  }
}

.is-good .ring-petal svg path {
  fill: var(--good-soft);
  stroke: var(--good);
  transition:
    fill 500ms,
    stroke 500ms;
}

.is-bad .ring-petal svg path {
  fill: var(--bad-soft);
  stroke: var(--bad);
  transition:
    fill 500ms,
    stroke 500ms;
}

.is-good .petal-ring,
.is-bad .petal-ring {
  transition: transform 900ms var(--ease-out);
}

.is-good .ring-petal {
  transition: transform 900ms var(--ease-out);
}

.is-good .check-stage {
  --ring-r: -128px;
}

.is-bad .check-stage {
  --ring-r: -100px;
}

.is-good .check-stage .answer-card {
  box-shadow:
    inset 0 0 0 2px var(--good),
    0 0 0 6px var(--good-soft),
    0 18px 36px -18px rgba(35, 56, 48, 0.45);
  transition: box-shadow 500ms var(--ease-out);
}

.is-bad .check-stage .answer-card {
  box-shadow:
    inset 0 0 0 2px var(--bad),
    0 0 0 6px var(--bad-soft),
    0 18px 36px -18px rgba(35, 56, 48, 0.45);
  transition: box-shadow 500ms var(--ease-out);
}

.check-caption {
  margin: 0;
  min-height: 1.5em;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-soft);
}

.caption-checking {
  opacity: 0;
  display: inline-block;
}

.ell i {
  font-style: normal;
  display: inline-block;
}

@media (prefers-reduced-motion: no-preference) {
  .ell i {
    animation: ell 1.4s var(--ease-in-out) infinite;
  }
  .ell i:nth-child(2) {
    animation-delay: 0.18s;
  }
  .ell i:nth-child(3) {
    animation-delay: 0.36s;
  }
}

@keyframes ell {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-0.12em);
  }
}

.verdict {
  min-height: 110px;
  margin-bottom: 4vh;
}

.verdict-word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 14vw, 64px);
  line-height: 1;
}

.is-good .verdict-word {
  color: var(--good);
}

.is-bad .verdict-word {
  color: var(--bad);
}

.verdict-sub {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
}

.flash[data-tone='good'] {
  background: radial-gradient(90% 70% at 50% 50%, rgba(79, 143, 98, 0.18) 0%, rgba(79, 143, 98, 0.5) 100%);
}

.flash[data-tone='bad'] {
  background: radial-gradient(90% 70% at 50% 50%, rgba(184, 96, 79, 0.16) 0%, rgba(184, 96, 79, 0.46) 100%);
}

/* ---------- the ending ---------- */

.finale-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(56px, 16vw, 84px);
  line-height: 1;
}

.ell.big i {
  margin-left: 0.02em;
}

.screen-winner {
  gap: 14px;
}

.crown-wrap {
  position: relative;
  width: 132px;
  height: 132px;
}

.crown {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 18px rgba(140, 108, 79, 0.35));
}

@media (prefers-reduced-motion: no-preference) {
  .crown {
    animation: crown-float 3.6s var(--ease-in-out) infinite alternate;
    transform-origin: 50% 80%;
  }
  .glint {
    animation: glint 3.2s var(--ease-in-out) infinite;
  }
  .glint.g2 {
    animation-delay: 1.1s;
  }
  .glint.g3 {
    animation-delay: 2.2s;
  }
}

@keyframes crown-float {
  from {
    transform: translateY(2px) rotate(-2.5deg);
  }
  to {
    transform: translateY(-6px) rotate(2.5deg);
  }
}

.glint {
  position: absolute;
  width: 14px;
  height: 14px;
  opacity: 0;
  background:
    linear-gradient(0deg, transparent 42%, #fffaf0 42%, #fffaf0 58%, transparent 58%),
    linear-gradient(90deg, transparent 42%, #fffaf0 42%, #fffaf0 58%, transparent 58%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}

.glint.g1 {
  left: 18%;
  top: 22%;
}

.glint.g2 {
  right: 14%;
  top: 30%;
}

.glint.g3 {
  left: 48%;
  top: 6%;
}

@keyframes glint {
  0%,
  70%,
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  80% {
    opacity: 1;
    transform: scale(1.1) rotate(45deg);
  }
}

.winner-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 14vw, 72px);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.winner-name.none {
  font-size: clamp(34px, 9vw, 44px);
  max-width: 11em;
}

.finale-hint {
  margin: 4vh 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 30px;
  color: var(--ink-soft);
}

.petal-rain {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.falling {
  position: absolute;
  top: -40px;
  left: var(--x);
  width: var(--size);
  height: var(--size);
  will-change: transform;
}

.falling svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .falling {
    animation: fall var(--dur) linear infinite;
    animation-delay: var(--delay);
  }
}

@media (prefers-reduced-motion: reduce) {
  .petal-rain {
    display: none;
  }
}

@keyframes fall {
  0% {
    transform: translate3d(0, -5vh, 0) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 0.95;
  }
  50% {
    transform: translate3d(calc(var(--drift) * 0.6), 52vh, 0) rotate(calc(var(--spin) * 0.5));
  }
  92% {
    opacity: 0.9;
  }
  100% {
    transform: translate3d(var(--drift), 108vh, 0) rotate(var(--spin));
    opacity: 0;
  }
}

.screen-revealed {
  gap: 16px;
}

.reveal-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(76px, 23vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.reveal-name .ltr {
  display: inline-block;
  opacity: 0;
}

.reveal-name .sp {
  display: inline-block;
  width: 0.24em;
}

.reveal-rule {
  opacity: 0;
}

.declension {
  margin: 4px 0 0;
  display: grid;
  gap: 6px;
}

.decl-row {
  display: grid;
  grid-template-columns: 4.2em auto;
  align-items: baseline;
  gap: 12px;
  opacity: 0;
  color: var(--ink-soft);
}

.decl-row dt {
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(140, 108, 79, 0.85);
}

.decl-row dd {
  margin: 0;
  text-align: left;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  color: rgba(35, 56, 48, 0.62);
}

/* ---------- loading ---------- */

.loader .flower {
  width: 56px;
  height: 56px;
}

@media (prefers-reduced-motion: no-preference) {
  .flower.spin {
    animation: ring-turn 6s linear infinite;
  }
}

.noscript {
  position: fixed;
  inset: auto 0 40%;
  text-align: center;
}

/* Short phones (and the keyboard): tighten. */
@media (max-height: 640px) {
  .medallion {
    --size: 104px;
  }
  .screen {
    gap: 12px;
  }
  .check-stage {
    min-height: 240px;
    --ring-r: -92px;
  }
}
