:root {
  --page-bg: #FFFFFF;
  --text-muted: #a39f9f;
  --text-ink: #121212;
  --button-ink: #ffffff;
  --button-bg: #264653;
  --button-share: #8fa603;
  --card-bg: #FFFFFF;
  --card-border: #e0d8c8;
}

.quiz-root[hidden] {
  display: none !important;
}

body.quiz-mode {
  background: var(--page-bg);
}

body.quiz-mode .ready-page {
  display: none;
}

.quiz-root {
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: start center;
  background: #FFFFFF;
  padding:
    calc(12px + env(safe-area-inset-top))
    14px
    calc(18px + env(safe-area-inset-bottom));
  font-family: "Open Sans", "Avenir Next", "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.scene-screen {
  width: min(100%, 402px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quiz-screen {
  animation: quiz-screen-enter 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-progress {
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(38, 70, 83, 0.08);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(143, 166, 3, 0.14), transparent 42%),
    #FFFFFF;
}

.quiz-progress--reveal {
  margin-bottom: 18px;
}

.quiz-progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #51616b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.quiz-progress-bar {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.quiz-progress-segment {
  height: 7px;
  border-radius: 999px;
  background: rgba(38, 70, 83, 0.12);
}

.quiz-progress-segment--active {
  background: linear-gradient(90deg, #264653, #8fa603);
}

.quiz-teaser {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(103, 162, 185, 0.16), rgba(143, 166, 3, 0.12)),
    #f8fbff;
  border: 1px solid rgba(103, 162, 185, 0.18);
  box-shadow: 0 12px 24px rgba(103, 162, 185, 0.1);
}

.quiz-teaser-label {
  display: inline-flex;
  margin-bottom: 4px;
  color: #67a2b9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quiz-teaser-copy {
  margin: 0;
  color: #1d2d35;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.28;
}

.scene-copy {
  margin: 0;
  max-width: 430px;
  color: var(--text-muted);
  text-align: center;
  font-size: clamp(15px, 4.2vw, 18px);
  font-weight: 600;
  line-height: 1.34;
}

.scene-copy p {
  margin: 0;
}

.scene-copy p + p {
  margin-top: 2px;
}

.scene-prompt {
  margin: 10px 0 0;
  color: var(--text-muted);
  text-align: center;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 600;
  line-height: 1.2;
}

.scene-image-wrap {
  width: 100%;
  border-radius: 30px;
  overflow: hidden;
  margin-top: 12px;
  box-shadow: 0 18px 34px rgba(38, 70, 83, 0.12);
}

.scene-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-actions {
  width: min(100%, 420px);
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.scene-actions--single {
  width: min(100%, 320px);
  margin-top: 14px;
}

.scene-action {
  width: 100%;
  border: 0;
  border-radius: 18px;
  background: var(--button-bg);
  color: var(--button-ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(38, 70, 83, 0.14);
  transition:
    transform 140ms ease,
    filter 140ms ease,
    box-shadow 140ms ease;
  touch-action: manipulation;
}

.scene-action:hover,
.scene-action:focus-visible {
  outline: none;
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 18px 32px rgba(38, 70, 83, 0.18);
}

.scene-action:active {
  transform: translateY(0);
}

.scene-action--single {
  min-height: 52px;
  height: auto;
  font-size: clamp(16px, 4.8vw, 18px);
  font-weight: 600;
}

.scene-action--option {
  min-height: max(48px, var(--option-height, 50px));
  padding: 10px 12px;
  text-align: center;
  font-size: clamp(13px, 3.8vw, 14px);
  font-weight: 600;
  line-height: 1.32;
}

.scene-screen--scene1 {
  padding-top: 6px;
}

.scene-screen--scene1 .scene-copy {
  max-width: 406px;
}

.scene-screen--scene1 .scene-prompt {
  margin-top: 10px;
  font-size: clamp(15px, 4vw, 18px);
}

.scene-screen--scene1 .scene-image-wrap {
  margin-top: 14px;
}

.scene-screen--scene2 {
  padding-top: 4px;
}

.scene-screen--scene2 .scene-copy {
  max-width: 403px;
}

.scene-screen--scene2 .scene-image-wrap {
  margin-top: 14px;
}

.scene-screen--scene2 .scene-actions {
  margin-top: 14px;
  gap: 10px;
}

.scene-screen--scene3 {
  padding-top: 2px;
}

.scene-screen--scene3 .scene-copy {
  max-width: 430px;
}

.scene-screen--scene3 .scene-image-wrap {
  margin-top: 14px;
}

.scene-screen--scene3 .scene-actions {
  margin-top: 14px;
  gap: 10px;
}

.scene-screen--scene4 {
  padding-top: 0;
}

.scene-screen--scene4 .scene-copy {
  max-width: 433px;
}

.scene-screen--scene4 .scene-image-wrap {
  margin-top: 14px;
}

.scene-screen--scene4 .scene-actions {
  margin-top: 14px;
  gap: 10px;
}

.loading-screen {
  width: min(100%, 402px);
  min-height: calc(100svh - 60px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 12px;
}

.loading-main {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
}

.loading-title {
  margin: 0;
  max-width: 390px;
  color: #000;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.28;
}

.loading-gif {
  width: min(100%, 500px);
  max-height: min(48svh, 500px);
  margin: 0 auto;
  align-self: center;
  object-fit: contain;
}

.loading-subtitle {
  margin: 0;
  align-self: end;
  max-width: 397px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.final-screen {
  width: min(100%, 402px);
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 0 0 8px;
}

.final-card {
  position: relative;
  isolation: isolate;
  width: min(100%, 360px);
  min-height: 728px;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background:
    radial-gradient(circle at top center, rgba(103, 162, 185, 0.14), transparent 34%),
    linear-gradient(180deg, #fffdfa 0%, #fdfaf5 100%);
  box-shadow: 0 22px 42px rgba(38, 70, 83, 0.18);
  overflow: hidden;
  padding: 14px 16px 16px;
}

.final-card.card-export-mode {
  background: #FFFFFF;
}

.final-card > * {
  position: relative;
  z-index: 1;
}

.final-tag {
  margin: 2px 0 8px;
  margin-left: auto;
  width: fit-content;
  padding: 6px 12.3px;
  border-radius: 8px;
  border: 0;
  background: #2c2c2c;
  color: #fdfcf9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.05;
  transform: rotate(3deg);
  transform-origin: center;
}

.final-kicker {
  margin: 0;
  color: #67a2b9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-transform: uppercase;
  text-align: center;
}

.final-name {
  margin: 8px 0 0;
  color: #121212;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.final-hook {
  margin: 8px auto 0;
  max-width: 284px;
  color: #264653;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

.final-hero {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 192px;
  padding-top: 14px;
}

.final-hero-image {
  max-width: 240px;
  max-height: 184px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.final-description {
  margin: 0 auto;
  max-width: 286px;
  color: #2c2c2c;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.01em;
}

.final-label {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.25em;
  line-height: 1.35;
  text-transform: uppercase;
}

.final-label--green {
  margin-top: 14px;
  color: #8db82a;
}

.final-label--orange {
  color: #e85429;
}

.final-label--yellow {
  color: #f5c428;
}

.result-chip-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5dc;
  background: #FFFFFF;
  color: #364153;
  font-family: "Inter", "Open Sans", Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}

.final-grid-head {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.final-grid-head--match {
  margin-top: 13px;
}

.final-grid-lists {
  margin-top: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.final-grid-lists ul {
  margin: 0;
  padding-left: 11px;
  display: grid;
  gap: 5px;
}

.final-grid-lists li {
  color: #111;
  font-size: 7.5px;
  font-weight: 600;
  line-height: 10.5px;
  letter-spacing: 0.14em;
}

.final-watermark {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  margin: 0;
  color: #f8f2f2;
  font-size: 65px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  z-index: 0;
  pointer-events: none;
}

.final-match-grid {
  margin-top: 3px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.match-column {
  display: flex;
  justify-content: center;
  align-items: start;
}

.match-item {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 0;
}

.match-item img {
  width: 126px;
  height: 94px;
  object-fit: contain;
}

.final-card.card-export-mode .match-item img {
  width: 142px;
  transform: scaleX(1.12);
  transform-origin: center;
}

.match-reason {
  margin: 0;
  margin-top: -2px;
  max-width: 136px;
  color: #4b5563;
  text-align: center;
  font-size: 7px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.final-convert {
  width: min(100%, 360px);
  padding: 16px 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(38, 70, 83, 0.1);
  background:
    radial-gradient(circle at top right, rgba(143, 166, 3, 0.16), transparent 38%),
    linear-gradient(135deg, rgba(103, 162, 185, 0.12), rgba(255, 255, 255, 0.98));
  box-shadow: 0 18px 34px rgba(38, 70, 83, 0.12);
}

.final-convert-bridge {
  margin: 0 0 8px;
  color: #51616b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.final-convert-title {
  margin: 0;
  color: #121212;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.final-convert-body {
  margin: 10px 0 0;
  color: #24343c;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.42;
}

.final-convert-proof {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.final-convert-button {
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  border: 0;
  border-radius: 18px;
  background: #121212;
  color: #FFFFFF;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 18px 34px rgba(18, 18, 18, 0.18);
  transition:
    transform 140ms ease,
    filter 140ms ease,
    box-shadow 140ms ease;
}

.final-convert-button:hover,
.final-convert-button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 20px 36px rgba(18, 18, 18, 0.22);
}

.final-actions {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.final-action {
  min-height: 50px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(38, 70, 83, 0.14);
  transition:
    transform 140ms ease,
    filter 140ms ease,
    box-shadow 140ms ease;
}

.final-action:hover,
.final-action:focus-visible {
  outline: none;
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 18px 32px rgba(38, 70, 83, 0.18);
}

.final-action:active {
  transform: translateY(0);
}

.final-action:disabled {
  cursor: wait;
  opacity: 0.75;
}

.final-action--primary {
  background: var(--button-bg);
}

.final-action--share {
  background: var(--button-share);
}

.share-card-stage {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.share-card {
  width: 360px;
  min-height: 640px;
  padding: 20px 20px 22px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(103, 162, 185, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(143, 166, 3, 0.18), transparent 28%),
    #FFFFFF;
  border: 1px solid rgba(224, 216, 200, 0.85);
  box-shadow: 0 24px 44px rgba(38, 70, 83, 0.16);
}

.share-card-tag {
  margin: 0 0 18px;
  margin-left: auto;
  width: fit-content;
  padding: 8px 13px;
  border-radius: 999px;
  background: #121212;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.share-card-kicker {
  margin: 0;
  color: #67a2b9;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.share-card-name {
  margin: 10px 0 0;
  color: #121212;
  text-align: center;
  font-size: 42px;
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.share-card-hook {
  margin: 10px auto 0;
  max-width: 284px;
  color: #264653;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.28;
}

.share-card-description {
  margin: 10px auto 0;
  max-width: 296px;
  color: #3f4c54;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.42;
}

.share-card-hero {
  display: grid;
  place-items: center;
  min-height: 270px;
  margin-top: 10px;
}

.share-card-image {
  max-width: 286px;
  max-height: 262px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.share-card-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.share-card-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5dc;
  background: #FFFFFF;
  color: #364153;
  font-size: 14px;
  font-weight: 600;
}

.share-card-match-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.share-card-match {
  padding: 14px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(38, 70, 83, 0.08);
  text-align: center;
  display: grid;
  justify-items: center;
}

.share-card-match span {
  display: block;
  color: #8fa603;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.share-card-match-image {
  display: block;
  width: 124px;
  height: 66px;
  margin-top: 10px;
  object-fit: contain;
}

.share-card-match strong {
  display: block;
  margin-top: 6px;
  color: #121212;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.share-card-footer {
  margin: 16px 0 0;
  color: #51616b;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.quiz-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(10px);
  max-width: min(90vw, 360px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(17, 17, 17, 0.2);
  background: #FFFFFF;
  color: #121212;
  font-family: "Open Sans", "Avenir Next", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  z-index: 40;
}

.quiz-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 520px) {
  .quiz-root {
    padding:
      calc(10px + env(safe-area-inset-top))
      12px
      calc(16px + env(safe-area-inset-bottom));
  }

  .scene-copy {
    font-size: clamp(14px, 4vw, 16px);
  }

  .scene-prompt {
    font-size: clamp(14px, 3.9vw, 16px);
  }

  .scene-screen--scene1 .scene-prompt {
    font-size: clamp(14px, 3.9vw, 16px);
  }

  .scene-action--single {
    min-height: 52px;
    height: auto;
    font-size: 16px;
  }

  .scene-actions--single {
    width: min(100%, 300px);
    margin-top: 12px;
  }

  .scene-actions {
    margin-top: 12px;
    gap: 8px;
  }

  .scene-screen--scene2 .scene-actions {
    gap: 8px;
  }

  .scene-screen--scene3 .scene-actions,
  .scene-screen--scene4 .scene-actions {
    gap: 8px;
  }

  .scene-action--option {
    padding: 9px 10px;
    font-size: 13px;
  }

  .loading-screen {
    min-height: calc(100svh - 60px);
    padding-top: 10px;
    padding-bottom: 12px;
  }

  .loading-title {
    font-size: 16px;
  }

  .loading-gif {
    width: min(100%, 500px);
    max-height: min(48svh, 380px);
  }

  .loading-subtitle {
    font-size: 14px;
  }

  .final-screen {
    width: min(100%, 402px);
  }

  .final-card,
  .final-convert,
  .final-actions {
    width: 100%;
  }

  .final-name {
    font-size: 28px;
  }

  .final-hook {
    font-size: 15px;
  }

  .final-convert-title {
    font-size: 22px;
  }
}

@media (max-width: 767px) and (max-height: 760px) {
  .scene-screen--scene1,
  .scene-screen--scene2,
  .scene-screen--scene3,
  .scene-screen--scene4 {
    padding-top: 0;
  }

  .scene-image-wrap {
    margin-top: 10px;
  }

  .scene-actions {
    margin-top: 10px;
  }

  .loading-screen {
    min-height: calc(100svh - 64px);
    padding-top: 8px;
    padding-bottom: 10px;
  }

  .loading-title {
    font-size: clamp(15px, 4.2vw, 18px);
  }

  .loading-gif {
    max-height: min(50svh, 420px);
  }

  .final-screen {
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-screen,
  .final-convert-button,
  .scene-action,
  .final-action,
  .quiz-toast {
    transition: none !important;
    animation: none !important;
  }
}

@keyframes quiz-screen-enter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  body {
    background: #FFFFFF !important;
  }

  #home-view,
  #quiz-toast,
  .final-actions {
    display: none !important;
  }

  #quiz-root {
    display: block !important;
    min-height: auto;
    padding: 0;
  }

  .final-screen {
    display: block;
    width: 100%;
    padding: 0;
  }

  .final-card {
    margin: 0 auto;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
