/* v20 — matma na wynos: premium polish */

/* SYPIALNIA: bed + sleeping hero rendered into the room art, pixel-aligned overlay (fade only, no transform) */
.bed20 { position: absolute; z-index: 3; display: none; height: auto; pointer-events: none; user-select: none; opacity: 0; transition: opacity .9s ease .2s, filter 1s ease; }
.bed-art .bed20--L { display: block; }
.is-asleep .bed20 { opacity: 1; filter: brightness(.8) saturate(.9); }
.bed20--L.bed20--smok { left: 44.844%; top: 48.611%; width: 33.594%; }
.bed20--L.bed20--ksiezniczka { left: 41.875%; top: 49.444%; width: 36.641%; }
.bed20--L.bed20--chlopiec { left: 42.422%; top: 48.889%; width: 36.25%; }
@media (orientation: portrait) {
  .bed-art .bed20--L { display: none; }
  .bed-art .bed20--P { display: block; }
  .bed20--P.bed20--smok { left: 19.167%; top: 46.953%; width: 67.083%; }
  .bed20--P.bed20--ksiezniczka { left: 19.306%; top: 52.578%; width: 66.111%; }
  .bed20--P.bed20--chlopiec { left: 19.306%; top: 52.578%; width: 64.167%; }
}

/* WRÓĆ — one fixed spot & size on every screen (bottom-right corner, which every room layout already keeps free):
   plain painted arrow, no box; label on a small castle plate for contrast */
