@font-face {
  font-family: "Montserrat";
  src: url("/assets/font/Montserrat-Default.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("/assets/font/Montserrat-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: linear-gradient(180deg, #fffaf4 0%, #fff4ef 52%, #fff8df 100%);
  --card: rgba(255, 252, 248, 0.9);
  --card-strong: #fffdf9;
  --text: #4f3d3d;
  --muted: #9a7f7f;

  --primary: #f2a7c0;
  --primary-strong: #e78fb0;
  --primary-light: #fff4f8;

  --secondary: #f6df8b;
  --secondary-soft: #fff4c7;

  --bg-very-transparent: rgba(242, 167, 192, 0.18);
  --bg-badge-soft: rgba(138, 112, 101, 0.1);
  --bg-btn-ghost: rgba(255, 250, 244, 0.9);
  --bg-audio: linear-gradient(180deg, rgba(246, 223, 139, 0.24), rgba(246, 223, 139, 0.04));
  --bg-toast: rgba(51, 24, 32, 0.92);
  --btn-shadow: rgba(231, 143, 176, 0.28);

  --line: rgba(214, 171, 171, 0.22);
  --success: #7bbf9a;
  --error: #de7f96;
  --warning: #f2c66d;

  --shadow: 0 20px 60px rgba(196, 160, 160, 0.16);

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
}

.container {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto 48px;
}

.hero {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
  padding: 40px 0 20px;
}

.hero--home {
  padding-top: 72px;
}

.hero--compact {
  padding-top: 32px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

.hero h1,
.section-heading h2,
.answer-card h3,
.mode-card h3 {
  margin: 0;
}

.hero h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.08;
}

.hero-text {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.back-link {
  font-size: 16px;
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--muted);
}

.stack-xl,
.stack-lg,
.stack-md {
  display: grid;
}

.stack-xl {
  gap: 24px;
}

.stack-lg {
  gap: 20px;
}

.stack-md {
  gap: 14px;
}

.grid-2cols {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card,
.mode-card,
.answer-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card {
  padding: 28px;
}

.card--full {
  grid-column: 1 / -1;
}

.mode-grid,
.answer-grid,
.summary-grid,
.choice-grid,
.button-row {
  display: grid;
  gap: 16px;
}

.mode-grid,
.answer-grid,
.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-card,
.answer-card {
  padding: 24px;
}

.mode-card {
  display: grid;
  gap: 16px;
}

.mode-card__top,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.mode-card p,
.helper-text,
.info-box,
#feedback-box,
.summary-label {
  color: var(--muted);
}

.mode-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--bg-very-transparent);
  font-size: 1.5rem;
}

.mode-card--disabled {
  opacity: 0.85;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-very-transparent);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.92rem;
}

.badge--soft {
  background: var(--bg-badge-soft);
  color: var(--muted);
}

.button-row {
  grid-auto-flow: column;
  justify-content: end;
}

.button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  pointer-events: none;
}

.button--primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 12px 24px var(--btn-shadow);
}

.button--primary:hover {
  background: var(--primary-strong);
}

.button--ghost {
  border-color: var(--line);
  background: var(--btn-bg-ghost);
  color: var(--text);
}

.button.is-loading {
  pointer-events: none;
  opacity: 1;
  border: none;
}

.button.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 0;
  background: rgba(255, 255, 255, 0.22);
  animation: button-progress-fill var(--loading-duration, 1000ms) linear forwards;
  z-index: 0;
}

.button.is-loading > * {
  position: relative;
  z-index: 1;
}

.button.is-loading {
  color: var(--primary-light);
}

.button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}

@keyframes button-progress-fill {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

.option {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.option:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 167, 192, 0.34);
  box-shadow: 0 10px 24px rgba(231, 143, 176, 0.12);
}

.option__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.option__box {
  position: relative;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 8px;
  border: 1.5px solid rgba(242, 167, 192, 0.45);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.option__box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg) scale(0.75);
  opacity: 0;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.option__content {
  min-width: 0;
}

.option__title {
  display: block;
  font-weight: 700;
  color: var(--text);
}

