:root {
  --washi: #f6efe4;
  --washi-deep: #ecdfcc;
  --paper: #fffdf8;
  --ink: #2b2a33;
  --ink-soft: #6b6672;
  --red: #c8372d;
  --red-deep: #a3271f;
  --sakura: #f4b8c5;
  --sakura-deep: #e58aa0;
  --gold: #b8935a;
  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', Georgia, serif;
  --round: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, #fbf6ee 0%, transparent 60%),
    linear-gradient(180deg, var(--washi) 0%, #f3e4dc 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- décor ---------- */

.sun {
  position: fixed;
  top: -14vmin;
  right: -14vmin;
  width: 62vmin;
  height: 62vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 55, 45, 0.9) 0%, rgba(200, 55, 45, 0.78) 62%, rgba(200, 55, 45, 0) 64%);
  opacity: 0.16;
  pointer-events: none;
}

.lanterns {
  position: fixed;
  z-index: 15;
  top: 0;
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  gap: clamp(6px, 2vw, 16px);
  pointer-events: none;
}

/* le balancement est piloté par app.js (pendule que l'on peut pousser) */
.lantern {
  width: clamp(40px, 11vw, 62px);
  aspect-ratio: 60 / 190;
  font-family: var(--serif);
  transform-origin: 50% 0;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 0 14px rgba(255, 150, 90, 0.55)) drop-shadow(0 8px 10px rgba(90, 50, 30, 0.18));
  will-change: transform;
}

.lantern.grabbed { cursor: grabbing; }

.lantern svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.lantern-b {
  width: clamp(32px, 8.5vw, 48px);
  margin-top: -34px;
}

@media (max-width: 600px) {
  /* cordes plus courtes sur téléphone pour ne pas masquer le texte */
  .lanterns { top: -14px; }
  .lantern-b { margin-top: -8px; }
}

/* ---------- les chats ---------- */

.cats {
  position: fixed;
  z-index: 15;
  left: 0;
  right: 0;
  bottom: max(2px, env(safe-area-inset-bottom));
  height: 0;
  pointer-events: none;
}

.cat {
  --fur: #fffaf2;
  --patch-a: #e8a25a;
  --patch-b: #4a3f42;
  --line: #5a4a45;
  --eye: #3a3338;
  --ear: #f4b8c5;
  position: absolute;
  left: 0;
  bottom: 0;
  width: clamp(58px, 16vw, 80px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  will-change: transform;
}

.cat-ginger { --fur: #f3b877; --patch-a: #dc8f47; --patch-b: #dc8f47; --line: #7a4a2a; }
.cat-black { --fur: #3f373b; --patch-a: #3f373b; --patch-b: #3f373b; --line: #241f22; --eye: #ffe08a; }

.cat-flip { display: block; }
.cat.left .cat-flip { transform: scaleX(-1); }

.cat svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.cat .fur { fill: var(--fur); stroke: var(--line); stroke-width: 1.4; stroke-linejoin: round; }
.cat .patch-a { fill: var(--patch-a); }
.cat .patch-b { fill: var(--patch-b); }
.cat .ear-in { fill: var(--ear); }
.cat .eye { fill: var(--eye); }
.cat .happy { fill: none; stroke: var(--eye); stroke-width: 1.6; stroke-linecap: round; display: none; }
.cat .mouth { fill: none; stroke: var(--line); stroke-width: 1; stroke-linecap: round; }
.cat .cat-tail { fill: none; stroke: var(--line); stroke-width: 7.8; stroke-linecap: round; }
.cat .cat-tail-in { fill: none; stroke: var(--fur); stroke-width: 5; stroke-linecap: round; }

.cat .leg, .cat .tail { transform-box: view-box; }
.cat .leg-1 { transform-origin: 23px 40px; }
.cat .leg-2 { transform-origin: 29px 40px; }
.cat .leg-3 { transform-origin: 45px 40px; }
.cat .leg-4 { transform-origin: 51px 40px; }
.cat .tail { transform-origin: 17px 34px; animation: cat-tail 2.4s ease-in-out infinite; }

.cat.walking .leg-1, .cat.walking .leg-4 { animation: cat-step 0.55s ease-in-out infinite; }
.cat.walking .leg-2, .cat.walking .leg-3 { animation: cat-step 0.55s ease-in-out infinite reverse; }
.cat.walking .cat-body { animation: cat-bob 0.275s ease-in-out infinite alternate; }

.cat.paw .leg-4 { animation: cat-paw 0.36s ease-in-out infinite alternate; }
.cat.hop .cat-body { animation: cat-hop 0.5s ease-out 2; }
.cat.paw .eye, .cat.hop .eye { display: none; }
.cat.paw .happy, .cat.hop .happy { display: block; }
.cat.stopped .tail, .cat.paw .tail, .cat.hop .tail { animation-duration: 0.7s; }

.cat-bubble {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 2px;
  padding: 5px 11px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 4px 10px -4px rgba(90, 50, 30, 0.45);
  font-family: var(--round);
  font-size: 14px;
  font-weight: 700;
  color: var(--red-deep);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%) scale(0.6);
  transform-origin: 50% 100%;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  pointer-events: none;
}

.cat-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

@keyframes cat-step {
  0%, 100% { transform: rotate(-24deg); }
  50% { transform: rotate(24deg); }
}

@keyframes cat-bob {
  from { transform: translateY(0); }
  to { transform: translateY(-1.5px); }
}

@keyframes cat-tail {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(14deg); }
}

@keyframes cat-paw {
  from { transform: translate(3px, 0) rotate(-55deg); }
  to { transform: translate(3px, 0) rotate(-108deg); }
}

@keyframes cat-hop {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-14px); }
}

