/* =========================================================
   Kin ♡ Yuri — 3 Months of Us · styles (v1.0)
   ---------------------------------------------------------
   สี & ฟอนต์ทั้งหมดอยู่ใน :root ด้านล่าง — แก้ที่นี่ที่เดียว
   ========================================================= */

:root {
  /* ---- Colors ---- */
  --bg: #fff7f0;            /* พื้นหลังครีม */
  --surface: #ffffff;       /* การ์ด / ปุ่มรอง */
  --ink: #5a4146;           /* ตัวหนังสือหลัก */
  --ink-soft: #8e7176;      /* ตัวหนังสือรอง */
  --pink-50: #fff0f3;
  --pink-100: #ffe1e8;
  --pink-200: #f9c6d2;
  --pink-300: #f2a5b8;
  --rose: #d0617d;          /* ปุ่มหลัก / หัวใจ */
  --rose-dark: #b04864;     /* หัวข้อ / เงาปุ่ม */
  --peach: #ffd9c7;
  --peach-soft: #ffeadf;
  --mint: #d8f1e3;          /* สถานะ "ถูกต้อง" */
  --mint-line: #96d2b0;
  --mint-ink: #3c7f5c;
  --line: #f2ddd8;

  /* envelope */
  --env-back: #f2a9bb;
  --env-front: #fbd2dc;
  --env-flap: #f7bfcc;

  /* ---- Fonts ---- */
  --font-display: "Itim", "Mali", "Noto Sans Thai", "Thonburi", "Leelawadee UI", system-ui, sans-serif;
  --font-body: "Mali", "Noto Sans Thai", "Sukhumvit Set", "Thonburi", "Leelawadee UI", system-ui, sans-serif;

  /* ---- Shape & motion ---- */
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --shadow-sm: 0 2px 8px rgba(176, 72, 100, .10);
  --shadow: 0 10px 28px rgba(176, 72, 100, .14);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);

  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

p, h1, h2 { overflow-wrap: break-word; }

/* Thai text: keep each space-separated phrase together (see phrases() in js/app.js) */
.phrase { display: inline-block; max-width: 100%; }

.app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

/* ---------- Progress ---------- */
.topbar {
  display: flex;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 0 4px;
}
.topbar.is-hidden { visibility: hidden; }

.progress { display: flex; align-items: center; gap: 7px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--pink-200);
  opacity: .55;
  transition: width .35s var(--ease-out), background-color .3s, opacity .3s;
}
.dot.is-done { background: var(--pink-300); opacity: 1; }
.dot.is-current { width: 24px; background: var(--rose); opacity: 1; }

/* ---------- Stage & page transitions ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 0 18px;
}

.page {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.page > :not(.decor) { position: relative; z-index: 1; }

/* page enter / exit animations are driven from js/app.js (see "Motion") */

.page-head { margin-top: 6px; }
.kicker {
  margin: 0;
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.page-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 8.4vw, 34px);
  line-height: 1.2;
  color: var(--rose-dark);
}
.page-title:focus, .welcome-title:focus, .finale-title:focus { outline: none; }

.heart { color: var(--rose); }
.btn--primary .heart { color: inherit; }

.feedback {
  min-height: 1.65em;
  margin: 0;
  font-weight: 600;
  color: var(--ink-soft);
}
.feedback.is-wrong { color: var(--rose-dark); }
.feedback.is-right { color: var(--mint-ink); }

.hint-text {
  margin: -6px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
  background: var(--peach-soft);
  border-radius: 999px;
  padding: 4px 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 12px 22px;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .15s var(--ease-out), background-color .2s, box-shadow .15s, color .2s;
}
.btn:focus-visible,
.key:focus-visible,
.option:focus-visible,
.tile:focus-visible,
.envelope:focus-visible { outline: 3px solid var(--pink-300); outline-offset: 3px; }

