/* «Код близькості». CSP забороняє style="" у розмітці: динамічні
   розміри JS ставить через element.style (CSSOM), решта -- тут. */
:root {
  color-scheme: light;
  --bg: #fbf1e9;
  --bg-2: #f6e3d6;
  --card: #fffaf6;
  --card-2: #fdeee4;
  --ink: #3a2230;
  --muted: #8a6a72;
  --line: rgba(90, 40, 60, 0.12);
  --accent: #e2566f;
  --accent-2: #f19a6b;
  --accent-ink: #ffffff;
  --blob-1: #ffc9b5;
  --blob-2: #f7b7c8;
  --blob-3: #ffe2a8;
  --shadow: 0 14px 40px rgba(120, 50, 60, 0.12);
  --t-secure: #4f9a7a;
  --t-anxious: #e2566f;
  --t-avoidant: #5b7fc4;
  --t-fearful: #9a6bc4;
  --bubble-them: #ffffff;
  --bubble-me: #e2566f;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d1219;
  --bg-2: #2a1822;
  --card: #2b1c25;
  --card-2: #36232e;
  --ink: #f6e8ec;
  --muted: #c3a8b2;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ff7a8f;
  --accent-2: #ffab7d;
  --accent-ink: #2a0f18;
  --blob-1: #5a2633;
  --blob-2: #4b2246;
  --blob-3: #4f3a22;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  --t-secure: #6cc49d;
  --t-anxious: #ff7a8f;
  --t-avoidant: #82a6ee;
  --t-fearful: #c09aea;
  --bubble-them: #3c2833;
  --bubble-me: #ff7a8f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* Фонові «плями» -- ненав'язлива анімація. */
.aq-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: linear-gradient(180deg, var(--bg), var(--bg-2)); }
.aq-bg span {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: aq-drift 22s ease-in-out infinite alternate;
}
.aq-bg span:nth-child(1) { background: var(--blob-1); top: -25vmax; left: -20vmax; }
.aq-bg span:nth-child(2) { background: var(--blob-2); bottom: -30vmax; right: -25vmax; animation-delay: -7s; }
.aq-bg span:nth-child(3) { background: var(--blob-3); top: 35%; left: 40%; width: 40vmax; height: 40vmax; animation-delay: -13s; opacity: 0.35; }

@keyframes aq-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(6vmax, 4vmax) scale(1.12); }
}

.aq-app { max-width: 560px; margin: 0 auto; }

/* Вихід у чат -- на всіх екранах гри. */
.aq-topbar { display: flex; min-height: 40px; align-items: center; }
.aq-exit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 14px/1 var(--font-body);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.aq-exit:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }

.aq-screen { animation: aq-in 0.45s cubic-bezier(.2, .7, .2, 1) both; }
.aq-screen.is-leaving { animation: aq-out 0.22s ease both; }

@keyframes aq-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes aq-out {
  to { opacity: 0; transform: translateY(-10px); }
}

