:root {
  --paper: #f5eee2;
  --card: #fffaf1;
  --ink: #3a2a25;
  --ink-soft: #7a655a;
  --rose: #e3a5a0;
  --wine: #7d2233;
  --kraft: #e6cca7;
  --kraft-d: #d8b98e;
  --kraft-dd: #c49f72;
  --hand: "Caveat", "Bradley Hand", cursive;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--serif);
  color: var(--ink);
  background-color: var(--paper);
  /* ziarno papieru */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.dev { padding-top: 48px; }

button { touch-action: manipulation; }

/* ---------- Pasek deweloperski ---------- */
#dev-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 10px;
  background: rgba(42, 31, 28, .9);
  backdrop-filter: blur(6px);
  font: 500 12px/1 system-ui, sans-serif;
  scrollbar-width: none;
}
#dev-nav::-webkit-scrollbar { display: none; }
#dev-nav button {
  flex: none; white-space: nowrap; cursor: pointer;
  font: inherit; color: var(--paper);
  background: transparent; border: 1px solid rgba(255,255,255,.22);
  padding: 8px 11px; border-radius: 999px;
}
#dev-nav button[aria-current="true"] { background: var(--paper); color: #2a1f1c; }
#dev-nav .reset { border-style: dashed; }

/* ---------- Tło ---------- */
.doodles svg {
  position: fixed; z-index: 0; pointer-events: none;
  fill: none; stroke: var(--wine); stroke-width: 1.3; stroke-linecap: round;
  opacity: .22;
}
.doodles .d1 { width: 46px; top: 12%; left: 6%;  transform: rotate(-14deg); }
.doodles .d2 { width: 28px; top: 20%; right: 9%; transform: rotate(12deg); }
.doodles .d3 { width: 34px; bottom: 14%; left: 10%; transform: rotate(8deg); }
.doodles .d4 { width: 52px; bottom: 8%; right: 7%; transform: rotate(-6deg); }

/* ---------- Układ ---------- */
#app { position: relative; z-index: 1; overflow-x: clip; min-height: calc(100dvh - 48px); display: flex; }
body:not(.dev) #app { min-height: 100dvh; }

.screen {
  flex: 1; width: 100%; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 64px; padding: 32px 22px 48px;
}

.page-head { text-align: center; transition: opacity .4s, transform .4s; }
.eyebrow {
  font-family: var(--hand); font-size: 1.6rem; color: var(--wine);
  margin: 0; transform: rotate(-3deg);
}
.title {
  font-weight: 400; font-size: 2.7rem; line-height: 1;
  letter-spacing: -.02em; margin: .15em 0 0;
}
.title em { font-style: italic; color: var(--wine); }

/* ---------- Koperta ---------- */
.envelope-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  transition: opacity .45s, transform .45s;
}
.envelope-wrap.leaving, .page-head.leaving { opacity: 0; transform: translateY(24px) scale(.96); }

.envelope {
  position: relative; display: block;
  width: min(82vw, 340px); aspect-ratio: 3 / 2;
  padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 16px 18px rgba(90, 55, 30, .22));
  animation: bob 4s ease-in-out infinite;
}
.envelope > span { position: absolute; display: block; }

.env-back { inset: 0; background: var(--kraft-dd); border-radius: 6px; z-index: 1; }

.env-letter {
  left: 6%; right: 6%; top: 7%; bottom: 6%; z-index: 2;
  background: var(--card);
  background-image: repeating-linear-gradient(to bottom, transparent 0 13px, rgba(125,34,51,.12) 13px 14px);
  background-position: 0 22px;
  border-radius: 2px;
  transition: transform .75s cubic-bezier(.2,.8,.2,1) .85s;
}

.env-pocket {
  inset: 0; z-index: 3; border-radius: 6px;
  background: var(--kraft);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-pocket::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--kraft-d), #dfc49c);
  clip-path: polygon(0 100%, 50% 46%, 100% 100%);
}
.env-to {
  position: absolute; left: 0; right: 0; bottom: 9%;
  text-align: center; font-family: var(--hand); font-size: 1.55rem; color: var(--ink);
  opacity: .8; transform: rotate(-2deg);
}

