/* Sam's Birthday — warm cozy kitchen */

:root {
  --th-paper: #f3e6cc;
  --th-paperEdge: #e6d4ad;
  --th-ink: #2a1b15;
  --th-accent: #b04a3a;
  --th-gold: #c89236;
  --th-handwrite: #3a2a1a;
  --th-cardFace: #fdf6e3;

  /* plate-up button glow — overridden per theme below */
  --th-plate-glow: rgba(176, 74, 58, 0.40);
  --th-plate-glow-hi: rgba(176, 74, 58, 0.65);

  --serif: "Instrument Serif", "DM Serif Display", Georgia, serif;
  --hand: "Caveat", "Shadows Into Light", cursive;
  --body: "DM Sans", "Geist", system-ui, sans-serif;
}

/* ── Per-theme plate-glow overrides ────────────────────────────────────────── */
[data-theme="tramway"] {
  --th-plate-glow: rgba(0, 107, 61, 0.42);
  --th-plate-glow-hi: rgba(0, 107, 61, 0.68);
}

[data-theme="takeout"] {
  --th-plate-glow: rgba(232, 168, 48, 0.40);
  --th-plate-glow-hi: rgba(232, 168, 48, 0.65);
}

[data-theme="cinematic"] {
  --th-plate-glow: rgba(217, 122, 58, 0.40);
  --th-plate-glow-hi: rgba(217, 122, 58, 0.65);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--body);
  color: var(--th-ink);
  background: var(--th-paper);
  min-height: 100vh;
  overflow: hidden;
}

#root {
  min-height: 100vh;
}

.app {
  position: relative;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--th-paper);
  color: var(--th-ink);
  transition: background 600ms ease, color 600ms ease;
}

/* Paper background */
.paper-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.6), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(0, 0, 0, 0.06), transparent 55%),
    var(--th-paper);
  pointer-events: none;
  z-index: 0;
}

.paper-noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: multiply;
  opacity: 0.55;
}

[data-theme="takeout"] .paper-noise,
[data-theme="cinematic"] .paper-noise {
  mix-blend-mode: screen;
  opacity: 0.3;
}

/* ====================================================== INTRO */
.intro {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 6vh 4vw;
}

.intro-card {
  text-align: center;
  max-width: 640px;
  position: relative;
  animation: rise 800ms cubic-bezier(.2, .7, .2, 1.05);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.intro-card {
  animation-fill-mode: forwards;
}

.intro-eyebrow {
  font-family: var(--hand);
  font-size: 28px;
  color: var(--th-accent);
  letter-spacing: 0.02em;
  margin-bottom: -16px;
  transform: rotate(-3deg);
}

.intro-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(80px, 14vw, 200px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 0.95;
  color: var(--th-ink);
}

.intro-flourish {
  color: var(--th-gold);
  margin: 12px 0 24px;
}

.intro-sub {
  font-family: var(--serif);
  font-size: 24px;
  font-style: italic;
  opacity: 0.78;
  margin: 0 0 36px;
  line-height: 1.45;
}

.intro-corner {
  position: absolute;
  pointer-events: none;
  color: var(--th-ink);
  opacity: 0.18;
}

.intro-corner-tl {
  top: 4vh;
  left: 4vw;
}

.intro-corner-br {
  bottom: 4vh;
  right: 4vw;
  transform: scaleX(-1);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--body);
  font-weight: 500;
  font-size: 17px;
  padding: 16px 28px;
  background: var(--th-ink);
  color: var(--th-paper);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 200ms cubic-bezier(.2, .8, .2, 1.1), box-shadow 200ms;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-ghost {
  display: inline-block;
  margin-top: 18px;
  background: none;
  border: none;
  font-family: var(--body);
  font-size: 14px;
  color: var(--th-ink);
  opacity: 0.55;
  cursor: pointer;
  padding: 6px 10px;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
}

.btn-ghost:hover {
  opacity: 0.85;
}

/* ====================================================== KITCHEN SCENE */
.scene {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30vh;
  background:
    linear-gradient(180deg, var(--th-paperEdge) 0%, color-mix(in srgb, var(--th-paperEdge) 80%, black) 100%);
  z-index: 1;
  box-shadow: inset 0 12px 24px rgba(0, 0, 0, 0.08);
}

.counter-edge {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: color-mix(in srgb, var(--th-ink) 40%, transparent);
  opacity: 0.4;
}

/* Wok positioning */
.wok-wrap {
  position: absolute;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  z-index: 3;
  transition: transform 1000ms cubic-bezier(.4, 0, .2, 1), opacity 800ms;
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.35));
}

