/* ---------- Czcionki (lokalnie, z polskimi znakami) ---------- */
@font-face {
  font-family: 'Dancing Script'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/dancing-script-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Dancing Script'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/dancing-script-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/nunito-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/nunito-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 800; font-display: swap;
  src: url(fonts/nunito-latin-ext-800-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 800; font-display: swap;
  src: url(fonts/nunito-latin-800-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Podstawa ---------- */
:root {
  --bg1: #1a0612;
  --bg2: #3a0d26;
  --pink: #ff5c9a;
  --pink-soft: #ffb3cf;
  --rose: #ff2e6d;
  --cream: #fff4f8;
  --glow: 0 0 24px rgba(255, 70, 140, .55);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--cream);
  background: var(--bg1);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
.script { font-family: 'Dancing Script', cursive; font-weight: 700; }

.sky {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(60% 45% at 50% 105%, rgba(255, 46, 109, .35), transparent 70%),
    radial-gradient(50% 40% at 15% 10%, rgba(140, 30, 90, .45), transparent 70%),
    radial-gradient(45% 40% at 90% 20%, rgba(90, 20, 80, .5), transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}
.sky::after { /* ziarno jak na zdjęciu z kliszy */
  content: ""; position: absolute; inset: 0; opacity: .08; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Pływające serduszka w tle */
.floating { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.floating span {
  position: absolute; bottom: -10vh;
  color: var(--pink);
  opacity: 0;
  animation: floatUp linear infinite;
  text-shadow: 0 0 12px rgba(255, 92, 154, .8);
}
@keyframes floatUp {
  0% { transform: translate(0, 0) rotate(0deg) scale(.6); opacity: 0; }
  10% { opacity: var(--o, .6); }
  50% { transform: translate(var(--sway, 30px), -55vh) rotate(20deg) scale(1); }
  90% { opacity: var(--o, .6); }
  100% { transform: translate(0, -120vh) rotate(-10deg) scale(.8); opacity: 0; }
}

main { position: relative; z-index: 2; height: 100%; }

/* ---------- Ekrany ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden;
  transform: scale(.96);
  transition: opacity .7s ease, transform .7s ease, visibility 0s linear .7s;
}
.screen.active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .7s ease .15s, transform .7s ease .15s, visibility 0s;
}

.card {
  width: min(520px, 100%);
  padding: clamp(24px, 6vw, 44px) clamp(20px, 5vw, 40px);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .04));
  border: 1px solid rgba(255, 179, 207, .28);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
}

/* ---------- Powitanie ---------- */
.big-heart { width: 92px; margin: 0 auto 10px; animation: beat 1.4s ease-in-out infinite; }
.big-heart svg { width: 100%; display: block; fill: var(--rose); filter: drop-shadow(0 0 18px rgba(255, 46, 109, .9)); }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(.98); }
  45% { transform: scale(1.12); }
  60% { transform: scale(1); }
}
.welcome h1 { margin: 0 0 28px; font-size: clamp(30px, 8.5vw, 48px); line-height: 1.15; }
.welcome .line { display: block; opacity: 0; transform: translateY(14px); }
.screen.active .welcome .line { animation: rise .9s cubic-bezier(.2, .8, .2, 1) forwards; }
.screen.active .welcome .line:nth-child(2) { animation-delay: .45s; }
.screen.active .welcome .line:nth-child(3) { animation-delay: .9s; }
.welcome .name {
  font-size: 1.55em;
  background: linear-gradient(90deg, #ffd1e3, #ff5c9a, #ffd1e3);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 92, 154, .6));
}
.screen.active .welcome .name { animation: rise .9s cubic-bezier(.2, .8, .2, 1) .9s forwards, shine 3s linear 1.8s infinite; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes shine { to { background-position: -200% 0; } }
.welcome .btn { opacity: 0; }
.screen.active .welcome .btn { animation: rise .8s ease 1.5s forwards, pulse 1.8s ease-in-out 2.3s infinite; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 30px;
  border: 0; border-radius: 999px;
  font-weight: 800; font-size: 18px; letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(135deg, #ff7aae, #ff2e6d);
  box-shadow: 0 10px 28px rgba(255, 46, 109, .45), inset 0 1px 0 rgba(255, 255, 255, .35);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 34px rgba(255, 46, 109, .6); }
.btn:active { transform: scale(.97); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 28px rgba(255, 46, 109, .45), 0 0 0 0 rgba(255, 92, 154, .55); }
  50% { box-shadow: 0 10px 28px rgba(255, 46, 109, .45), 0 0 0 14px rgba(255, 92, 154, 0); }
}
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---------- Quiz ---------- */
.progress { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; }
.progress span { width: 34px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .18); transition: background .4s; }
.progress span.done { background: var(--pink); box-shadow: var(--glow); }
.q-num { margin: 0 0 6px; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--pink-soft); font-weight: 800; }
.q-title { margin: 0 0 24px; font-size: clamp(28px, 7.5vw, 40px); line-height: 1.15; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option {
  position: relative;
  padding: 16px 10px;
  border-radius: 18px;
  border: 1.5px solid rgba(255, 179, 207, .4);
  background: rgba(255, 255, 255, .07);
  font-size: 20px; font-weight: 800;
  cursor: pointer;
  opacity: 0; transform: translateY(16px) scale(.95);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) forwards;
  transition: background .2s, border-color .2s, transform .2s;
}
.option:last-child:nth-child(odd) { grid-column: 1 / -1; }
.option:hover:not(:disabled) { background: rgba(255, 92, 154, .22); border-color: var(--pink); transform: translateY(-2px); }
.option:disabled { cursor: default; }
.option.wrong { opacity: .45 !important; text-decoration: line-through; border-color: rgba(255, 255, 255, .15); animation: none; transform: none; }
.option.right { background: linear-gradient(135deg, #ff7aae, #ff2e6d); border-color: transparent; box-shadow: var(--glow); }
.card.shake { animation: shake .5s ease; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(9px) rotate(1deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- Komunikat ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 46, 109, .55), rgba(26, 6, 18, .96) 70%);
  animation: fadeIn .35s ease;
}
.overlay[hidden] { display: none; }
.overlay.bad { background: radial-gradient(circle at 50% 50%, rgba(120, 10, 40, .65), rgba(10, 2, 8, .97) 70%); }
.overlay-inner { text-align: center; max-width: 640px; animation: pop .6s cubic-bezier(.2, 1.4, .4, 1); }
.overlay.bad .overlay-inner { animation: pop .5s ease, shake .5s ease .5s; }
.overlay-icon { font-size: 76px; line-height: 1; margin-bottom: 14px; animation: beat 1.3s ease-in-out infinite; }
.overlay-text { margin: 0 0 30px; font-size: clamp(38px, 10vw, 72px); line-height: 1.12; text-shadow: 0 0 30px rgba(255, 92, 154, .8); }
.overlay.bad .overlay-text { text-shadow: 0 0 24px rgba(255, 40, 80, .7); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }

/* Wybuch serduszek */
.burst {
  position: fixed; z-index: 60; pointer-events: none;
  color: var(--pink);
  text-shadow: 0 0 10px rgba(255, 92, 154, .9);
  animation: burst var(--d, 1.4s) cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.2) rotate(var(--r)); opacity: 0; }
}

/* ---------- Koperta ---------- */
.letter-wrap { text-align: center; }
.letter-title { margin: 0 0 34px; font-size: clamp(34px, 9vw, 52px); text-shadow: 0 0 22px rgba(255, 92, 154, .7); }
.envelope {
  --w: min(320px, 82vw);
  position: relative; display: block;
  width: var(--w); height: calc(var(--w) * .64);
  margin: 0 auto;
  padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 900px;
  animation: wobble 2.4s ease-in-out infinite;
}
.envelope.open { animation: none; cursor: default; }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-8px); } }
.env-back, .env-front, .env-flap, .env-paper { position: absolute; left: 0; width: 100%; }
.env-back { inset: 0; height: 100%; border-radius: 10px; background: #c92a5c; }
.env-paper {
  left: 6%; width: 88%; height: 88%; bottom: 4%;
  z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 8px;
  background: linear-gradient(#fffaf3, #ffe9f1);
  color: #c21d55;
  font-size: calc(var(--w) * .1);
  transition: transform 1s cubic-bezier(.3, .8, .3, 1) .55s;
}
.paper-heart { font-size: .9em; animation: beat 1.3s ease-in-out infinite; }
.env-front {
  inset: 0; height: 100%; z-index: 3; border-radius: 10px;
  background: linear-gradient(160deg, #ff6b98, #e23a72);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  top: 0; height: 58%; z-index: 4;
  background: linear-gradient(#ff7aa6, #e8417a);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 10px 10px 0 0;
  transform-origin: top center;
  transition: transform .7s ease, z-index 0s linear .35s;
}
.env-seal {
  position: absolute; z-index: 5; left: 50%; top: 58%;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8db4, #b5103f);
  color: #fff; font-size: 22px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
  transition: opacity .3s, transform .3s;
}
.envelope.open .env-seal { opacity: 0; transform: scale(.3); }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-paper { transform: translateY(-62%); }
.hint { margin-top: 26px; color: var(--pink-soft); font-size: 16px; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Serce ze zdjęć ---------- */
#s-heart { flex-direction: column; padding: 0; }
.heart-stage { position: relative; width: 100%; height: 100%; }
.tile {
  position: absolute;
  padding: 0; margin: 0;
  border: 2px solid #fff; border-radius: 8px;
  background: #2a0a1c center / cover no-repeat;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5), 0 0 12px rgba(255, 92, 154, .35);
  cursor: pointer;
  opacity: 0;
  transform: translate(-50%, -50%) translate(var(--fx), var(--fy)) rotate(var(--fr)) scale(.2);
  transition: transform 1.3s cubic-bezier(.2, .8, .25, 1), opacity .9s ease, box-shadow .25s;
  will-change: transform;
}
.tile.in { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)); }
@media (hover: hover) { .tile.in:hover { z-index: 10; transform: translate(-50%, -50%) rotate(0deg) scale(1.6); box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 22px rgba(255, 92, 154, .9); transition-duration: .3s; } }
.tile.in:focus-visible {
  z-index: 10;
  transform: translate(-50%, -50%) rotate(0deg) scale(1.6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 22px rgba(255, 92, 154, .9);
  transition-duration: .3s;
}
.heart-stage.done .tile.in:not(:hover):not(:focus-visible) { animation: tileBeat 1.6s ease-in-out infinite; }
@keyframes tileBeat {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--r)) scale(1); }
  20% { transform: translate(-50%, -50%) rotate(var(--r)) scale(1.08); }
  40% { transform: translate(-50%, -50%) rotate(var(--r)) scale(1); }
}

.final {
  position: absolute; z-index: 5;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}
.final p { margin: 0; text-shadow: 0 0 18px rgba(255, 92, 154, .9), 0 2px 4px rgba(0, 0, 0, .6); }
.final-text { line-height: 1.2; }
.final-name { margin-top: .45em !important; font-size: 1.18em; color: #ffd1e3; }
.final.show { animation: finalIn 2.2s cubic-bezier(.2, .8, .2, 1) forwards; }
.final.show .final-name { animation: beat 1.6s ease-in-out 2.4s infinite; }
@keyframes finalIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); filter: blur(10px); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
}
.heart-hint {
  position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom));
  margin: 0; text-align: center; font-size: 15px; color: var(--pink-soft);
  opacity: 0; transition: opacity .8s;
}
.heart-hint.show { opacity: .9; }

