/* ============================================================================
   COUNTRY CLASH — styles.css
   A dark, aurora-lit, glassmorphic social icebreaker.
   Type: Clash Display (headlines, a wink at the name) + General Sans (UI).
   ----------------------------------------------------------------------------
   Contents
     1.  Tokens
     2.  Reset & base
     3.  Aurora backdrop
     4.  Primitives (buttons, inputs, fields, searchbar, toast)
     5.  Intro (cinematic)
     6.  Login
     7.  App shell (topbar, views, tabbar)
     8.  Deck & swipe card
     9.  Card bodies (vote_country, text_answer)
     10. Deck state screens (loading / error / empty / done)
     11. Results
     12. People
     13. Country picker sheet
     14. Motion keyframes
     15. Responsive & accessibility
   ========================================================================== */

/* 1 · TOKENS ------------------------------------------------------------- */
:root {
  /* type */
  --font-display: "Clash Display", "General Sans", system-ui, sans-serif;
  --font-body: "General Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* surface / ink */
  --bg-0: #08070f;
  --bg-1: #0e0b1a;
  --ink: #f5f3fc;
  --ink-2: rgba(245, 243, 252, 0.64);
  --ink-3: rgba(245, 243, 252, 0.42);
  --line: rgba(255, 255, 255, 0.10);
  --line-2: rgba(255, 255, 255, 0.055);
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.075);
  --glass-3: rgba(255, 255, 255, 0.11);

  /* hues */
  --violet: #7c5cff;
  --pink: #ff5ca8;
  --cyan: #29e0d0;
  --amber: #ffb443;
  --mint: #34e0a1;   /* send  */
  --coral: #ff6b6b;  /* skip  */

  --grad-primary: linear-gradient(135deg, #8a6bff 0%, #ff5ca8 100%);
  --grad-cool: linear-gradient(135deg, #29e0d0 0%, #7c5cff 100%);
  --grad-text: linear-gradient(120deg, #ffffff 0%, #d7ccff 40%, #ff9ecb 100%);

  /* radii */
  --r-xl: 30px;
  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 11px;
  --r-pill: 999px;

  /* shadows */
  --shadow-card: 0 30px 80px -20px rgba(0, 0, 0, 0.65),
                 0 2px 0 0 rgba(255, 255, 255, 0.06) inset,
                 0 0 0 1px var(--line);
  --shadow-float: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 40px -8px color-mix(in srgb, var(--violet) 55%, transparent);

  /* blur */
  --blur: blur(26px) saturate(150%);

  /* layout */
  --page-max: 460px;      /* mobile-first column width */
  --tabbar-h: 74px;
  --topbar-h: 58px;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 2 · RESET & BASE ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--ink);
  min-height: 100svh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* lock scroll bounce on the app shell; views scroll internally */
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg { display: block; fill: currentColor; }
input, textarea { outline: none; }
::selection { background: color-mix(in srgb, var(--pink) 45%, transparent); }

/* consistent focus ring for keyboard users */
:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--cyan) 80%, white);
  outline-offset: 2px;
  border-radius: 6px;
}

.is-hidden { display: none !important; }
[hidden] { display: none !important; }

/* 3 · AURORA BACKDROP ---------------------------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 90% at 50% -10%, #16112b 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  overflow: hidden;
}
.blob {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  mix-blend-mode: screen;
  will-change: transform;
}
.blob--violet {
  background: radial-gradient(circle at 30% 30%, var(--violet), transparent 62%);
  top: -22vmax; left: -14vmax;
  animation: drift-a 34s var(--ease-out) infinite alternate;
}
.blob--pink {
  background: radial-gradient(circle at 60% 40%, var(--pink), transparent 60%);
  bottom: -26vmax; right: -18vmax;
  animation: drift-b 40s var(--ease-out) infinite alternate;
}
.blob--cyan {
  background: radial-gradient(circle at 50% 50%, var(--cyan), transparent 58%);
  top: 30%; left: 40%;
  opacity: 0.32;
  animation: drift-c 46s var(--ease-out) infinite alternate;
}
/* fine film grain to kill banding on the gradients */
.grain {
  position: absolute; inset: 0;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* 4 · PRIMITIVES --------------------------------------------------------- */

/* --- card shell --- */
.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-card);
}