.scene-cooking .wok-wrap {
  animation: wok-shake 0.5s ease-in-out infinite alternate;
}

@keyframes wok-shake {
  0% {
    transform: translateX(-50%) rotate(-1.2deg) translateY(-2px);
  }

  100% {
    transform: translateX(-50%) rotate(1.2deg) translateY(0);
  }
}

.scene-cards .wok-wrap {
  transform: translateX(-50%) translateY(40vh) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

.scene-dish .wok-wrap {
  transform: translateX(-50%) translateY(-10vh) scale(1.05) rotate(-15deg);
}

.wok-steam {
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  color: var(--th-ink);
  opacity: 0.5;
}

/* Stage holds ingredients in their toss / card positions */
.stage {
  position: absolute;
  inset: 0;
  z-index: 4;
}

/* Cards-phase: stage becomes a centered flex wrap. Tossing ingredients keep
   position: absolute so they're taken out of grid flow. */
.scene-cards .stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: clamp(16px, 3vh, 36px) clamp(16px, 3vw, 44px);
  padding: clamp(100px, 17vh, 200px) clamp(16px, 5vw, 80px) clamp(40px, 8vh, 100px);
  max-width: 1200px;
  left: 50%;
  right: auto;
  width: 100%;
  transform: translateX(-50%);
}

.ing {
  position: absolute;
  transform-origin: center;
}

/* Cooking phase: start at wok center, animate up & out in an arc */
.ing-tossing {
  left: 50%;
  bottom: 18vh;
  width: 100px;
  height: 100px;
  margin-left: -50px;
  opacity: 0;
  animation: toss var(--toss-dur) cubic-bezier(.3, .9, .5, 1) forwards;
  animation-delay: var(--toss-delay);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}

@keyframes toss {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(0.4);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  40% {
    transform: translate(calc(var(--dx) * 0.55), calc(var(--dy) * 1.05)) rotate(calc(var(--rot) * 0.5)) scale(1.1);
  }

  70% {
    transform: translate(calc(var(--dx) * 0.95), calc(var(--dy) * 0.5)) rotate(calc(var(--rot) * 0.8)) scale(1);
  }

  100% {
    transform: translate(var(--land-x), var(--land-y)) rotate(var(--rot)) scale(0.8);
    opacity: 1;
  }
}

.ing-illo {
  pointer-events: none;
}

/* Cards phase: laid out on counter as recipe cards */
.ing-card {
  /* Inline (flex item) — scales to viewport */
  position: relative;
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  width: clamp(160px, 18vw, 220px);
  flex: 0 0 auto;
  opacity: 0;
  animation: card-in 700ms cubic-bezier(.2, .8, .2, 1.1) forwards;
  animation-delay: var(--card-delay);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.85) rotate(-4deg);
  }

  to {
    opacity: 1;
    transform: var(--card-tilt, rotate(0deg));
  }
}

/* Slight random-ish tilts per row/col */
.ing-card:nth-child(1) {
  --card-tilt: rotate(-3deg);
}

.ing-card:nth-child(2) {
  --card-tilt: rotate(2deg);
}

.ing-card:nth-child(3) {
  --card-tilt: rotate(-1.5deg);
}

.ing-card:nth-child(4) {
  --card-tilt: rotate(2.5deg);
}

.ing-card:nth-child(5) {
  --card-tilt: rotate(-2deg);
}

.ing-card:nth-child(6) {
  --card-tilt: rotate(1.5deg);
}

.ing-card:nth-child(7) {
  --card-tilt: rotate(-2.5deg);
}

.ing-card:nth-child(8) {
  --card-tilt: rotate(3deg);
}

.ing-card:nth-child(9) {
  --card-tilt: rotate(-1deg);
}

/* The actual card UI */
.card {
  display: block;
  width: 100%;
  background: var(--th-cardFace);
  border: none;
  border-radius: 4px;
  padding: clamp(10px, 1.5vh, 18px) clamp(10px, 1.5vw, 18px) clamp(12px, 2vh, 22px);
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 12px 24px rgba(0, 0, 0, 0.18),
    0 30px 50px rgba(0, 0, 0, 0.12);
  font-family: var(--body);
  color: var(--th-handwrite);
  position: relative;
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1.1), box-shadow 220ms;
}

