:root {
  --paper: #f3ede5;
  --paper-light: #fbf8f3;
  --card: #fffdf9;
  --ink: #292424;
  --muted: #756b67;
  --line: rgba(41, 36, 36, 0.14);
  --rose: #c94e63;
  --rose-dark: #a7354a;
  --rose-soft: #f2c6cd;
  --shadow: 0 28px 80px rgba(61, 43, 39, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.9), transparent 18rem),
    radial-gradient(circle at 88% 78%, rgba(201, 78, 99, 0.1), transparent 24rem),
    linear-gradient(150deg, var(--paper-light), var(--paper));
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(100%, 620px);
  min-height: 100dvh;
  margin-inline: auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
}

.step-label {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
}

.intro-copy {
  padding-block: 38px 24px;
}

.section-copy {
  padding-block: 38px 28px;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--rose-dark);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

h1 {
  max-width: 16ch;
  font-size: clamp(1.95rem, 8vw, 2.7rem);
}

h2 {
  font-size: clamp(1.65rem, 7vw, 2.2rem);
}

.intro-copy > p:last-child {
  max-width: 38ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.polaroid {
  position: relative;
  width: 100%;
  padding: 11px 11px 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 7px;
  background: var(--card);
  box-shadow: var(--shadow);
  transform: rotate(-1.1deg);
  transform-origin: center;
  user-select: none;
  will-change: transform;
}

.decoy-card {
  z-index: 2;
  transition:
    transform 340ms cubic-bezier(0.22, 0.8, 0.28, 1),
    opacity 420ms ease,
    box-shadow 180ms ease;
}

.photo-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 3px;
  background: #dfd6ce;
}

.photo-stage img,
.memory-photo img,
.panorama-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.scratch-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  transition: opacity 360ms ease;
}

.scratch-layer.is-cleared {
  opacity: 0;
  pointer-events: none;
}

.scratch-progress {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: white;
  background: rgba(36, 30, 30, 0.68);
  backdrop-filter: blur(9px);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.62rem;
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.scratch-progress > span {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.scratch-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose-soft), white);
  transition: width 100ms linear;
}

.scratch-progress.is-hidden {
  opacity: 0;
  transform: translateY(6px);
}

.photo-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 11px 8px 13px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.84rem;
  font-style: italic;
}

.photo-caption span:last-child {
  color: var(--rose);
  font-size: 1rem;
}

.gesture-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 21px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  transition: opacity 220ms ease;
}

.gesture-hint span {
  color: var(--rose);
  font-size: 1rem;
}

.gesture-hint.is-hidden {
  opacity: 0;
}

.quiz {
  margin-top: 42px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 249, 0.72);
  box-shadow: 0 18px 50px rgba(61, 43, 39, 0.08);
  animation: reveal 480ms cubic-bezier(0.2, 0.8, 0.25, 1);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.answers {
  display: grid;
  gap: 9px;
  margin-top: 22px;
}

.answers button {
  min-height: 51px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  touch-action: manipulation;
}

.answers button:hover,
.answers button:focus-visible {
  border-color: var(--rose-soft);
  background: white;
  transform: translateY(-1px);
}

.answers button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
}

.answers button.is-correct {
  border-color: var(--rose);
  color: var(--rose-dark);
  background: #fff4f5;
  opacity: 1;
}

.feedback {
  min-height: 1.4em;
  margin: 15px 0 0;
  color: var(--rose-dark);
  font-size: 0.79rem;
  font-weight: 700;
  line-height: 1.5;
}

.quiz.is-wrong {
  animation: shake 280ms ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-5px);
  }
  70% {
    transform: translateX(5px);
  }
}

.swipe-instruction {
  display: flex;
  gap: 15px;
  align-items: center;
  margin: 24px 0 10px;
  padding: 16px 18px;
  border-radius: 18px;
  color: white;
  background: var(--ink);
  box-shadow: 0 16px 40px rgba(41, 36, 36, 0.18);
  animation: reveal 360ms ease;
}

.swipe-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-light);
  font-size: 1.25rem;
  animation: nudge 1.6s ease-in-out infinite;
}

@keyframes nudge {
  0%,
  100% {
    transform: translateX(2px);
  }
  50% {
    transform: translateX(-5px);
  }
}

.swipe-instruction strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.swipe-instruction p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
}

.decoy-card.is-swipe-ready {
  cursor: grab;
  box-shadow: 0 32px 90px rgba(61, 43, 39, 0.22);
  touch-action: pan-y;
}

.decoy-card.is-dragging,
.memory-card.is-dragging {
  cursor: grabbing;
  transition: none;
  touch-action: none;
}

.decoy-card.is-leaving {
  pointer-events: none;
  transition: transform 520ms cubic-bezier(0.35, 0.1, 0.7, 0.15), opacity 420ms ease;
}

