:root {
  --foreground: #8d6e63;
  --border: #c46987;
  --pink: #ff69b4;
  --hot-pink: #ff1493;
  --light-pink: #ffb6c1;
  --shadow-pink: #ffe4e1;
  --paper: #fffbf0;
  --blue: #bbdbfd;
  --green: #d7ffae;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--foreground);
  font-family: "Quicksand", Arial, sans-serif;
  user-select: none;
  overflow-x: hidden;
  overflow-y: auto;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  background: transparent;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
  height: auto;
}

::-webkit-scrollbar {
  display: none;
}

.page-shell {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: visible;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(to bottom, #b6f1e8, #ffe0eb, #fef5d0);
}

.grid-bg {
  position: fixed;
  inset: 0;
  opacity: .9;
  background-image: linear-gradient(#ffbfdd, transparent 2px), linear-gradient(90deg, #ffbfdd, transparent 2px);
  background-size: 40px 40px;
}

.screen {
  position: relative;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(100vh - 80px);
  padding: 40px 20px;
}

.screen.active {
  display: flex;
  animation: screenIn .8s ease both;
}

.screen.exiting {
  animation: screenOut .35s ease both;
}

.window-card {
  width: 100%;
  max-width: min(448px, calc(100vw - 40px));
  min-width: 0;
  padding: 12px;
  text-align: center;
  border: 4px solid var(--border);
  border-radius: 32px;
  background: var(--blue);
  box-shadow: -7px 7px 0 var(--light-pink);
}

.window-dots {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  padding: 0 8px 8px 0;
}

.single-dot {
  justify-content: flex-end;
}

.dot {
  width: 19px;
  height: 19px;
  border: 3px solid var(--border);
  border-radius: 999px;
}

.yellow {
  background: #ffe29c;
}

.green {
  background: #aaf184;
}

.pink {
  background: #ffb1d0;
}

.card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  border: 4px solid var(--border);
  border-radius: 6px 6px 24px 24px;
  background: white;
}

.bear-float {
  margin-bottom: 32px;
  animation: bob 3s ease-in-out infinite;
}

.bear-frame {
  position: relative;
  width: 128px;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--light-pink);
  border-radius: 32px;
  background: white;
  box-shadow: 8px 8px 0 var(--light-pink);
}

.mini-heart {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  color: var(--pink);
  fill: currentColor;
  stroke: currentColor;
  z-index: 2;
}

.bear-img {
  position: absolute;
  bottom: -6px;
  z-index: 3;
}

h1,
h2,
h4,
.tap-copy {
  font-family: "Caveat", cursive;
}

h1 {
  margin: 0 0 16px;
  color: var(--pink);
  font-size: clamp(3rem, 8vw, 3.75rem);
  line-height: 1;
  font-weight: 700;
  text-shadow: 2px 2px 0 #ffe4e1;
}

.intro-card h1 {
  font-weight: 600;
}

.card-inner p {
  max-width: 360px;
  margin: 0 0 32px;
  font-size: clamp(1.125rem, 3vw, 1.25rem);
  line-height: 1.5;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease;
}

.primary-btn {
  padding: 14px 32px;
  border: 4px solid var(--hot-pink);
  color: white;
  background: var(--pink);
  box-shadow: 0 6px 0 var(--hot-pink);
}