.card::before {
  /* faint paper texture */
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(0, 0, 0, 0.04), transparent 60%),
    radial-gradient(ellipse at 90% 90%, rgba(0, 0, 0, 0.05), transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

.card:hover {
  transform: translateY(-6px) rotate(0deg) scale(1.04);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 22px 36px rgba(0, 0, 0, 0.25),
    0 40px 60px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.card-tape {
  position: absolute;
  width: 50px;
  height: 14px;
  background: rgba(220, 200, 130, 0.55);
  border: 1px solid rgba(160, 130, 60, 0.25);
  top: -6px;
}

.card-tape-1 {
  left: 30px;
  transform: rotate(-8deg);
}

.card-tape-2 {
  right: 30px;
  transform: rotate(7deg);
}

.card-ing {
  display: flex;
  justify-content: center;
  align-items: center;
  height: clamp(80px, 13vh, 130px);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.card-ing svg {
  width: clamp(70px, 9vw, 110px);
  height: clamp(70px, 9vw, 110px);
}

.card-meta {
  text-align: center;
  border-top: 1px dashed color-mix(in srgb, var(--th-handwrite) 30%, transparent);
  padding-top: 10px;
  position: relative;
  z-index: 1;
}

.card-name {
  font-family: var(--serif);
  font-size: clamp(16px, 1.6vw, 22px);
  letter-spacing: 0.01em;
  color: var(--th-ink);
}

.card-friend {
  font-family: var(--hand);
  font-size: clamp(16px, 1.6vw, 22px);
  color: var(--th-accent);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.card-opened-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--th-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.ing-opened .card {
  opacity: 0.78;
}

.ing-opened .card-ing {
  filter: saturate(0.7);
}

/* Returning ingredients during plate-up phase — stay in flow, then
   shrink + drop toward the wok area. */
.ing-returning {
  position: relative;
  left: auto;
  top: auto;
  width: clamp(160px, 18vw, 220px);
  flex: 0 0 auto;
  height: clamp(100px, 14vh, 140px);
  display: flex;
  justify-content: center;
  align-items: center;
  animation: ing-return 1800ms cubic-bezier(.5, 0, .2, 1) forwards;
  animation-delay: var(--return-delay);
}

@keyframes ing-return {
  0% {
    opacity: 1;
    transform: rotate(0deg) scale(1) translateY(0);
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: rotate(540deg) scale(0.2) translateY(30vh);
  }
}

.scene-dish .stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: clamp(16px, 3vh, 36px) clamp(16px, 3vw, 44px);
  padding: clamp(100px, 17vh, 200px) clamp(16px, 5vw, 80px) clamp(40px, 8vh, 100px);
  max-width: 1200px;
  left: 50%;
  width: 100%;
  transform: translateX(-50%);
}

/* Cards header */
.cards-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  text-align: center;
  padding: clamp(20px, 4vh, 48px) 24px 0;
  pointer-events: none;
  animation: rise 800ms 400ms forwards;
  opacity: 0;
}

.cards-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.05;
}

.cards-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(14px, 1.4vw, 18px);
  opacity: 0.65;
  margin: 4px 0 0;
}

/* Progress pill */
.progress-pill {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 50;
  background: var(--th-ink);
  color: var(--th-paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--body);
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: rise 700ms 700ms both;
}

.progress-count {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.02em;
}

.progress-label {
  opacity: 0.7;
}

/* Plate up button */
.btn-plate {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  font-family: var(--body);
  font-weight: 500;
  font-size: 18px;
  padding: 18px 32px;
  background: var(--th-accent);
  color: var(--th-paper);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 32px var(--th-plate-glow), 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 60;
  animation: plate-pop 800ms cubic-bezier(.2, .8, .2, 1.3) both, plate-pulse 2.4s 800ms ease-in-out infinite;
}

