/* The survey's look: a deck of color cards, one question a card, dealt
   over a pale Seoul street. The magpie perches on each card's edge and
   passes on what it heard. One light world: the page is read on a phone
   in daylight as often as at a desk. */

:root {
  color-scheme: light;
  --canvas: #faf9f4;
  --white: #ffffff;
  --ink: #171e28;
  --ink-muted: #5b6472;
  --ink-faint: #69707c;
  --line: #e7e5dd;
  --cobalt: #2454ed;
  --cobalt-deep: #1a3dc4;
  --lime: #d5f18c;
  --coral: #ff887d;
  --coral-deep: #d2402f;
  --sky: #e2eeff;
  --pink: #ffe7e7;

  --display: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --hand: "Gaegu", ui-rounded, cursive;

  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.2, 1.35, 0.4, 1);
  --lift:
    0 1px 2px rgb(23 30 40 / 0.06), 0 10px 26px -12px rgb(23 30 40 / 0.22);
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-end: max(16px, env(safe-area-inset-right, 0px));
  /* How much of the street shows under the deck. */
  --street: clamp(36px, 7dvh, 96px);
  /* Room above the deck for the language button and the magpie. */
  --top: 62px;
  /* The language bar above it. */
  --bar: 58px;
  /* The foot of a card and the round Next in it. */
  --foot: 86px;
  --go-size: 68px;
}

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

html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line) var(--canvas);
}

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--canvas);
  color: var(--ink);
  font: 400 1rem/1.625 var(--body);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

::selection {
  background: var(--ink);
  color: var(--white);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

[data-tone="cobalt"] :focus-visible {
  outline-color: var(--white);
}

h1:focus {
  outline: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Top: the language, where a thumb or an eye finds it first ---- */

.top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px var(--gutter-end) 0 var(--gutter);
}

.lang {
  position: relative;
  z-index: 3;
}

.lang summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font: 700 0.875rem/1 var(--display);
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s;
}

.lang summary::-webkit-details-marker {
  display: none;
}

.lang summary:hover,
.lang[open] summary {
  border-color: var(--ink);
}

.lang summary svg {
  color: var(--ink-faint);
  transition: rotate 0.25s var(--out);
}

.lang[open] summary svg {
  rotate: 180deg;
}

.lang img {
  width: 24px;
  height: 18px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(23 30 40 / 0.12);
  object-fit: cover;
}

.lang-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: max-content;
  min-width: 100%;
  max-width: min(18rem, calc(100vw - 32px));
  padding: 6px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--lift);
}

.lang-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  color: var(--ink);
  font: 700 0.9375rem/1 var(--display);
  text-decoration: none;
}

.lang-menu a:hover {
  background: var(--canvas);
}

.lang-menu a svg {
  margin-inline-start: auto;
  color: var(--cobalt);
}

.lang-menu p {
  margin: 4px 0 0;
  padding: 8px 10px 6px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* ---- The deck: the card on top and the edges of the ones to come ---- */

#stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--top) var(--gutter-end) var(--street) var(--gutter);
}

.deck {
  position: relative;
  isolation: isolate;
  width: min(100%, 30rem);
  /* As tall as its card, never taller than the screen less the language
     bar, the magpie's perch and the street. */
  --room: max(
    22rem,
    min(45rem, 100dvh - var(--top) - var(--bar) - var(--street) - 4px)
  );
  max-height: var(--room);
  margin: auto;
}

body.is-done .deck {
  height: auto;
  margin-top: 0;
}

.deck::before,
.deck::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 34px;
  transition:
    background-color 0.45s,
    transform 0.6s var(--spring),
    opacity 0.3s;
}

.deck::before {
  z-index: -1;
  transform: rotate(3.2deg) translate(8px, 8px);
}

.deck::after {
  z-index: -2;
  transform: rotate(-3.4deg) translate(-7px, 12px);
}

.deck[data-next=""]::before,
.deck[data-after=""]::after,
body.is-done .deck::before,
body.is-done .deck::after {
  opacity: 0;
}

.deck[data-next="cobalt"]::before,
.deck[data-after="cobalt"]::after {
  background: var(--cobalt);
}

.deck[data-next="lime"]::before,
.deck[data-after="lime"]::after {
  background: var(--lime);
}

