:root {
  --accent: #8B6BB1;
  --accent-deep: #534AB7;
  --accent-soft: #faf8fd;
  --accent-tint: #f0ebf8;
  --bg: #f5f3f8;
  --card: #fff;
  --surface: #f7f5fa;
  --fg: #1a1a1a;
  --muted: #666;
  --muted-2: #888;
  --line: #e0e0e0;
  --ok: #4caf8a;
  --warn: #e8a020;
  --err: #d9534f;
  --soft-track: #e8e4f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 12px 40px;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.phone {
  width: 340px;
  background: var(--card);
  border: 0.5px solid #ddd;
  border-radius: 24px;
  overflow: hidden;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 10px;
  border-bottom: 0.5px solid #eee;
  gap: 8px;
}
.tb-back {
  font-size: 18px;
  color: #888;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  background: transparent;
  border: none;
}
.tb-back:hover { background: #f0f0f0; }
.tb-back[aria-hidden="true"] { visibility: hidden; }
.tb-title {
  font-size: 13px;
  color: #888;
  font-weight: 500;
  flex: 1;
  text-align: center;
}

.prog {
  display: flex;
  gap: 3px;
  padding: 9px 16px 0;
}
.pseg {
  height: 3px;
  border-radius: 2px;
  flex: 1;
  background: var(--soft-track);
}
.pseg.done { background: var(--accent); }

.sc {
  padding: 18px 16px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.3;
}
.sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: -4px;
}
.sub-bold {
  font-size: 13px;
  color: var(--fg);
  font-weight: 600;
  line-height: 1.5;
  margin-top: -4px;
}

.btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  flex-shrink: 0;
  font-family: inherit;
}
.btn:hover { background: #7a5ca0; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.fbbox {
  background: var(--accent-tint);
  border-radius: 10px;
  padding: 13px;
  color: var(--accent-deep);
  font-size: 13px;
  line-height: 1.6;
}
.fbbox strong { font-weight: 600; color: #3a2d8a; }
.fbbox ul { list-style: none; padding: 0; margin: 6px 0 0; }
.fbbox li { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.fbbox .fck { color: var(--accent); font-size: 12px; flex-shrink: 0; margin-top: 2px; }

.input-field {
  width: 100%;
  padding: 11px 13px;
  border: 0.5px solid #ccc;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--fg);
  outline: none;
  min-height: 44px;
  font-family: inherit;
}
.input-field:focus { border-color: var(--accent); }

.label { display: block; font-size: 12px; color: var(--muted); margin: 4px 0 4px; }

.error {
  color: var(--err);
  font-size: 12px;
  min-height: 16px;
  margin-top: 2px;
}

.intro-hero {
  display: block;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}

.intro-hero img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 56 / 15;
  object-fit: cover;
  border-radius: 10px;
}

.stub {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-family: monospace;
}

@media (min-width: 641px) {
  body {
    background: linear-gradient(180deg, #faf8fd 0%, #f0eaf7 100%);
    padding: 32px 16px 48px;
    font-size: 17px;
  }
  .phone {
    width: 480px;
    border-radius: 28px;
    box-shadow: 0 10px 40px rgba(139,107,177,0.10);
  }
  .sc { padding: 22px 22px 30px; }
  h2 { font-size: 20px; }
  .btn { padding: 14px 20px; font-size: 15px; min-height: 50px; }
  .input-field { padding: 13px 15px; min-height: 48px; }
  .topbar { padding: 16px 22px 12px; }
  .tb-title { font-size: 14px; }
}

@media (min-width: 1024px) {
  body { padding: 48px 16px 64px; }
  .phone {
    width: 560px;
    border-radius: 32px;
    box-shadow: 0 20px 60px rgba(139,107,177,0.15);
  }
  .sc { padding: 28px 32px 36px; }
  h2 { font-size: 22px; }
  .btn { padding: 16px 24px; font-size: 16px; min-height: 56px; }
  .input-field { padding: 14px 18px; min-height: 52px; font-size: 15px; }
}

.group-intro-icon {
  font-size: 56px;
  text-align: center;
  line-height: 1;
  margin: 8px 0 4px;
}
.group-intro-title {
  text-align: center;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.3;
  margin: 0 8px;
}
.group-intro-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (min-width: 641px) {
  .group-intro-icon { font-size: 64px; }
  .group-intro-title { font-size: 21px; }
}
@media (min-width: 1024px) {
  .group-intro-icon { font-size: 72px; }
  .group-intro-title { font-size: 23px; }
}

.iopt-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.iopt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 0.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  outline-offset: 2px;
}
.iopt:hover { border-color: var(--accent); background: var(--accent-soft); }
.iopt.sel { border-color: var(--accent); background: var(--accent-soft); }
.iopt-icon { font-size: 20px; line-height: 1; }
.iopt-lbl { font-size: 12px; color: var(--muted); line-height: 1.2; }
.iopt.sel .iopt-lbl { font-weight: 500; }
.iopt[data-v="0"].sel .iopt-lbl { color: var(--ok); }
.iopt[data-v="1"].sel .iopt-lbl { color: var(--fg); }
.iopt[data-v="2"].sel .iopt-lbl { color: var(--warn); }
.iopt[data-v="3"].sel .iopt-lbl { color: var(--err); }

@media (min-width: 641px) {
  .iopt { padding: 14px 8px; }
  .iopt-icon { font-size: 22px; }
  .iopt-lbl { font-size: 13px; }
}
@media (min-width: 1024px) {
  .iopt { padding: 16px 8px; }
  .iopt-icon { font-size: 24px; }
}

.result-hero {
  background: linear-gradient(165deg, #fbf9fe 0%, var(--accent-tint) 100%);
  border: 0.5px solid #e4d9f3;
  border-radius: 18px;
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.score-big { text-align: center; margin: 0; }
.score-big .v {
  font-size: 64px;
  font-weight: 600;
  color: var(--accent-deep);
  line-height: 1;
  letter-spacing: -1px;
}
.score-big .l { color: var(--muted); margin-top: 6px; font-size: 12px; }

.zone-pill {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.zone-row { text-align: center; margin: 0; }

.result-hero .fbbox {
  background: #fff;
  border: 0.5px solid #ece3f6;
  color: var(--fg);
  margin-top: 2px;
  font-size: 13.5px;
  line-height: 1.55;
}
.result-hero .fbbox p { color: var(--accent-deep); }

.result-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.result-cta .sub { margin-top: 0; }

.result-section { margin-top: 14px; }
.result-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 0.5px solid #f0ecf5;
}
.bar-row:last-child { border-bottom: none; }
.bar-lbl {
  font-size: 12.5px;
  color: var(--fg);
  width: 130px;
  flex-shrink: 0;
  line-height: 1.3;
  font-weight: 500;
}
.bar-track {
  flex: 1;
  height: 10px;
  background: var(--soft-track);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.04);
}
.bar-fill {
  height: 100%;
  border-radius: 6px;
  width: 0;
  transition: width 0.6s ease-out;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
}
.bar-num {
  font-size: 12px;
  font-weight: 600;
  min-width: 38px;
  padding: 3px 8px;
  text-align: center;
  flex-shrink: 0;
  color: var(--accent-deep);
  background: var(--accent-tint);
  border-radius: 999px;
}

@media (min-width: 641px) {
  .result-hero { padding: 26px 22px 20px; gap: 12px; }
  .score-big .v { font-size: 72px; }
  .score-big .l { font-size: 13px; }
  .result-hero .fbbox { font-size: 14px; }
  .result-section h3 { font-size: 13px; }
  .bar-row { padding: 10px 0; gap: 12px; }
  .bar-lbl { font-size: 13px; width: 160px; }
  .bar-track { height: 12px; border-radius: 7px; }
  .bar-fill { border-radius: 7px; }
  .bar-num { font-size: 12.5px; min-width: 42px; padding: 4px 9px; }
}

@media (min-width: 641px) {
  .phone-wide { width: 720px; }
}

@media (min-width: 1024px) {
  .phone-wide {
    width: 920px;
    border-radius: 32px;
  }
  .phone-wide .sc {
    padding: 32px 36px;
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-auto-flow: dense;
    gap: 20px 36px;
    align-items: start;
  }
  .phone-wide .sc > .result-hero {
    grid-column: 1;
    padding: 28px 22px 22px;
  }
  .phone-wide .sc > .result-cta {
    grid-column: 1;
  }
  .phone-wide .sc > .result-section {
    grid-column: 2;
    margin-top: 0;
  }
  .phone-wide .sc > .result-section + .result-section {
    grid-column: 2;
    margin-top: 8px;
  }
  .phone-wide .score-big .v { font-size: 76px; }
  .phone-wide .bar-lbl { width: 200px; font-size: 13.5px; }
  .phone-wide .bar-num { min-width: 46px; font-size: 13px; }
}

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

.fbbox p { margin: 0; }

/* ---- error screen ------------------------------------------------ */
.error-icon {
  font-size: 48px;
  text-align: center;
  line-height: 1;
  margin: 8px 0 4px;
}

.btn-support {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 48px;
}

/* ---- finalizing screen ------------------------------------------- */
.sc-finalizing {
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.finalizing-icon {
  font-size: 48px;
  line-height: 1;
  margin: 8px 0 4px;
}

.finalizing-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
  margin-top: 4px;
}

.finalizing-dots span {
  animation: dots-pulse 1.2s ease-in-out infinite;
}

.finalizing-dots span:nth-child(2) { animation-delay: 0.2s; }
.finalizing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dots-pulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