.btn--primary {
  background: var(--rose);
  color: #fff;
  box-shadow: 0 4px 0 var(--rose-dark), var(--shadow-sm);
}
.btn--primary:active { transform: scale(.96); box-shadow: 0 2px 0 var(--rose-dark); }
.btn--primary.is-locked {
  background: var(--pink-100);
  color: var(--rose-dark);
  box-shadow: 0 4px 0 var(--pink-200);
}
.btn--ghost {
  background: var(--surface);
  color: var(--rose-dark);
  border-color: var(--pink-200);
}
.btn--ghost:active { transform: scale(.96); background: var(--pink-50); }
.btn--ghost[aria-pressed="true"] { background: var(--pink-100); border-color: var(--pink-300); }
.btn--soft {
  background: var(--pink-100);
  color: var(--rose-dark);
  border-color: var(--pink-200);
  box-shadow: 0 4px 0 var(--pink-200);
}
.btn--soft:active { transform: scale(.96); box-shadow: 0 2px 0 var(--pink-200); }
.btn--soft[disabled] { cursor: progress; opacity: .85; }
.btn--big { min-height: 60px; padding: 14px 44px; font-size: 20px; }
.btn--wide { width: 100%; max-width: 320px; }
.btn--small { min-height: 44px; padding: 8px 18px; font-size: 15px; }