.deck[data-next="coral"]::before,
.deck[data-after="coral"]::after {
  background: var(--coral);
}

.deck[data-next="sky"]::before,
.deck[data-after="sky"]::after {
  background: #d3e3fd;
}

.deck[data-next="paper"]::before,
.deck[data-after="paper"]::after {
  background: var(--white);
  box-shadow: 0 0 0 1.5px var(--line);
}

/* The way to the privacy notice: on the first card and by the email. */
.privacy-link {
  order: -1;
  color: var(--ink-muted);
  font-size: 0.8125rem;
}

.notify .privacy-link {
  display: inline-block;
  margin-top: 8px;
}

/* The privacy notice: a plain page to read. */
.doc-page {
  min-height: 100dvh;
}

.doc {
  max-width: 40rem;
  margin: 0 auto;
  padding: 32px var(--gutter) 64px;
  line-height: 1.6;
}

.doc h1 {
  margin: 16px 0 8px;
  font: 800 2rem/1.15 var(--display);
}

.doc h2 {
  margin: 28px 0 6px;
  font: 700 1.125rem/1.3 var(--display);
}

.doc-lead {
  color: var(--ink-muted);
  font-size: 1.0625rem;
}

.doc ul {
  padding-left: 1.2em;
}

.doc a {
  color: var(--cobalt);
}

/* Where Turnstile shows itself, the rare time it must ask. */
.turnstile {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 50;
  translate: -50% 0;
}

/* ---- A card: one question, as loud as the page gets ---- */

.card {
  --card: var(--white);
  --on: var(--ink);
  --soft: var(--ink-muted);
  --chip: rgb(23 30 40 / 0.08);
  --go: var(--ink);
  --go-on: var(--white);
  --ring: var(--ink);

  position: relative;
  display: flex;
  flex-direction: column;
  /* Sized by what it holds; a card with a long list stops at the room
     the screen has and its list scrolls. A card is the same size before
     an answer and after it: nothing in it changes size. */
  max-height: var(--room);
  padding: 52px 18px 12px;
  border-radius: 34px;
  background: var(--card);
  color: var(--on);
  transition:
    transform 0.6s var(--spring),
    opacity 0.3s;
}

.card.is-entering {
  opacity: 0;
  transform: translateY(20px) scale(0.93) rotate(2.6deg);
}

.card.is-leaving {
  opacity: 0;
  transform: translate(-112%, -4%) rotate(-15deg);
  transition:
    transform 0.34s cubic-bezier(0.5, 0, 0.8, 0.2),
    opacity 0.34s ease-in;
}

.card[data-tone="cobalt"] {
  --card: var(--cobalt);
  --on: var(--white);
  --soft: rgb(255 255 255 / 0.82);
  --chip: rgb(255 255 255 / 0.2);
  --go: var(--white);
  --go-on: var(--ink);
  --ring: var(--lime);
}

.card[data-tone="lime"] {
  --card: var(--lime);
  --soft: #46522a;
}

.card[data-tone="coral"] {
  --card: var(--coral);
  --soft: #5c2a25;
}

.card[data-tone="sky"] {
  --card: #d3e3fd;
  --soft: #40506c;
}

.card[data-tone="paper"] {
  box-shadow: 0 0 0 1.5px var(--line);
}

/* The magpie on the card's top edge, and what it says. */

.perch {
  position: absolute;
  z-index: 2;
  top: -60px;
  inset-inline: 2px 8px;
  display: flex;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
}

.perch img {
  flex: none;
  width: 104px;
  filter: drop-shadow(0 6px 8px rgb(23 30 40 / 0.18));
}

.bubble {
  margin: 4px 0 0;
  padding: 7px 15px 8px;
  border-radius: 18px 18px 18px 4px;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--lift);
  font: 700 clamp(1.125rem, 4.9vw, 1.375rem) / 1.2 var(--hand);
  transform: rotate(-2deg);
  transform-origin: left bottom;
}

/* The magpie's answer back: the bubble hops as it changes. */
.bubble.is-new {
  animation: hop 0.55s var(--spring);
}

@keyframes hop {
  from {
    opacity: 0;
    transform: rotate(-8deg) scale(0.8);
  }
}