/* --- buttons --- */
.btn {
  --pad-y: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: var(--pad-y) 22px;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  transition: transform 0.18s var(--ease-spring), filter 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn--block { display: flex; width: 100%; }
.btn--primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 12px 34px -12px color-mix(in srgb, var(--pink) 70%, transparent),
              0 1px 0 0 rgba(255, 255, 255, 0.25) inset;
}
.btn--primary:hover { filter: brightness(1.06); }
.btn__arrow { width: 20px; height: 20px; transition: transform 0.25s var(--ease-spring); }
.btn--primary:hover .btn__arrow { transform: translateX(3px); }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  background: var(--glass);
  border: 1px solid var(--line-2);
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--glass-2); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 20px; height: 20px; }

/* --- fields / inputs --- */
.field { display: block; margin-bottom: 18px; }
.field__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}
.field__hint { display: block; font-size: 0.76rem; color: var(--ink-3); margin-top: 7px; }
.input {
  width: 100%;
  padding: 15px 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 1rem;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  border-color: color-mix(in srgb, var(--violet) 75%, white 5%);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 22%, transparent);
}

/* trigger button that opens the country picker */
.country-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.country-trigger:hover { background: rgba(0, 0, 0, 0.3); border-color: var(--glass-3); }
.country-trigger:active { transform: scale(0.99); }
.country-trigger__flag { font-size: 1.5rem; line-height: 1; }
.country-trigger__text { flex: 1; font-weight: 500; color: var(--ink); }
.country-trigger.is-empty .country-trigger__text { color: var(--ink-3); font-weight: 400; }
.country-trigger__chev { width: 18px; height: 18px; color: var(--ink-3); }

/* --- searchbar --- */
.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.searchbar:focus-within {
  border-color: color-mix(in srgb, var(--cyan) 60%, white 5%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 18%, transparent);
}
.searchbar__icon { width: 19px; height: 19px; color: var(--ink-3); flex: none; }
.searchbar__input {
  flex: 1;
  background: none;
  border: none;
  font-size: 0.95rem;
}
.searchbar__input::placeholder { color: var(--ink-3); }
.searchbar__input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* --- toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 90;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: rgba(20, 16, 34, 0.9);
  border: 1px solid var(--line);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-float);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease-spring);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* 5 · INTRO -------------------------------------------------------------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 100% at 50% 40%, transparent 40%, var(--bg-0) 100%);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.intro.is-leaving { opacity: 0; transform: scale(1.04); pointer-events: none; }
