/* Мурко і чарівний мішок: карта світу, літери, сніг, напис місця, кодовий замок, кросворд,
   записки ельфа, нонограма, судоку, шифр. Загальні стилі — у engine/engine.css. */
#stage { background: #0a1626; }
:root { --walnut: #6e4524; --walnut-d: #43290f; --parch: #fbf4e4; --parch2: #f2e3c3; --gold: #e9a93b; --gold-l: #ffe39a; --holly: #b4322a; --pine: #2e7a4e; }

/* ---------- сніг і напис місця ---------- */
#snow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; transition: opacity .8s; }
#snow.off { opacity: 0; }
#snow i { position: absolute; top: -12px; border-radius: 50%; background: #fff; animation: fall linear infinite; }
@keyframes fall { to { transform: translate3d(40px, 940px, 0); } }
#loc { position: absolute; z-index: 9; left: 30px; top: 24px; padding: 8px 26px 10px 22px; border-radius: 18px; border: 4px solid var(--walnut-d);
  background: rgba(251,244,228,.94); color: var(--walnut-d); font-size: 30px; font-weight: 800; box-shadow: 0 6px 0 rgba(67,41,15,.35); display: none; }
#loc.on { display: block; animation: pop .3s; }
#loc::before { content: '📍 '; }

/* ---------- комета в пролозі ---------- */
.comet { position: absolute; z-index: 3; top: 90px; left: -320px; width: 320px; height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, transparent, rgba(255,240,200,.95)); box-shadow: 0 0 16px rgba(255,227,154,.9);
  transform: rotate(14deg); animation: comet 2.6s ease-in forwards; }