.meter {
  position: absolute;
  top: 18px;
  inset-inline: 132px 22px;
  height: 6px;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  inline-size: var(--done, 0%);
  border-radius: inherit;
  background: currentColor;
  opacity: 0.85;
  transition: inline-size 0.6s var(--out);
}

h1 {
  margin: 0;
  /* Sized by the screen's width and its height, so it never crowds a short one. */
  font: 800 clamp(1.625rem, min(9.6vw, 5.2dvh), 3.125rem) / 1 var(--display);
  letter-spacing: -0.04em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.card.is-first h1 {
  font-size: clamp(2rem, min(12vw, 6.8dvh), 3.75rem);
  line-height: 0.98;
}

.hint {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--soft);
  font-weight: 500;
  line-height: 1.5;
}

/* Full: the hint shakes once and says how many may be picked. */
.hint.is-full {
  animation: shake 0.4s;
}

@keyframes shake {
  25% {
    translate: -5px 0;
  }

  75% {
    translate: 5px 0;
  }
}

/* ---- Blocks: one pick, each answer a slab of the card ---- */

body.is-past-first .top {
  visibility: hidden;
}

.blocks {
  flex: 0 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  height: clamp(8.5rem, 24dvh, 13rem);
  margin-top: 20px;
}

/* Three or more: each block keeps room for its share above its words,
   so the two never overlap. */
.blocks:has(.block:nth-child(3)) {
  height: auto;
  grid-auto-rows: 6.5rem;
}

.block {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  min-height: 0;
  padding: 16px;
  border: 0;
  border-radius: 24px;
  background: var(--white);
  color: var(--ink);
  font: 800 clamp(1.25rem, min(6.8vw, 3.6dvh), 2rem) / 1.02 var(--display);
  letter-spacing: -0.035em;
  text-align: start;
  transition:
    transform 0.35s var(--spring),
    background-color 0.25s,
    color 0.25s,
    opacity 0.25s;
}

/* Answers are white; only the first question's pair is two colors, the
   one loud moment of the survey. */
.card.is-first .block:nth-child(2) {
  background: var(--lime);
}

/* Once answered, both turn white so the shares show as they fill. */
.card.is-first.is-answered .block {
  background: var(--white);
}

/* "Something else" reads as the fallback: a quieter white, with words as
   dark as the rest so it still reads as something to tap. */
.block[data-option="other"],
.bar[data-option="other"] {
  background: rgb(255 255 255 / 0.62);
}

.blocks:has(.block:nth-child(3)) .block {
  padding-top: 2.75rem;
  font-size: clamp(1rem, min(5.2vw, 2.8dvh), 1.375rem);
  line-height: 1.08;
}

@media (hover: hover) {
  .block:hover:not(:disabled) {
    transform: translateY(-4px) rotate(-1.2deg);
  }

  .block:nth-child(even):hover:not(:disabled) {
    transform: translateY(-4px) rotate(1.2deg);
  }
}

.block:active:not(:disabled) {
  transform: scale(0.96);
}

.block.is-picked {
  background: var(--ink);
  color: var(--white);
  transform: scale(0.97);
}

.is-sending .block:not(.is-picked) {
  opacity: 0.55;
}

.block-label {
  position: relative;
}

/* A share fills its block from the floor, like a tank. */
.block-fill {
  position: absolute;
  z-index: -1;
  inset: auto 0 0;
  height: 0;
  background: #dbe4f6;
  transition: height 1.1s var(--out);
}

.is-answered .block {
  background: var(--white);
}

.is-answered .block.is-mine .block-fill {
  background: var(--lime);
}

.is-shown .block-fill {
  height: var(--share, 0%);
}

.block .pct {
  position: absolute;
  top: 12px;
  inset-inline-start: 16px;
  font: 800 clamp(2rem, min(12vw, 6.4dvh), 3.5rem) / 1 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.blocks:has(.block:nth-child(3)) .pct {
  top: 12px;
  font-size: 1.5rem;
}

/* The check on an answer of one's own: a sticker on its corner, so the
   answer's words stay where they were. */
.mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.05em;
  height: 1.05em;
  margin-inline-start: 0.3em;
  vertical-align: -0.12em;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  letter-spacing: 0;
  animation: pop 0.45s var(--spring);
}

/* On a block the check sits on the line above the words, so the words
   stay exactly where they were. */
.block .mark {
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 0;
  margin: 0;
}