.intro__flags { position: absolute; inset: 0; overflow: hidden; }
.intro__flag {
  position: absolute;
  font-size: 2rem;
  opacity: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
  animation: flag-float 6s var(--ease-out) forwards;
  will-change: transform, opacity;
}
.intro__copy { position: relative; text-align: center; max-width: 620px; }
.intro__globe {
  width: 58px; height: 58px;
  margin: 0 auto 22px;
  color: var(--cyan);
  opacity: 0;
  animation: rise 0.9s var(--ease-spring) 0.1s forwards, spin-slow 22s linear infinite;
}
.intro__globe svg { width: 100%; height: 100%; }
.intro__title {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.intro__title .line:first-child {
  display: block;
  font-size: clamp(1rem, 4vw, 1.35rem);
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.intro__brand {
  display: block;
  font-size: clamp(2.8rem, 13vw, 5.2rem);
  font-weight: 700;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.intro__sub {
  margin-top: 20px;
  font-size: clamp(1rem, 4.4vw, 1.4rem);
  color: var(--ink);
  font-weight: 500;
}
.intro__meta {
  margin-top: 10px;
  font-size: clamp(0.8rem, 3.4vw, 1rem);
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
/* staggered blur-in for each .line */
.intro .line {
  opacity: 0;
  filter: blur(12px);
  transform: translateY(14px);
  animation: text-in 0.9s var(--ease-out) forwards;
}
.intro .line[data-i="0"] { animation-delay: 0.15s; }
.intro .line[data-i="1"] { animation-delay: 0.3s; }
.intro .line[data-i="2"] { animation-delay: 0.7s; }
.intro .line[data-i="3"] { animation-delay: 1.0s; }

/* 6 · LOGIN -------------------------------------------------------------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 0.6s var(--ease-out);
}
.login__card {
  width: 100%;
  max-width: 400px;
  padding: 34px 28px 30px;
  position: relative;
  animation: rise 0.7s var(--ease-spring);
}
.login__badge {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--grad-cool);
  color: #04121a;
  box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--cyan) 70%, transparent);
  margin-bottom: 20px;
}
.login__badge svg { width: 26px; height: 26px; }
.login__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login__lede { color: var(--ink-2); margin: 6px 0 26px; }

/* 7 · APP SHELL ---------------------------------------------------------- */
.app {
  position: relative;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  min-height: 100svh;
  padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  animation: fade-in 0.5s var(--ease-out);
}

.topbar {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: 100%;
  max-width: var(--page-max);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(var(--bg-0), color-mix(in srgb, var(--bg-0) 20%, transparent));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.topbar__brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}
.topbar__globe { width: 22px; height: 22px; color: var(--cyan); }
.me-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--line);
  transition: background 0.2s, transform 0.15s;
}
.me-chip:hover { background: var(--glass-2); }
.me-chip:active { transform: scale(0.95); }
.me-chip__flag { font-size: 1.15rem; line-height: 1; }
.me-chip__name { font-weight: 600; font-size: 0.9rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* views */
.view { display: none; padding: 0 18px; }
.view.is-active { display: block; animation: view-in 0.4s var(--ease-out); }
.view__head { padding: 12px 0 16px; }
.view__title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.view__lede { color: var(--ink-2); margin: 2px 0 16px; font-size: 0.95rem; }

/* the play view centers the deck vertically in available space */
.view--play {
  padding: 0 18px;
  min-height: calc(100svh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: none;
}
.view--play.is-active { display: flex; flex-direction: column; }
.view--play.is-active { display: flex; flex-direction: column; }

/* tabbar */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: 100%;
  max-width: var(--page-max);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(10, 8, 18, 0.72);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.tabbar__pill {
  position: absolute;
  top: 8px;
  left: 14px;
  width: calc((100% - 28px - 8px) / 3);
  height: 50px;
  border-radius: var(--r-md);
  background: var(--glass-2);
  border: 1px solid var(--line);
  transition: transform 0.34s var(--ease-spring);
  pointer-events: none;
}
.tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--r-md);
  color: var(--ink-3);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.25s;
}
.tab svg { width: 22px; height: 22px; transition: transform 0.25s var(--ease-spring); }
.tab.is-active { color: var(--ink); }
.tab.is-active svg { transform: translateY(-1px) scale(1.05); }
.tab:active svg { transform: scale(0.9); }

/* 8 · DECK & SWIPE CARD -------------------------------------------------- */
.deck {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px 0;
  overflow: hidden;
}

/* a single swipe card */
.card-swipe {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 400px;
  margin-inline: auto;          /* center horizontally; swipe JS owns transform */
  display: flex;
  flex-direction: column;
  padding: 26px 24px 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-card);
  touch-action: pan-y;         /* lets JS decide horizontal vs vertical */
  user-select: none;
  will-change: transform;
  /* --tint is driven by JS while dragging: -1 (skip) … +1 (send) */
  --tint: 0;
}
/* directional glow tinted by --tint */
.card-swipe::after {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--mint) calc(max(0, var(--tint)) * 100%), transparent) inset,
    0 0 44px -6px color-mix(in srgb, var(--mint) calc(max(0, var(--tint)) * 80%), transparent);
}
.card-swipe::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--coral) calc(max(0, calc(var(--tint) * -1)) * 100%), transparent) inset,
    0 0 44px -6px color-mix(in srgb, var(--coral) calc(max(0, calc(var(--tint) * -1)) * 80%), transparent);
}
/* the card behind (peek), non-interactive */
.card-swipe.is-behind {
  transform: scale(0.94) translateY(18px);
  opacity: 0.55;
  filter: blur(0.4px);
  pointer-events: none;
}
.card-swipe.is-dragging { transition: none; }
.card-swipe.is-settling { transition: transform 0.4s var(--ease-spring), opacity 0.4s; }
.card-swipe.is-gone { transition: transform 0.45s var(--ease-out), opacity 0.4s; opacity: 0; }