.env-flap {
  left: 0; right: 0; top: 0; height: 60%; z-index: 4;
  background: linear-gradient(to bottom, #dcbf96, var(--kraft-d) 70%, #cdac7f);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 6px 6px 0 0;
  transform-origin: top center;
  transition: transform .6s cubic-bezier(.45,0,.2,1) .3s, z-index 0s .6s;
}

.env-seal {
  left: 50%; top: 60%; z-index: 5;
  width: 58px; height: 58px; margin: -29px 0 0 -29px;
  display: grid !important; place-items: center;
  border-radius: 47% 53% 50% 50% / 53% 47% 53% 47%;
  background: radial-gradient(circle at 35% 30%, #b8404f, var(--wine) 55%, #561320);
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.13), inset 0 0 0 7px rgba(255,255,255,.06), 0 2px 4px rgba(0,0,0,.3);
  color: rgba(255, 215, 215, .7); font-size: 22px;
  transition: transform .35s, opacity .35s;
}

.envelope.open { animation: none; cursor: default; }
.envelope.open .env-seal   { transform: scale(1.35) rotate(15deg); opacity: 0; }
.envelope.open .env-flap   { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-letter { transform: translateY(-46%); }

.hint {
  margin: 0; font-family: var(--hand); font-size: 1.45rem; color: var(--ink-soft);
  animation: pulse 2.2s ease-in-out infinite;
  transition: opacity .3s;
}
.envelope.open + .hint { opacity: 0; animation: none; }

@keyframes bob {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50%      { transform: rotate(-1deg) translateY(-6px); }
}
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- List ---------- */
.screen.long { justify-content: flex-start; padding-top: 24px; gap: 40px; }

.letter {
  position: relative; width: 100%;
  background: var(--card);
  background-image: repeating-linear-gradient(to bottom, transparent 0 33px, rgba(125,34,51,.10) 33px 34px);
  background-position: 0 45px;
  padding: 38px 24px 30px 30px;
  border-radius: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,.05), 0 22px 40px -14px rgba(90,55,30,.4);
  transform: rotate(-.6deg);
  animation: unfold .8s cubic-bezier(.2,.8,.2,1) both;
}
/* czerwony margines jak w zeszycie */
.letter::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 18px;
  width: 1px; background: rgba(200, 80, 80, .35);
}
.letter p {
  font-family: var(--hand); font-size: 1.55rem; line-height: 34px;
  margin: 0 0 34px;
}
.letter .letter-greeting { font-size: 1.9rem; color: var(--wine); }
.letter .letter-sign { text-align: right; font-size: 2rem; color: var(--wine); transform: rotate(-3deg); }
.letter-actions { display: flex; justify-content: center; }

@keyframes unfold {
  from { opacity: 0; transform: translateY(40px) rotate(2deg) scale(.95); }
}

/* ---------- Taśma ---------- */
.tape {
  position: absolute; top: -14px; left: 50%;
  width: 116px; height: 30px;
  transform: translateX(-50%) rotate(-4deg);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.25) 0 6px, transparent 6px 12px),
    rgba(227, 165, 160, .6);
  clip-path: polygon(0 8%, 5% 0, 30% 6%, 60% 0, 96% 5%, 100% 0, 97% 50%, 100% 100%, 70% 94%, 35% 100%, 4% 95%, 0 100%, 3% 50%);
}

/* ---------- Przycisk ---------- */
.btn {
  font-family: var(--hand); font-size: 1.7rem; line-height: 1;
  color: var(--card); background: var(--wine);
  border: 0; cursor: pointer;
  padding: 12px 28px 14px;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 4px 0 rgba(58, 42, 37, .25);
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(58,42,37,.25); }

/* ---------- Karteczka (etapy w budowie) ---------- */
.note {
  position: relative; width: 100%; text-align: center;
  background: var(--card); padding: 40px 24px 32px;
  box-shadow: 0 22px 40px -14px rgba(90,55,30,.4);
  transform: rotate(.8deg);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.note .title { font-size: 2.2rem; }
.note-text { margin: 0; color: var(--ink-soft); font-style: italic; }

/* ---------- Mniej ruchu ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}

/* =====================================================================
   WSPÓLNE ELEMENTY
   ===================================================================== */
[hidden] { display: none !important; }

.code-strip {
  align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; margin-bottom: -12px;
  background: var(--card); border: 1px dashed rgba(125,34,51,.35); border-radius: 4px;
  transform: rotate(-.5deg);
}
.cs-label { font-family: var(--hand); font-size: 1.15rem; color: var(--ink-soft); white-space: nowrap; }
.cs-cells { display: flex; gap: 4px; }
.cs-cell {
  width: 24px; height: 30px; display: grid; place-items: center;
  border-bottom: 2px solid rgba(58,42,37,.25);
  font: 600 1.15rem var(--serif); color: var(--wine);
}
.cs-cell.got { border-color: var(--wine); animation: pop .4s ease-out; }

.counter { margin: -12px 0 0; font-family: var(--hand); font-size: 1.35rem; color: var(--ink-soft); text-align: center; }
.counter.big { font-size: 2rem; color: var(--wine); }
.hint-static { margin: 0; font-family: var(--hand); font-size: 1.5rem; color: var(--ink-soft); }
.end-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: rise .5s ease-out both; }
.link-btn {
  background: none; border: 0; padding: 6px; cursor: pointer;
  font-family: var(--hand); font-size: 1.3rem; color: var(--wine);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}