/* Blocks drawn after the first card: the share and, on one's own pick,
   the check beside it, on their own line above the words. */
.pct-line {
  position: absolute;
  top: 12px;
  inset-inline-start: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.block .pct-line .pct {
  position: static;
}

.block .pct-line .mark {
  position: static;
}

.mark svg {
  width: 62%;
  height: 62%;
}

@keyframes pop {
  from {
    transform: scale(0);
  }
}

/* ---- Bars: every pick that fits, a ragged stack of fat bars ---- */

.bars {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin: 12px -8px 0;
  padding: 4px 8px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--chip) transparent;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
}

.bar {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: none;
  min-height: 50px;
  padding: 8px 14px 8px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font: 700 1rem / 1.2 var(--display);
  letter-spacing: -0.01em;
  text-align: start;
  transition:
    transform 0.35s var(--spring),
    background-color 0.2s,
    color 0.2s;
}

@media (hover: hover) {
  .bar:hover:not(:disabled):not([aria-pressed="true"]) {
    transform: translateX(4px);
  }
}

.bar[aria-pressed="true"] {
  background: var(--ink);
  color: var(--white);
}

/* Two to a row: the words take the cell, the share sits under them. */
.bars.is-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* One height for every cell: the words and the share under them. */
  grid-auto-rows: 74px;
  align-content: start;
}

/* Cells as tall as three or four lines of words need, when some do. */
.bars.is-pair.is-tall {
  grid-auto-rows: 100px;
}

.bars.is-pair .bar {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  align-items: start;
  gap: 4px;
  min-height: 0;
  height: 100%;
  padding: 10px 10px 8px 12px;
  font-size: 0.875rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.bars.is-pair .pct {
  display: block;
  min-width: 0;
  min-height: 1.2em;
  font-size: 0.9375rem;
  text-align: end;
}

.bar.is-out {
  opacity: 0.45;
}

/* The check stands beside the words, level with their first line, so it
   sits in the same place whether the words take one line or three. */
.bar-label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* One bar to a row: words, then a column kept for the check, then the
   share. The check's column is there before any pick. */
.bars:not(.is-pair) .bar {
  grid-template-columns: minmax(0, 1fr) 1.15em auto;
}

.bars:not(.is-pair) .bar > .bar-label {
  grid-column: 1;
}

.bars:not(.is-pair) .bar > .mark {
  grid-column: 2;
  align-self: start;
  margin: calc((1lh - 1.05em) / 2) 0 0;
}

.bars:not(.is-pair) .bar > .pct {
  grid-column: 3;
}

/* Two to a row: the check in the top corner, the words kept clear of it. */
.bars.is-pair .bar-label {
  padding-inline-end: 1.35em;
}

.bars.is-pair .bar > .mark {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  margin: calc((1lh - 1.05em) / 2) 0 0;
}

.is-answered .bar.is-mine .mark {
  background: var(--lime);
  color: var(--ink);
}

.bar.is-picked {
  background: var(--ink);
  color: var(--white);
  transform: rotate(0deg) scale(1.03);
}

.is-sending .bar:not(.is-picked) {
  opacity: 0.55;
}

/* A share fills its bar from the start; the fill is clipped to the bar's
   corners on its own, so the check can sit over the bar's edge. */
.bar-fill {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.bar-fill::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgb(23 30 40 / 0.12);
  transition: width 1.1s var(--out);
}

[dir="rtl"] .bar-fill::before {
  inset: 0 0 0 auto;
}

.is-answered .bar.is-mine {
  background: var(--ink);
  color: var(--white);
}

/* The visitor's own pick fills in cobalt: white words stay readable over it. */
.is-answered .bar.is-mine .bar-fill::before {
  background: var(--cobalt);
}

.card[data-tone="cobalt"].is-answered .bar.is-mine .bar-fill::before {
  background: #5b7bff;
}

.is-answered .bar.is-mine .mark {
  background: var(--lime);
  color: var(--ink);
}

.is-shown .bar-fill::before {
  width: var(--share, 0%);
}

.bar .pct {
  /* The share's place is kept from the start, so a label never rewraps. */
  min-width: 2.7em;
  font-size: 1.125em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-align: end;
}

/* ---- The foot of a card: who answered, and the way on ---- */

.card-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* One height on every card, whatever stands in it, and room above. */
  height: var(--foot);
  margin-top: auto;
  padding-top: 14px;
  box-sizing: content-box;
}