.secondary-btn {
  padding: 12px 24px;
  border: 4px solid var(--pink);
  color: var(--pink);
  background: white;
  box-shadow: 0 6px 0 var(--pink);
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.primary-btn:active,
.secondary-btn:active {
  transform: translateY(2px) scale(.95);
}

.heart-icon,
.primary-btn svg,
.secondary-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-btn svg path,
.secondary-btn svg path {
  stroke: currentColor;
}

.game-screen,
.letter-screen {
  align-items: stretch;
}

.game-wrap,
.letter-wrap {
  width: 100%;
  min-height: calc(100vh - 80px);
  max-width: 672px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.pill-title {
  margin-bottom: 24px;
  text-align: center;
}

.pill-title h2 {
  margin: 0;
  padding: 12px 24px;
  color: var(--pink);
  font-size: clamp(2.25rem, 7vw, 3rem);
  line-height: 1.1;
  font-weight: 600;
  background: white;
  border: 4px solid var(--light-pink);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--light-pink);
}

.messages {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 8px;
}

.message-row {
  position: relative;
  width: 100%;
  max-width: 384px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heart-balloon {
  position: absolute;
  z-index: 20;
  width: 64px;
  height: 72px;
  filter: drop-shadow(0 3px 3px #0000001f);
  animation: floatHeart var(--float-duration, 2s) ease-in-out infinite;
}

.heart-balloon.popping {
  animation: popHeart .15s ease forwards;
}

.message-card {
  width: 100%;
  height: 85%;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  text-align: center;
  border: 2px solid var(--light-pink);
  border-radius: 16px;
  background: white;
  box-shadow: 4px 4px 0 var(--shadow-pink);
  animation: messageIn .3s ease both;
}

.message-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 700;
}

.bow-area {
  width: 100%;
  height: 176px;
  margin-top: 24px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bow-widget {
  position: relative;
  width: 192px;
  height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.arrow {
  position: absolute;
  bottom: 40px;
  width: 8px;
  height: 64px;
  z-index: 50;
  transform-origin: bottom;
  transition: transform .15s ease, opacity .1s ease;
}

.arrow-tail {
  width: 8px;
  height: 64px;
  border-radius: 999px 999px 0 0;
  background: #8d6e63;
}

.arrow-head {
  position: absolute;
  top: -8px;
  left: -2px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #99a1af;
}

.arrow::after {
  content: "";
  position: absolute;
  left: -4px;
  bottom: -4px;
  width: 16px;
  height: 16px;
  background: #ff6568;
  clip-path: polygon(50% 0, 100% 40%, 75% 100%, 50% 76%, 25% 100%, 0 40%);
}

.bow-svg {
  position: absolute;
  bottom: 16px;
  z-index: 20;
  overflow: visible;
  pointer-events: none;
}

.drag-handle {
  position: absolute;
  bottom: 10px;
  z-index: 60;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-dot {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a;
}

.drag-dot span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}

.drag-label {
  position: absolute;
  bottom: -20px;
  margin: 0;
  color: var(--pink);
  font-size: 14px;
  font-weight: 700;
  opacity: .7;
}

.next-letter {
  position: absolute;
  bottom: 32px;
  padding-block: 12px;
  animation: popButton .45s ease both;
}

.flip-space {
  width: 100%;
  max-width: 384px;
  height: 444px;
  margin-bottom: 104px;
  perspective: 1200px;
}

.letter-card {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2, .65, .25, 1);
}

.letter-card.flipped {
  transform: rotateY(180deg);
}

.letter-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  border: 4px solid var(--light-pink);
  border-radius: 32px;
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--shadow-pink);
}

.letter-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.letter-back {
  transform: rotateY(180deg);
}

.dot-pattern {
  position: absolute;
  inset: 0;
  border-radius: 32px;
  opacity: .1;
  pointer-events: none;
  background-image: radial-gradient(var(--pink) 2px, transparent 2px);
  background-size: 20px 20px;
}

.side-sticker {
  position: absolute;
  z-index: 1;
}

.right-sticker {
  top: 16px;
  right: -12px;
  width: 112px;
}

.left-sticker {
  left: -8px;
  bottom: 12px;
  width: 104px;
}

.round-heart {
  position: relative;
  z-index: 2;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  border: 4px solid var(--light-pink);
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px #0000001a;
}

.round-heart svg {
  width: 40px;
  height: 40px;
  color: var(--pink);
  fill: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}

.tap-copy {
  position: relative;
  z-index: 2;
  margin: 16px 0 0;
  padding: 8px 24px;
  color: var(--pink);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid var(--shadow-pink);
  border-radius: 999px;
  background: white;
  box-shadow: 0 1px 3px #0000001a;
}

.letter-content {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 32px;
}

.letter-content h4 {
  margin: 0 0 12px;
  color: var(--pink);
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
}

.letter-content p {
  height: 276px;
  margin: 0;
  overflow-y: scroll;
  white-space: pre-wrap;
  color: var(--foreground);
  font-family: "Caveat", cursive;
  font-size: 24px;
  line-height: 1.625;
  font-weight: 700;
  pointer-events: none;
}

.letter-content strong {
  position: absolute;
  right: 40px;
  bottom: 32px;
  color: var(--pink);
  font-family: "Caveat", cursive;
  font-size: 30px;
  font-weight: 700;
}

.continue-btn {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding-block: 12px;
  animation: continueIn .5s .3s ease both;
}

.continue-btn:hover {
  transform: translateX(-50%) translateY(-2px) scale(1.05);
}

.continue-btn:active {
  transform: translateX(-50%) translateY(2px) scale(.95);
}

.outro-card {
  background: var(--green);
}

.outro-inner {
  padding-inline: 24px;
}

.final-heart-wrap {
  position: relative;
  margin: 16px 0 32px;
  animation: wobble 2s ease-in-out infinite;
}

.final-heart {
  position: relative;
  z-index: 1;
  width: 144px;
  height: 144px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 8px solid #ffe29c;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 10px #fff8e7;
}

.final-heart svg {
  width: 80px;
  height: 80px;
  color: var(--hot-pink);
  fill: currentColor;
}

.final-ring {
  position: absolute;
  inset: -20px;
  z-index: 0;
  border: 4px dashed var(--light-pink);
  border-radius: 50%;
  opacity: .5;
  animation: spin 10s linear infinite;
}

.credit {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  color: rgba(0, 0, 0, .5);
  font-size: 14px;
  font-weight: 300;
  pointer-events: none;
  animation: creditIn .8s ease both;
}

.hidden {
  display: none !important;
}

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

@keyframes screenOut {
  to {
    opacity: 0;
    transform: scale(.9);
    filter: blur(10px);
  }
}

@keyframes bob {
  0%, 100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-15px) rotate(2deg);
  }
}

@keyframes floatHeart {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes popHeart {
  to {
    opacity: 0;
    transform: scale(0);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.5);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes popButton {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

@keyframes continueIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(.8);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes wobble {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes creditIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (min-width: 640px) {
  .pill-title h2 {
    padding: 16px 32px;
  }

  .message-row {
    height: 80px;
  }

  .message-card {
    height: 100%;
  }

  .bow-area {
    height: 176px;
  }
}

@media (min-width: 768px) {
  .message-card p {
    font-size: 16px;
  }
}