.ph { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e9dccb; }
.ph-empty {
  display: grid; place-items: center;
  background: repeating-linear-gradient(-45deg, #eadfcf 0 10px, #e4d6c2 10px 20px);
  color: var(--ink-soft); font: italic .85rem var(--serif);
}

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(58, 42, 37, .45); backdrop-filter: blur(3px);
  animation: fade .3s ease-out;
}
.digit-card {
  position: relative; width: min(100%, 320px); text-align: center;
  background: var(--card); padding: 40px 24px 28px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.45);
  transform: rotate(-1.5deg);
  animation: unfold .6s cubic-bezier(.2,.8,.2,1) both;
}
.digit-label { margin: 10px 0 0; color: var(--ink-soft); font-style: italic; }
.digit {
  font: 600 6.5rem/1 var(--serif); color: var(--wine);
  margin: 8px 0 4px; animation: pop .6s .25s cubic-bezier(.3,1.6,.5,1) both;
}
.digit-hint { margin: 0 0 22px; font-family: var(--hand); font-size: 1.3rem; color: var(--ink-soft); }

.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* =====================================================================
   2. OŚ CZASU
   ===================================================================== */
.timeline { list-style: none; margin: 0; padding: 0; width: 100%; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: repeating-linear-gradient(to bottom, var(--wine) 0 8px, transparent 8px 16px); opacity: .4;
}
.tl-item { position: relative; display: flex; padding: 14px 0; }
.tl-item.l { justify-content: flex-start; }
.tl-item.r { justify-content: flex-end; }
.tl-dot {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: var(--wine); box-shadow: 0 0 0 5px var(--paper);
}
.tl-card {
  position: relative; width: 74%; background: var(--card); padding: 10px 10px 14px;
  box-shadow: 0 14px 26px -12px rgba(90,55,30,.4);
  opacity: 0; transition: opacity .6s, transform .6s cubic-bezier(.2,.8,.2,1);
}
.tl-item.l .tl-card { transform: translateX(-30px) rotate(-2deg); }
.tl-item.r .tl-card { transform: translateX(30px) rotate(2deg); }
.tl-item.l.in .tl-card { opacity: 1; transform: rotate(-1.5deg); }
.tl-item.r.in .tl-card { opacity: 1; transform: rotate(1.5deg); }
.tl-card .tape { width: 70px; height: 22px; top: -10px; }
.tl-date { margin: 10px 0 0; font-family: var(--hand); font-size: 1.25rem; color: var(--wine); }
.tl-title { margin: 0; font-weight: 600; font-size: 1.1rem; }
.tl-text { margin: 4px 0 0; font-size: .92rem; line-height: 1.4; color: var(--ink-soft); }

/* =====================================================================
   3. QUIZ
   ===================================================================== */