@keyframes plate-pop {
  from {
    transform: translateX(-50%) translateY(40px) scale(0.7);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes plate-pulse {

  0%,
  100% {
    box-shadow: 0 12px 32px var(--th-plate-glow), 0 4px 8px rgba(0, 0, 0, 0.15);
  }

  50% {
    box-shadow: 0 12px 36px var(--th-plate-glow-hi), 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

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

.btn-skip {
  position: fixed !important;
  top: auto !important;
  right: 24px !important;
  bottom: 24px !important;
  left: auto !important;
  z-index: 99;
  margin: 0;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--th-paper);
  font-family: var(--body);
  font-weight: 500;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-skip:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.cards-header .btn-skip {
  pointer-events: auto;
}

/* ====================================================== MODAL */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 8, 0.55);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  animation: fade-in 240ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
  background: var(--th-paper);
  color: var(--th-ink);
  padding: 40px 48px 14px;
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: modal-in 500ms cubic-bezier(.2, .8, .2, 1.1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--th-ink);
  opacity: 0.5;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
}

.modal-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

/* Note */
.note {
  position: relative;
  background: #fffdf6;
  padding: 36px 32px 28px;
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  background-image:
    repeating-linear-gradient(180deg, transparent 0, transparent 31px, rgba(94, 138, 188, 0.18) 31px, rgba(94, 138, 188, 0.18) 32px);
  border-left: 2px solid rgba(192, 57, 43, 0.3);
}

.note-pin {
  position: absolute;
  top: -8px;
  left: 30px;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 35% 30%, #e8a830, #b04a3a);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.note-food {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 22px;
  padding: 0 0 16px;
  border-bottom: 1px dashed color-mix(in srgb, var(--th-handwrite) 28%, transparent);
}

.note-food-illo {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--th-paper) 58%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--th-handwrite) 12%, transparent);
}

.note-food-illo svg {
  width: 64px;
  height: 64px;
}

.note-food-meta {
  min-width: 0;
}

.note-food-name {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.02;
  color: var(--th-ink);
}

.note-food-friend {
  font-family: var(--hand);
  font-size: 25px;
  line-height: 1;
  color: var(--th-accent);
  margin-top: 4px;
}

.note-body {
  font-family: var(--hand);
  font-size: 24px;
  line-height: 1.35;
  margin: 0;
  color: var(--th-handwrite);
}

.note-sign {
  font-family: var(--hand);
  font-size: 28px;
  color: var(--th-accent);
  margin-top: 20px;
  text-align: right;
}

/* ====================================================== FINALE */
.finale {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 6vh 4vw;
  animation: rise 1000ms cubic-bezier(.2, .7, .2, 1.05);
  text-align: center;
}

.finale-dish {
  filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.3));
  animation: dish-arrive 1200ms cubic-bezier(.2, .7, .2, 1.1);
}

.finale-dish svg {
  display: block;
  width: min(92vw, 560px);
  height: auto;
}

@keyframes dish-arrive {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.7);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.finale-steam {
  position: absolute;
  top: 8vh;
  left: 50%;
  transform: translateX(-50%);
  color: var(--th-ink);
  opacity: 0.5;
  pointer-events: none;
}

.finale-text {
  margin-top: -20px;
  max-width: 640px;
}

.finale-eyebrow {
  font-family: var(--hand);
  font-size: 28px;
  color: var(--th-accent);
  margin-bottom: 0;
  transform: rotate(-1.5deg);
}

.finale-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 120px);
  margin: 8px 0 18px;
  line-height: 0.96;
  letter-spacing: -0.02em;
}

.finale-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  line-height: 1.5;
  opacity: 0.78;
  margin: 0;
  text-wrap: pretty;
}

.finale-restart {
  margin-top: 0;
}

