:root {
  --cream: #fdf6ec;
  --paper: #fffaf2;
  --blush: #f4b8a8;
  --terracotta: #d97b5f;
  --brown: #6b4f3f;
  --ink: #4a3a30;
  --tape: #f6e8c8;
  --success: #8a9a5b;
  --error-warm: #b5503e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Quicksand', sans-serif;
  background: var(--cream);
  color: var(--ink);
  overflow: hidden;
  height: 100vh;
}

main#app { position: relative; z-index: 1; height: 100vh; }

.caveat-title {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  color: var(--brown);
  margin: 0;
}

.caveat-title.small { font-size: clamp(1.8rem, 4vw, 2.6rem); }

.subtitle {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  max-width: 32ch;
  margin-top: 0.5rem;
  color: var(--ink);
  opacity: 0.85;
}

.eyebrow {
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--terracotta);
  margin-bottom: 0.5rem;
}

.btn {
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 999px;
  background: var(--terracotta);
  color: var(--paper);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-glow {
  box-shadow: 0 0 0 0 rgba(217, 123, 95, 0.6);
  animation: glow-pulse 2.4s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 123, 95, 0.45); }
  50% { box-shadow: 0 0 0 14px rgba(217, 123, 95, 0); }
}

/* ---------- placeholder image fallback ---------- */

.ph-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: linear-gradient(135deg, #f4dccb, #f4b8a8);
}

.ph-img.img-fallback {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ph-img.img-fallback::after {
  content: "photo coming soon";
  font-family: 'Quicksand', sans-serif;
  font-size: 0.85rem;
  color: var(--brown);
  opacity: 0.6;
  padding: 0 0.5rem;
}

/* ---------- screen manager ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0.45s;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen[data-active="true"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}


/* ---------- sound toggle (cute boombox) ---------- */

.sound-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 60;
  width: 3.6rem;
  height: 3.2rem;
  border-radius: 16px;
  border: none;
  background: var(--paper);
  box-shadow: 0 6px 16px -3px rgba(74, 58, 48, 0.35);
  cursor: pointer;
  padding: 0.3rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sound-toggle:hover { transform: translateY(-2px) scale(1.04); }
.sound-toggle:active { transform: translateY(0) scale(0.96); }

.sound-toggle-svg { width: 100%; height: 100%; display: block; }

.boombox-body { fill: var(--terracotta); }
.boombox-handle { fill: var(--brown); opacity: 0.85; }
.boombox-speaker { fill: var(--paper); }
.boombox-speaker-dot { fill: var(--terracotta); }

.note {
  fill: none;
  stroke: var(--blush);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.4;
  transform-origin: center;
}

.sound-toggle.is-on .boombox-speaker-dot {
  animation: boombox-thump 0.9s ease-in-out infinite;
}

.sound-toggle.is-on .note {
  opacity: 1;
  animation: note-bob 1.6s ease-in-out infinite;
}

.sound-toggle.is-on .note-2 { animation-delay: 0.35s; }

@keyframes boombox-thump {
  0%, 100% { r: 2.6; }
  50% { r: 1.7; }
}

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

.sound-toggle.is-off .boombox-body { opacity: 0.7; }

/* ---------- particles ---------- */

.particle {
  position: fixed;
  z-index: 60;
  width: var(--size, 8px);
  height: var(--size, 8px);
  border-radius: 50%;
  background: var(--color, var(--blush));
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: particle-burst 0.7s ease-out forwards;
}

@keyframes particle-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3);
  }
}

/* ---------- shake ---------- */

.shake { animation: shake-anim 0.4s ease; }

@keyframes shake-anim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- start screen ---------- */

.screen-start {
  background: linear-gradient(135deg, var(--cream), var(--blush), var(--terracotta), var(--cream));
  background-size: 400% 400%;
  animation: pan-gradient 18s ease infinite;
}

@keyframes pan-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.start-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.drift {
  position: absolute;
  inset: -20%;
  background-image: radial-gradient(var(--paper) 2px, transparent 2px);
  background-size: 70px 70px;
  opacity: 0.18;
  animation: drift-move 30s linear infinite;
}

.drift-2 {
  background-size: 110px 110px;
  background-position: 30px 20px;
  opacity: 0.1;
  animation-duration: 45s;
  animation-direction: reverse;
}