/* ---------- Podgląd ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14, 3, 10, .92);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .3s ease;
}
.lightbox[hidden] { display: none; }
.lb-inner { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 56px 12px 16px; }
.lb-figure { margin: 0; max-width: min(92vw, 720px); display: flex; flex-direction: column; align-items: center; }
.lb-figure img {
  display: block;
  max-width: 100%; max-height: calc(100dvh - 210px);
  border-radius: 14px; border: 3px solid #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6), 0 0 30px rgba(255, 92, 154, .4);
  animation: pop .45s cubic-bezier(.2, 1.3, .4, 1);
}
.lb-figure figcaption { margin-top: 14px; text-align: center; max-width: 560px; }
.lb-count { display: block; font-size: 13px; letter-spacing: .14em; color: var(--pink-soft); font-weight: 800; margin-bottom: 4px; }
.lb-caption { display: block; font-size: clamp(22px, 5.6vw, 32px); line-height: 1.2; }
.lb-close, .lb-nav {
  position: absolute; border: 0; cursor: pointer;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff;
  transition: background .2s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 92, 154, .5); }
.lb-close { top: max(10px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; font-size: 20px; }
.lb-nav { top: 50%; width: 48px; height: 48px; margin-top: -24px; font-size: 34px; line-height: 1; padding-bottom: 4px; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }

@media (max-width: 600px) {
  .lb-nav { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); margin: 0; }
  .lb-inner { padding-bottom: 76px; }
  .lb-figure img { max-height: calc(100dvh - 250px); }
}
@media (max-height: 560px) {
  .big-heart { width: 60px; }
  .welcome h1 { margin-bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
  .floating { display: none; }
}
