:root {
  --navy-950: #070b18;
  --navy-900: #0b1020;
  --navy-800: #111a31;
  --ink: #17223b;
  --muted: #63708a;
  --line: #dfe6f1;
  --blue: #1f64f2;
  --blue-dark: #1149bd;
  --blue-soft: #edf4ff;
  --green: #168257;
  --green-soft: #eaf8f1;
  --amber: #b86a0b;
  --amber-soft: #fff5e5;
  --white: #fff;
  --shadow: 0 20px 70px rgba(10, 27, 69, 0.14);
  --shadow-soft: 0 10px 30px rgba(10, 27, 69, 0.09);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  font-family: "Noto Sans Thai", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--navy-950);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--navy-950); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(48, 108, 242, 0.28), transparent 32rem),
    linear-gradient(160deg, #081024 0%, #0b1020 52%, #11182b 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.page-glow {
  position: fixed;
  z-index: 0;
  width: 32rem;
  height: 32rem;
  border-radius: 999px;
  filter: blur(70px);
  pointer-events: none;
  opacity: 0.22;
}

.page-glow-one { top: -16rem; right: -9rem; background: #2371ff; }
.page-glow-two { bottom: -20rem; left: -12rem; background: #13b68a; opacity: 0.12; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.86);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: linear-gradient(145deg, #307cff, #1551d5);
  box-shadow: 0 9px 24px rgba(31, 100, 242, 0.35);
  font-size: 1.1rem;
  font-weight: 800;
}

.brand-text { font-family: Inter, sans-serif; font-weight: 800; font-size: 1.02rem; }
.topbar-note { color: rgba(255, 255, 255, 0.64); font-size: 0.79rem; }
.inherit-color { color: inherit; }

.surface {
  border: 1px solid rgba(221, 231, 247, 0.88);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 2.75rem;
  align-items: center;
  margin-top: 34px;
  padding: clamp(1.5rem, 4vw, 3.75rem);
  overflow: hidden;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  color: var(--blue-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(31, 100, 242, 0.12);
  content: "";
}

h1, h2, h3, p { margin-top: 0; }

.hero h1 {
  max-width: 640px;
  margin-bottom: 1rem;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: -0.06em;
}

.hero h1 span { color: var(--blue); }

.hero-lede {
  max-width: 600px;
  margin-bottom: 1.6rem;
  color: #485671;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.75;
}

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.85rem; }
.microcopy-compact { margin: 0; }
.microcopy-no-bottom { margin-bottom: 0; }
.alert-error { margin-top: 1rem; border-color: #f0caca; padding: 0.9rem 1rem; color: #9d3030; background: #fff3f3; font-size: 0.82rem; }

.primary-button, .secondary-button, .line-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 0;
  border-radius: 13px;
  padding: 0.72rem 1.2rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #3b85ff);
  box-shadow: 0 11px 24px rgba(31, 100, 242, 0.28);
}

.primary-button:hover, .line-button:hover { transform: translateY(-2px); box-shadow: 0 15px 28px rgba(31, 100, 242, 0.32); }

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.secondary-button:hover { border-color: #b8c7df; background: #f8fbff; }

.button-small { min-height: 40px; padding: 0.55rem 0.9rem; font-size: 0.86rem; }

.microcopy { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.55; }

.hero-visual {
  position: relative;
  min-height: 300px;
  border-radius: 24px;
  padding: 1rem;
  background: linear-gradient(145deg, #0c1a3a, #142b5d 55%, #1f64f2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 23px 48px rgba(19, 45, 104, 0.24);
  overflow: hidden;
}

.hero-visual::after {
  position: absolute;
  top: -7rem;
  right: -5rem;
  width: 18rem;
  height: 18rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(255, 255, 255, 0.04), 0 0 0 56px rgba(255, 255, 255, 0.03);
  content: "";
}

.hero-visual-title { position: relative; z-index: 1; color: rgba(255, 255, 255, 0.7); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

.score-preview {
  position: absolute;
  right: 1.2rem;
  bottom: 1.2rem;
  left: 1.2rem;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  padding: 1.2rem;
  color: #fff;
  background: rgba(7, 16, 39, 0.62);
  backdrop-filter: blur(12px);
}

.score-preview-label { margin-bottom: 0.35rem; color: rgba(255, 255, 255, 0.62); font-size: 0.72rem; }
.score-preview-value { margin-bottom: 0.55rem; font-family: Inter, sans-serif; font-size: 3rem; font-weight: 800; line-height: 1; }
.score-preview-denom { color: rgba(255, 255, 255, 0.7); font-size: 1.2rem; }
.score-preview-row { display: flex; flex-wrap: wrap; gap: 0.42rem; }
.score-chip { border-radius: 999px; padding: 0.34rem 0.55rem; color: #dce8ff; background: rgba(68, 132, 255, 0.22); font-size: 0.68rem; }

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.benefit-card { padding: 1.15rem 1.2rem; border: 1px solid rgba(221, 231, 247, 0.8); border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.95); box-shadow: var(--shadow-soft); }
.benefit-icon { display: grid; width: 34px; height: 34px; place-items: center; margin-bottom: 0.75rem; border-radius: 10px; color: var(--blue-dark); background: var(--blue-soft); font-weight: 800; }
.benefit-card h3 { margin-bottom: 0.32rem; font-size: 0.92rem; }
.benefit-card p { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.55; }

.info-strip { display: flex; flex-wrap: wrap; gap: 0.55rem 1rem; align-items: center; margin-top: 1rem; padding: 0.9rem 1.15rem; border: 1px solid #cae9d8; border-radius: 15px; color: #17623f; background: var(--green-soft); font-size: 0.79rem; line-height: 1.45; }
.info-strip strong { color: #0f5b39; }

.quiz-shell { max-width: 780px; margin: 34px auto 0; padding: clamp(1.2rem, 4vw, 2.4rem); }
.quiz-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.quiz-kicker { margin-bottom: 0.35rem; color: var(--blue); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.quiz-header h1 { margin-bottom: 0; font-size: clamp(1.35rem, 4vw, 2rem); letter-spacing: -0.04em; }
.timer { display: inline-flex; align-items: center; gap: 0.42rem; white-space: nowrap; border: 1px solid #d3def0; border-radius: 999px; padding: 0.45rem 0.7rem; color: var(--blue-dark); background: #f6f9ff; font-family: Inter, sans-serif; font-size: 0.85rem; font-weight: 800; }
.timer.is-low { border-color: #f2c5c5; color: #b33a3a; background: #fff1f1; }
.progress-meta { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.45rem; color: var(--muted); font-size: 0.76rem; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e9eef6; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1f64f2, #5a9bff); transition: width 220ms ease; }

.question-card { margin-top: 1.5rem; padding: clamp(1.15rem, 4vw, 2rem); border: 1px solid #e1e8f3; border-radius: 20px; background: #fbfdff; }
.question-number { margin-bottom: 0.85rem; color: var(--blue); font-family: Inter, sans-serif; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; }
.question-prompt { margin-bottom: 1.45rem; color: var(--ink); font-family: Inter, "Noto Sans Thai", sans-serif; font-size: clamp(1.12rem, 3vw, 1.45rem); font-weight: 700; line-height: 1.55; }
.blank { display: inline-block; min-width: 3.5rem; border-bottom: 2px solid var(--blue); color: var(--blue); }
.option-list { display: grid; gap: 0.7rem; }
.option-button { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 0.7rem; width: 100%; align-items: center; border: 1px solid #d9e2f0; border-radius: 14px; padding: 0.8rem 0.9rem; color: var(--ink); text-align: left; background: #fff; transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
.option-button:hover { border-color: #9ab8ed; background: #f7faff; transform: translateY(-1px); }
.option-button.is-selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 3px rgba(31, 100, 242, 0.1); }
.option-label { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; color: #51627f; background: #edf1f7; font-family: Inter, sans-serif; font-size: 0.82rem; font-weight: 800; }
.option-button.is-selected .option-label { color: #fff; background: var(--blue); }
.option-text { overflow-wrap: anywhere; font-family: Inter, "Noto Sans Thai", sans-serif; font-size: 0.98rem; line-height: 1.4; }
.quiz-error { min-height: 1.3rem; margin: 0.75rem 0 0; color: #bc3535; font-size: 0.78rem; }
.quiz-actions { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: 1.2rem; }

.result-shell { max-width: 860px; margin: 34px auto 0; padding: clamp(1.2rem, 4vw, 2.4rem); }
.result-hero { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 1.4rem; align-items: center; }
.result-score { display: grid; min-height: 180px; place-items: center; border-radius: 24px; color: #fff; text-align: center; background: linear-gradient(145deg, #1855c8, #3c89ff); box-shadow: 0 17px 34px rgba(31, 100, 242, 0.25); }
.result-score small { display: block; margin-bottom: 0.45rem; color: rgba(255, 255, 255, 0.72); font-size: 0.75rem; }
.result-score strong { display: block; font-family: Inter, sans-serif; font-size: 3.25rem; line-height: 1; }
.result-score-denom { color: rgba(255, 255, 255, 0.72); font-size: 1.15rem; }
.result-copy .eyebrow { margin-bottom: 0.5rem; }
.result-copy h1 { margin-bottom: 0.55rem; font-size: clamp(1.5rem, 4vw, 2.2rem); letter-spacing: -0.045em; }
.result-copy p { margin-bottom: 0.75rem; color: var(--muted); line-height: 1.65; }
.result-band { display: inline-flex; border-radius: 999px; padding: 0.45rem 0.7rem; color: #196441; background: var(--green-soft); font-size: 0.78rem; font-weight: 800; }
.teaser-insight { display: flex; gap: 0.8rem; align-items: flex-start; margin-top: 1.5rem; padding: 1rem 1.1rem; border: 1px solid #f0ddb8; border-radius: 16px; background: var(--amber-soft); }
.teaser-insight-icon { display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: #9b5909; background: #ffe4af; font-weight: 900; }
.teaser-insight h2 { margin-bottom: 0.2rem; color: #6f470d; font-size: 0.95rem; }
.teaser-insight p { margin: 0; color: #795820; font-size: 0.83rem; line-height: 1.55; }
.result-lock { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid #dbe5f3; border-radius: 18px; background: #f7faff; }
.result-lock h2 { margin-bottom: 0.35rem; font-size: 1.1rem; }
.result-lock > p { margin-bottom: 1rem; color: var(--muted); font-size: 0.83rem; line-height: 1.55; }
.locked-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; margin-bottom: 1.2rem; }
.locked-skill { position: relative; overflow: hidden; border: 1px solid #dce5f1; border-radius: 12px; padding: 0.8rem; color: #6a7890; background: #fff; font-size: 0.76rem; }
.locked-skill::after { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent); content: ""; transform: translateX(-100%); }
.locked-skill span { display: block; margin-bottom: 0.2rem; color: #34435f; font-weight: 800; }
.locked-skill-state { color: #8793a8 !important; font-weight: 500 !important; }

.lead-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: #31415f; font-size: 0.79rem; font-weight: 800; }
.form-field input, .form-field select { width: 100%; min-height: 44px; border: 1px solid #cfdbea; border-radius: 11px; outline: none; padding: 0.62rem 0.75rem; color: var(--ink); background: #fff; }
.form-field input:focus, .form-field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 100, 242, 0.11); }
.checkbox-field { display: flex; gap: 0.6rem; align-items: flex-start; color: #53627b; font-size: 0.76rem; line-height: 1.55; }
.checkbox-field input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 0.1rem; accent-color: var(--blue); }
.form-note { margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; }
.loading-copy { margin: 0; color: var(--muted); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; grid-column: 1 / -1; }
.lead-error { grid-column: 1 / -1; min-height: 1.3rem; margin: 0; color: #bc3535; font-size: 0.78rem; }

.line-success { margin-top: 1.2rem; padding: 1.15rem; border: 1px solid #c7e8d5; border-radius: 16px; background: var(--green-soft); }
.line-success h2 { margin-bottom: 0.35rem; color: #155c3b; font-size: 1.05rem; }
.line-success p { margin-bottom: 0.9rem; color: #286c4b; font-size: 0.82rem; line-height: 1.55; }
.line-button { color: #fff; background: #06b659; box-shadow: 0 10px 22px rgba(6, 182, 89, 0.2); }
.line-button:hover { box-shadow: 0 14px 28px rgba(6, 182, 89, 0.28); }

.footer-note { margin-top: 1rem; color: rgba(255, 255, 255, 0.62); text-align: center; font-size: 0.72rem; line-height: 1.55; }
.loading-state, .error-state { display: grid; min-height: 60vh; place-items: center; text-align: center; }
.loading-state .surface, .error-state .surface { max-width: 460px; padding: 2rem; }
.spinner { width: 32px; height: 32px; margin: 0 auto 1rem; border: 3px solid #dce7f7; border-top-color: var(--blue); border-radius: 50%; animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.no-script { width: min(600px, calc(100% - 32px)); margin: 3rem auto; border-radius: 14px; padding: 1rem; color: #fff; text-align: center; background: #8c2d2d; }

@media (max-width: 780px) {
  .app-shell { width: min(100% - 20px, 700px); padding-top: 18px; }
  .topbar-note { display: none; }
  .hero { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 22px; }
  .hero-visual { min-height: 230px; }
  .benefit-grid { grid-template-columns: 1fr; }
  .benefit-card { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 0.7rem; }
  .benefit-icon { grid-row: span 2; margin-bottom: 0; }
  .benefit-card h3, .benefit-card p { align-self: center; }
  .result-hero { grid-template-columns: 1fr; }
  .result-score { min-height: 140px; }
  .locked-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .app-shell { width: calc(100% - 16px); padding-bottom: 28px; }
  .hero, .quiz-shell, .result-shell { border-radius: 20px; }
  .hero { padding: 1.25rem; }
  .hero h1 { font-size: 2.25rem; }
  .hero-actions > * { width: 100%; }
  .quiz-header { flex-direction: column; }
  .timer { align-self: flex-start; }
  .lead-form { grid-template-columns: 1fr; }
  .form-field.full, .form-actions, .lead-error { grid-column: auto; }
  .locked-grid { grid-template-columns: 1fr 1fr; }
  .quiz-actions { flex-direction: column-reverse; }
  .quiz-actions > * { width: 100%; }
}
