:root {
  --background: #f5f2ed;
  --surface: #fbfaf7;
  --surface-soft: #e9e3da;
  --ink: #292521;
  --muted: #756f68;
  --line: #d8d1c8;
  --accent: #c95f58;
  --accent-hover: #b9504a;
  --success-soft: #dfe7de;
  --blush: #efd6d1;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body,
button {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

body {
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  position: relative;
  width: min(100%, 460px);
  height: 100dvh;
  margin-inline: auto;
  overflow: hidden;
  background: var(--background);
}

.stage-progress {
  position: absolute;
  z-index: 3;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  left: max(20px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  pointer-events: none;
}

.stage-progress__bar {
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
  transition: background-color 0.2s ease;
}

.stage-progress__bar.is-complete,
.stage-progress__bar.is-current {
  background: var(--accent);
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) auto;
  row-gap: 16px;
  padding:
    max(18px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

.screen__top,
.screen__content,
.screen__actions {
  width: 100%;
}

.screen__top {
  display: flex;
  align-items: center;
}

.screen__content {
  align-self: center;
  min-height: 0;
}

.screen__actions {
  display: grid;
  gap: 8px;
}

.illustration {
  display: grid;
  place-items: center;
  width: min(58vw, 210px);
  height: clamp(132px, 23dvh, 180px);
  margin: 0 auto clamp(22px, 3.5dvh, 32px);
}

.illustration--large {
  width: min(62vw, 225px);
  height: clamp(148px, 26dvh, 205px);
}

.illustration svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line--thin {
  stroke-width: 4;
}

.line--accent {
  stroke: var(--accent);
}

.shape-cream {
  fill: var(--surface-soft);
}

.shape-blush {
  fill: var(--blush);
}

.shape-coral,
.fill-coral {
  fill: var(--accent);
}

.fill-paper {
  fill: var(--surface);
}

.fill-success {
  fill: var(--success-soft);
}

.copy-block {
  max-width: 370px;
  margin-inline: auto;
  text-align: center;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(27px, 7.4vw, 33px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.button {
  width: 100%;
  min-height: 56px;
  padding: 13px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.button--primary {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.button--primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button--answer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  color: var(--ink);
  text-align: center;
  border-color: var(--line);
  background: var(--surface);
  font-weight: 500;
}

.button--answer:hover {
  border-color: #beb5aa;
  background: #f0ece6;
}

.button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(201, 95, 88, 0.25);
  outline-offset: 3px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.icon-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.answer-list {
  grid-template-columns: 1fr;
}

.feedback-content,
.reward-content,
.proposal-content,
.celebration-content {
  align-self: center;
}

.screen--celebration .screen__content {
  grid-row: 2;
}

.screen--celebration .screen__actions {
  grid-row: 3;
}

.proposal-actions {
  gap: 0;
  padding-bottom: 72px;
}

.button--escape {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  width: min(calc(100vw - 40px), 420px);
  min-width: 0;
  min-height: 56px;
  padding: 13px 17px;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface);
  font-size: 14px;
  cursor: default;
  transform: translate3d(var(--escape-x, -200px), var(--escape-y, -200px), 0);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.proposal-illustration {
  width: min(72vw, 255px);
}

.proposal-detail {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

[data-screen="proposal"].is-active .proposal-detail {
  animation: proposal-detail 0.5s ease 0.18s forwards;
}

.celebration-content .copy-block {
  position: relative;
  text-align: center;
}

.screen--celebration::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(78vw, 350px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #eee1da;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -55%) scale(0.72);
}

.screen--celebration.is-active::before {
  animation: celebration-halo 0.85s ease forwards;
}

.celebration-mark {
  width: clamp(76px, 22vw, 96px);
  margin: 0 auto 28px;
}

.celebration-mark svg {
  display: block;
  width: 100%;
  fill: var(--accent);
}

.screen--celebration.is-active .celebration-mark {
  animation: celebration-heart 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.screen--celebration.is-active .copy-block {
  animation: celebration-copy 0.45s ease 0.18s both;
}

.celebration-date {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.text-button {
  min-height: 44px;
  padding: 9px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.text-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes celebration-halo {
  from {
    opacity: 0;
    transform: translate(-50%, -55%) scale(0.72);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -55%) scale(1);
  }
}

@keyframes celebration-heart {
  from {
    opacity: 0;
    transform: scale(0.68);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes celebration-copy {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes proposal-detail {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-height: 680px) {
  .screen {
    row-gap: 10px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .illustration {
    height: 112px;
    margin-bottom: 16px;
  }

  .illustration--large {
    height: 132px;
  }

  h1,
  h2 {
    font-size: clamp(24px, 6.8vw, 29px);
  }

  .button,
  .button--answer {
    min-height: 52px;
  }
}