@media (hover: hover) {
  .btn--primary:not(.is-locked):hover { background: #c55672; }
  .btn--ghost:hover { background: var(--pink-50); }
  .btn--soft:not([disabled]):hover { background: var(--pink-200); }
}

.spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.icon { display: inline-flex; width: 1em; height: 1em; }
.icon svg { width: 100%; height: 100%; }

.continue { margin-top: 4px; }

/* ---------- Bottom nav ---------- */
.navbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
  padding: 14px 0 max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, rgba(255, 247, 240, 0));
}
.navbar .btn { width: 100%; padding-left: 12px; padding-right: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .25s, transform .25s var(--ease-out);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Decorations ---------- */
.decor { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.decor__item {
  position: absolute;
  font-size: var(--s, 20px);
  width: var(--s, 20px);
  height: var(--s, 20px);
  line-height: 1;
  color: var(--pink-300);
  opacity: .45;
  transform: rotate(var(--r, 0deg));
}

/* ---------- Mascots ---------- */
/* Pixel art on a 32×32 grid: keep sizes at whole multiples of 32px (96 / 128) so every art pixel is equal */
.mascot {
  display: block;
  width: 96px;
  height: auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.bob   { animation: bob 3.2s ease-in-out infinite; }
.bob-2 { animation: bob 3.2s ease-in-out -1.6s infinite; }

/* ---------- 1 · Welcome ---------- */
.page--welcome { justify-content: center; gap: 10px; padding-bottom: 24px; }
.welcome-hero {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}
.welcome-hero .mascot { width: 96px; }
.welcome-hero .envelope { margin-bottom: 18px; }
.welcome-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(46px, 14vw, 60px);
  line-height: 1.05;
  color: var(--rose-dark);
}
.welcome-subtitle {
  margin: 0;
  font-size: 21px;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.welcome-note {
  margin: 6px 0 0;
  padding: 3px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1.5px dashed var(--pink-200);
  border-radius: 999px;
}
.welcome-actions {
  width: 100%;
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.resume-card {
  width: 100%;
  max-width: 340px;
  padding: 20px 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.resume-title { margin: 0; font-family: var(--font-display); font-size: 24px; color: var(--rose-dark); }
.resume-text { margin: 2px 0 16px; color: var(--ink-soft); }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn-row .btn { flex: 1 1 120px; }

/* ---------- Envelope (shared) ---------- */
.envelope {
  position: relative;
  display: block;
  width: min(78vw, 290px);
  aspect-ratio: 7 / 5;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
}
button.envelope { cursor: pointer; touch-action: manipulation; transition: transform .3s var(--ease-out); }
button.envelope.is-open { transform: translateY(-10px); }
.envelope > span { position: absolute; display: block; }
.envelope__back {
  inset: 0;
  background: var(--env-back);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.envelope__paper {
  left: 7%;
  right: 7%;
  top: 7%;
  bottom: 8%;
  z-index: 1;
  border-radius: 8px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 14px, var(--pink-100) 14px 16px) 14% 26% / 72% 46% no-repeat,
    #fffdfb;
  transition: transform .4s var(--ease-out) .3s;
}
.envelope__front {
  inset: 0;
  z-index: 2;
  background: var(--env-front);
  border-radius: 14px;
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.envelope__flap {
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  z-index: 3;
  background: var(--env-flap);
  border-radius: 14px 14px 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .4s var(--ease-out) .1s, z-index 0s linear .3s;
}
.envelope__seal {
  left: 50%;
  top: 58%;
  z-index: 4;
  width: 22%;
  aspect-ratio: 1;
  display: grid !important;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  font-size: clamp(12px, 5vw, 22px);
  line-height: 1;
  box-shadow: 0 2px 0 var(--rose-dark);
  transition: opacity .2s, transform .3s;
}
.envelope.is-open .envelope__flap { transform: rotateX(180deg); z-index: 0; }
.envelope.is-open .envelope__seal { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
.envelope.is-open .envelope__paper { transform: translateY(-48%); }

.envelope--mini { width: 92px; }
.envelope--mini .envelope__back,
.envelope--mini .envelope__front { border-radius: 8px; }
.envelope--mini .envelope__flap { border-radius: 8px 8px 0 0; }
.envelope--mini .envelope__seal { font-size: 11px; box-shadow: none; }
.envelope--float { animation: floaty 3.6s ease-in-out infinite; }

/* ---------- 2 · Password ---------- */
.lock { width: 66px; height: 66px; }
.lock svg { width: 100%; height: 100%; overflow: visible; }
.lock-shackle {
  fill: none;
  stroke: var(--rose-dark);
  stroke-width: 6;
  stroke-linecap: round;
  transform-origin: 44px 30px;
  transition: transform .55s var(--ease-bounce);
}
.lock-body { fill: var(--pink-300); transition: fill .3s; }
.is-unlocked .lock { animation: pop .55s var(--ease-bounce); }
.is-unlocked .lock-shackle { transform: translateY(-7px) rotate(26deg); }
.is-unlocked .lock-body { fill: var(--mint-line); }

.question {
  margin: 0;
  max-width: 20em;
  font-size: 19px;
  font-weight: 600;
}

.slots { display: flex; justify-content: center; gap: 12px; }
.slot {
  display: grid;
  place-items: center;
  width: 56px;
  height: 64px;
  border: 2px solid var(--pink-200);
  border-radius: 16px;
  background: var(--surface);
  font-size: 28px;
  font-weight: 600;
  color: var(--rose-dark);
  transition: background-color .2s, border-color .2s, color .2s;
}
.slot.is-filled { border-color: var(--rose); background: var(--pink-50); animation: pop .22s var(--ease-out); }
.is-unlocked .slot { border-color: var(--mint-line); background: var(--mint); color: var(--mint-ink); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 300px;
}
.key {
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--line);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .1s, box-shadow .1s, background-color .15s;
}
.key:active { transform: scale(.96); box-shadow: 0 1px 0 var(--line); background: var(--pink-50); }
.key--fn { display: grid; place-items: center; background: var(--peach-soft); color: var(--ink-soft); font-size: 18px; }
.key--fn .icon { width: 26px; height: 26px; }
.is-unlocked .keypad { display: none; }

/* ---------- 3 · Gallery & photos ---------- */
.photos { display: grid; gap: 14px; width: 100%; }
.photos--1 { grid-template-columns: 1fr; max-width: 300px; }
.photos--2 { grid-template-columns: 1fr 1fr; }
.photos--3 { grid-template-columns: 1fr 1fr; }
.photos--3 .polaroid:first-child { grid-column: 1 / -1; justify-self: center; width: 74%; }

.polaroid {
  margin: 0;
  padding: 8px 8px 10px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.polaroid:nth-child(odd)  { rotate: -1.6deg; }
.polaroid:nth-child(even) { rotate: 1.6deg; }
.polaroid__frame {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 10px;
  background: var(--pink-50);
}
.polaroid__frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.polaroid figcaption { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.missing {
  display: grid;
  place-content: center;
  height: 100%;
  padding: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  word-break: break-all;
}

.message-card {
  position: relative;
  width: 100%;
  margin: 8px 0 0;
  padding: 20px 18px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  white-space: pre-line;
}
.message-card::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 72px;
  height: 20px;
  margin-left: -36px;
  border-radius: 4px;
  background: var(--pink-200);
  opacity: .75;
  rotate: -3deg;
}

/* ---------- 4 · Photo puzzle ---------- */
.instruction { margin: -4px 0 0; color: var(--ink-soft); white-space: pre-line; }

.puzzle-wrap { position: relative; width: min(100%, 340px); }
.puzzle {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), 1fr);
  grid-template-rows: repeat(var(--n, 3), 1fr);
  gap: 5px;
  width: 100%;
  aspect-ratio: 1;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: gap .5s var(--ease-out);
}
.tile {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background-color: var(--pink-50);
  background-repeat: no-repeat;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .18s var(--ease-out), box-shadow .18s, border-radius .5s;
}
.tile.is-selected {
  z-index: 2;
  transform: scale(.88);
  box-shadow: 0 0 0 3px var(--rose), 0 6px 14px rgba(90, 65, 70, .2);
}
.tile.swap { animation: swapIn .3s var(--ease-bounce); }
.show-hint .tile.is-home::after {
  content: "♥";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 13px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 3px var(--rose), 0 0 1px var(--rose);
}
.puzzle.is-solved { gap: 0; animation: glow 1.4s ease-out; }
.puzzle.is-solved .tile { border-radius: 0; cursor: default; }
.puzzle.is-solved .tile::after { display: none; }

.puzzle-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- 5 · Quiz ---------- */
.quiz-question {
  width: 100%;
  margin: 4px 0 0;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 19px;
  font-weight: 600;
  white-space: pre-line;
}
.options { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--line);
  font-size: 18px;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s, background-color .2s, border-color .2s, opacity .3s, box-shadow .12s;
}
.option:active { transform: scale(.97); box-shadow: 0 1px 0 var(--line); }
.option__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--peach-soft);
  color: var(--rose-dark);
  font-weight: 600;
  font-size: 16px;
}
.option.is-wrong { border-color: var(--pink-300); background: var(--pink-50); }
.option.is-correct {
  border-color: var(--mint-line);
  background: var(--mint);
  box-shadow: 0 3px 0 var(--mint-line);
  color: var(--mint-ink);
  animation: pop .45s var(--ease-bounce);
}
.option.is-correct .option__badge { background: #fff; color: var(--mint-ink); }
.option.is-dim { opacity: .4; }
.is-solved .option { cursor: default; }

/* ---------- 6 · Letter ---------- */
.letter-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding-top: 60px;
}
.tap-hint { margin: 0; color: var(--ink-soft); animation: pulse 1.8s ease-in-out infinite; }

.letter-paper {
  width: 100%;
  padding: 28px 22px 26px;
  background: #fffdfb;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 6px solid var(--pink-200);
  text-align: left;
  font-size: 17px;
  line-height: 1.9;
}
.letter-paper:focus { outline: none; }
.letter-paper p { margin: 0 0 1em; white-space: pre-line; }
.letter-greeting { font-family: var(--font-display); font-size: 23px; color: var(--rose-dark); }
.letter-closing { margin-top: 1.4em !important; }
.letter-signature {
  margin-bottom: 0 !important;
  text-align: right;
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--rose-dark);
}

/* ---------- 7 · Finale ---------- */
.page--finale { gap: 14px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.finale-title {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 11.5vw, 48px);
  line-height: 1.15;
  color: var(--rose-dark);
}
.mascot-pair { display: flex; align-items: flex-end; justify-content: center; }
.mascot-pair .mascot { width: 96px; }
/* fixed 28×24 box; the heart inside may briefly grow during its pixel "pop" without moving the mascots */
.pair-heart-box {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  margin: 0 6px 40px;
}
.pair-heart {
  display: block;
  flex: none;
  width: 28px;
  height: 24px;
  max-width: none; /* lets the pop briefly overshoot its 28px box */
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
@media (min-width: 420px) {
  .welcome-hero .mascot, .mascot-pair .mascot { width: 128px; }
}
.day-count { margin: -4px 0 0; color: var(--ink-soft); }
.day-count strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  color: var(--rose);
}
/* Page 7: large landscape photos, one per row, ~95% of the content width */
.strip { display: flex; flex-direction: column; align-items: stretch; gap: 18px; width: 100%; }
.strip .polaroid { width: 100%; padding: 8px; border-radius: 18px; }
.strip .polaroid__frame { aspect-ratio: 16 / 9; border-radius: 12px; }
.strip .polaroid:nth-child(odd)  { rotate: -0.8deg; }
.strip .polaroid:nth-child(even) { rotate: 0.8deg; }
.finale-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
}