@media (prefers-reduced-motion: reduce) {
  .cat .tail, .cat.walking .leg, .cat.walking .cat-body { animation: none; }
}

.side-kanji {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: 76px;
  writing-mode: vertical-rl;
  font-size: 15px;
  letter-spacing: 0.5em;
  color: var(--red);
  opacity: 0.45;
  pointer-events: none;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* ---------- scènes ---------- */

main {
  position: fixed;
  inset: 0;
}

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 18px calc(64px + env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.7s ease 0.15s, visibility 0s;
}

.scene-inner {
  margin: auto;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------- enveloppe ---------- */

.eyebrow {
  margin: 0 0 34px;
  font-size: 15px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--red);
}

.envelope {
  position: relative;
  width: min(84vw, 380px);
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 18px 22px rgba(90, 50, 30, 0.22));
  animation: float 4.5s ease-in-out infinite;
}

.envelope > span {
  position: absolute;
  display: block;
}

.env-back {
  inset: 0;
  z-index: 1;
  border-radius: 8px;
  background: #e2cfb6;
}

.env-paper {
  z-index: 2;
  left: 6%;
  right: 6%;
  top: 8%;
  height: 84%;
  border-radius: 4px;
  background:
    repeating-linear-gradient(180deg, transparent 0 17px, rgba(200, 55, 45, 0.12) 17px 18px) 0 22px / 100% 100% no-repeat,
    var(--paper);
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.45s;
}

.env-front {
  inset: 0;
  z-index: 3;
  border-radius: 8px;
  background:
    linear-gradient(to top right, #f5e9d8 49.6%, transparent 50%) left / 50.2% 100% no-repeat,
    linear-gradient(to top left, #f5e9d8 49.6%, transparent 50%) right / 50.2% 100% no-repeat;
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
}

.env-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #faf1e3;
  clip-path: polygon(0 100%, 50% 46%, 100% 100%);
}

.env-flap {
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(180deg, #ecdcc6, #e6d3ba);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 8px 8px 0 0;
  transform-origin: top;
  transition: transform 0.6s ease, z-index 0s linear 0.3s;
}

.env-seal {
  z-index: 5;
  left: 50%;
  top: 59%;
  width: 21%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid !important;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e0584c, var(--red) 55%, var(--red-deep));
  color: #ffe9df;
  font-size: clamp(22px, 7vw, 32px);
  font-weight: 600;
  box-shadow: 0 3px 6px rgba(120, 30, 20, 0.35), inset 0 0 0 3px rgba(255, 255, 255, 0.14);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.env-address {
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 9%;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  transition: opacity 0.3s ease;
}

.envelope.open {
  animation-play-state: paused;
  cursor: default;
}

.envelope.open .env-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope.open .env-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

.envelope.open .env-paper {
  transform: translateY(-52%);
}

.envelope.open .env-address {
  opacity: 0;
}

.hint {
  margin: 38px 0 0;
  font-family: var(--round);
  font-size: 15px;
  color: var(--ink-soft);
  animation: breathe 2.4s ease-in-out infinite;
}

/* ---------- papier ---------- */

.paper {
  position: relative;
  width: 100%;
  padding: 30px 26px 26px;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 22px 40px -18px rgba(90, 50, 30, 0.35), 0 2px 6px rgba(90, 50, 30, 0.08);
  text-align: left;
  font-size: 18px;
  line-height: 1.75;
}

.paper::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(184, 147, 90, 0.35);
  border-radius: 3px;
  pointer-events: none;
}

.paper.center { text-align: center; }

.paper p { margin: 0 0 14px; }

.paper-kicker {
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--red);
  text-align: center;
  margin-bottom: 18px !important;
}

h1, h2 {
  margin: 0 0 14px;
  font-weight: 800;
  line-height: 1.35;
  text-wrap: balance;
}

h1 { font-size: 30px; }
h2 { font-size: 24px; }

strong {
  font-weight: 800;
  background: linear-gradient(transparent 62%, rgba(244, 184, 197, 0.75) 62%);
}

.muted {
  color: var(--ink-soft);
  font-family: var(--round);
  font-size: 15px;
}

.rdv {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 6px;
  background: #fbf3ea;
  display: grid;
  gap: 8px;
}

.rdv div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rdv dt {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff3ec;
  font-size: 15px;
}

.rdv dd {
  margin: 0;
  font-weight: 600;
}

.signature {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px !important;
  font-style: italic;
}

