: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(12, 1fr);
  gap: 5px;
  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--secondary {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.button--secondary:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  background: #f4e9e6;
}

.button:disabled,
.button:disabled:hover {
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-soft);
  cursor: not-allowed;
}

.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;
}

.question-content h2 {
  font-size: clamp(21px, 5.8vw, 27px);
  line-height: 1.22;
}

.feedback-content h2,
.order-content h2 {
  font-size: clamp(22px, 6.2vw, 29px);
  line-height: 1.24;
  text-wrap: pretty;
}

.feedback-content h2.is-compact {
  max-width: 390px;
  font-size: clamp(18px, 5vw, 23px);
  line-height: 1.3;
}

.order-content h2 {
  font-size: clamp(20px, 5.5vw, 26px);
}

.button--answer {
  font-size: 15px;
  line-height: 1.28;
}

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

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

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

.screen--celebration {
  background: #fce3d2;
}

.proposal-actions {
  gap: 8px;
}

.agreement {
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.agreement:hover {
  color: var(--ink);
  border-color: #beb5aa;
  background: #f0ece6;
}

.agreement input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.agreement__box {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.agreement__box svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.agreement input:checked + .agreement__box {
  border-color: var(--accent);
  background: var(--accent);
}

.agreement input:checked + .agreement__box svg {
  visibility: visible;
}

.agreement input:focus-visible + .agreement__box {
  outline: 3px solid rgba(201, 95, 88, 0.25);
  outline-offset: 3px;
}

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

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

.order-spark {
  transform-box: fill-box;
  transform-origin: center;
}

[data-screen="order"].is-active .order-spark {
  animation: proposal-detail 0.55s ease 0.15s both;
}

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

.celebration-content .copy-block {
  position: relative;
  z-index: 3;
  padding: 14px 16px;
  text-align: center;
}

.celebration-content {
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.celebration-gif {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #fce3d2;
}

.celebration-gif img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.celebration-date {
  margin: 12px 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;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.screen--celebration .screen__actions {
  position: relative;
  z-index: 3;
}

@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;
  }

  .question-content h2 {
    font-size: clamp(19px, 5.5vw, 24px);
  }

  .feedback-content h2,
  .order-content h2 {
    font-size: clamp(20px, 5.8vw, 26px);
  }

}
