*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #6b6b6b;
  --border: #111111;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --header-height: 4.25rem;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.header__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
  display: block;
}

.header__title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* Main */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* Roadmap */
.roadmap {
  margin-bottom: 2.5rem;
}

.roadmap__track {
  position: relative;
  padding: 0 0.5rem;
}

.roadmap__line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 999px;
  transform: translateY(-50%);
  z-index: 0;
}

.roadmap__steps {
  list-style: none;
  display: flex;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.roadmap__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.roadmap__dot {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.roadmap__dot-inner {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: transparent;
}

.roadmap__step--active .roadmap__dot-inner {
  background: var(--muted);
}

.roadmap__step--done .roadmap__dot {
  background: var(--fg);
}

.roadmap__label {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

/* Stages */
.stage {
  text-align: center;
}

.stage--hidden,
.step--hidden {
  display: none;
}

.stage__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.stage__text {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  color: var(--fg);
}

.stage__text--small {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn--outline {
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--border);
  min-width: 7rem;
}

.btn--outline:hover {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary {
  background: var(--fg);
  color: var(--bg);
  border: 2px solid var(--border);
  width: 100%;
  max-width: 20rem;
  margin-top: 0.5rem;
}

.btn--primary:hover {
  opacity: 0.85;
}

.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.gender-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Quiz */
.quiz__layout {
  display: contents;
}

.quiz__header {
  display: contents;
}

.quiz__counter {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.quiz__prompt {
  margin-bottom: 1rem;
}

.quiz__image-wrap {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz__image {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.quiz__options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.quiz__option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  background: var(--bg);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 0;
}

.quiz__option:hover {
  background: #f5f5f5;
}

.quiz__option img {
  width: 100%;
  height: auto;
  display: block;
}

.quiz__timer-wrap {
  margin-top: 0.5rem;
}

.quiz__timer {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.quiz__hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.quiz__hint--hidden {
  display: none;
}

/* Quiz: fit entire question in viewport (no scroll) */
body.body--quiz {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.body--quiz .header {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
}

body.body--quiz .main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(0.5rem, 1.5vh, 1.25rem) 1.25rem;
  overflow: hidden;
}

body.body--quiz .roadmap {
  flex-shrink: 0;
  margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
}

body.body--quiz .roadmap__label {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
}

body.body--quiz #stage-quiz {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  text-align: center;
}

body.body--quiz .quiz__layout {
  display: grid;
  grid-template-rows: auto minmax(0, 2fr) minmax(0, 3fr) auto;
  gap: clamp(0.25rem, 1vh, 0.75rem);
  flex: 1;
  min-height: 0;
}

body.body--quiz .quiz__header {
  display: block;
  flex-shrink: 0;
}

body.body--quiz .quiz__counter {
  margin-bottom: 0.125rem;
  font-size: clamp(0.75rem, 1.8vh, 0.875rem);
}

body.body--quiz .quiz__prompt {
  margin-bottom: 0;
  font-size: clamp(0.9375rem, 2.2vh, 1.25rem);
  line-height: 1.3;
}

body.body--quiz .quiz__image-wrap {
  margin-bottom: 0;
  min-height: 0;
  overflow: hidden;
}

body.body--quiz .quiz__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

body.body--quiz .quiz__options {
  margin-bottom: 0;
  min-height: 0;
  gap: clamp(0.25rem, 0.8vh, 0.75rem);
  align-content: stretch;
}

body.body--quiz .quiz__option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.2rem, 0.5vh, 0.5rem);
  min-height: 0;
  overflow: hidden;
}

body.body--quiz .quiz__option img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

body.body--quiz .quiz__timer-wrap {
  flex-shrink: 0;
  margin-top: 0;
}

body.body--quiz .quiz__timer {
  font-size: clamp(1.125rem, 3vh, 1.5rem);
  line-height: 1.2;
}

body.body--quiz .quiz__hint {
  font-size: clamp(0.75rem, 1.8vh, 0.875rem);
  margin-top: 0.25rem;
  line-height: 1.3;
}

@media (max-height: 700px) {
  body.body--quiz .header {
    padding: 0.5rem 1rem;
  }

  body.body--quiz .header__title {
    font-size: 1rem;
  }

  body.body--quiz .logo {
    width: 1.75rem;
    height: 1.75rem;
  }

  body.body--quiz .roadmap__dot {
    width: 1.125rem;
    height: 1.125rem;
  }

  body.body--quiz .roadmap__label {
    margin-top: 0.375rem;
  }
}

@media (max-height: 520px) {
  body.body--quiz .quiz__layout {
    grid-template-rows: auto minmax(0, 1.6fr) minmax(0, 2.4fr) auto;
    gap: 0.2rem;
  }
}

/* Calc */
.calc__number {
  font-size: 4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2rem;
}

/* Form fields */
.field {
  display: block;
  text-align: left;
  max-width: 20rem;
  margin: 0 auto 0.5rem;
}

.field__label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
  color: var(--muted);
}

.field__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}

.field__input:focus {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.phone-input {
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.phone-input__prefix {
  padding: 0.75rem 0 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  user-select: none;
  flex-shrink: 0;
}

.phone-input__field {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem 0.75rem 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  border: none;
  background: transparent;
  color: var(--fg);
}

.phone-input__field:focus {
  outline: none;
}

.phone-input:focus-within {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.field__input:focus {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.field__error {
  color: #c00;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.field__error--hidden {
  display: none;
}

/* Result */
.result__message {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.6;
}

/* Spinner */
.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid #ddd;
  border-top-color: var(--fg);
  border-radius: 50%;
  margin: 1rem auto;
  animation: spin 0.8s linear infinite;
}

.spinner--large {
  width: 3.5rem;
  height: 3.5rem;
  border-width: 4px;
  margin: 0 auto 1.5rem;
}

.loading-panel {
  padding: 2.5rem 1rem;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-panel__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.loading-panel__hint {
  font-size: 0.875rem;
  color: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
  .header__title {
    font-size: 1rem;
  }

  .gender-buttons {
    flex-direction: column;
    align-items: center;
  }

  .quiz__options {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .calc__number {
    font-size: 3rem;
  }
}