@keyframes drift-move {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

.start-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start-content .caveat-title {
  font-size: clamp(4rem, 16vw, 9rem);
  line-height: 1;
}

.start-content .btn { margin-top: 2.5rem; }

/* ---------- choose screen ---------- */

.choose-cards {
  display: flex;
  gap: 3rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.choice-card {
  width: 300px;
  background: var(--paper);
  border: none;
  border-radius: 14px;
  padding: 1.6rem;
  cursor: pointer;
  box-shadow: 0 10px 25px -8px rgba(74, 58, 48, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.choice-card::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  width: 56px;
  height: 20px;
  background: var(--tape);
  opacity: 0.85;
}

.choice-card:hover { transform: translateY(-4px); }

.choice-card .ph-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
}

.choice-name {
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
}

.choice-card.correct {
  animation: success-pulse 0.7s ease;
  box-shadow: 0 0 0 4px var(--success);
}

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

.choose-feedback {
  margin-top: 1.5rem;
  min-height: 1.5em;
  font-weight: 600;
  color: var(--error-warm);
  max-width: 40ch;
  text-align: center;
}

/* ---------- eating game ---------- */

.game-intro {
  margin-bottom: 1rem;
  text-align: center;
  max-width: 50ch;
}

.eating-field {
  position: relative;
  width: min(920px, 90vw);
  height: min(560px, 62vh);
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 14px 34px -8px rgba(74, 58, 48, 0.32);
  overflow: hidden;
}

.eating-mosaic {
  position: absolute;
  inset: 0;
}

.eating-mosaic .ph-img {
  position: absolute;
  inset: 0;
}

.mosaic-tiles {
  position: absolute;
  inset: 0;
  display: grid;
}

.mosaic-tile {
  background: var(--paper);
  transition: opacity 0.4s ease;
}

.mosaic-tile.revealed {
  opacity: 0;
}

.burger-counter {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 6;
  background: var(--paper);
  color: var(--brown);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  box-shadow: 0 4px 10px -2px rgba(74, 58, 48, 0.3);
  pointer-events: none;
}

.sprite {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blush);
  box-shadow: 0 4px 10px -2px rgba(74, 58, 48, 0.4);
  z-index: 5;
  background-size: cover;
  background-position: center;
}

.burger {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--tape);
  z-index: 4;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.burger.collected {
  opacity: 0;
  transform: scale(1.6);
}

.burger img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.yum-bubble {
  position: absolute;
  z-index: 6;
  transform: translate(-50%, -100%);
  background: var(--paper);
  color: var(--terracotta);
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 2px solid var(--tape);
  pointer-events: none;
  white-space: nowrap;
  animation: yum-float 0.7s ease-out forwards;
}

@keyframes yum-float {
  0% { opacity: 0; transform: translate(-50%, -90%) scale(0.6); }
  30% { opacity: 1; transform: translate(-50%, -120%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

.dpad {
  display: none;
  margin-top: 1.2rem;
  position: relative;
  width: 140px;
  height: 140px;
}

.dpad-btn {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  border: none;
  background: var(--paper);
  box-shadow: 0 4px 10px -2px rgba(74, 58, 48, 0.3);
  font-size: 1.1rem;
  color: var(--brown);
}

.dpad-up { top: 0; left: 47px; }
.dpad-down { bottom: 0; left: 47px; }
.dpad-left { top: 47px; left: 0; }
.dpad-right { top: 47px; right: 0; }

@media (pointer: coarse) {
  .dpad { display: block; }
}

#eating-next { margin-top: 1.5rem; }

/* ---------- note screens ---------- */

.screen-note {
  flex-direction: row;
  gap: 3.5rem;
  align-items: center;
  justify-content: center;
}

.note-photo {
  margin: 0;
  width: 340px;
  flex-shrink: 0;
  background: #fff;
  padding: 1.2rem 1.2rem 1.7rem;
  box-shadow: 0 12px 30px -8px rgba(74, 58, 48, 0.32);
  position: relative;
}

.note-photo::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 70px;
  height: 26px;
  background: var(--tape);
  opacity: 0.85;
}

.note-photo .ph-img {
  aspect-ratio: 1 / 1;
}

.note-card {
  background: var(--paper);
  max-width: 580px;
  padding: 3rem;
  border-radius: 10px;
  box-shadow: 0 18px 40px -10px rgba(107, 79, 63, 0.18);
  transform: rotate(-0.4deg);
  line-height: 1.8;
  font-size: 1.12rem;
}

.note-card h3 { margin: 0 0 1rem; }
.note-card p { margin: 0 0 1.5rem; white-space: pre-wrap; }

/* ---------- typing game ---------- */

.screen-game-typing { justify-content: flex-start; padding-top: 2.5rem; }

.chat-header {
  width: min(720px, 92vw);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 250, 242, 0.75);
  border-radius: 18px 18px 0 0;
  margin-top: 1rem;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.chat-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brown);
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--ink);
  opacity: 0.65;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.chat-thread {
  width: min(720px, 92vw);
  flex: 1;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0 0 1rem;
  padding: 1.1rem;
  background: rgba(255, 250, 242, 0.5);
  border-radius: 0 0 18px 18px;
}

.chat-bubble {
  align-self: flex-end;
  background: var(--terracotta);
  color: var(--paper);
  padding: 0.6rem 1rem;
  border-radius: 16px 16px 4px 16px;
  max-width: 85%;
  font-size: 0.95rem;
  opacity: 0;
  transform: translateX(20px);
  animation: bubble-in 0.35s ease forwards;
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}

.bubble-send-icon {
  flex-shrink: 0;
  display: inline-flex;
  width: 14px;
  height: 14px;
  margin-bottom: 0.1rem;
}

.bubble-send-icon svg {
  width: 100%;
  height: 100%;
  fill: var(--paper);
  opacity: 0.8;
}

@keyframes bubble-in {
  to { opacity: 1; transform: translateX(0); }
}

.chat-bubble.reply {
  align-self: flex-start;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--tape);
  border-radius: 16px 16px 16px 4px;
  transform: translateX(-20px);
  animation: bubble-in-left 0.35s ease forwards;
}