.option__description {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.option__input:checked + .option__box {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  transform: scale(1.02);
  box-shadow: 0 8px 18px rgba(231, 143, 176, 0.22);
}

.option__input:checked + .option__box::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.option__input:checked ~ .option__content .option__title {
  color: var(--primary-strong);
}

.option:has(.option__input:checked) {
  border-color: rgba(242, 167, 192, 0.42);
  background: rgba(242, 167, 192, 0.12);
  box-shadow: 0 12px 26px rgba(231, 143, 176, 0.12);
}

.option:has(.option__input:focus-visible) {
  outline: 2px solid rgba(242, 167, 192, 0.32);
  outline-offset: 2px;
}

.summary-item,
.audio-box,
.info-box,
.feedback-box,
.table-wrapper {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.summary-item {
  display: grid;
  gap: 4px;
}

.summary-item strong {
  font-size: 1.5rem;
}

.audio-box {
  background: var(--bg-audio);
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-button {
  min-height: 60px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  text-align: left;
  color: var(--text);
}

.choice-button.is-selected {
  border-color: rgba(242, 167, 192, 0.42);
  background: rgba(242, 167, 192, 0.18);
  color: var(--primary-strong);
}

.feedback-box {
  font-weight: 600;
}

.feedback-box.is-success {
  border-color: rgba(30, 170, 120, 0.24);
  background: rgba(30, 170, 120, 0.08);
  color: var(--success);
}

.feedback-box.is-error {
  border-color: rgba(217, 83, 111, 0.24);
  background: rgba(217, 83, 111, 0.08);
  color: var(--error);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.stats-table th {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--bg-toast);
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.stars-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
}

.star-shell {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 60px;
  height: 60px;
}

.stars-row > .star-shell:nth-child(2) {
  position: relative;
  bottom: 12px;
}

.star-icon {
  position: absolute;
  inset: 0;
  width: 60px;
  height: 60px;
  object-fit: contain;
  transform-origin: center;
}

.star-icon--base {
  opacity: 0.38;
  filter: grayscale(1) saturate(0);
  transform: scale(1);
}

.star-icon--earned {
  opacity: 0;
  filter: none;
  transform: scale(0.35);
}

.star-icon.is-wiggle {
  animation: star-wiggle 420ms ease-in-out forwards;
  animation-delay: var(--star-delay, 0ms);
}

.star-icon.is-pop {
  animation: star-pop-in 500ms cubic-bezier(0.2, 0.9, 0.25, 1.25) forwards;
  animation-delay: var(--star-delay, 0ms);
}

.star-shell.is-burst-all::before,
.star-shell.is-burst-all::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
}

.star-shell.is-burst-all::before {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(246, 223, 139, 0.95);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  animation: star-ring-burst 720ms ease-out forwards;
  animation-delay: var(--burst-delay, 980ms);
}

.star-shell.is-burst-all::after {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(246, 223, 139, 0.95);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  box-shadow:
    0 -26px 0 0 rgba(246, 223, 139, 0.95),
    18px -18px 0 0 rgba(255, 244, 199, 0.95),
    26px 0 0 0 rgba(246, 223, 139, 0.95),
    18px 18px 0 0 rgba(255, 244, 199, 0.95),
    0 26px 0 0 rgba(246, 223, 139, 0.95),
    -18px 18px 0 0 rgba(255, 244, 199, 0.95),
    -26px 0 0 0 rgba(246, 223, 139, 0.95),
    -18px -18px 0 0 rgba(255, 244, 199, 0.95);
  animation: star-spark-burst 760ms ease-out forwards;
  animation-delay: var(--burst-delay, 980ms);
}

@keyframes star-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  70% {
    opacity: 1;
    transform: scale(1.14);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes star-ring-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  30% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(3.2);
  }
}

@keyframes star-spark-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

@keyframes star-wiggle {
  0% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-6deg);
  }
  40% {
    transform: rotate(5deg);
  }
  60% {
    transform: rotate(-4deg);
  }
  80% {
    transform: rotate(3deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.results-summary-box {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.results-summary-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.results-summary-precision {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.results-summary-precision strong {
  font-size: 1.7rem;
  line-height: 1;
}

.stats-groups {
  display: grid;
  gap: 16px;
}

.stats-group-card {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.stats-group-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: var(--text);
}

.stats-group-list {
  display: grid;
  gap: 10px;
}

.stats-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.stats-group-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.stats-group-item:last-child {
  padding-bottom: 0;
}

.stats-group-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stats-group-dot {
  color: var(--primary-strong);
  font-size: 1.1rem;
  line-height: 1;
}

.stats-group-inversion {
  color: var(--text);
  min-width: 0;
}

.stats-group-meta {
  flex-shrink: 0;
}

.stats-group-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-very-transparent);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.92rem;
}

@media (max-width: 860px) {
  .grid-2cols,
  .mode-grid,
  .answer-grid,
  .summary-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-auto-flow: row;
  }

  .card {
    padding: 22px;
  }
}

@media (max-width: 570px) {
  .badge {
    display: flex;
    min-width: max-content;
  }

  .hero {
    padding: 12px 0 10px;
  }

  .hero--compact .eyebrow,
  .hero--compact h1,
  .hero--compact .hero-text {
    display: none;
  }

  .hero--compact .back-link {
    margin-bottom: 0;
  }

  .container {
    width: 100%;
    margin: 0;
  }

  .card {
    border-radius: 0;
    max-width: 100%;
  }

  .stack-lg {
    gap: 12px;
  }

  .stack-md {
    gap: 8px;
  }

  .card .helper-text,
  .card--full .summary-grid,
  .card .info-box {
    display: none;
  }

  .choice-grid {
    gap: 8px;
  }

  .audio-box,
  .answer-card {
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .audio-box .helper-text {
    margin: 0;
  }

  .choice-button {
    min-height: 30px;
  }

  .table-wrapper {
    padding: 14px;
  }

  .stats-table th,
  .stats-table td {
    padding: 8px 7px;
  }

  .stats-table th:nth-child(3),
  .stats-table td:nth-child(3),
  .stats-table th:nth-child(4),
  .stats-table td:nth-child(4) {
    display: none;
  }

  .option {
    padding: 14px;
    grid-template-columns: 20px 1fr;
    gap: 12px;
  }

  .option__box {
    width: 20px;
    height: 20px;
    border-radius: 7px;
  }

  .option__box::after {
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
  }

  .option__description {
    display: none;
  }

  #results-panel .button-row {
    justify-content: center;
  }
}

@media (max-width: 570px) {
  .stats-group-card {
    padding: 14px;
  }

  .stats-group-item {
    align-items: flex-start;
    gap: 10px;
  }

  .stats-group-pill {
    min-width: 56px;
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.85rem;
  }
}

@media (max-width: 570px) {
  .results-summary-box {
    padding: 22px;
  }

  .results-summary-content {
    justify-content: center;
    text-align: center;
  }

  .results-summary-precision {
    justify-items: center;
  }
}