/* SEND / SKIP stamps */
.card-badge {
  position: absolute;
  top: 26px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  border: 2.5px solid currentColor;
  text-transform: uppercase;
}
.card-badge--send { right: 22px; color: var(--mint); transform: rotate(10deg); opacity: max(0, var(--tint)); }
.card-badge--skip { left: 22px; color: var(--coral); transform: rotate(-10deg); opacity: max(0, calc(var(--tint) * -1)); }

/* card header */
.card-swipe__cat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--glass-2);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 18px;
}
.card-swipe__cat .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--grad-cool);
}
.card-swipe__q {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 6.4vw, 1.95rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

/* 9 · CARD BODIES -------------------------------------------------------- */

/* --- vote_country --- */
.card-swipe__body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.vote-search { margin-bottom: 12px; }
.vote-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 0 -8px;
  padding: 0 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-3) transparent;
}
.vote-list::-webkit-scrollbar { width: 6px; }
.vote-list::-webkit-scrollbar-thumb { background: var(--glass-3); border-radius: 99px; }

.c-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.16s, border-color 0.16s, transform 0.12s;
}
.c-row + .c-row { margin-top: 3px; }
.c-row:hover { background: var(--glass); }
.c-row:active { transform: scale(0.99); }
.c-row__flag { font-size: 1.5rem; line-height: 1; flex: none; }
.c-row__name { flex: 1; font-weight: 500; }
.c-row__tick {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  color: transparent;
  flex: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.c-row__tick svg { width: 14px; height: 14px; }
.c-row.is-selected {
  background: color-mix(in srgb, var(--violet) 16%, transparent);
  border-color: color-mix(in srgb, var(--violet) 55%, transparent);
}
.c-row.is-selected .c-row__tick {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
}

/* --- text_answer --- */
.text-answer { flex: 1; display: flex; flex-direction: column; }
.text-answer__area {
  flex: 1;
  width: 100%;
  min-height: 150px;
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  font-size: 1.15rem;
  line-height: 1.45;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.text-answer__area::placeholder { color: var(--ink-3); }
.text-answer__area:focus {
  border-color: color-mix(in srgb, var(--violet) 70%, white 5%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 20%, transparent);
}
.text-answer__meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px;
  font-size: 0.8rem; color: var(--ink-3);
}
.text-answer__count { font-variant-numeric: tabular-nums; font-weight: 600; }
.text-answer__count.is-near { color: var(--amber); }
.text-answer__count.is-max { color: var(--coral); }

/* deck controls (explicit buttons, mirror the swipe) */
.deck-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 0 6px;
}
.deck-controls__hint { font-size: 0.78rem; color: var(--ink-3); min-width: 150px; text-align: center; }
.round-btn {
  display: grid; place-items: center;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: transform 0.16s var(--ease-spring), box-shadow 0.2s, border-color 0.2s;
}
.round-btn svg { width: 26px; height: 26px; }
.round-btn:active { transform: scale(0.88); }
.round-btn--skip { color: var(--coral); }
.round-btn--skip:hover { border-color: color-mix(in srgb, var(--coral) 55%, transparent); box-shadow: 0 0 24px -8px var(--coral); }
.round-btn--send { color: var(--mint); }
.round-btn--send:hover { border-color: color-mix(in srgb, var(--mint) 55%, transparent); box-shadow: 0 0 24px -8px var(--mint); }

/* 10 · DECK STATE SCREENS ------------------------------------------------ */
.state {
  text-align: center;
  max-width: 340px;
  padding: 20px;
  animation: rise 0.5s var(--ease-spring);
}
.state__emoji { font-size: 3.4rem; margin-bottom: 14px; }
.state__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.state__text { color: var(--ink-2); line-height: 1.55; margin-bottom: 20px; }
.state .btn { margin: 0 auto; }