.castle-back, .castle-back.kitchen-back, .castle-back.bathroom-back, .castle-back.bedroom-back,
.castle-back.wardrobe-back, .castle-back.playroom-back {
  position: fixed !important; z-index: 70;
  right: max(10px, env(safe-area-inset-right, 0px)) !important; bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
  left: auto !important; top: auto !important; margin: 0 !important; transform: none;
  width: 74px !important; min-width: 74px !important; height: 70px !important; min-height: 70px !important; max-width: none;
  padding: 0 !important; gap: 2px !important; justify-content: flex-end !important; align-items: center !important;
  background: none !important; border: 0 !important; box-shadow: none !important; border-radius: 0;
}
.castle-back:active { transform: translateY(3px) scale(.95); }
.castle-back .castle-back-arrow { width: 54px !important; height: 42px !important; }
.castle-back .castle-back-lab {
  font-size: .76rem !important; font-weight: 800; line-height: 1; letter-spacing: .03em; color: #3E1650 !important;
  padding: 3px 9px 4px !important; margin: 0 !important; border-radius: 8px;
  background: linear-gradient(#FFFBF1, #F4E3BF) !important; border: 1.5px solid #C9A14A !important;
  box-shadow: 0 1px 0 rgba(110, 74, 22, .35), 0 3px 6px rgba(58, 18, 72, .18) !important; text-shadow: none !important;
}

/* TOP BAR: bigger castle home, labelled "Zamek" */
.topbar--solid .tb-home-castle { width: auto !important; min-width: 52px; height: auto !important; min-height: 50px; padding: 0 2px; }
.topbar--solid .tb-home-castle img { height: 44px !important; width: auto; }
.topbar--solid .tb-home-lab { font-size: .7rem; margin-top: -3px; color: #3E1650; letter-spacing: .04em; }
@media (max-height: 420px), (max-width: 420px) {
  .topbar--solid .tb-home-castle img { height: 38px !important; }
  .topbar--solid .tb-home-lab { font-size: .64rem; }
}
/* the in-flow slot keeps each room's old layout space; the button itself sits fixed in the corner */
.castle-back-slot { display: block; flex: none; width: 74px; height: 70px; pointer-events: none; visibility: hidden; justify-self: end; align-self: end; }
.castle-back-slot--bedroom-back { grid-area: back; }
.castle-back-slot--wardrobe-back { grid-area: back; }
.castle-back-slot--bathroom-back, .castle-back-slot--playroom-back { display: none; }

/* ŁAZIENKA: one evenly spaced tool row, centred at the bottom (all orientations); Wróć keeps its own corner */
.bt16 .bt-tray { left: 50% !important; right: auto !important; top: auto !important; bottom: 10px !important; transform: translateX(-50%) !important;
  grid-template-columns: repeat(4, 1fr) !important; gap: .4rem !important; padding: .4rem !important; justify-items: center; }
.bt16 .bt-tool { width: 84px; }
.bt16 .bt-pet-zone { bottom: 112px !important; }
.bt16 .bathroom-pet { height: min(40vh, 230px) !important; }
.bt16 .bt-duck { right: 17% !important; left: auto !important; bottom: 118px !important; }
.bt16 .bt-brush { right: 9% !important; left: auto !important; bottom: auto !important; top: 47% !important; }
@media (orientation: landscape) and (max-height: 500px) {
  .bt16 .bt-tray { bottom: 6px !important; gap: .3rem !important; padding: .3rem !important; }
  .bt16 .bt-tool { width: 74px; }
  .bt16 .bt-pet-zone { bottom: 92px !important; }
  .bt16 .bathroom-pet { height: min(40vh, 150px) !important; }
  .bt16 .bt-duck { right: 21% !important; bottom: 14px !important; }
  .bt16 .bt-brush { right: 8.5% !important; top: 40% !important; }
}
@media (orientation: portrait) {
  .bt16 .bt-tray { bottom: 86px !important; gap: .3rem !important; padding: .35rem !important; }
  .bt16 .bt-tool { width: 78px; }
  .bt16 .bt-pet-zone { bottom: 190px !important; }
  .bt16 .bathroom-pet { height: min(28vh, 220px) !important; }
  .bt16 .bt-duck { right: 7% !important; bottom: 196px !important; }
  .bt16 .bt-brush { left: 6% !important; right: auto !important; top: auto !important; bottom: 200px !important; }
  .bt16 .bt-hint { left: 10px !important; right: 92px !important; width: auto !important; max-width: none !important; transform: none !important; bottom: 18px !important; }
}

/* v20: zzz rise right above the sleeping hero's head */
.bedroom15 .bed-zzz { left: 66%; top: 46%; width: 12%; height: 8%; }
@media (orientation: portrait) {
  .bedroom15 .bed-zzz { left: 62%; top: 50%; width: 20%; height: 5%; }
  /* bottom hint never runs under the Wróć corner */
  body.world-zamek .bedroom-screen .bedroom-hint { margin: 0 92px .3rem 12px !important; align-self: stretch; }
}
/* bathroom: while the coach hand shows the first step, the step pill (same words as the bubble) steps aside */
body:has(.v17-coach) .bt16 .bt-hint { visibility: hidden; }

/* HUB: hero on the path before the gate — soft contact shadow only (no disc, no pedestal) */
.hub-screen .hub-pet { position: relative; }
.hub-screen .hub-pet .pet-sprite { position: relative; }
.hub-screen .hub-pet .pet-sprite::after {
  content: ""; position: absolute; left: 30%; right: 30%; bottom: 5%; height: 7%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(52, 30, 40, .30), rgba(52, 30, 40, .12) 60%, rgba(52, 30, 40, 0));
  filter: blur(3px);
}
.hub-screen .hub-pet-name { position: relative; margin: -8% auto 0; z-index: 2; }
/* portrait/tablet: centre the gate in the picture so the hero can stand in front of it */
@media (orientation: portrait) { body:has(.hub-screen) .sky { background-position: 59% 100% !important; } }
/* phone landscape: Misje board moves left of "Baw się" so the gate stays free for the hero */
@media (orientation: landscape) and (max-height: 500px) {
  body.world-zamek .hub-screen .hub-board { left: calc(50% - 222px); bottom: 26px; }
}
.v17-cap.is-near::after { display: none; }
.v17-cap.is-near { max-width: min(300px, 80vw); }
/* shop: the pantry note spans the whole row (was squeezed into the first tab cell) */
body.world-zamek .wd-cats .wd-cats-note { grid-column: 1 / -1; margin: 0 0 .2rem; line-height: 1.25; }
/* play (lesson path): the buddy hero sits in the free bottom-left corner of the board, never on the answers */
@media (orientation: landscape) {
  body:has(.play-area) #mascot-buddy { left: max(26px, calc(50% - 468px + 18px)) !important; right: auto !important; bottom: 18px !important; transform-origin: bottom left; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body:has(.play-area) #mascot-buddy { left: 22px !important; bottom: 16px !important; transform: scale(.66); }
}

/* ==========================================================================
   v20 — castle restyle: Mapa królestwa · story · success (parchment + gold, plum/gold buttons)
   ========================================================================== */
body.world-zamek .map-wrap > .card,
body.world-zamek .story-screen > .card,
body.world-zamek .success-screen > .card {
  background: linear-gradient(180deg, rgba(255,251,241,.97) 0%, rgba(245,230,198,.97) 100%);
  border: 3px solid #C99A3C;
  border-radius: 22px;
  box-shadow: 0 6px 0 #8E6420, 0 14px 30px rgba(74,31,92,.28), inset 0 0 0 3px #FFF6DE;
  color: #4A1F5C;
}
body.world-zamek .map-wrap h2,
body.world-zamek .story-screen h2,
body.world-zamek .success-screen h1 { color: #5A2370; text-shadow: 0 1px 0 #fff; }
body.world-zamek .map-wrap .muted,
body.world-zamek .success-screen p { color: #6B4A2A; }
body.world-zamek .success-screen .lead { color: #4A1F5C; }
body.world-zamek .map-wrap .hero-name,
body.world-zamek .story-screen .hero-name,
body.world-zamek .success-screen .hero-name {
  background: linear-gradient(180deg, #8E4FC0 0%, #5A2370 100%);
  border: 2px solid #E9C46A; border-radius: 10px; color: #FFF3D6;
  box-shadow: 0 3px 0 #3A1248; text-shadow: 0 1px 0 rgba(40,10,50,.5);
}
/* story scroll bubble */
body.world-zamek .story-screen .story-bubble {
  background: linear-gradient(180deg, #FFFDF6, #F8EBCF);
  border: 3px solid #C99A3C; border-radius: 16px;
  box-shadow: 0 4px 0 #8E6420, inset 0 0 0 2px #FFF6DE;
  color: #3E2A1A;
}
body.world-zamek .story-screen .story-bubble::after { display: none; }
body.world-zamek .story-screen .story-bubble .who { color: #7A2E9A; }
/* buttons: gold primary, plum secondary, parchment ghost */
body.world-zamek :is(.story-screen, .success-screen) .btn.primary {
  background: linear-gradient(180deg, #FFE48A 0%, #F2C04A 55%, #D99A1E 100%);
  border: 2px solid #FFF1BE; color: #4A1F5C; text-shadow: 0 1px 0 rgba(255,255,255,.5);
  box-shadow: 0 6px 0 #8E6420, 0 10px 16px rgba(74,31,92,.22), inset 0 2px 0 rgba(255,255,255,.5);
}
body.world-zamek :is(.story-screen, .success-screen) .btn.alt {
  background: linear-gradient(180deg, #A465D6 0%, #6B2E8A 58%, #521E6C 100%);
  border: 2px solid #E9C46A; color: #FFF3D6;
  box-shadow: 0 6px 0 #3A1248, 0 10px 16px rgba(58,18,72,.25), inset 0 2px 0 rgba(255,255,255,.3);
}
body.world-zamek :is(.story-screen, .success-screen) .btn.ghost {
  background: linear-gradient(180deg, #FFFBF1, #F3E2BF);
  border: 3px solid #C99A3C; color: #5A2370;
  box-shadow: 0 5px 0 #8E6420;
}
/* map level plaques */
body.world-zamek .map-path::before { background: repeating-linear-gradient(180deg, #E9C46A 0 12px, #C99A3C 12px 24px); opacity: .7; }
body.world-zamek .level-node {
  background: linear-gradient(180deg, #FFFBF1 0%, #F3E2BF 100%);
  border: 3px solid #C99A3C; border-radius: 18px;
  box-shadow: 0 5px 0 #8E6420, 0 10px 16px rgba(74,31,92,.18), inset 0 0 0 2px #FFF6DE;
}
body.world-zamek .level-node.open {
  border-color: #E9B23C; animation: none;
  box-shadow: 0 0 0 3px rgba(233,196,106,.55), 0 5px 0 #8E6420, 0 10px 18px rgba(74,31,92,.22);
  background: linear-gradient(180deg, #FFFCEB 0%, #F5DF9F 100%);
}
body.world-zamek .level-node.done { background: linear-gradient(180deg, #FBFFF1, #E3EEC4); border-color: #9DB25A; box-shadow: 0 5px 0 #6E7F2E; }
body.world-zamek .level-node.locked { background: #EEE7DA; border-color: #BFAF95; box-shadow: 0 5px 0 #9C8C72; }
body.world-zamek .level-node .emoji {
  border-radius: 14px; border: 2px solid #C99A3C;
  background: linear-gradient(180deg, #FFF6DE, #EED9A8);
  box-shadow: 0 3px 0 #8E6420, inset 0 0 0 2px #FFFBF1;
}
body.world-zamek .level-node.open .emoji { background: linear-gradient(180deg, #FFE48A, #F2C04A); box-shadow: 0 3px 0 #8E6420; }
body.world-zamek .level-node.done .emoji { background: linear-gradient(180deg, #F1F8D6, #CFE09A); }
body.world-zamek .level-node .info strong { color: #4A1F5C; }
body.world-zamek .level-node .info span { color: #6B4A2A; }
body.world-zamek .level-node .badge {
  background: linear-gradient(180deg, #A465D6, #5A2370); color: #FFF3D6;
  border: 2px solid #E9C46A; border-radius: 10px; box-shadow: 0 2px 0 #3A1248;
}
body.world-zamek .level-node.open .badge { background: linear-gradient(180deg, #FFE48A, #D99A1E); color: #4A1F5C; box-shadow: 0 2px 0 #8E6420; }
body.world-zamek .level-node.done .badge { background: linear-gradient(180deg, #9DB25A, #6E7F2E); color: #fff; }
body.world-zamek .level-node.locked .badge { background: #D8CDB8; color: #6B5A40; border-color: #BFAF95; box-shadow: 0 2px 0 #9C8C72; }

/* landscape: compact map header (hero beside the title) and side-by-side story/success */
body.world-zamek .level-node.locked { opacity: .86; }
@media (orientation: landscape) {
  body.world-zamek .map-wrap > .card { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 1rem; text-align: left; padding: .45rem 1rem !important; }
  body.world-zamek .map-wrap > .card .hero-art { grid-row: 1 / span 2; min-height: 0; }
  body.world-zamek .map-wrap > .card .hero-art .hero-img { height: 78px; }
  body.world-zamek .map-wrap > .card h2 { align-self: end; margin: 0; }
  body.world-zamek .map-wrap > .card .muted { align-self: start; }
  body.world-zamek .map-path { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; }
  body.world-zamek .map-path::before { display: none; }
  body.world-zamek .level-node { min-height: 64px; padding: .45rem .7rem; }
  body.world-zamek .level-node .emoji { width: 46px; height: 46px; font-size: 1.5rem; }
}
@media (orientation: landscape) {
  body.world-zamek :is(.story-screen, .success-screen) > .card {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); column-gap: 1.1rem; align-items: center;
    width: min(860px, 100%); margin: 0 auto;
  }
  body.world-zamek :is(.story-screen, .success-screen) > .card > .hero-art { grid-column: 1; grid-row: 1 / span 9; min-height: 0; margin: 0; }
  body.world-zamek :is(.story-screen, .success-screen) > .card > :not(.hero-art) { grid-column: 2; }
}
@media (orientation: landscape) and (max-height: 560px) {
  body.world-zamek :is(.story-screen, .success-screen) > .card { padding: .5rem 1rem !important; }
  body.world-zamek :is(.story-screen, .success-screen) > .card > .hero-art .hero-img { height: 150px; }
  body.world-zamek .story-screen .story-bubble { margin: .35rem 0 .7rem; font-size: 1rem; padding: .6rem .8rem; }
  body.world-zamek :is(.story-screen, .success-screen) .btn.huge { min-height: 46px; padding: .4rem 1rem; font-size: 1.12rem; }
  body.world-zamek :is(.story-screen, .success-screen) .btn.block { margin: .2rem 0; min-height: 40px; padding: .3rem 1rem; font-size: 1rem; }
  body.world-zamek .success-screen h1 { margin: 0; font-size: 1.4rem; }
  body.world-zamek .success-screen .sticker-big { font-size: 2rem !important; height: auto; width: auto; margin: 0 !important; line-height: 1; }
  body.world-zamek .success-screen .sticker-big svg, body.world-zamek .success-screen .sticker-big img { height: 38px !important; width: auto !important; }
  body.world-zamek .success-screen .stars { margin: 0 !important; font-size: 1.15rem; }
  body.world-zamek .success-screen .stars svg, body.world-zamek .success-screen .stars img { height: 24px !important; width: auto !important; }
  body.world-zamek .success-screen p { margin: .05rem 0; font-size: .95rem; }
}
@media (orientation: landscape) and (max-height: 560px) {
  body.world-zamek .success-screen > .card { padding: .35rem 1rem !important; }
  body.world-zamek .success-screen .lead { font-size: 1rem; margin: .1rem 0; }
}
@media (orientation: portrait) and (max-height: 960px) {
  body.world-zamek .success-screen > .card { padding: .7rem 1rem !important; }
  body.world-zamek .success-screen .sticker-big { font-size: 3.6rem; margin: .1rem 0; }
  body.world-zamek .success-screen .sticker-big :is(svg, img) { height: 64px !important; width: auto !important; }
  body.world-zamek .success-screen .stars { margin: .1rem 0; }
  body.world-zamek .success-screen > .card > .hero-art { min-height: 0; }
  body.world-zamek .success-screen > .card > .hero-art .hero-img { height: 128px; }
  body.world-zamek .success-screen p { margin: .2rem 0; font-size: 1.02rem; }
  body.world-zamek .success-screen .btn.huge { min-height: 58px; padding: .6rem 1rem; }
  body.world-zamek .success-screen .btn.block { margin: .28rem 0; }
}
@media (orientation: landscape) {
  body.world-zamek :is(.story-screen, .success-screen) > .card { align-items: start; align-content: center; row-gap: 0; }
  body.world-zamek :is(.story-screen, .success-screen) > .card > .hero-art { align-self: center; }
  body.world-zamek .success-screen .stars { animation: none; }
}
@media (orientation: landscape) and (max-height: 560px) {
  body.world-zamek .success-screen > .card > .hero-art .hero-img { height: 132px; }
  body.world-zamek .success-screen .btn.block { min-height: 38px; }
}