/* --- старт --- */
.aq-start {
  min-height: calc(100dvh - 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px 4px;
}

.aq-start-art { position: relative; width: 140px; height: 140px; display: grid; place-items: center; margin-bottom: 8px; }
.aq-start-emoji {
  font-size: 64px;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  animation: aq-float 4s ease-in-out infinite;
}
.aq-heart { position: absolute; color: var(--accent); font-size: 22px; animation: aq-float 3.4s ease-in-out infinite; }
.aq-heart--a { top: 2px; right: 0; }
.aq-heart--b { bottom: 10px; left: -4px; font-size: 16px; color: var(--accent-2); animation-delay: -1.6s; }

@keyframes aq-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.aq-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 9vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.aq-slogan { margin: 0; max-width: 34ch; font-size: 17px; color: var(--muted); }
.aq-meta { margin: 0; font-size: 14px; color: var(--muted); }

.aq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  font: 700 17px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.aq-btn:active { transform: scale(0.97); }
.aq-btn:disabled { opacity: 0.5; cursor: default; }
.aq-btn:focus-visible, .aq-option:focus-visible, .aq-back:focus-visible, .aq-lang button:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
}
.aq-btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 10px 24px rgba(226, 86, 111, 0.32);
  min-width: 220px;
}
.aq-btn--ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.aq-btn--chat { background: var(--card); color: var(--accent); border: 2px solid var(--accent); }
.aq-chat-hint { margin: -2px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

.aq-lang { display: flex; gap: 4px; margin-top: 8px; padding: 4px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.aq-lang button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 700 13px/1 var(--font-body);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.aq-lang button.is-active { background: var(--accent); color: var(--accent-ink); }

/* --- сцена --- */
.aq-scene-head { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.aq-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 15px/1 var(--font-body);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.aq-back[disabled] { visibility: hidden; }
.aq-progress-label { font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.aq-progress { height: 6px; margin: 10px 0 18px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.aq-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.45s cubic-bezier(.2, .7, .2, 1);
}

.aq-scene-body.is-turning { animation: aq-turn 0.4s cubic-bezier(.2, .7, .2, 1) both; }
.aq-scene-body.is-turning-back { animation: aq-turn-back 0.4s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes aq-turn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes aq-turn-back { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

.aq-visual {
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}

/* Візуал «ситуація»: велика емоджі на м'якому градієнті. */
.aq-illustration {
  position: relative;
  height: 150px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, var(--blob-3), transparent 60%), radial-gradient(circle at 75% 70%, var(--blob-2), transparent 60%), var(--card-2);
}
.aq-illustration-main { font-size: 68px; line-height: 1; animation: aq-float 4s ease-in-out infinite; }
.aq-illustration-accent { position: absolute; right: 22%; top: 20%; font-size: 30px; animation: aq-float 3.2s ease-in-out infinite; animation-delay: -1s; }
.aq-illustration-caption {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Візуал «переписка». */
.aq-chat { padding: 0 0 14px; background: var(--card-2); }
.aq-chat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
}
.aq-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  font-size: 15px;
}
.aq-chat-list { display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 0; }
.aq-bubble {
  max-width: 82%;
  padding: 9px 12px 7px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  animation: aq-pop 0.35s cubic-bezier(.2, .8, .3, 1.3) both;
  animation-delay: 0.15s;
}
.aq-bubble time { display: block; margin-top: 2px; font-size: 11px; opacity: 0.7; text-align: right; }
.aq-bubble--them { align-self: flex-start; background: var(--bubble-them); color: var(--ink); border-bottom-left-radius: 6px; }
.aq-bubble--me { align-self: flex-end; background: var(--bubble-me); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.aq-chat-status { align-self: flex-end; font-size: 12px; color: var(--muted); padding-right: 4px; }
@keyframes aq-pop { from { opacity: 0; transform: scale(0.85) translateY(6px); } to { opacity: 1; transform: none; } }

.aq-scene-title { margin: 0 0 6px; font-family: var(--font-display); font-size: 24px; line-height: 1.2; }
.aq-scene-text { margin: 0 0 18px; font-size: 17px; }

.aq-options { display: grid; gap: 10px; }
.aq-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font: 500 16px/1.4 var(--font-body);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(120, 50, 60, 0.07);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  animation: aq-in 0.4s cubic-bezier(.2, .7, .2, 1) both;
}
.aq-option:nth-child(2) { animation-delay: 0.06s; }
.aq-option:nth-child(3) { animation-delay: 0.12s; }
.aq-option:nth-child(4) { animation-delay: 0.18s; }
.aq-option-mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
@media (hover: hover) {
  .aq-option:hover { border-color: var(--line); transform: translateY(-1px); }
}
.aq-option:active { transform: scale(0.98); }
.aq-option.is-selected { border-color: var(--accent); background: var(--card-2); }
.aq-option.is-selected .aq-option-mark { background: var(--accent); color: var(--accent-ink); }
.aq-options.is-locked .aq-option { pointer-events: none; }

/* --- обробка --- */
.aq-processing {
  min-height: calc(100dvh - 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.aq-pulse { position: relative; width: 120px; height: 120px; margin-bottom: 18px; }
.aq-pulse span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  opacity: 0.6;
  animation: aq-ring 1.8s ease-out infinite;
}
.aq-pulse span:nth-child(2) { animation-delay: 0.6s; }
.aq-pulse span:nth-child(3) { animation-delay: 1.2s; }
@keyframes aq-ring {
  from { transform: scale(0.3); opacity: 0.8; }
  to { transform: scale(1.1); opacity: 0; }
}
.aq-processing-text { margin: 0; font-family: var(--font-display); font-size: 24px; }
.aq-processing-step { margin: 0; min-height: 1.5em; color: var(--muted); }

/* --- результат --- */
.aq-result-hero { text-align: center; padding: 8px 0 4px; }
.aq-result-art {
  width: 120px;
  height: 120px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 60px;
  background: var(--card);
  box-shadow: var(--shadow), 0 0 0 8px rgba(226, 86, 111, 0.12);
  animation: aq-pop 0.6s cubic-bezier(.2, .8, .3, 1.3) both;
}
.aq-kicker { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.aq-result-title { margin: 6px 0 6px; font-family: var(--font-display); font-size: clamp(30px, 8vw, 40px); line-height: 1.1; color: var(--type-color, var(--accent)); }
.aq-result-tagline { margin: 0 auto; max-width: 30ch; font-size: 18px; font-style: italic; }
.aq-mixed { margin: 18px 0 0; padding: 14px 16px; border-radius: 18px; background: var(--card-2); font-size: 15px; }
.aq-result-summary { margin: 18px 0; font-size: 17px; }

.aq-card { margin: 0 0 14px; padding: 18px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.aq-card h3 { margin: 0 0 14px; font-size: 16px; }

.aq-bars { display: grid; gap: 12px; }
.aq-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: 15px; }
.aq-bar-row strong { font-variant-numeric: tabular-nums; }
.aq-bar-track { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.aq-bar-fill { height: 100%; width: 0; border-radius: 999px; transition: width 0.9s cubic-bezier(.2, .7, .2, 1); }
.aq-fill-secure { background: var(--t-secure); }
.aq-fill-anxious { background: var(--t-anxious); }
.aq-fill-avoidant { background: var(--t-avoidant); }
.aq-fill-fearful { background: var(--t-fearful); }
.aq-bar-row.is-primary { font-weight: 700; }

.aq-map svg { display: block; width: 100%; height: auto; max-width: 360px; margin: 0 auto; }
.aq-map .q-secure { fill: var(--t-secure); }
.aq-map .q-anxious { fill: var(--t-anxious); }
.aq-map .q-avoidant { fill: var(--t-avoidant); }
.aq-map .q-fearful { fill: var(--t-fearful); }
.aq-map .q { opacity: 0.14; }
.aq-map .q.is-active { opacity: 0.3; }
.aq-map .q-label { fill: var(--ink); font: 600 11px var(--font-body); opacity: 0.75; }
.aq-map .axis { stroke: var(--line); stroke-width: 1.5; }
.aq-map .axis-label { fill: var(--muted); font: 600 11px var(--font-body); }
.aq-map .dot-ring { fill: var(--card); }
.aq-map .dot { fill: var(--ink); }
.aq-map .dot-halo { fill: var(--ink); opacity: 0.15; animation: aq-halo 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes aq-halo { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.5); } }
.aq-map-caption { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

.aq-sections { display: grid; gap: 14px; margin-bottom: 18px; }
.aq-section { padding: 18px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.aq-section h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 16px; }
.aq-section p { margin: 0; }
.aq-section ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.aq-actions { display: grid; gap: 10px; }
.aq-actions .aq-btn { width: 100%; }
.aq-disclaimer { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-align: center; }

/* --- поширення --- */
.aq-share-preview {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(20, 8, 14, 0.6);
  animation: aq-in 0.25s ease both;
}
.aq-share-card {
  position: relative;
  width: min(100%, 380px);
  max-height: 100%;
  overflow: auto;
  padding: 16px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}
.aq-share-card img { width: 100%; border-radius: 16px; display: block; }
.aq-share-card p { margin: 12px 0; font-size: 14px; color: var(--muted); }
.aq-share-actions { display: grid; gap: 8px; }
.aq-share-actions .aq-btn { width: 100%; min-width: 0; }
.aq-share-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--card-2);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  z-index: 1;
}

.aq-toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  body { padding-top: 40px; }
  .aq-option { padding: 16px 18px; }
}

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