.quiz-card {
  position: relative; width: 100%; background: var(--card); padding: 34px 22px 26px;
  box-shadow: 0 22px 40px -14px rgba(90,55,30,.4); text-align: center;
}
.quiz-card.enter { animation: unfold .5s cubic-bezier(.2,.8,.2,1) both; }
.quiz-top { display: flex; justify-content: space-between; align-items: baseline; }
.quiz-tag { font-family: var(--hand); font-size: 1.3rem; color: var(--wine); }
.quiz-count { font-size: .85rem; color: var(--ink-soft); }
.quiz-q { font-weight: 400; font-size: 1.55rem; line-height: 1.25; margin: 14px 0 22px; text-align: left; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opts.who { flex-direction: row; }
.quiz-opts.who .opt { flex: 1; font-size: 1.6rem; padding: 14px 6px; }
.opt {
  font: 1.05rem/1.3 var(--serif); color: var(--ink); text-align: left; cursor: pointer;
  background: #fff; border: 1.5px solid rgba(58,42,37,.22); padding: 13px 16px;
  border-radius: 12px 4px 12px 4px / 4px 12px 4px 12px;
  transition: background .2s, transform .1s;
}
.quiz-opts.who .opt { text-align: center; font-family: var(--hand); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt.ok { background: var(--wine); border-color: var(--wine); color: var(--card); animation: pop .35s; }
.opt.bad { text-decoration: line-through; opacity: .45; animation: shake .4s; }
.opt:disabled:not(.ok):not(.bad) { opacity: .6; }
.quiz-comment { min-height: 2.2em; margin: 16px 0 6px; font-family: var(--hand); font-size: 1.45rem; }
.quiz-comment.good { color: var(--wine); }
.quiz-comment.bad { color: var(--ink-soft); animation: pop .3s; }
.quiz-score { font: 400 4.5rem/1 var(--serif); margin-top: 8px; }
.quiz-score b { color: var(--wine); font-weight: 600; }
.quiz-sub { margin: 4px 0 0; color: var(--ink-soft); font-style: italic; }
.quiz-verdict { font-family: var(--hand); font-size: 1.6rem; margin: 18px 0 24px; }

/* =====================================================================
   5. PUZZLE
   ===================================================================== */
.puzzle-frame {
  position: relative; width: min(86vw, 360px); padding: 8px; background: #fffdf8;
  box-shadow: 0 18px 30px -14px rgba(90,55,30,.5); transform: rotate(-1deg);
}
.puzzle { touch-action: none; user-select: none; -webkit-user-select: none; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; aspect-ratio: 1; transition: gap .5s; }
.tile {
  border: 0; padding: 0; cursor: grab; aspect-ratio: 1; position: relative;
  background-size: calc(var(--n) * 100%) calc(var(--n) * 100%);
  transition: transform .15s, box-shadow .15s;
}
.puzzle-frame.solved .puzzle { gap: 0; }
.puzzle-frame.solved .tile { cursor: default; }
.puzzle-frame::after {
  content: ""; position: absolute; inset: 8px; background: var(--img) center / cover;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.puzzle-frame.peek::after { opacity: 1; }
.puzzle-msg {
  position: relative; width: 100%; background: var(--card); padding: 34px 22px 24px; text-align: center;
  box-shadow: 0 22px 40px -14px rgba(90,55,30,.4); animation: unfold .6s both;
}
.puzzle-msg p { font-family: var(--hand); font-size: 1.6rem; line-height: 1.3; margin: 0 0 20px; }

/* =====================================================================
   6. SERDUSZKA
   ===================================================================== */
.game-box {
  position: relative; width: 100%; height: min(58vh, 500px);
  background: #fffaf1; border-radius: 6px; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(125,34,51,.15), 0 18px 30px -16px rgba(90,55,30,.45);
  background-image: radial-gradient(rgba(125,34,51,.08) 1px, transparent 1.5px);
  background-size: 18px 18px;
}
.game { display: block; width: 100%; height: 100%; touch-action: none; }
.game-hud {
  position: absolute; top: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between;
  font: 600 1.4rem var(--hand); color: var(--wine); pointer-events: none;
}
.game-time { color: var(--ink-soft); font-weight: 400; }
.game-start {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 24px; text-align: center; background: rgba(255,250,241,.9);
}
.game-start p { margin: 0 0 6px; font-size: 1.05rem; }
.game-start .small { font-size: .9rem; color: var(--ink-soft); margin-bottom: 18px; }
.records {
  position: relative; width: 100%; background: var(--card); padding: 34px 22px 24px; text-align: center;
  box-shadow: 0 22px 40px -14px rgba(90,55,30,.4); animation: unfold .6s both;
}
.records-title { font-weight: 400; font-size: 1.6rem; margin: 0 0 12px; }
.records ol { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; }
.records li { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px dashed rgba(58,42,37,.2); }
.records li.me { color: var(--wine); font-weight: 600; }
.records-note { font-family: var(--hand); font-size: 1.5rem; color: var(--wine); margin: 0 0 16px; transform: rotate(-2deg); }

/* =====================================================================
   8. TORT
   ===================================================================== */
.cake-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 30px; }
.candles { display: flex; flex-direction: column; align-items: center; margin-bottom: -6px; position: relative; z-index: 2; }
.candle-row { display: flex; align-items: flex-end; gap: 14px; }
.candle-row:has(.small) { gap: 5px; }
.candle-row.back { margin-bottom: -20px; }
.candle-row.front { position: relative; }
.candles:has(.small) { margin-bottom: -12px; }
.candles.tappable { cursor: pointer; }
.candle {
  position: relative; display: block; width: 12px; height: var(--h); border: 0; padding: 0;
  background: repeating-linear-gradient(-35deg, #fffaf1 0 6px, var(--rose) 6px 11px);
  border-radius: 3px 3px 0 0; cursor: default;
}
.candle:not(:disabled) { cursor: pointer; }
.candle::before { content: ""; position: absolute; left: 50%; top: -7px; width: 2px; height: 8px; margin-left: -1px; background: #3a2a25; }
.flame {
  position: absolute; left: 50%; bottom: calc(100% + 4px); width: 14px; height: 24px; margin-left: -7px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 75%, #fff7c2 0 25%, #ffc94a 45%, #ff8a3c 70%, transparent 72%);
  filter: drop-shadow(0 0 8px rgba(255,180,60,.8));
  transform-origin: 50% 90%;
  animation: flame .9s var(--d) ease-in-out infinite alternate;
  transition: opacity .2s, transform .2s;
}
.candle.flicker .flame { animation-duration: .12s; transform: skewX(18deg) scaleY(.8); }
.candle.out .flame { opacity: 0; transform: scale(.2); animation: none; }
.smoke {
  position: absolute; left: 50%; bottom: calc(100% + 6px); width: 10px; height: 10px; margin-left: -5px;
  border-radius: 50%; background: rgba(120,110,105,.45); opacity: 0;
}
.candle.out .smoke { animation: smoke 1.6s ease-out forwards; }
@keyframes flame { from { transform: rotate(-3deg) scaleY(1); } to { transform: rotate(3deg) scaleY(1.12); } }
@keyframes smoke { 0% { opacity: .8; transform: translateY(0) scale(.6); } 100% { opacity: 0; transform: translate(10px, -60px) scale(2.6); } }

.cake { display: flex; flex-direction: column; align-items: center; }
.tier { position: relative; border-radius: 10px 10px 4px 4px; }
.tier.top { width: 170px; height: 70px; background: #f6d9d3; }
.tier.bottom { width: 250px; height: 96px; background: #e9c4bc; margin-top: -2px; }
.drips {
  position: absolute; left: -2px; right: -2px; top: -2px; height: 30px;
  background: #fffaf1; border-radius: 10px 10px 0 0;
  -webkit-mask: radial-gradient(circle at 12px 30px, #000 10px, transparent 10.5px) 0 0 / 40px 40px repeat-x, linear-gradient(#000 0 18px, transparent 18px);
          mask: radial-gradient(circle at 12px 30px, #000 10px, transparent 10.5px) 0 0 / 40px 40px repeat-x, linear-gradient(#000 0 18px, transparent 18px);
}
.dots {
  position: absolute; left: 14px; right: 14px; bottom: 18px; height: 10px;
  background: radial-gradient(circle, var(--wine) 3.5px, transparent 4px) 0 0 / 26px 10px repeat-x;
}
.plate { width: 300px; height: 14px; margin-top: -2px; background: #fffdf8; border-radius: 50%; box-shadow: 0 8px 14px -6px rgba(90,55,30,.4); }
.mic-level { width: 180px; height: 8px; border-radius: 4px; background: rgba(58,42,37,.12); overflow: hidden; margin-top: -18px; }
.mic-level span { display: block; height: 100%; width: 0; background: var(--wine); transition: width .08s; }
.wish { margin: 0; font: italic 400 2.6rem var(--serif); color: var(--wine); animation: pop .6s cubic-bezier(.3,1.6,.5,1); }

/* =====================================================================
   9. SEJF I ZDRAPKA
   ===================================================================== */
.safe { position: relative; width: min(86vw, 340px); aspect-ratio: 5 / 6; perspective: 1200px; }
.safe.shake { animation: shake .4s; }
.safe-inside {
  position: absolute; inset: 0; border-radius: 14px; padding: 16px;
  background: #3a2a25; box-shadow: inset 0 0 0 8px #2a1d19, inset 0 10px 30px rgba(0,0,0,.6);
  display: grid; place-items: center;
}
.safe-door {
  position: absolute; inset: 0; z-index: 2; border-radius: 14px; padding: 22px 22px 20px;
  background: linear-gradient(145deg, #8c7a6b, #5e4e43);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.12), inset 0 -6px 0 rgba(0,0,0,.2), 0 20px 34px -14px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 14px;
  transform-origin: left center; transition: transform 1.1s cubic-bezier(.5,0,.2,1);
}
.safe.open .safe-door { transform: rotateY(-105deg); pointer-events: none; }
.safe-hinge { position: absolute; left: -6px; top: 18%; width: 10px; height: 36px; border-radius: 4px; background: #3a2a25; }
.safe-hinge.b { top: auto; bottom: 18%; }
.safe-display {
  display: flex; justify-content: center; gap: 5px; padding: 10px; border-radius: 6px;
  background: #1f2a1f; box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.safe-display span {
  width: 26px; height: 34px; display: grid; place-items: center;
  font: 600 1.4rem ui-monospace, monospace; color: #9ee89e; text-shadow: 0 0 6px rgba(120,255,120,.6);
  border-bottom: 2px solid rgba(158,232,158,.25);
}
.keypad { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  border: 0; border-radius: 8px; cursor: pointer;
  background: linear-gradient(#efe6da, #d4c6b4); color: var(--ink);
  font: 600 1.3rem var(--serif); box-shadow: 0 3px 0 #6e5d50;
}
.keypad button:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e5d50; }
.keypad .ok { background: linear-gradient(#a63a4b, var(--wine)); color: var(--card); font-size: 1.05rem; }

.ticket { position: relative; height: 100%; width: auto; aspect-ratio: 3 / 4; }
.ticket-body {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 20px; border-radius: 8px;
  background: var(--card);
  -webkit-mask: radial-gradient(circle at 0 74%, transparent 12px, #000 12.5px) left / 51% 100% no-repeat,
                radial-gradient(circle at 100% 74%, transparent 12px, #000 12.5px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle at 0 74%, transparent 12px, #000 12.5px) left / 51% 100% no-repeat,
                radial-gradient(circle at 100% 74%, transparent 12px, #000 12.5px) right / 51% 100% no-repeat;
}
.ticket-body::after { content: ""; position: absolute; left: 18px; right: 18px; top: 74%; border-top: 2px dashed rgba(125,34,51,.3); }
.ticket-tag { margin: 0; font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-soft); }
.ticket-title { margin: 8px 0 10px; font-weight: 400; font-style: italic; font-size: 2rem; line-height: 1.05; color: var(--wine); }
.ticket-text { margin: 0 0 56px; font-family: var(--hand); font-size: 1.4rem; line-height: 1.2; }
.ticket-details { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.scratch { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; touch-action: none; cursor: crosshair; transition: opacity .8s; }
.scratch.gone { opacity: 0; pointer-events: none; }
.final {
  margin: 0; text-align: center; font: italic 400 2.2rem/1.15 var(--serif); color: var(--wine);
  animation: pop .7s cubic-bezier(.3,1.6,.5,1);
}
.puzzle-frame.solved::after { opacity: 1; transition: opacity .6s .45s; }


/* =====================================================================
   PUZZLE: przeciąganie
   ===================================================================== */
.tile.dragging {
  z-index: 10; cursor: grabbing; transition: none;
  box-shadow: 0 14px 24px -6px rgba(0,0,0,.45), 0 0 0 3px var(--card);
}
.tile.over { filter: brightness(.75); box-shadow: inset 0 0 0 3px var(--wine); }
.tile.landed { animation: land .3s cubic-bezier(.3,1.6,.5,1); }
@keyframes land { from { transform: scale(.85); } }

/* =====================================================================
   MEMO
   ===================================================================== */
.memo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.mcard { border: 0; padding: 0; background: none; cursor: pointer; aspect-ratio: 1; perspective: 600px; }
.mc-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,.7,.3,1);
}
.mcard.up .mc-inner { transform: rotateY(180deg); }
.mc-back, .mc-front {
  position: absolute; inset: 0; border-radius: 6px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 6px 12px -6px rgba(90,55,30,.45);
}
.mc-back {
  display: grid; place-items: center;
  background: var(--kraft) repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px);
  border: 3px solid var(--card);
}
.mc-back span { color: var(--wine); font-size: 1.4rem; opacity: .7; }
.mc-front { transform: rotateY(180deg); background: var(--card); border: 3px solid var(--card); }
.mc-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 2rem; }
.mcard.match .mc-front { box-shadow: 0 0 0 3px var(--wine); animation: matched .5s ease-out; }
.mcard.miss .mc-front { animation: shake .4s; }
@keyframes matched { 40% { transform: rotateY(180deg) scale(1.12); } }

/* =====================================================================
   SERDUSZKA: dodatki
   ===================================================================== */
.game-time.low { color: #b3261e; font-weight: 600; animation: pulse .5s infinite; }
.game-start .gold { color: #d4a640; text-shadow: 0 0 6px rgba(230,180,60,.8); }
.lose-title { font: 400 2rem var(--serif); color: var(--wine); margin: 0 0 6px !important; }

/* =====================================================================
   SIŁOMIERZ
   ===================================================================== */
.screen[data-step="silomierz"] { gap: 18px; padding-top: 20px; }
.screen[data-step="silomierz"] .title { font-size: 2.2rem; }

/* dzwonek, rura i podstawa są w jednej osi; napisy wiszą po prawej */
.meter { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; padding-right: 175px; }
.bell-wrap { position: relative; width: 44px; height: 46px; display: grid; place-items: center; margin-bottom: -2px; }
.bell { font-size: 2.4rem; line-height: 1; transform-origin: 50% 8%; display: block; }
.meter.won .bell { animation: ring .14s ease-in-out 14 alternate; }
@keyframes ring { from { transform: rotate(-26deg); } to { transform: rotate(26deg); } }
.shock {
  position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; border: 3px solid var(--wine); opacity: 0; pointer-events: none;
}
.meter.won .shock { animation: shock .9s ease-out 2; }
@keyframes shock { from { opacity: .8; transform: scale(.4); } to { opacity: 0; transform: scale(9); } }

.tower { position: relative; width: 44px; height: min(36vh, 320px); }
.track {
  position: relative; width: 44px; height: 100%; background: #fffaf1;
  border: 2px solid var(--ink); border-radius: 22px; overflow: hidden;
  box-shadow: inset 0 4px 10px rgba(0,0,0,.08);
}
.fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: linear-gradient(to top, var(--rose), #c85a68 60%, var(--wine));
}
.meter.won .fill { animation: glow .6s ease-in-out infinite alternate; }
@keyframes glow { to { filter: brightness(1.25) saturate(1.2); } }
.puck {
  position: absolute; left: 50%; bottom: 0; width: 34px; height: 34px; margin-left: -17px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--card); color: var(--wine); font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.meter.won .puck { animation: beat .5s ease-in-out infinite; }
@keyframes beat { 30% { transform: scale(1.3); } 60% { transform: scale(.95); } }
.base { width: 110px; height: 14px; margin-top: -2px; background: var(--kraft-dd); border-radius: 4px 4px 2px 2px; }

.scale { list-style: none; margin: 0; padding: 0; position: absolute; left: calc(100% + 12px); top: 0; bottom: 0; width: 200px; }
.scale li {
  position: absolute; left: 0; translate: 0 50%;
  font-family: var(--hand); font-size: 1.25rem; white-space: nowrap;
  color: rgba(58,42,37,.3); transform-origin: left center;
  transition: color .25s, opacity .25s, scale .25s;
}
.scale li::before { content: "♡ "; transition: color .2s; }
.scale li.on { color: var(--wine); scale: 1.1; }
.scale li.on::before { content: "♥ "; }
.scale li.stamp { animation: stamp .45s cubic-bezier(.3,1.7,.5,1); }
@keyframes stamp {
  0% { transform: scale(1.9) rotate(-10deg); opacity: 0; }
  60% { transform: scale(.92) rotate(2deg); opacity: 1; }
  100% { transform: none; }
}
.scale li:last-child { font-weight: 700; }
.scale li .ch { display: inline-block; }
.meter.won .scale li:last-child { scale: 1.12; }
.meter.won .scale li:last-child .ch { animation: wave .5s calc(var(--i) * 45ms) ease-in-out infinite alternate; }
@keyframes wave { from { transform: translateY(3px); } to { transform: translateY(-6px) rotate(-4deg); color: #c4485a; } }

.now-word {
  margin: 4px 0 0; min-height: 2.4rem; text-align: center;
  font: 600 1.9rem/1.2 var(--hand); color: var(--wine);
}
.now-word.up { animation: wordUp .4s cubic-bezier(.3,1.6,.5,1); }
.now-word.down { animation: wordDown .35s ease-out; color: var(--ink-soft); }
.now-word.win { font-size: 2.1rem; animation: wordWin .6s cubic-bezier(.3,1.6,.5,1), heartbeat .9s .6s ease-in-out infinite; }
@keyframes wordUp { from { transform: scale(.4) translateY(14px); opacity: 0; } }
@keyframes wordDown { from { transform: translateY(-10px); opacity: 0; } }
@keyframes wordWin { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }
@keyframes heartbeat { 15% { transform: scale(1.12); } 30% { transform: scale(1); } 45% { transform: scale(1.08); } }

.hammer-btn {
  width: 128px; height: 128px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #c4485a, var(--wine) 60%, #561320);
  color: var(--card); font: 700 1.9rem var(--hand); letter-spacing: .04em;
  box-shadow: 0 8px 0 #4a0f1b, 0 16px 24px -6px rgba(0,0,0,.35);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.hammer-btn.hit { animation: press .12s ease-out; }
.hammer-btn:disabled { filter: grayscale(.3); opacity: .7; }
@keyframes press { 50% { transform: translateY(6px) scale(.96); box-shadow: 0 2px 0 #4a0f1b, 0 6px 10px -4px rgba(0,0,0,.35); } }

.screen.quake { animation: quake .5s ease-out; }
@keyframes quake {
  10%, 50% { transform: translate(-6px, 3px) rotate(-.6deg); }
  30%, 70% { transform: translate(6px, -3px) rotate(.6deg); }
  90% { transform: translate(-2px, 1px); }
}

/* =====================================================================
   UCIEKAJĄCY PRZYCISK
   ===================================================================== */
.run-card {
  position: relative; width: 100%; background: var(--card); padding: 34px 22px 18px; text-align: center;
  box-shadow: 0 22px 40px -14px rgba(90,55,30,.4); transform: rotate(-.8deg);
}
.run-q { font-weight: 400; font-size: 1.6rem; line-height: 1.25; margin: 0 0 10px; }
.run-tease { min-height: 2.2rem; margin: 0; font-family: var(--hand); font-size: 1.45rem; color: var(--wine); }
.run-tease.pop { animation: pop .3s cubic-bezier(.3,1.6,.5,1); }
.run-arena { position: relative; width: 100%; height: min(40vh, 340px); margin-top: -10px; }
.run-yes, .run-no {
  position: absolute; border: 0; cursor: pointer;
  font: 600 1.7rem/1 var(--hand); padding: 14px 34px 16px;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  transform: rotate(var(--spin, 0deg)) scale(var(--scale, 1));
  transition: left .28s cubic-bezier(.3,1.4,.5,1), top .28s cubic-bezier(.3,1.4,.5,1), transform .28s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.run-yes {
  left: calc(50% - 120px); top: 40%;
  color: var(--card); background: var(--wine); box-shadow: 3px 4px 0 rgba(58,42,37,.25); z-index: 2;
}
.run-no {
  left: calc(50% + 20px); top: 40%;
  color: var(--ink); background: var(--card); box-shadow: 3px 4px 0 rgba(58,42,37,.15);
  transform-origin: center;
}
.run-yes.tired { left: calc(50% - 50px); top: 36%; animation: wiggle .5s ease-in-out 2; }
.run-yes.caught { animation: pop .5s cubic-bezier(.3,1.6,.5,1); --scale: 1.5; }
@keyframes wiggle { 25% { rotate: -6deg; } 75% { rotate: 6deg; } }
.run-success { margin: 0; font: italic 400 2.4rem var(--serif); color: var(--wine); animation: pop .6s cubic-bezier(.3,1.6,.5,1); }

/* twarze na zdjęciach są zwykle w górnej części kadru */
.tl-photo, .mc-front img { object-position: 50% 30%; }

/* małe świeczki (gdy jest ich dużo) */
.candle.small { width: 7px; border-radius: 2px 2px 0 0;
  background: repeating-linear-gradient(-35deg, #fffaf1 0 4px, var(--rose) 4px 7px); }
.candle.small::before { top: -5px; height: 6px; width: 1.5px; }
.candle.small .flame { width: 9px; height: 15px; margin-left: -4.5px; bottom: calc(100% + 3px); filter: drop-shadow(0 0 5px rgba(255,180,60,.8)); }
.candle.small .smoke { width: 7px; height: 7px; margin-left: -3.5px; }
.candle-row.back .candle.small { filter: brightness(.93); }

/* oś czasu: podpis odręczny i dwa zdjęcia na sobie */
.tl-caption { margin: 2px 0 0; font-family: var(--hand); font-size: 1.45rem; line-height: 1.15; color: var(--ink); }
.tl-pics.two { position: relative; aspect-ratio: 1 / .78; }
.tl-pol {
  position: absolute; width: 56%; padding: 4px 4px 14px; background: #fffdf8;
  box-shadow: 0 8px 16px -6px rgba(90,55,30,.45);
}
.tl-pol .tl-photo { aspect-ratio: 1; }
.tl-pol.a { left: 0; top: 2%; transform: rotate(-5deg); }
.tl-pol.b { right: 0; top: 12%; transform: rotate(5deg); }
.tl-item.in .tl-pol.b { animation: dropIn .6s .35s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes dropIn { from { opacity: 0; transform: translate(20px, -30px) rotate(18deg); } }

/* termin na bonie pod linią perforacji */
.ticket-details { position: absolute; left: 0; right: 0; top: 74%; bottom: 0; display: grid; place-items: center; font-family: var(--hand); font-size: 1.35rem; color: var(--wine); }
.ticket-text { margin: 0 0 22%; }