/* loading spinner (globe orbit) */
.loader {
  position: relative;
  width: 62px; height: 62px;
  margin: 0 auto 20px;
}
.loader__ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--cyan);
  border-right-color: var(--violet);
  animation: spin 1s linear infinite;
}
.loader__core {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 1.6rem;
  animation: pulse 1.6s ease-in-out infinite;
}
.loader-dots { display: inline-flex; gap: 4px; }
.loader-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0.3s; }

/* 11 · RESULTS ----------------------------------------------------------- */
.results-list { display: flex; flex-direction: column; gap: 16px; padding-bottom: 8px; }

.result-card {
  padding: 20px 18px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.result-card__cat {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 6px;
}
.result-card__q {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 600; line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.result-card__count { font-size: 0.82rem; color: var(--ink-3); margin-bottom: 16px; }

/* vote bars */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 8px;
}
.bar__fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(0);
  border-radius: var(--r-md);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--violet) 42%, transparent),
    color-mix(in srgb, var(--pink) 34%, transparent));
  transition: transform 0.9s var(--ease-out);
}
.bar:first-of-type .bar__fill {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--violet) 62%, transparent),
    color-mix(in srgb, var(--pink) 52%, transparent));
}
.bar.is-you { box-shadow: 0 0 0 1px color-mix(in srgb, var(--cyan) 60%, transparent) inset; }
.bar__flag { position: relative; font-size: 1.35rem; line-height: 1; flex: none; }
.bar__name { position: relative; flex: 1; font-weight: 500; font-size: 0.95rem; }
.bar__name .you-tag {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--cyan); margin-left: 7px;
  padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--cyan) 16%, transparent);
  vertical-align: middle;
}
.bar__pct {
  position: relative;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.bar__votes { position: relative; font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }

/* text-answer feed inside a result card */
.answers { display: flex; flex-direction: column; gap: 10px; }
.answer {
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line-2);
}
.answer.is-you { border-color: color-mix(in srgb, var(--cyan) 45%, transparent); background: color-mix(in srgb, var(--cyan) 7%, rgba(0,0,0,0.18)); }
.answer__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.answer__flag { font-size: 1.2rem; line-height: 1; }
.answer__name { font-weight: 600; font-size: 0.9rem; }
.answer__country { font-size: 0.76rem; color: var(--ink-3); margin-left: auto; }
.answer__text { font-size: 1rem; line-height: 1.45; color: var(--ink); }
.answer__more {
  margin: 4px auto 0; display: block;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-2);
  padding: 6px 10px; border-radius: var(--r-pill);
}
.answer__more:hover { color: var(--ink); background: var(--glass); }

/* reactions */
.reactions { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.react {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: var(--glass);
  border: 1px solid var(--line-2);
  font-size: 0.85rem;
  transition: transform 0.15s var(--ease-spring), background 0.18s, border-color 0.18s;
}
.react:hover { background: var(--glass-2); }
.react:active { transform: scale(0.88); }
.react.is-on {
  background: color-mix(in srgb, var(--pink) 18%, transparent);
  border-color: color-mix(in srgb, var(--pink) 45%, transparent);
}
.react__emoji { font-size: 1rem; line-height: 1; transition: transform 0.2s var(--ease-spring); }
.react.is-pop .react__emoji { animation: react-pop 0.4s var(--ease-spring); }
.react__n { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.8rem; color: var(--ink-2); min-width: 8px; }
.react.is-on .react__n { color: var(--ink); }

/* 12 · PEOPLE ------------------------------------------------------------ */
.people-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.person {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  animation: rise 0.4s var(--ease-out) both;
}
.person.is-you { border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }
.person__avatar {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 1.7rem;
  flex: none;
  background: var(--glass-2);
  border: 1px solid var(--line);
}
.person__avatar .flag { line-height: 1; }
.person__body { flex: 1; min-width: 0; }
.person__top { display: flex; align-items: baseline; gap: 8px; }
.person__name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em; }
.person__you {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; color: var(--cyan);
  padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--cyan) 16%, transparent);
}
.person__country { font-size: 0.82rem; color: var(--ink-3); margin-bottom: 8px; }
.person__stats { display: flex; gap: 16px; margin-bottom: 8px; }
.person__stat { display: flex; align-items: baseline; gap: 5px; }
.person__stat b { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.person__stat span { font-size: 0.72rem; color: var(--ink-3); }
.person__recent {
  font-size: 0.86rem;
  color: var(--ink-2);
  line-height: 1.4;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line-2);
}
.person__recent .q { color: var(--ink-3); font-size: 0.74rem; display: block; margin-bottom: 2px; }

