/* ==========================================================================
   castle17.css — v17 (princess / castle path only, loaded last)
   8pt spacing scale · spring motion · unified plaques & answer medals
   · Smocze jajka rebuilt (eg-*) · pantry eating · leftovers
   Never restyles .castle-back (castle.css owns the shield override).
   ========================================================================== */
:root {
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --shadow-soft: 0 2px 0 rgba(110, 74, 22, .55), 0 8px 18px rgba(74, 31, 92, .18);
  --ans: 68px;
}
@media (orientation: portrait) { :root { --ans: 80px; } }

/* ---- unified plaque + question ---------------------------------------- */
body.world-zamek .pr-plaque {
  border-radius: 16px; padding: var(--s1) var(--s3);
  box-shadow: inset 0 0 0 2px #FFF6DE, 0 4px 0 #8E6420, 0 12px 24px rgba(74, 31, 92, .18);
}
body.world-zamek .pr-q.is-new { animation: v17QIn .45s var(--spring) both; }
@keyframes v17QIn { from { transform: translateY(-6px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- unified answer medals: one size, even gaps, staggered spring-in ---- */
body.world-zamek .pr-choices { display: flex; justify-content: center; align-items: center; gap: var(--s3); }
body.world-zamek .pr-medal { width: var(--ans); height: var(--ans); font-size: calc(var(--ans) * .4); flex: 0 0 auto; }
body.world-zamek .pr-medal span { display: block; line-height: 1; }
body.world-zamek .pr-choices.is-on > .pr-medal,
body.world-zamek .eg-ans > .pr-medal { animation: v17In .5s var(--spring) both; animation-delay: calc(var(--k, 0) * 90ms); }
body.world-zamek .pr-medal.is-good { animation: goodPop .6s var(--spring); }
body.world-zamek .pr-medal.is-dud { animation: dudWobble .5s ease; }
body.world-zamek .pr-medal.is-hint { animation: hintBob .8s ease-in-out infinite alternate; }
@keyframes v17In { from { transform: translateY(var(--s2)) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (hover: hover) { body.world-zamek .pr-medal:not(.is-dud):hover { transform: translateY(-3px) scale(1.06); } }
body.world-zamek .pr-medal:not(.is-dud):active { transform: translateY(3px) scale(.95); transition-duration: .06s; }

/* ---- playroom: pet stands bottom-left in both orientations, facing in --- */
body.world-zamek .pr-game--egg .pr-dragon { right: auto; left: var(--s2); bottom: var(--s1); transform: scaleX(-1); }

/* ==========================================================================
   (c) SMOCZE JAJKA — v17 rebuild
   ========================================================================== */
.pr-game--egg .pr-field--egg { display: block; padding: 0; gap: 0; }
.pr-game--egg .pr-dragon .playroom-pet { height: 120px; }
@media (orientation: portrait) { .pr-game--egg .pr-dragon .playroom-pet { height: 140px; } }

.eg-scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: var(--s2); padding-top: var(--s1);
}
@media (orientation: portrait) { .eg-scene { padding-top: var(--s2); gap: var(--s3); } }

/* nest — a strict grid of dimples, rows of 5 (portrait) or 5+5 (landscape) */
.eg-nest {
  --eg: 44px;
  display: flex; flex-direction: column; align-items: center; gap: var(--s1);
  padding: 12px; border-radius: 28px;
  background:
    repeating-linear-gradient(28deg, rgba(150, 100, 40, .12) 0 3px, transparent 3px 9px),
    repeating-linear-gradient(-32deg, rgba(150, 100, 40, .10) 0 2px, transparent 2px 8px),
    radial-gradient(ellipse at 50% 35%, #FFF3D8 0, #EBCF98 64%, #CFA761 100%);
  border: 3px solid #B98A3E;
  box-shadow: inset 0 4px 10px rgba(120, 70, 20, .28), inset 0 -3px 0 rgba(255, 255, 255, .35), 0 4px 0 #8E6420, 0 14px 26px rgba(74, 31, 92, .2);
  animation: v17In .5s var(--spring) both;
}
.eg-nest.is-port { padding: var(--s2); border-radius: 32px; }
.eg-row { display: flex; gap: var(--s2); }
.eg-nest.is-port .eg-row { gap: 0; }
.eg-five { display: flex; gap: var(--s1); }
.eg-cell {
  position: relative; display: block;
  width: var(--eg); height: calc(var(--eg) * 1.29);
}
.eg-cell::before { /* dimple in the straw */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: 0; height: 26%;
  border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, rgba(120, 72, 22, .32), rgba(120, 72, 22, 0) 70%);
}
.eg-egg {
  position: absolute; inset: 0; display: block; cursor: default;
  transform-origin: 50% 92%; -webkit-tap-highlight-color: transparent; outline: none;
}
.eg-egg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none;
  filter: drop-shadow(0 3px 2px rgba(90, 50, 20, .35)); }
.eg-egg.is-wait { visibility: hidden; }
.eg-egg:not(.is-wait) { animation: egPop .45s var(--spring) both; }
.eg-egg.is-drop { animation: egDrop .6s var(--spring) both; }
.eg-egg.is-extra img { filter: hue-rotate(220deg) saturate(1.25) drop-shadow(0 3px 2px rgba(90, 50, 20, .35)); }
@keyframes egPop { from { transform: scale(.2) translateY(30%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes egDrop { 0% { transform: translateY(-140%) scale(.8); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }

/* number badge */
.eg-num {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  min-width: calc(var(--eg) * .62); height: calc(var(--eg) * .62); padding: 0 4px;
  margin: calc(var(--eg) * -.31) 0 0 calc(var(--eg) * -.31);
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  border-radius: 999px; font-style: normal; font-weight: 800;
  font-size: calc(var(--eg) * .36); line-height: 1; color: #FFF8E6;
  background: linear-gradient(180deg, #A465D6, #5A2370); border: 2px solid #E9C46A;
  box-shadow: 0 2px 0 #3A1248; opacity: 0; transform: scale(.3); pointer-events: none;
  transition: opacity .25s ease, transform .3s var(--ease-out);
}
.eg-egg.is-num .eg-num { opacity: 1; transform: none; animation: egNum .45s var(--spring) both; }
@keyframes egNum { from { transform: scale(1.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* shake → crack → grey shell */
.eg-half { opacity: 0; transition: transform .8s var(--ease-out), opacity .8s ease, filter .6s ease; }
.eg-half--t { clip-path: polygon(0 0, 100% 0, 100% 46%, 86% 54%, 72% 44%, 58% 55%, 44% 44%, 30% 55%, 16% 45%, 0 53%); }
.eg-half--b { clip-path: polygon(0 53%, 16% 45%, 30% 55%, 44% 44%, 58% 55%, 72% 44%, 86% 54%, 100% 46%, 100% 100%, 0 100%); }
.eg-egg.is-shake { animation: egShake .4s ease-in-out infinite; }
@keyframes egShake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
.eg-egg.is-hatched { animation: none; }
.eg-egg.is-hatched .eg-full { opacity: 0; }
.eg-egg.is-hatched .eg-half { opacity: 1; }
.eg-egg.is-hatched .eg-half--t { transform: translate(22%, -48%) rotate(32deg); opacity: 0; }
.eg-egg.is-hatched .eg-half--b { opacity: .5; filter: grayscale(1) brightness(1.05) drop-shadow(0 2px 1px rgba(60, 40, 30, .25)); }
.eg-baby {
  position: absolute; z-index: 22; height: auto; pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 6px rgba(60, 25, 70, .3));
  animation: egFly 1.8s cubic-bezier(.4, .05, .5, 1) forwards;
}
@keyframes egFly {
  0% { transform: translate(-50%, -40%) scale(.2); opacity: 0; }
  18% { transform: translate(-50%, -70%) scale(1.05); opacity: 1; }
  32% { transform: translate(-50%, -80%) scale(1) rotate(-6deg); }
  100% { transform: translate(calc(-50% + var(--fx, 80px)), var(--fy, -300px)) scale(.6) rotate(14deg); opacity: 0; }
}

/* counting aid + success */
.pr-game--egg .eg-scene:has(.eg-slot.is-ask) .eg-egg:not(.is-hatched) { cursor: pointer; }
.eg-egg.is-counted img { filter: drop-shadow(0 0 6px #FFE27A) drop-shadow(0 3px 2px rgba(90, 50, 20, .35)); }
.eg-egg.is-counted.is-extra img { filter: hue-rotate(220deg) saturate(1.25) drop-shadow(0 0 6px #FFE27A); }
.eg-egg.is-wiggle { animation: egWiggle .6s var(--spring) both; }
@keyframes egWiggle { 40% { transform: translateY(-14%) scale(1.08) rotate(-6deg); } 70% { transform: rotate(5deg); } }

/* slot under the nest: caption bubble during the story, then 3 medals + tip */
.eg-slot {
  position: relative; flex: 0 0 auto;
  width: min(100% - 2 * var(--s2), 480px); height: 96px;
  display: grid; place-items: center;
}
@media (orientation: portrait) { .eg-slot { height: 120px; } }
.eg-cap {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 100%; box-sizing: border-box;
  display: flex; align-items: baseline; gap: var(--s1); white-space: nowrap;
  padding: var(--s1) var(--s3); border-radius: 22px;
  background: #FFFDF6; border: 3px solid #C99A3C; color: #4A1F5C;
  box-shadow: inset 0 0 0 2px #FFF6DE, var(--shadow-soft);
  font-size: 1.12rem; font-weight: 700; line-height: 1.25;
  opacity: 0; transition: opacity .3s ease;
}
.eg-cap::after { /* tail toward the pet (bottom-left) */
  content: ""; position: absolute; left: 22px; bottom: -11px; width: 18px; height: 18px;
  background: #FFFDF6; border-right: 3px solid #C99A3C; border-bottom: 3px solid #C99A3C;
  transform: rotate(45deg) skew(8deg, 8deg); border-radius: 0 0 4px 0;
}
.eg-cap.is-on { opacity: 1; animation: egCap .45s var(--spring) both; }
@keyframes egCap { from { transform: translate(-50%, -38%) scale(.86); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.eg-cap-who { font-weight: 800; color: #8E4FC0; font-size: .82em; text-transform: uppercase; letter-spacing: .06em; }
.eg-cap-who::after { content: ":"; }
.eg-cap em { font-style: normal; font-weight: 800; color: #B8306A; font-size: 1.15em; }
.eg-ans {
  display: grid; grid-template-columns: repeat(3, var(--ans)); gap: var(--s4);
  justify-content: center; align-items: center;
}
.eg-ans:empty { display: none; }
.eg-tip {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  white-space: nowrap; font-size: .8rem; line-height: 20px; font-weight: 800; color: #5A2370; letter-spacing: .02em;
  padding: 2px var(--s2); border-radius: 999px; background: rgba(255, 250, 238, .9);
  box-shadow: 0 0 0 2px #E9C46A, 0 4px 10px rgba(74, 31, 92, .15);
  opacity: 0; pointer-events: none;
}
.eg-slot.is-ask { align-content: start; }
.eg-slot.is-ask .eg-cap { opacity: 0; animation: none; pointer-events: none; }
.eg-slot.is-ask .eg-tip { opacity: 1; animation: egTip 1.6s ease-in-out .5s infinite; }
@keyframes egTip { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.07); box-shadow: 0 0 0 2px #E9C46A, 0 0 14px rgba(255, 226, 122, .9); } }
@media (orientation: portrait) {
  .eg-cap { white-space: normal; text-align: center; flex-wrap: wrap; justify-content: center; font-size: 1.15rem; width: max-content; max-width: 100%; }
  .eg-tip { font-size: .9rem; }
}

/* plaque equation (grows piece by piece) */
.eg-listen { display: block; font-size: 1.05rem; font-weight: 700; color: #8E4FC0; line-height: 2rem; animation: v17QIn .45s var(--spring) both; }
.eg-eq { display: inline-flex; align-items: center; justify-content: center; gap: .28em; min-height: 1.1em; min-width: 3em;
  font-size: 2.1rem; font-weight: 800; line-height: 1.05; color: #4A1F5C; white-space: nowrap; }
.eg-t { display: inline-block; font-weight: 800; }
.eg-t.is-op { color: #C98A1E; }
.eg-t.is-in { animation: egEq .55s var(--spring) both; animation-delay: calc(var(--k, 0) * 120ms); }
.eg-t.is-q { color: #B8306A; animation: egEq .55s var(--spring) both, qPulse 1.3s ease-in-out .6s infinite; }
.eg-t.is-ok { color: #2F8A3A; animation: goodPop .6s var(--spring); }
@keyframes egEq { from { transform: scale(2) translateY(-18%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (orientation: landscape) and (max-height: 500px) { .eg-eq { font-size: 1.8rem; } }

/* ==========================================================================
   Kitchen — eaten food really leaves the shelf
   ========================================================================== */
.pantry[data-open="true"] .pantry-fruit.is-gone {
  opacity: 0; transform: scale(.15) translateY(-40%); pointer-events: none;
  transition: opacity .3s ease, transform .35s cubic-bezier(.5, 0, .75, 0);
}
.pantry-fruit.is-refill img { animation: v17Refill .5s var(--spring) .3s both; }
@keyframes v17Refill { from { transform: scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
.pantry-empty.is-new { animation: v17In .5s var(--spring) both; }
.castle-ghost.is-eaten {
  transition: left .32s var(--ease-out), top .32s var(--ease-out), transform .36s cubic-bezier(.5, 0, .75, 0) .12s, opacity .2s ease .26s;
  transform: translate(-50%, -50%) scale(.1) rotate(-20deg);
  opacity: 0;
}

/* ==========================================================================
   Global playroom alignment (landscape): pet bottom-left, content centred
   on the viewport axis with symmetric side gutters (no more right-heavy
   220px padding). Portrait already stacks centrally.
   ========================================================================== */
@media (orientation: landscape) {
  body.world-zamek .pr-game .pr-dragon { right: auto; left: var(--s2); bottom: var(--s1); transform: scaleX(-1); }
  body.world-zamek .pr-game .pr-dragon .playroom-pet { height: min(36vh, 136px); }
  body.world-zamek .pr-game--egg .pr-dragon .playroom-pet { height: 120px; }
  body.world-zamek .pr-field--fruit,
  body.world-zamek .pr-field--treats,
  body.world-zamek .pr-field--pairs,
  body.world-zamek .pr-field--riddles { padding-left: 168px !important; padding-right: 168px !important; }
  body.world-zamek .pr-field--vault { padding-left: var(--s4) !important; padding-right: var(--s4) !important; }

  /* (f) tower: pile | tower | (mirror gutter) — tower on the centre axis, bigger bricks */
  body.world-zamek .pr-field--tower {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 0 var(--s4) var(--s1) !important; gap: var(--s1) var(--s3);
  }
  body.world-zamek .pr-field--tower .tw-side { grid-column: 1; grid-row: 1; justify-self: center; }
  body.world-zamek .pr-field--tower .tw-site { grid-column: 2; grid-row: 1; }
  body.world-zamek .pr-field--tower .pr-choices { grid-column: 1 / -1; grid-row: 2; }
  body.world-zamek .pr-field--tower .pr-choices:empty { display: none; }
  body.world-zamek .tw-site { --bw: min(46px, calc(400px / var(--b)), calc((136px / var(--a) - 8px) * 1.23)); }
}
@media (orientation: portrait) {
  body.world-zamek .tw-site { --bw: min(44px, calc(320px / var(--b))); }
}

/* (e) riddles: comparison rows on a strict 10-column grid (rows line up) */
body.world-zamek .rd-row:not(.rd-row--pile) {
  display: grid; grid-template-columns: repeat(10, 26px); gap: 2px; max-width: none; justify-content: start;
}
body.world-zamek .rd-row:not(.rd-row--pile) img { width: 26px; height: 26px; }
@media (orientation: portrait) {
  body.world-zamek .rd-row:not(.rd-row--pile) { grid-template-columns: repeat(10, 24px); }
  body.world-zamek .rd-row:not(.rd-row--pile) img { width: 24px; height: 24px; }
}
@media (orientation: portrait) {
  body.world-zamek .rd-row:not(.rd-row--pile) { grid-template-columns: repeat(10, 20px); }
  body.world-zamek .rd-row:not(.rd-row--pile) img { width: 20px; height: 20px; }
  body.world-zamek .pr-field--tower { padding-bottom: 72px !important; }
}

/* (g) wardrobe category tabs: 4 equal columns, never overflow */
body.world-zamek .wd-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s1); overflow: visible; margin-top: var(--s1); }
body.world-zamek .wd-cat {
  min-width: 0; padding: 4px 4px; gap: 4px; justify-content: center; white-space: normal; text-align: left;
  line-height: 1.05; font-size: .68rem; min-height: 36px; transition: transform .25s var(--spring), filter .2s;
}
body.world-zamek .wd-cat span { overflow-wrap: anywhere; }
body.world-zamek .wd-cat img { width: 20px; height: 20px; flex: none; }
body.world-zamek .wd-cat:active { transform: scale(.94); }
@media (orientation: portrait) {
  body.world-zamek .wd-cat { flex-direction: column; text-align: center; min-height: 48px; font-size: .66rem; }
}

/* ==========================================================================
   v17b — NO NARRATOR: speaker/replay buttons hidden, pet speech-bubble
   captions, and a visual "touch here" coach on the first step.
   ========================================================================== */
.no-lektor .castle-speak, .no-lektor [data-act="speak"], .no-lektor .pr-speak, .no-lektor [data-tog="voice"] { display: none !important; }

.v17-cap {
  position: fixed; z-index: 90; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px);
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 20px 14px;
  border-radius: 20px; background: linear-gradient(180deg, #FFFDF4, #FFF3D1);
  border: 2px solid #E9C779; box-shadow: var(--shadow-soft, 0 8px 24px rgba(74,31,92,.18));
  color: #4A1F5C; font: 800 1.05rem/1.3 inherit; text-align: center; pointer-events: none;
  transform: translate(-50%, -12px) scale(.96); opacity: 0;
  transition: opacity .25s var(--ease-out, ease-out), transform .45s var(--spring, cubic-bezier(.34,1.56,.64,1));
}
.v17-cap b { display: block; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: #8E5BB0; margin-bottom: 2px; }
.v17-cap::after {
  content: ""; position: absolute; left: 50%; top: -9px; width: 16px; height: 16px; margin-left: -8px;
  background: #FFFDF4; border-left: 2px solid #E9C779; border-top: 2px solid #E9C779; transform: rotate(45deg);
}
.v17-cap.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
@media (orientation: portrait) { .v17-cap { top: calc(env(safe-area-inset-top, 0px) + 80px); font-size: 1.1rem; } }

/* coach hand */
.v17-coach { position: fixed; z-index: 80; width: 0; height: 0; pointer-events: none; --rot: 0deg; }
/* v17b: the hand sits beside/under its target and taps TOWARD it (fingertip leads; never over text) */
.v17-coach-hand {
  position: absolute; left: -26px; top: -30px; width: 52px; height: 60px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 60'%3E%3Cpath d='M18 4c3 0 5 2 5 5v17l2-1c3-1 5 0 6 2 2-1 5-1 6 2 2-1 5 0 6 3v11c0 9-6 15-15 15h-3c-6 0-10-3-13-8L4 35c-2-3 0-6 3-6 2 0 3 1 5 3l1 2V9c0-3 2-5 5-5z' fill='%23FFF6E8' stroke='%235A2370' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M23 26v9M31 28v7M37 31v5' stroke='%235A2370' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
  filter: drop-shadow(0 6px 8px rgba(74, 31, 92, .3));
  transform: rotate(var(--rot)); animation: v17Tap 1.4s var(--ease-out, ease-out) infinite;
}
.v17-coach-lab {
  position: absolute; white-space: nowrap; padding: 4px 12px; border-radius: 999px;
  background: #5A2370; color: #FFF3D1; font: 800 .85rem/1.2 inherit; box-shadow: 0 4px 12px rgba(74,31,92,.3);
  animation: v17In .5s var(--spring, ease-out) both;
}
.v17-coach.is-right .v17-coach-lab, .v17-coach.is-left .v17-coach-lab { left: -48px; top: 28px; }
.v17-coach.is-below .v17-coach-lab, .v17-coach.is-above .v17-coach-lab { left: 30px; top: -13px; }
@keyframes v17Tap {
  0%, 100% { transform: rotate(var(--rot)) translateY(12px); }
  45% { transform: rotate(var(--rot)) translateY(-2px) scale(.94); }
  60% { transform: rotate(var(--rot)) translateY(1px); }
}
@keyframes v17Ring { 0% { transform: scale(.6); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
.v17-glow { filter: drop-shadow(0 0 10px rgba(255, 206, 80, .95)) brightness(1.04); transition: filter .3s ease-out; }
@media (prefers-reduced-motion: reduce) { .v17-coach-hand { animation: none; } }