/* ---------- Save card preview (js/memory-card.js) ---------- */
.card-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(90, 65, 70, .45);
  animation: fadeIn .25s ease-out both;
}
.card-modal__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 16px 16px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
  animation: popIn .35s var(--ease-bounce) both;
}
.card-modal__title { margin: 0; font-family: var(--font-display); font-size: 22px; color: var(--rose-dark); }
.card-modal__img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 56vh;
  max-height: 56dvh;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  -webkit-touch-callout: default;
}
.card-modal__hint { margin: 0; font-size: 15px; color: var(--ink-soft); }
.card-modal .btn-row { width: 100%; }

/* ---------- Fallback / misc ---------- */
.noscript { padding: 40px 20px; text-align: center; }

/* ---------- Effects layer ---------- */
.fx { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.fx-heart {
  position: absolute;
  font-size: 18px;
  line-height: 1;
  animation: burst .95s var(--ease-out) forwards;
}
.fx-confetti {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation: fall var(--dur, 3s) linear var(--delay, 0s) both;
}
.fx-pixel {
  position: absolute;
  width: 14px;
  height: 12px;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
.fx-float {
  position: absolute;
  bottom: -40px;
  font-size: var(--size, 18px);
  line-height: 1;
  animation: rise var(--dur, 7s) linear forwards;
}

/* ---------- Keyframes ---------- */
@keyframes bob        { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes floaty     { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes pop        { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes popIn      { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes pulse      { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes swapIn { from { transform: scale(.82); } to { transform: scale(1); } }
@keyframes glow {
  0%   { box-shadow: 0 0 0 0 rgba(208, 97, 125, .55), var(--shadow); }
  100% { box-shadow: 0 0 0 22px rgba(208, 97, 125, 0), var(--shadow); }
}
@keyframes burst {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.4); }
  to   { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); }
}
@keyframes fall { to { transform: translate(var(--drift, 0), 110vh) rotate(var(--rot, 360deg)); } }
@keyframes rise {
  0%   { opacity: 0; transform: translate(0, 0); }
  12%  { opacity: .85; }
  100% { opacity: 0; transform: translate(var(--drift, 0), -110vh); }
}

.shake  { animation: shake .45s ease-in-out; }
.wiggle { animation: wiggle .3s ease-in-out 2; }

/* ---------- Short screens (e.g. iPhone SE) ---------- */
@media (max-height: 700px) {
  .page { gap: 12px; }
  .lock { width: 52px; height: 52px; }
  .slot { height: 56px; }
  .key { min-height: 52px; }
  .welcome-title { font-size: clamp(42px, 13vw, 52px); }
}
@media (max-height: 600px) {
  .page { gap: 10px; }
  .lock { display: none; }
  .slot { height: 50px; }
  .keypad { gap: 8px; }
  .key { min-height: 46px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
}