/* generic empty row for search misses */
.empty-note {
  text-align: center;
  color: var(--ink-3);
  padding: 40px 20px;
  font-size: 0.95rem;
}
.empty-note .em { font-size: 2rem; display: block; margin-bottom: 10px; }

/* 13 · COUNTRY PICKER SHEET --------------------------------------------- */
.picker { position: fixed; inset: 0; z-index: 60; }
.picker__backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 3, 10, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.3s ease;
}
.picker__sheet {
  position: absolute;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--page-max);
  max-height: 86svh;
  display: flex;
  flex-direction: column;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  background: rgba(14, 11, 26, 0.86);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: 0 -30px 80px -20px rgba(0, 0, 0, 0.7);
  animation: sheet-up 0.42s var(--ease-spring);
}
.picker.is-closing .picker__sheet { animation: sheet-down 0.3s var(--ease-out) forwards; }
.picker.is-closing .picker__backdrop { animation: fade-out 0.3s ease forwards; }
.picker__grabber {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--glass-3);
  margin: 4px auto 12px;
}
.picker__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.picker__title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.searchbar--in-sheet { margin-bottom: 12px; }
.picker__list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-3) transparent;
}
.picker__list::-webkit-scrollbar { width: 6px; }
.picker__list::-webkit-scrollbar-thumb { background: var(--glass-3); border-radius: 99px; }

/* 14 · MOTION KEYFRAMES -------------------------------------------------- */
@keyframes drift-a { to { transform: translate(14vmax, 10vmax) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-12vmax, -8vmax) scale(1.1); } }
@keyframes drift-c { to { transform: translate(-8vmax, 12vmax) scale(0.9); } }

@keyframes text-in { to { opacity: 1; filter: blur(0); transform: translateY(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: 0.7; } }
@keyframes dot-bounce { 0%,100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-6px); opacity: 1; } }
@keyframes react-pop { 0% { transform: scale(1); } 45% { transform: scale(1.45) rotate(-8deg); } 100% { transform: scale(1); } }
@keyframes sheet-up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheet-down { to { transform: translate(-50%, 100%); } }
@keyframes flag-float {
  0% { opacity: 0; transform: translateY(30px) scale(0.6); }
  20% { opacity: 0.9; }
  80% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-120px) scale(1); }
}

/* 15 · RESPONSIVE & ACCESSIBILITY --------------------------------------- */

/* Desktop: keep the phone-width column but give it a premium framed feel */
@media (min-width: 620px) {
  :root { --page-max: 480px; }
  .app {
    margin: 22px auto;
    min-height: min(880px, calc(100svh - 44px));
    border: 1px solid var(--line);
    border-radius: 34px;
    overflow: hidden;
    box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.8);
    background: color-mix(in srgb, var(--bg-1) 55%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  .topbar, .tabbar { position: absolute; }
  .topbar { border-radius: 34px 34px 0 0; }
  .tabbar { border-radius: 0 0 34px 34px; }
  .picker__sheet { border-radius: 26px; bottom: auto; top: 50%; transform: translate(-50%, -50%); animation: rise 0.4s var(--ease-spring); }
  .picker.is-closing .picker__sheet { animation: fade-out 0.25s ease forwards; }
  .view, .view--play { padding-left: 22px; padding-right: 22px; }
  /* hover affordance only where a real pointer exists */
  .card-swipe { cursor: grab; }
  .card-swipe.is-dragging { cursor: grabbing; }
}

@media (min-width: 620px) {
  .toast { position: absolute; }
}

/* respect reduced-motion: kill ambient/looping motion, keep instant states */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.05ms !important;
  }
  .blob { animation: none; }
  .intro .line, .intro__globe { opacity: 1; filter: none; transform: none; }
}