.foot-way {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 80px;
}

.promise,
.people {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--soft);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
}

/* A typed answer too thin to keep: said beside the button, in the card's ink. */
.people.is-hint {
  color: var(--on);
  font-weight: 700;
}

/* Next: a round button whose ring closes as the card counts down. */
.go {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: var(--go-size);
  height: var(--go-size);
  margin: 6px;
  border: 0;
  border-radius: 50%;
  background: var(--go);
  color: var(--go-on);
  font: 800 0.8125rem/1 var(--display);
  transition: transform 0.3s var(--spring);
}

.go:hover {
  transform: scale(1.06);
}

.go:active {
  transform: scale(0.95);
}

.go-rim {
  position: absolute;
  inset: -6px;
}

.go-ring {
  display: block;
  width: 100%;
  height: 100%;
  rotate: -90deg;
}

.go-ring circle {
  fill: none;
  stroke: var(--ring);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.go.is-counting .go-ring circle {
  animation: ring var(--seconds, 5s) linear forwards;
}

@keyframes ring {
  to {
    stroke-dashoffset: 0;
  }
}

.go-arrow {
  display: flex;
  margin-top: 1px;
  transition: translate 0.25s var(--out);
}

.go:hover .go-arrow {
  translate: 3px 0;
}

.primary,
.quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  font: 800 1.0625rem/1 var(--display);
  transition:
    background-color 0.2s,
    opacity 0.2s,
    transform 0.3s var(--spring);
}