.hanko {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  border-radius: 5px;
  color: var(--red);
  font-style: normal;
  font-size: 20px;
  font-weight: 600;
  transform: rotate(-6deg);
  opacity: 0.9;
}

/* ---------- boutons ---------- */

.plea {
  min-height: 1.75em;
  margin: 18px 0 4px !important;
  text-align: center;
  font-family: var(--round);
  font-size: 16px;
  line-height: 1.5;
  color: var(--red-deep);
}

.plea.pop { animation: pop 0.35s ease; }

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  min-height: 64px;
}

.btn {
  font-family: var(--round);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  padding: 14px 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1), background 0.2s, left 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2), top 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transform: scale(var(--scale, 1));
}

.btn:active { transform: scale(calc(var(--scale, 1) * 0.95)); }

.btn-primary {
  background: var(--red);
  color: #fff6f0;
  box-shadow: 0 8px 18px -8px rgba(200, 55, 45, 0.8);
}

.btn-primary:hover { background: var(--red-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: #d9cdbd;
}

.btn.fleeing {
  position: fixed;
  z-index: 30;
  margin: 0;
  background: var(--paper);
}

.btn:focus-visible, .link:focus-visible, .card:focus-visible, .envelope:focus-visible {
  outline: 3px solid var(--sakura-deep);
  outline-offset: 3px;
}

.link {
  margin-top: 16px;
  padding: 8px;
  border: 0;
  background: none;
  font-family: var(--round);
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* ---------- la joie ---------- */

.joy-heart {
  width: 120px;
  margin: 0 auto 6px;
}

.joy-heart svg {
  display: block;
  width: 100%;
  fill: var(--red);
  filter: drop-shadow(0 10px 14px rgba(200, 55, 45, 0.35));
  transform-origin: 50% 60%;
}

.scene.active .joy-heart svg { animation: heartbeat 1.1s ease-in-out 0.5s infinite, drop-in 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) both; }

.joy-kanji {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--red);
}

.joy h2 {
  margin: 6px 0 8px;
  font-size: 38px;
}

.joy-sub {
  margin: 0;
  font-family: var(--round);
  font-size: 17px;
  color: var(--ink-soft);
}

.ask {
  margin-top: 34px;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.ask.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.ask p {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

/* ---------- les cartes ---------- */

.cards {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  perspective: 900px;
}

.card-face {
  grid-area: 1 / 1;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.7s cubic-bezier(0.3, 1.2, 0.5, 1);
}

.card-back {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.14) 0 9px, transparent 10px),
    radial-gradient(circle at 78% 70%, rgba(255, 255, 255, 0.12) 0 12px, transparent 13px),
    radial-gradient(circle at 60% 20%, rgba(255, 255, 255, 0.1) 0 6px, transparent 7px),
    var(--red);
  color: #fff3ec;
  box-shadow: 0 10px 18px -10px rgba(200, 55, 45, 0.9);
}

.card-num {
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
}

.card-front {
  background: #fbf3ea;
  border: 1px solid rgba(184, 147, 90, 0.4);
  transform: rotateX(-180deg);
}

.card.flipped { cursor: default; }
.card.flipped .card-back { transform: rotateX(180deg); }
.card.flipped .card-front { transform: rotateX(0deg); }

.card-title {
  font-size: 20px;
  font-weight: 800;
}

.card-text {
  font-family: var(--round);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.finale {
  display: none;
  margin-top: 24px;
}

.finale.visible {
  display: block;
  animation: rise 0.7s ease both;
}

.finale-line {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px !important;
}

/* ---------- omikuji ---------- */

.omikuji {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.omikuji-btn {
  font-size: 15px;
  padding: 11px 20px;
  background: transparent;
  color: var(--red-deep);
  border-color: var(--sakura);
}

.omikuji-btn.shaking { animation: shake 0.6s ease; }

.omikuji-slip {
  width: 100%;
  padding: 16px 16px 14px;
  border-radius: 4px;
  background: #fff7f4;
  border-top: 4px solid var(--red);
  border-bottom: 4px solid var(--red);
  animation: unroll 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  transform-origin: top;
}

.omikuji-slip b {
  display: block;
  font-size: 30px;
  font-weight: 800;
  color: var(--red);
  line-height: 1.2;
}

.omikuji-slip small {
  display: block;
  margin-bottom: 8px;
  font-family: var(--round);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.omikuji-slip span {
  font-size: 17px;
  line-height: 1.6;
}

/* ---------- animations ---------- */

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.16); }
  28% { transform: scale(1); }
  42% { transform: scale(1.1); }
  56% { transform: scale(1); }
}

@keyframes drop-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-7deg); }
  40% { transform: rotate(6deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(3deg); }
}

@keyframes unroll {
  from { opacity: 0; transform: scaleY(0.2); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 360px) {
  .paper { padding: 26px 20px 22px; font-size: 17px; }
  .btn { padding: 13px 18px; font-size: 16px; }
  .actions { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .envelope, .hint, .scene.active .joy-heart svg { animation: none; }
  .card-face, .env-paper, .env-flap { transition-duration: 0.01s; }
}
