:root {
  --green-dark: #075e54;
  --green: #128c7e;
  --green-light: #d9fdd3;
  --accent: #25d366;
  --ink: #172522;
  --muted: #64716e;
  --paper: #fff;
  --chat-bg: #efeae2;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(37, 211, 102, .14), transparent 25rem),
    linear-gradient(150deg, #f8f4ed 0%, #e9f7f0 100%);
  font-family: Poppins, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

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

.quiz-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.phone {
  width: min(100%, 510px);
  min-width: 0;
  height: min(820px, calc(100vh - 44px));
  height: min(820px, calc(100dvh - 44px));
  min-height: 590px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  overflow: hidden;
  background: var(--chat-bg);
  border: 1px solid rgba(7, 94, 84, .12);
  border-radius: 28px;
  box-shadow: 0 26px 70px rgba(23, 54, 46, .18);
}

.chat-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #fff;
  background: var(--green-dark);
}

.chat-header img {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
}

.chat-contact { min-width: 0; flex: 1; }
.chat-contact strong { display: block; font-size: .98rem; }
.chat-contact span { display: flex; align-items: center; gap: 6px; font-size: .72rem; opacity: .86; }
.chat-contact i { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px rgba(37, 211, 102, .15); }

.restart-button {
  flex: 0 0 auto;
  padding: 7px 9px;
  color: rgba(255, 255, 255, .88);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 999px;
  font-size: .67rem;
  cursor: pointer;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid rgba(7, 94, 84, .08);
}

.progress-track { min-width: 0; height: 6px; flex: 1 1 auto; overflow: hidden; background: #dfe7e3; border-radius: 999px; }
.progress-track span { display: block; width: 20%; height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); border-radius: inherit; transition: width .4s ease; }
.progress-wrap > span { flex: 0 0 auto; color: var(--muted); font-size: .64rem; font-weight: 600; white-space: nowrap; }

.chat-area {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 22px;
  scroll-behavior: smooth;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 15px 15px, rgba(7, 94, 84, .035) 1.5px, transparent 1.6px),
    radial-gradient(circle at 38px 38px, rgba(7, 94, 84, .025) 1px, transparent 1.1px);
  background-size: 52px 52px;
}

.day-label {
  width: max-content;
  margin: 0 auto 14px;
  padding: 5px 10px;
  color: #54716a;
  background: rgba(225, 245, 242, .94);
  border-radius: 7px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
  font-size: .65rem;
  text-transform: uppercase;
}

.bubble {
  position: relative;
  width: fit-content;
  max-width: 88%;
  margin: 0 0 9px;
  padding: 10px 13px 18px;
  border-radius: 9px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .09);
  font-size: .88rem;
  line-height: 1.5;
  animation: bubble-in .28s ease both;
}

.bubble.bot { background: var(--paper); border-top-left-radius: 2px; }
.bubble.user { margin-left: auto; background: var(--green-light); border-top-right-radius: 2px; }
.bubble small { position: absolute; right: 8px; bottom: 4px; color: #82908d; font-size: .57rem; }
.bubble.user small::after { content: ' ✓✓'; color: #2b8dcc; }

.typing {
  width: 62px;
  display: flex;
  gap: 4px;
  padding: 13px 16px;
  background: #fff;
  border-radius: 9px;
  border-top-left-radius: 2px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .09);
}

.typing i { width: 7px; height: 7px; background: #9ba6a3; border-radius: 50%; animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .13s; }
.typing i:nth-child(3) { animation-delay: .26s; }

.answer-area {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 8px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 12px;
  background: rgba(248, 250, 249, .96);
  border-top: 1px solid rgba(7, 94, 84, .08);
}

.option-button {
  width: 100%;
  min-height: 42px;
  padding: 9px 14px;
  color: var(--green-dark);
  background: #fff;
  border: 1px solid rgba(18, 140, 126, .3);
  border-radius: 10px;
  font-size: .79rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, color .15s ease, background .15s ease;
}

.option-button:hover, .option-button:focus-visible { color: #fff; background: var(--green); transform: translateY(-1px); outline: none; }
.option-button:disabled { opacity: .55; cursor: default; transform: none; }
.option-button-muted { color: #68736f; border-color: #cbd4d1; }

.name-form { min-width: 0; width: 100%; display: flex; gap: 8px; }
.name-form input { min-width: 0; flex: 1; padding: 11px 13px; border: 1px solid #c9d6d1; border-radius: 12px; outline: none; }
.name-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 140, 126, .12); }
.name-form button { padding: 10px 16px; color: #fff; background: var(--green); border: 0; border-radius: 12px; font-weight: 700; cursor: pointer; }
.field-error { color: #b12d2d; font-size: .68rem; }

.privacy-note { padding: 7px 12px 10px; color: #73807d; background: #f8faf9; text-align: center; font-size: .6rem; }
.privacy-note a { color: var(--green-dark); }

.results-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(245, 250, 247, .97);
}

.results-overlay[hidden] { display: none; }
.results-card { width: min(100%, 430px); text-align: center; }
.result-avatar-wrap { position: relative; width: 104px; height: 104px; display: grid; place-items: center; margin: 0 auto 22px; }
.result-avatar-wrap img { width: 76px; height: 76px; object-fit: cover; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 7px 20px rgba(7, 94, 84, .2); }
.result-ring { position: absolute; inset: 0; border: 4px solid rgba(37, 211, 102, .18); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
.results-card h1 { margin: 0 0 8px; font-size: clamp(1.45rem, 6vw, 2rem); }
.results-card p { margin: 0 0 22px; color: var(--muted); font-size: .88rem; }
.loading-track { height: 9px; overflow: hidden; background: #dfe9e4; border-radius: 999px; }
.loading-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); border-radius: inherit; animation: load 3.2s ease forwards; }
.loading-checks { display: grid; gap: 9px; margin: 22px 0 0; padding: 0; color: #9aa5a1; text-align: left; list-style: none; font-size: .78rem; }
.loading-checks li { transition: color .3s ease; }
.loading-checks li.active { color: var(--green-dark); font-weight: 600; }

@keyframes bubble-in { from { opacity: 0; transform: translateY(7px); } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes load { to { width: 100%; } }

@media (max-width: 560px) {
  .quiz-page { padding: 0; }
  .phone { width: 100%; max-width: 100vw; height: 100vh; height: 100dvh; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  .bubble { max-width: 92%; }
  .restart-button { font-size: 0; }
  .restart-button::after { content: '↻'; font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