@keyframes bubble-in-left {
  to { opacity: 1; transform: translateX(0); }
}

.chat-bubble.typing-dots {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  padding: 0.7rem 1rem;
}

.chat-bubble.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terracotta);
  opacity: 0.5;
  animation: dot-pulse 1s ease-in-out infinite;
}

.chat-bubble.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-bubble.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-pulse {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.typing-target {
  width: min(680px, 92vw);
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  margin-bottom: 0.8rem;
  text-align: center;
  line-height: 1.6;
}

.typing-target .char { opacity: 0.4; }
.typing-target .char.correct { opacity: 1; color: var(--success); }
.typing-target .char.incorrect { opacity: 1; color: var(--error-warm); text-decoration: underline; }

.typing-input {
  width: min(680px, 92vw);
  font-family: 'Quicksand', sans-serif;
  font-size: 1.1rem;
  padding: 0.9rem 1.2rem;
  border-radius: 999px;
  border: 2px solid var(--blush);
  outline: none;
  background: var(--paper);
}

.typing-input:focus { border-color: var(--terracotta); }

/* ---------- final screen ---------- */

.screen-final {
  text-align: center;
  gap: 1.5rem;
}

.final-photo {
  margin: 0 auto 1.5rem;
  width: min(420px, 85%);
  background: #fff;
  padding: 1rem 1rem 1.4rem;
  box-shadow: 0 10px 24px -8px rgba(74, 58, 48, 0.28);
  position: relative;
}

.final-photo::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 70px;
  height: 26px;
  background: var(--tape);
  opacity: 0.85;
}

.final-photo .ph-img {
  width: 100%;
  height: auto;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}

.final-card {
  background: var(--paper);
  width: min(1040px, 94vw);
  padding: 3.2rem;
  border-radius: 10px;
  box-shadow: 0 18px 40px -10px rgba(107, 79, 63, 0.18);
  text-align: left;
  display: flex;
  flex-direction: column;
}

.final-message {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.8;
  color: var(--ink);
}

.final-message p { margin: 0 0 1.2rem; }
.final-message p:last-child { margin-bottom: 0; }

.final-card .final-signoff {
  margin-top: 2rem;
  align-self: flex-end;
  text-align: right;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
}

/* ---------- ambient decorative blobs (fill empty space, cute not generic) ---------- */

.screen-choose::before,
.screen-game-eating::before,
.screen-note::before,
.screen-game-typing::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 60vmin;
  height: 60vmin;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
}

.screen-choose::before { background: var(--blush); top: -10%; left: -15%; }
.screen-game-eating::before { background: var(--tape); top: 60%; right: -15%; }
.screen-note::before { background: var(--blush); top: -15%; right: -10%; }
.screen-game-typing::before { background: var(--tape); bottom: -15%; left: -10%; }

/* ---------- confetti (subtle, static dots) ---------- */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(var(--blush) 2px, transparent 2px),
    radial-gradient(var(--terracotta) 2px, transparent 2px);
  background-size: 90px 90px, 130px 130px;
  background-position: 0 0, 45px 60px;
  opacity: 0.12;
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
  .screen-note {
    flex-direction: column;
    gap: 1.5rem;
  }
  .note-photo { width: 200px; }
  .chat-thread { max-height: 42vh; }
}

@media (max-width: 480px) {
  .choice-card { width: 42vw; min-width: 140px; }
  .eating-field { width: 95vw; height: 50vh; }
  .start-content .caveat-title { font-size: clamp(3.2rem, 18vw, 6rem); }
  .note-card { padding: 1.4rem; }
  .final-card { padding: 1.4rem; }
  .chat-header { padding: 0.5rem 0.8rem; gap: 0.5rem; }
  .chat-avatar { width: 32px; height: 32px; }
}