.finale-actions {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Ensure buttons in the finale line up (override intro spacing) */
.finale-actions .btn-ghost {
  margin-top: 0;
  /* remove intro's top offset */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  line-height: 1;
  height: 44px;
  /* enforce equal visual height */
  min-width: 150px;
  /* provide consistent button widths */
  font-size: 15px;
}

.finale-actions .btn-ghost[disabled] {
  opacity: 0.5;
  cursor: progress;
}

/* Flames */
.flame {
  transform-origin: center bottom;
  animation: flicker 0.36s ease-in-out infinite alternate;
}

.flame-1 {
  animation-delay: 0ms;
}

.flame-2 {
  animation-delay: 80ms;
}

.flame-3 {
  animation-delay: 40ms;
}

.flame-4 {
  animation-delay: 120ms;
}

.flame-5 {
  animation-delay: 60ms;
}

@keyframes flicker {
  0% {
    transform: scaleY(0.85) scaleX(1.05);
    opacity: 0.85;
  }

  100% {
    transform: scaleY(1.15) scaleX(0.95);
    opacity: 1;
  }
}

.steam {
  animation: steam-rise 3s ease-in-out infinite;
}

.steam-1 {
  animation-delay: 0ms;
}

.steam-2 {
  animation-delay: 600ms;
}

.steam-3 {
  animation-delay: 1200ms;
}

@keyframes steam-rise {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  30% {
    opacity: 0.7;
  }

  100% {
    opacity: 0;
    transform: translateY(-40px);
  }
}

/* Mobile */
@media (max-width: 760px) {
  .modal {
    gap: 8px;
    padding: 28px 28px 14px;
  }

  .note-body {
    font-size: 20px;
  }
}

/* Short viewports — tighten the cards layout so 3 rows always fit */
@media (max-height: 720px) {
  .scene-cards .stage {
    padding-top: clamp(80px, 14vh, 140px);
    padding-bottom: clamp(24px, 5vh, 60px);
  }

  .card {
    padding: 8px 10px 12px;
  }

  .card-ing {
    height: clamp(60px, 11vh, 100px);
    margin-bottom: 4px;
  }

  .card-ing svg {
    width: clamp(60px, 8vw, 90px);
    height: clamp(60px, 8vw, 90px);
  }

  .card-meta {
    padding-top: 6px;
  }

  .cards-header {
    padding-top: clamp(12px, 2.5vh, 28px);
  }
}

@media (max-height: 560px) {
  .scene-cards .stage {
    padding-top: clamp(60px, 11vh, 100px);
  }

  .cards-title {
    font-size: clamp(20px, 3vw, 32px);
  }

  .cards-sub {
    font-size: 12px;
  }

  .card-meta {
    padding-top: 4px;
  }
}

/* ====================================================== HK TRAM GREEN (Pantone 3415 C) */
/* Sam's favourite colour woven through the site. The tramway theme replaces     */
/* the warm terracotta accent with the deep, vivid green of the Hong Kong trams. */

[data-theme="tramway"] .paper-noise {
  mix-blend-mode: multiply;
  opacity: 0.42;
}

/* Faint green radial wash on the paper — like light through tram windows */
[data-theme="tramway"] .paper-bg {
  background:
    radial-gradient(ellipse at 22% 12%, rgba(255, 255, 255, 0.52), transparent 50%),
    radial-gradient(ellipse at 78% 88%, rgba(0, 60, 25, 0.07), transparent 55%),
    var(--th-paper);
}

/* Note ruled lines: tram-green instead of blue */
[data-theme="tramway"] .note {
  background-image: repeating-linear-gradient(180deg,
      transparent 0, transparent 31px,
      rgba(0, 107, 61, 0.14) 31px,
      rgba(0, 107, 61, 0.14) 32px);
  border-left: 2px solid rgba(0, 107, 61, 0.30);
}

/* Note pin: tram green enamel with brass highlight */
[data-theme="tramway"] .note-pin {
  background: radial-gradient(circle at 35% 30%, #c9863a, #006B3D);
}

/* Card tape: translucent tram-green cellophane */
[data-theme="tramway"] .card-tape {
  background: rgba(0, 107, 61, 0.16);
  border-color: rgba(0, 107, 61, 0.20);
}

/* Primary button: show the actual tram green, not dark ink */
[data-theme="tramway"] .btn-primary {
  background: var(--th-accent);
  box-shadow: 0 8px 24px rgba(0, 107, 61, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
}

[data-theme="tramway"] .btn-primary:hover {
  box-shadow: 0 14px 30px rgba(0, 107, 61, 0.45);
}

/* Progress pill: tram green background */
[data-theme="tramway"] .progress-pill {
  background: var(--th-accent);
}

/* Narrow phones: tighten the cards layout so the fixed-position progress
   pill, plate-up button, and bottom card row don't pile on top of each
   other in a 375x667 viewport. */
@media (max-width: 480px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  #root,
  .app {
    min-height: 100svh;
  }

  .app {
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .intro,
  .finale,
  .scene {
    min-height: 100svh;
    width: 100%;
  }

  .scene {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .scene-cards,
  .scene-dish {
    height: auto;
  }

  .scene-cards .stage {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: none;
    min-height: 100svh;
    align-content: flex-start;
    padding: 96px 12px 110px;
    gap: 12px;
    overflow: visible;
  }

  .scene-dish .stage {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: none;
    min-height: 100svh;
    align-content: flex-start;
    padding: 96px 12px 80px;
    gap: 12px;
    overflow: visible;
  }

  .ing-card,
  .ing-returning {
    width: min(164px, calc((100vw - 48px) / 2));
  }

  .card {
    min-height: 168px;
    padding: 8px 10px 12px;
  }

  .card-ing {
    height: 82px;
    margin-bottom: 4px;
  }

  .card-ing svg {
    width: 78px;
    height: 78px;
  }

  .card-meta {
    padding-top: 7px;
  }

  .card-name {
    font-size: clamp(15px, 4.1vw, 17px);
    line-height: 1.12;
  }

  .card-friend {
    font-size: clamp(16px, 4.3vw, 18px);
    line-height: 1.05;
  }

  .card-tape {
    width: 38px;
    height: 12px;
  }

  .card-tape-1 {
    left: 22px;
  }

  .card-tape-2 {
    right: 22px;
  }

  .cards-header {
    padding: 14px 84px 0 16px;
  }

  .cards-title {
    font-size: clamp(21px, 6vw, 28px);
  }

  .cards-sub {
    font-size: 12px;
  }

  .progress-pill {
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    font-size: 11px;
  }

  .progress-count {
    font-size: 14px;
  }

  .btn-plate {
    bottom: 18px;
    font-size: 15px;
    padding: 12px 22px;
  }

  .intro-title {
    font-size: clamp(64px, 18vw, 96px);
  }

  .intro-eyebrow {
    font-size: 22px;
  }

  .modal-back {
    place-items: start center;
    padding: 14px 10px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .modal {
    max-height: calc(100svh - 28px);
    overflow-y: auto;
    padding: 40px 12px 10px;
    border-radius: 6px;
  }

  .modal-close {
    top: 8px;
    right: 8px;
  }

  .note {
    padding: 28px 18px 22px;
  }

  .note-body {
    font-size: clamp(18px, 5.1vw, 20px);
    line-height: 1.28;
  }

  .note-sign {
    font-size: 23px;
    margin-top: 14px;
  }

  .note-food {
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .note-food-illo {
    width: 58px;
    height: 58px;
  }

  .note-food-illo svg {
    width: 52px;
    height: 52px;
  }

  .note-food-name {
    font-size: clamp(22px, 6vw, 25px);
  }

  .note-food-friend {
    font-size: clamp(20px, 5.4vw, 23px);
  }

  .finale {
    place-items: start center;
    padding: 28px 4vw 34px;
    overflow: visible;
  }

  .finale-dish svg {
    width: min(94vw, 420px);
  }

  .finale-text {
    padding: 0 16px;
    margin-top: -8px;
  }

  .finale-title {
    font-size: clamp(36px, 9vw, 56px);
  }

  .finale-sub {
    font-size: 18px;
    line-height: 1.38;
  }

  .finale-actions {
    gap: 10px;
  }

  .finale-actions .btn-ghost {
    min-width: 132px;
  }
}

@media (max-width: 360px) {
  .scene-cards .stage {
    padding-top: 108px;
  }

  .cards-header {
    padding: 12px 86px 0 14px;
    text-align: left;
  }

  .cards-title {
    font-size: 20px;
    line-height: 1.02;
  }

  .cards-sub {
    font-size: 11px;
    line-height: 1.25;
  }

  .progress-pill {
    gap: 0;
    padding: 6px 10px;
  }

  .progress-label {
    display: none;
  }
}

/* ====================================================== CONFETTI */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 80;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  opacity: 0;
  will-change: transform, opacity;
  animation: confetti-fall 2600ms cubic-bezier(.25, .55, .4, 1) forwards;
}

.confetti-piece.cp-strip {
  border-radius: 1px;
}

.confetti-piece.cp-disc {
  border-radius: 50%;
  width: 9px;
  height: 9px;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -40px, 0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translate3d(var(--cx, 0px), 105vh, 0) rotate(var(--cr, 720deg));
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti {
    display: none;
  }
}