.memory-screen {
  animation: screen-in 580ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.shoulder-scene {
  position: relative;
  min-height: 360px;
  isolation: isolate;
}

.memory-card {
  z-index: 2;
  cursor: grab;
  transform: rotate(1.2deg);
  transition:
    transform 620ms cubic-bezier(0.35, 0.1, 0.7, 0.15),
    opacity 420ms ease;
  touch-action: none;
}

.memory-card.is-leaving-memory {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(16px, 115vh, 0) rotate(10deg);
}

.memory-photo {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 3px;
  background: #d8cec5;
}

.memory-photo::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(244, 226, 192, 0.12), transparent 38%),
    repeating-linear-gradient(0deg, rgba(42, 32, 28, 0.025) 0 1px, transparent 1px 3px);
  content: "";
  pointer-events: none;
}

.memory-frame {
  position: absolute;
  inset: 0;
  filter: sepia(0.08) saturate(0.84) contrast(0.96);
  opacity: 0;
  transform: scale(1.025);
  transition: opacity 360ms ease, transform 520ms ease;
}

.memory-frame.is-visible {
  opacity: 1;
  transform: scale(1);
}

.memory-hint {
  margin-bottom: 6px;
}

.panorama-step {
  animation: screen-in 520ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

.shoulder-quiz {
  position: relative;
  z-index: 5;
}

.panorama-card {
  position: relative;
  z-index: 2;
  transform: rotate(-0.8deg);
  transition: transform 620ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

.panorama-photo {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: #d8cec5;
}

.panorama-photo img {
  object-fit: cover;
  object-position: left center;
  transition: object-position 900ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

.bump-status {
  width: fit-content;
  margin: 15px auto 0;
  padding: 10px 15px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  box-shadow: 0 12px 28px rgba(41, 36, 36, 0.16);
  font-size: 0.72rem;
  font-weight: 800;
  animation: reveal 260ms ease;
}

.shoulder-character {
  position: absolute;
  z-index: 4;
  bottom: 60px;
  left: -150px;
  width: 250px;
  height: 160px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-80px) scale(0.4);
  transform-origin: left bottom;
}

.shoulder-head {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 31px;
  width: 54px;
  height: 62px;
  border-radius: 48% 48% 44% 44%;
  background: #d8aa8c;
  box-shadow: inset -8px 0 rgba(80, 57, 48, 0.08);
}

.shoulder-head::before {
  position: absolute;
  top: -5px;
  right: -2px;
  left: -2px;
  height: 25px;
  border-radius: 60% 65% 25% 25%;
  background: #5f4a42;
  content: "";
}

.shoulder-body {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 232px;
  height: 104px;
  border-radius: 58% 58% 18% 12%;
  background: #252425;
  box-shadow: inset 0 8px rgba(255, 255, 255, 0.035);
  transform-origin: right center;
}

.shoulder-scene.is-bumping .shoulder-character {
  animation: shoulder-charge 900ms cubic-bezier(0.16, 0.86, 0.26, 1) forwards;
}

.shoulder-scene.is-bumping .shoulder-body {
  animation: shoulder-grow 720ms 80ms cubic-bezier(0.16, 0.86, 0.26, 1) forwards;
}

.shoulder-scene.is-bumping .panorama-card {
  animation: panorama-bump 900ms 110ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

.shoulder-scene.is-bumping .panorama-photo img {
  object-position: 88% center;
}

@keyframes panorama-bump {
  0%,
  100% {
    transform: rotate(-0.8deg) translateX(0);
  }
  42% {
    transform: rotate(1.2deg) translateX(24px);
  }
}

@keyframes shoulder-charge {
  0% {
    opacity: 0;
    transform: translateX(-80px) scale(0.4);
  }
  26% {
    opacity: 1;
  }
  70% {
    opacity: 1;
    transform: translateX(72px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(130px) scale(1.05);
  }
}

@keyframes shoulder-grow {
  0% {
    transform: scaleX(0.7);
  }
  58% {
    transform: scaleX(1.7);
  }
  100% {
    transform: scaleX(1.35);
  }
}

.final-copy {
  padding: 38px 10px 18px;
  text-align: center;
  animation: final-in 700ms cubic-bezier(0.18, 0.85, 0.28, 1);
}

@keyframes final-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.final-copy h2 {
  margin-inline: auto;
  max-width: 15ch;
}

.final-message {
  max-width: 31ch;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

.signature {
  margin: 14px 0 0;
  color: var(--rose-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-style: italic;
}

.restart-button {
  min-height: 49px;
  margin-top: 29px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease;
}

.restart-button:hover,
.restart-button:focus-visible {
  background: white;
  transform: translateY(-2px);
}

:focus-visible {
  outline: 3px solid rgba(201, 78, 99, 0.3);
  outline-offset: 3px;
}

@media (min-width: 700px) {
  .page-shell {
    padding-block: 32px 70px;
  }

  .intro-copy,
  .section-copy {
    padding-top: 50px;
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding-inline: 12px;
  }

  .intro-copy,
  .section-copy {
    padding-top: 32px;
  }

  .polaroid {
    padding: 9px 9px 0;
  }

  .photo-caption {
    min-height: 54px;
    font-size: 0.77rem;
  }

  .quiz {
    padding: 21px 17px;
  }

  .shoulder-scene {
    min-height: 310px;
  }

  .shoulder-character {
    bottom: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