.comet::after { content: ""; position: absolute; right: -12px; top: -9px; width: 24px; height: 24px; border-radius: 50%; background: #fffbe8; box-shadow: 0 0 26px 10px rgba(255,227,154,.85); }
@keyframes comet { 0% { transform: translate(0,0) rotate(14deg); opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(2200px,420px) rotate(14deg); opacity: 0; } }

/* ---------- карта світу ---------- */
#wmap { background: radial-gradient(ellipse at center, #1b3555, #0a1626 75%); z-index: 35; }
#wmap .mapbox { position: absolute; left: 0; top: 14px; width: 1600px; height: 872px; }
#wmap .mapbox > img { width: 100%; height: 100%; display: block; }
#wmap svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.seg-u { fill: none; stroke: rgba(43,27,10,.5); stroke-width: 8; stroke-linecap: round; }
.seg { fill: none; stroke: var(--parch); stroke-width: 3.5; stroke-dasharray: 1 10; stroke-linecap: round; }
.seg.done { stroke: var(--gold); stroke-dasharray: none; stroke-width: 5; }
.pt { position: absolute; z-index: 2; transform: translate(-50%, -25px); display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: none; cursor: default; font-family: inherit; }
.pt.side { flex-direction: row; transform: translate(-25px, -50%); }
.pt.side b { margin: 0 0 0 8px; }
.pt i { position: relative; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; font: 900 21px/1 "Nunito", sans-serif; font-style: normal; color: var(--walnut-d);
  background: radial-gradient(circle at 35% 30%, #fffaf0, #e3cd9c); border: 3px solid var(--walnut); box-shadow: 0 3px 0 var(--walnut-d), 0 7px 12px rgba(0,0,0,.4); }
.pt b { margin-top: 8px; padding: 3px 12px 5px; border-radius: 8px; background: var(--parch); color: var(--walnut-d); border: 2px solid var(--walnut); font-size: 19px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pt.lock i { background: radial-gradient(circle at 35% 30%, #ece4d4, #b9ab90); color: #6d5f4a; border-color: #6d5f4a; }
.pt.done i { background: radial-gradient(circle at 35% 30%, #6fc08f, var(--pine)); border-color: #1d5434; color: #fff; }
.pt.cur { cursor: pointer; }
.pt.cur i { background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold)); border-color: #8a5a14; box-shadow: 0 3px 0 #8a5a14, 0 0 22px rgba(255,214,120,.8); }
.pt.cur i::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--gold-l); animation: ring 1.7s ease-out infinite; }
@keyframes ring { from { transform: scale(.75); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
#wmap .mk { position: absolute; z-index: 3; width: 84px; transform: translate(calc(-100% - 14px), calc(-100% + 24px)); transition: transform .4s ease; pointer-events: none; }
#wmap .mk.walk { transform: translate(-50%, calc(-100% - 4px)); }
#wmap .mk img { width: 100%; display: block; filter: drop-shadow(0 6px 4px rgba(0,0,0,.45)); }
#wmap .mk.walk img { animation: bob .42s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-9px) rotate(3deg); } }
#wmap .hud { position: absolute; z-index: 4; left: 24px; top: 24px; display: flex; align-items: center; gap: 22px; padding: 8px 22px 8px 24px; border-radius: 18px;
  background: linear-gradient(#5d3a1c, #3b230d); border: 3px solid var(--gold); box-shadow: 0 6px 14px rgba(0,0,0,.45); }
#wmap .hud > b { font-size: 28px; color: var(--parch); }
.tags { display: flex; gap: 8px; }
.tag { position: relative; width: 38px; height: 48px; padding-top: 10px; border-radius: 6px 6px 9px 9px; display: grid; place-items: center; font-size: 26px; font-weight: 900; color: transparent; border: 2px dashed rgba(251,244,228,.4); }
.tag::before { content: ""; position: absolute; top: 5px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; border: 2px solid rgba(251,244,228,.4); }
.tag.on { background: var(--parch); border: 2px solid var(--gold); color: var(--holly); box-shadow: 0 2px 0 var(--walnut-d); }
#wmap .go { position: absolute; z-index: 5; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 7px 26px 7px 7px; border-radius: 50px;
  border: 3px solid var(--walnut); background: var(--parch); color: var(--walnut); box-shadow: 0 8px 22px rgba(0,0,0,.45); cursor: pointer; font: 900 30px "Nunito", sans-serif; }
#wmap .go img { width: 70px; height: 70px; object-fit: contain; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #2f5582, #132945); padding: 4px; }
#wmap .go span { display: flex; flex-direction: column; align-items: flex-start; font-size: 17px; font-weight: 800; color: #7d654a; text-align: left; }
#wmap .go span b { font-size: 28px; color: var(--walnut-d); }

/* ---------- нагорода: літера ---------- */
#reward { z-index: 36; }
#reward .panel { width: 820px; padding: 40px 50px 44px; text-align: center; background: var(--parch); color: #2c1e12; border: 6px solid var(--walnut-d); animation: pop .35s; }
#reward .rt { font-size: 32px; font-weight: 700; line-height: 1.4; margin: 0 0 26px; }
#reward .rt b { color: var(--holly); }
#reward .rt .souv { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; padding: 10px 16px; border-radius: 16px; background: var(--parch2); font-size: 26px; font-weight: 700; color: var(--walnut-d); }
#reward .rt .souv img { width: 72px; height: 72px; object-fit: contain; }
.bigtag, .wordrow span { position: relative; display: grid; place-items: center; margin: 0 auto 24px; width: 120px; height: 150px; padding-top: 22px; border-radius: 10px 10px 16px 16px; background: #fff;
  border: 4px solid var(--gold); box-shadow: 0 7px 0 var(--walnut); font-size: 84px; font-weight: 900; color: var(--holly); transform-origin: 50% 0; animation: swing 1.6s ease-in-out; }
.bigtag::before, .wordrow span::before { content: ""; position: absolute; top: 12px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: var(--parch2); border: 3px solid var(--walnut); }
@keyframes swing { 0% { transform: rotate(-14deg) scale(.6); opacity: 0; } 30% { transform: rotate(9deg); opacity: 1; } 55% { transform: rotate(-5deg); } 80% { transform: rotate(2deg); } 100% { transform: none; } }
.wordrow { display: flex; justify-content: center; gap: 14px; margin: 22px 0 26px; }
.wordrow span { margin: 0; width: 92px; height: 118px; padding-top: 18px; font-size: 64px; animation-fill-mode: both; }
.wordrow span::before { top: 9px; width: 14px; height: 14px; margin-left: -7px; }

/* ---------- кодовий замок ---------- */
.lockgame { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.lockgame .prob { display: flex; align-items: center; gap: 24px; max-width: 1150px; padding: 20px 26px; border-radius: 20px; background: rgba(255,255,255,.07); }
.lockgame .prob p { margin: 0; font-size: 31px; line-height: 1.4; }
.dg { flex: none; width: 92px; height: 92px; padding: 0; border: 3px solid rgba(160,200,255,.6); border-radius: 18px; background: #fff; text-align: center;
  font: 900 46px "Nunito", sans-serif; color: #0b1030; -webkit-appearance: none; appearance: none; }
.dg.ok { border-color: #2fbf71; background: #dff7e9; } .dg.no { border-color: #e65656; background: #ffe3e3; }
.lockbox { display: flex; align-items: flex-end; gap: 22px; }
.padlock { width: 96px; height: 108px; }
.shackle { transition: transform .6s cubic-bezier(.3,1.6,.5,1); transform-origin: 46px 32px; transform-box: view-box; }
.lockbox.open .shackle { transform: translateY(-6px) rotate(30deg); }
.wheels { display: flex; gap: 10px; padding: 10px; border-radius: 16px; background: #3b230d; }
.wheels span { width: 66px; height: 84px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(#2a1808, #7a4f28 50%, #2a1808); color: var(--gold-l); font-size: 44px; font-weight: 900; box-shadow: inset 0 2px 5px rgba(0,0,0,.6); }
.wheels span.cur { outline: 4px solid #ffcf4a; outline-offset: 2px; }
.lockbox.open .wheels span { background: linear-gradient(#174a2c, #3b9a64 50%, #174a2c); color: #fff; outline: none; }
.lockcap { font-size: 24px; color: #cfe0ff; }
.lockcap b { color: #ffcf4a; }

/* ---------- кросворд ---------- */
.cw-grid { --s: 42px; display: flex; flex-direction: column; gap: 4px; max-width: 1180px; margin: 0 auto; width: 100%; }
.cw-grid > div { display: grid; grid-template-columns: 1fr calc((var(--s) + 3px) * var(--cols)); align-items: center; gap: 24px; padding: 3px 12px; border-radius: 12px; }
.cw-grid > div:nth-child(odd) { background: rgba(255,255,255,.05); }
.cw-grid .clue { display: flex; align-items: center; gap: 10px; font-size: 23px; line-height: 1.25; }
.cw-grid .clue em { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #5fb3ff; color: #0b1030; font-size: 16px; font-weight: 900; font-style: normal; }
.cells { display: flex; gap: 3px; }
.cells input { width: var(--s); height: calc(var(--s) + 2px); padding: 0; border: 2px solid #bd9f68; border-radius: 8px; background: #fff; text-align: center;
  font: 900 24px "Nunito", sans-serif; text-transform: uppercase; color: #2c1e12; caret-color: var(--holly); -webkit-appearance: none; appearance: none; }
.cells input.k { background: var(--gold-l); border-color: #c98a1c; }
.cells input:focus { outline: none; border-color: #5fb3ff; box-shadow: 0 0 0 3px rgba(95,179,255,.45); }
.cells input.ok { background: #dff7e9; border-color: #2fbf71; } .cells input.no { background: #ffe3e3; border-color: #e65656; }

/* ---------- записки ельфа ---------- */
.logic { display: grid; grid-template-columns: 420px 1fr; gap: 30px; align-items: start; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: n; }
.notes li { position: relative; padding: 12px 14px 13px 54px; border-radius: 4px 16px 16px 4px; background: #fffbea; color: #2c1e12; font-size: 23px; font-weight: 700; line-height: 1.3; box-shadow: 2px 3px 0 rgba(110,69,36,.25); }
.notes li::before { counter-increment: n; content: counter(n); position: absolute; left: 13px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--walnut-d); font: 900 15px/28px "Nunito", sans-serif; text-align: center; }
.kids { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kid { padding: 10px 12px 12px; border-radius: 16px; background: rgba(255,255,255,.07); border: 3px solid rgba(160,200,255,.35); }
.kid > b { display: block; margin: 0 0 8px 4px; font-size: 26px; }
.kid.ok { border-color: #7be0a2; background: rgba(123,224,162,.18); } .kid.no { border-color: #ff8f8f; background: rgba(255,120,120,.18); }
.gifts { display: flex; gap: 6px; }
.gb { flex: 1; min-width: 0; padding: 8px 2px 9px; border: 2px solid var(--parch2); border-radius: 12px; background: var(--parch); font: 800 15px "Nunito", sans-serif; color: #2c1e12; cursor: pointer; }
.gb i { display: block; font-style: normal; } .gb i svg { display: block; width: 44px; height: 44px; margin: 0 auto 3px; }
.gb.sel { background: var(--gold-l); border-color: #c98a1c; box-shadow: inset 0 0 0 2px #c98a1c; }

/* ---------- нонограма ---------- */
.ngwrap { display: flex; gap: 40px; align-items: center; justify-content: center; }
.ngwrap .side { width: 380px; display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.segc { display: inline-flex; gap: 4px; padding: 5px; border-radius: 16px; background: rgba(255,255,255,.1); }
.segc button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 12px; background: transparent; color: #fff; font: 800 21px "Nunito", sans-serif; cursor: pointer; }
.segc button.on { background: #fff; color: #0b1030; }
.segc .sw { width: 18px; height: 18px; border-radius: 3px; background: #0b1030; border: 2px solid #fff; }
.segc .segx { font-style: normal; color: #a08a68; }
.hintb { padding: 10px 18px; border: 2px solid var(--gold); border-radius: 14px; background: rgba(255,227,154,.12); color: var(--gold-l); font: 800 21px "Nunito", sans-serif; cursor: pointer; }
.hintb:disabled { opacity: .45; cursor: default; }
.ngmsg { font-size: 22px; line-height: 1.35; color: #ffe39a; min-height: 60px; }
.ng { --cs: 74px; display: grid; width: max-content; touch-action: none; }
.nc { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px; font-size: 26px; font-weight: 900; color: #ffe9a8; line-height: 1.1; }
.nr { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding-right: 12px; font-size: 26px; font-weight: 900; color: #ffe9a8; }
.gc { width: var(--cs); height: var(--cs); display: grid; place-items: center; border: 1px solid #cdb27c; background: #fff; cursor: pointer; touch-action: none; }
.gc.t { border-top: 3px solid var(--walnut-d); } .gc.l { border-left: 3px solid var(--walnut-d); } .gc.r { border-right: 3px solid var(--walnut-d); } .gc.b { border-bottom: 3px solid var(--walnut-d); }
.gc.f { background: #2c1e12; }
.gc.m::after { content: "✕"; font: 900 32px/1 "Nunito", sans-serif; color: #a99271; }
.gc.f.ok { background: var(--pine); } .gc.f.no { background: var(--holly); } .gc.f.win { background: var(--gold); }
.gc.hint { box-shadow: inset 0 0 0 5px var(--gold); }

/* ---------- судоку ---------- */
.sdwrap { display: flex; gap: 50px; align-items: center; justify-content: center; }
.sd { display: grid; grid-template-columns: repeat(4, 104px); border: 4px solid var(--walnut-d); border-radius: 14px; overflow: hidden; }
.sc { width: 104px; height: 104px; display: grid; place-items: center; border: 1px solid #d6bf8f; background: #fff; font-size: 52px; font-weight: 900; color: #2a5db0; cursor: pointer; }
.sc.g { background: var(--parch2); color: var(--walnut-d); cursor: default; }
.sc.sel { background: var(--gold-l); box-shadow: inset 0 0 0 4px var(--gold); }
.sc.ok { background: #dff7e9; } .sc.no { background: #ffe3e3; }
.sc.r2 { border-right: 4px solid var(--walnut-d); } .sc.b2 { border-bottom: 4px solid var(--walnut-d); }
.kp { display: grid; grid-template-columns: repeat(2, 96px); gap: 14px; }
.kp button { width: 96px; height: 96px; border: 3px solid var(--walnut); border-radius: 18px; background: #fff; color: var(--walnut-d); font: 900 40px "Nunito", sans-serif; cursor: pointer; box-shadow: 0 4px 0 var(--walnut); }
.kp button:last-child { grid-column: span 2; width: auto; }
.kp button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--walnut); }

/* ---------- крижаний шифр ---------- */
.cipher { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.cipher .key { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 14px 18px; border-radius: 18px; border: 3px solid #a9c6e0; background: linear-gradient(#eef6fc, #d3e6f5); }
.cipher .key span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 12px; background: #fff; font-size: 26px; font-weight: 900; color: #10223a; box-shadow: 0 2px 0 #a9c6e0; }
.cipher .key b { font-size: 30px; color: var(--holly); }
.cipher .ex { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; }
.cipher .ex label { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 18px; border-radius: 16px; background: rgba(255,255,255,.08); font-size: 30px; font-weight: 800; white-space: nowrap; }
.cipher .ex small { font-size: 18px; color: #9fb6e8; margin-right: 6px; }
.cipher .ex .dg { width: 110px; height: 64px; font-size: 32px; }
.cipher .word { display: flex; gap: 10px; }
.cipher .word span { width: 64px; height: 76px; border-radius: 12px; display: grid; place-items: center; border: 3px solid #a9c6e0; background: #e3eff9; color: #9ab3c9; font-size: 42px; font-weight: 900; }
.cipher .word span.on { background: #fff; color: var(--holly); border-color: var(--holly); animation: pop .5s; }

/* фінальна картка: слово з літер */
#endcard .t2 .wordrow { margin: 28px 0; }