.primary {
  background: var(--ink);
  color: var(--white);
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.primary:active:not(:disabled),
.quiet:active:not(:disabled) {
  transform: scale(0.96);
}

.primary:disabled {
  opacity: 0.32;
}

.quiet {
  border: 1.5px solid var(--ink);
  background: var(--white);
  color: var(--ink);
}

.quiet:hover:not(:disabled) {
  background: var(--ink);
  color: var(--white);
}

.link {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: inherit;
  font: 700 0.9375rem/1 var(--display);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

/* ---- Typed answers ---- */

.answer {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 14px;
}

.field {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--white);
  color: var(--ink);
  font-size: 1.0625rem;
  line-height: 1.5;
  caret-color: var(--cobalt);
  transition: border-color 0.2s;
}

textarea.field {
  flex: 0 1 auto;
  height: clamp(6rem, 22dvh, 11rem);
  min-height: 4.5rem;
  resize: none;
}

input.field {
  min-height: 54px;
  border-radius: 999px;
}

.field::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.field:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.failed {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--white);
  color: var(--coral-deep);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

.said {
  margin: 12px 0 0;
  color: var(--coral-deep);
  font-size: 0.9375rem;
  font-weight: 600;
}

.said:empty {
  display: none;
}

.said.is-done {
  color: var(--ink);
}

/* ---- Where from: flags to press ---- */

.countries {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 12px;
}

.countries .field {
  border-color: var(--line);
}

.flags {
  flex: 0 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  align-content: start;
  gap: 4px;
  min-height: 0;
  margin: 8px -8px 0;
  padding: 4px 8px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  /* The list fades out at the card's foot: there is more below. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}

.flag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 2px 10px;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: none;
  font: 700 0.75rem/1.25 var(--display);
  text-align: center;
  transition:
    background-color 0.18s,
    border-color 0.18s,
    opacity 0.18s;
}

.flag img {
  width: 52px;
  height: 39px;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgb(23 30 40 / 0.12),
    0 4px 10px -6px rgb(23 30 40 / 0.3);
  object-fit: cover;
  transition: transform 0.3s var(--spring);
}

.flag span {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

@media (hover: hover) {
  .flag:hover:not(:disabled) {
    background: var(--canvas);
  }

  .flag:hover:not(:disabled) img {
    transform: translateY(-3px) rotate(-3deg);
  }
}

.flag.is-picked {
  background: var(--lime);
  border-color: var(--ink);
}

.flag:disabled:not(.is-picked) {
  opacity: 0.4;
}

.none {
  margin: 16px 2px 0;
  color: var(--ink-muted);
}

/* ---- The end: the type, as a transit pass that lands with confetti ---- */

.card.is-end {
  height: auto;
  padding: 0 0 8px;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.pass {
  position: relative;
  margin-top: 0;
  opacity: 0;
  transform: translateY(46px) rotate(7deg) scale(0.88);
  transition:
    opacity 0.4s,
    transform 0.9s var(--spring);
}

body.is-done #stage {
  padding-top: 52px;
  padding-bottom: 20px;
}

.pass.is-shown {
  opacity: 1;
  transform: rotate(-1.6deg);
}

.pass-magpie {
  position: absolute;
  z-index: 1;
  top: -60px;
  inset-inline-end: 14px;
  width: clamp(80px, 22vw, 104px);
  rotate: 5deg;
}

.pass-card {
  position: relative;
  overflow: hidden;
  padding: 0 20px;
  border-radius: 26px;
  background: var(--white);
  box-shadow:
    0 1px 2px rgb(23 30 40 / 0.06),
    0 20px 40px -20px rgb(23 30 40 / 0.34);
}

.pass-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 34px;
  margin: 0 -20px 14px;
  padding: 0 16px;
  background:
    linear-gradient(
      115deg,
      transparent 0 18%,
      rgb(255 255 255 / 0.22) 18% 24%,
      transparent 24%
    ),
    var(--cobalt);
  color: var(--white);
}

.pass-strip span {
  display: flex;
}

.pass-lead {
  margin: 0 0 6px;
  color: var(--ink-muted);
  font: 700 0.875rem/1 var(--display);
}

.pass h1 {
  display: inline;
  font-size: clamp(1.75rem, min(8.6vw, 4.6dvh), 2.625rem);
  line-height: 1.08;
  /* A swipe of highlighter under every line of the name. */
  background: linear-gradient(
    transparent 64%,
    var(--lime) 64% 92%,
    transparent 92%
  );
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.pass-line {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.pass-same {
  margin: 10px 0 0;
  font: 700 0.9375rem/1.5 var(--display);
}

.pass-same mark {
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--coral);
  color: var(--ink);
}

.pass-skyline {
  width: calc(100% + 40px);
  max-width: none;
  height: 60px;
  margin: 8px -20px 0;
  object-fit: cover;
  object-position: center bottom;
  mask-image: linear-gradient(to bottom, transparent, #000 60%);
}

/* A short screen keeps a slimmer street, so the buttons stay in view. */
@media (max-height: 760px) {
  .pass-skyline {
    height: 40px;
  }
}

.confetti {
  position: absolute;
  z-index: 2;
  inset: -30px 0 auto;
  height: 0;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: 0;
  left: var(--x);
  width: 10px;
  height: 15px;
  border-radius: 3px;
  background: var(--lime);
  opacity: 0;
}

.confetti span[data-color="1"] {
  background: var(--coral);
}

.confetti span[data-color="2"] {
  background: var(--cobalt);
}

.confetti span[data-color="3"] {
  background: var(--ink);
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pass.is-shown .confetti span {
  animation: fall 1.5s var(--delay) cubic-bezier(0.2, 0.6, 0.4, 1) both;
}

@keyframes fall {
  0% {
    opacity: 1;
    transform: translate(0, -40px) rotate(0deg);
  }

  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--drift), 380px) rotate(var(--turn));
  }
}

.share {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
  text-align: center;
}

.share-ask {
  margin: 0 0 10px;
  font: 800 1rem/1.3 var(--display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.send {
  width: 100%;
  min-height: 56px;
  background: var(--cobalt);
  font-size: 1.125rem;
}

.send:hover:not(:disabled) {
  background: var(--cobalt-deep);
}

.copy {
  margin-top: 0;
}

.address {
  margin: 4px 0 0;
  color: var(--cobalt-deep);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.notify {
  margin-top: 10px;
  padding: 16px 18px 18px;
  border-radius: 22px;
  background: var(--white);
  box-shadow: 0 0 0 1.5px var(--line);
}

.notify h2 {
  margin: 0;
  font: 800 1rem/1.3 var(--display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.notify > p {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.notify-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.notify-form .field,
.notify-form .quiet {
  min-height: 48px;
}

.notify-form .quiet {
  flex: none;
  padding: 0 20px;
}

.notify-form .field {
  flex: 1;
  min-width: 0;
  width: auto;
  border-color: var(--line);
}

.noscript {
  margin: 0 var(--gutter) 24px;
  color: var(--coral-deep);
}

/* ---- The street the deck stands on: Seoul, fading up into the paper ---- */

.scene {
  position: absolute;
  inset: auto 0 0;
  height: clamp(140px, 25dvh, 300px);
  overflow: hidden;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, transparent, #000 52%);
}

/* The end has its own skyline, on the pass. */
body.is-done .scene {
  display: none;
}

.scene img {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: max(100%, 56rem);
  max-width: none;
  translate: -50% 0;
}

/* ---- Short screens: the frame gives room to the answers ---- */

@media (max-height: 720px) {
  :root {
    --top: 50px;
    --bar: 52px;
    --foot: 64px;
    --go-size: 54px;
    --street: 20px;
  }

  .top {
    padding-top: 8px;
  }

  .lang summary {
    min-height: 38px;
  }

  .card {
    padding-top: 40px;
  }

  .perch {
    top: -50px;
  }

  .perch img {
    width: 82px;
  }

  .bubble {
    font-size: 1.0625rem;
  }

  .meter {
    top: 12px;
  }

  .go {
    font-size: 0.75rem;
  }
}

/* The smallest phones: the question gives up a little size too. */
@media (max-height: 600px) {
  :root {
    --top: 46px;
    --bar: 52px;
    --street: 10px;
  }

  h1 {
    font-size: clamp(1.5rem, min(9vw, 4.8dvh), 2rem);
  }

  .card.is-first h1 {
    font-size: clamp(1.75rem, min(10.5vw, 5.8dvh), 2.25rem);
  }

  .hint {
    margin-top: 4px;
  }
}

@media (max-width: 380px) {
  .bars {
    gap: 6px;
  }

  .bar {
    padding: 3px 8px 3px 10px;
    font-size: clamp(0.75rem, min(3.6vw, 2dvh), 0.875rem);
  }

  .bar .pct {
    min-width: 2.4em;
  }
}

/* ---- How a share's fill meets the rest: its leading edge ---- */

/* Bars fill left to right: the edge is the fill's right side. */
.card[data-edge="wave"] .bar-fill::before {
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24'%3E%3Cpath d='M0 0H6Q12 6 6 12Q0 18 6 24H0Z'/%3E%3C/svg%3E")
      right top / 12px 24px repeat-y,
    linear-gradient(#000 0 0) left / calc(100% - 11px) 100% no-repeat;
  animation: sway-y 1.6s 1.1s ease-in-out 2;
}

.card[data-edge="zigzag"] .bar-fill::before {
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16'%3E%3Cpath d='M0 0H2L10 8L2 16H0Z'/%3E%3C/svg%3E")
      right top / 10px 16px repeat-y,
    linear-gradient(#000 0 0) left / calc(100% - 9px) 100% no-repeat;
}

.card[data-edge="round"] .bar-fill::before {
  /* A gentle bulge, the same on a short bar and a tall cell. */
  border-radius: 0 18px 18px 0 / 0 50% 50% 0;
}

/* Blocks fill from the floor: the edge is the fill's top. */
.card[data-edge="wave"] .block-fill {
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cpath d='M0 12V6Q6 0 12 6Q18 12 24 6V12Z'/%3E%3C/svg%3E")
      left top / 24px 12px repeat-x,
    linear-gradient(#000 0 0) bottom / 100% calc(100% - 11px) no-repeat;
  animation: sway-x 1.6s 1.1s ease-in-out 2;
}

.card[data-edge="zigzag"] .block-fill {
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10'%3E%3Cpath d='M0 10V8L8 0L16 8V10Z'/%3E%3C/svg%3E")
      left top / 16px 10px repeat-x,
    linear-gradient(#000 0 0) bottom / 100% calc(100% - 9px) no-repeat;
}

.card[data-edge="round"] .block-fill {
  border-radius: 50% 50% 0 0 / 18px 18px 0 0;
}

@keyframes sway-y {
  50% {
    mask-position:
      right 12px,
      left;
  }
}

@keyframes sway-x {
  50% {
    mask-position:
      12px top,
      bottom;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }

  .card.is-entering,
  .pass {
    opacity: 1;
    transform: none;
  }

  .bubble.is-new,
  .mark {
    animation: none;
  }
}
