@font-face { font-family: 'Nunito'; font-weight: 400 1000; font-display: swap; src: url('fonts/nunito-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Nunito'; font-weight: 400 1000; font-display: swap; src: url('fonts/nunito-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Цвета темы мира: карточки окон, текст на панелях художника, кнопки. */
body {
  --ground: #2a1640; --card: #fff4ec; --cardEdge: #e7b56a; --ink: #4b2142; --muted: #8a5f7c;
  --accent: #d0457a; --accentInk: #fff; --btn: #f6e3d6; --btnInk: #4b2142;
  --lvInk: #5a2448; --goalInk: #4b2142; --movesInk: #fff; --mapTop: rgba(42, 22, 64, .86);
}
body[data-theme="space"] {
  --ground: #0b1430; --card: #13254a; --cardEdge: #3fa8ff; --ink: #eaf3ff; --muted: #9db4d8;
  --accent: #f29b1d; --accentInk: #23130a; --btn: #1e3768; --btnInk: #eaf3ff;
  --lvInk: #eaf3ff; --goalInk: #eaf3ff; --movesInk: #fff2dc; --mapTop: rgba(8, 16, 40, .88);
}
body[data-theme="underwater"] {
  --ground: #06415e; --card: #eafcff; --cardEdge: #5fd3ee; --ink: #0b4560; --muted: #3f7d93;
  --accent: #ffb81c; --accentInk: #4a2b00; --btn: #c9f2fb; --btnInk: #0b4560;
  --lvInk: #0b4560; --goalInk: #0b4560; --movesInk: #5b3300; --mapTop: rgba(4, 52, 76, .86);
}
body[data-theme="military"] {
  --ground: #2c2a1c; --card: #f1e7c9; --cardEdge: #8a7a3e; --ink: #36301d; --muted: #6f6745;
  --accent: #6f8f2a; --accentInk: #fff; --btn: #e2d6ad; --btnInk: #36301d;
  --lvInk: #f4e8c4; --goalInk: #36301d; --movesInk: #fff3dc; --mapTop: rgba(36, 34, 22, .9);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ground); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
img { -webkit-user-drag: none; user-drag: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
#app { position: fixed; inset: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; }
.screen.on { display: flex; flex-direction: column; }
.ib { display: grid; place-items: center; width: 48px; height: 48px; flex: none; transition: transform .12s; }
.ib:active { transform: scale(.92); }
.ib img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- карта уровней ---------- */
#map { background: var(--ground); }
.mapTop { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; background: var(--mapTop); backdrop-filter: blur(6px); color: #fff; }
.mapTop h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 1000; letter-spacing: .2px; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.total { display: flex; align-items: center; gap: 4px; font-size: 13px; color: rgba(255,255,255,.8); }
.total img { width: 26px; height: 26px; }
.total b { font-size: 18px; color: #fff; font-weight: 900; }
.ib.round { width: 42px; height: 42px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 10px; background: var(--mapTop); scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; width: 128px; height: 64px; border-radius: 14px; background-size: cover; background-position: center 35%; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 6px 9px; text-align: left; border: 2px solid rgba(255,255,255,.25); box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.chip b { font-size: 13px; font-weight: 1000; line-height: 1.1; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.chip span { font-size: 11px; font-weight: 800; opacity: .95; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.chip.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35), 0 3px 8px rgba(0,0,0,.35); }
#worlds { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); }
.world { position: relative; padding: 0 0 18px; }
.wHead { position: relative; height: 150px; overflow: hidden; display: flex; align-items: flex-end; padding: 14px 16px; color: #fff; }
.wHead .wbg { position: absolute; inset: 0; background-size: cover; background-position: center 30%; }
.wHead::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.55)); }
.wHead .wtxt { position: relative; z-index: 1; }
.wHead h2 { margin: 0; font-size: 24px; font-weight: 1000; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.wHead p { margin: 2px 0 0; font-size: 14px; font-weight: 700; opacity: .92; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.wHead .guideMini { position: absolute; right: 6px; bottom: -6px; height: 160px; z-index: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.wBody { padding: 14px 10px 4px; }
.lvGrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px 6px; }
.lvBtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lvBtn .coin { position: relative; width: 58px; height: 58px; display: grid; place-items: center; }
.lvBtn .coin img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.lvBtn .coin b { position: relative; font-size: 21px; font-weight: 1000; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 6px rgba(0,0,0,.35); }
.lvBtn .st { display: flex; gap: 1px; height: 15px; }
.lvBtn .st img { width: 15px; height: 15px; }
.lvBtn.lock .coin { filter: grayscale(1) brightness(.75); opacity: .6; }
.lvBtn.lock .coin b { display: none; }
.lvBtn .lockIc { position: relative; width: 22px; height: 22px; color: #fff; display: none; }
.lvBtn.lock .lockIc { display: block; }
.lvBtn.cur .coin { animation: curPulse 1.4s ease-in-out infinite; }
.lvBtn.cur .coin::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 0 12px rgba(255,255,255,.7); }
@keyframes curPulse { 50% { transform: scale(1.08); } }
.soon { margin: 6px 16px 0; text-align: center; color: rgba(255,255,255,.7); font-weight: 700; font-size: 14px; }

/* ---------- экран уровня ---------- */
#game { color: #fff; }
#game .bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
#game > *:not(.bg) { position: relative; z-index: 1; }
.top { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 2px; }
.top .ib { width: 46px; height: 46px; }
.lvPanel { position: relative; flex: 1; height: 46px; display: grid; place-items: center; }
.lvPanel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.lvPanel b { position: relative; font-size: 20px; font-weight: 1000; color: var(--lvInk); letter-spacing: .3px; }
.hud { display: flex; gap: 8px; padding: 4px 10px 0; height: 84px; }
.goals { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; }
.goals > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
#goalList { position: relative; display: flex; align-items: center; justify-content: space-around; width: 100%; padding: 0 12px; }
.goal { display: flex; align-items: center; gap: 4px; }
.goal img { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.goal b { min-width: 26px; font-size: 22px; font-weight: 1000; color: var(--goalInk); }
.goal.done b { color: #2fae4e; }
.goal .ok { width: 24px; height: 24px; color: #2fae4e; display: none; }
.goal.done .ok { display: block; }
.goal.done b { display: none; }
.goal.bump img { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.25); } }
.moves { position: relative; width: 96px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--movesInk); }
.moves > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.moves span { position: relative; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .6px; line-height: 1; }
.moves b { position: relative; font-size: 32px; font-weight: 1000; line-height: 1.05; }
.moves.low b { color: #ffd2cc; animation: lowPulse .9s ease-in-out infinite; }
body[data-theme="underwater"] .moves.low b { color: #b3261e; }
@keyframes lowPulse { 50% { transform: scale(1.12); } }
.prog { position: relative; height: 34px; margin: 4px 22px 0; }
.prog .track { position: absolute; left: 0; right: 0; top: 50%; width: 100%; height: 18px; transform: translateY(-50%); object-fit: fill; }
.fillClip { position: absolute; left: 0; top: 50%; height: 18px; transform: translateY(-50%); width: 0; overflow: hidden; transition: width .35s ease; border-radius: 9px; }
.fillClip img { position: absolute; left: 0; top: 0; height: 100%; object-fit: fill; }
.pst { position: absolute; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); transition: transform .25s; }
.pst.lit { transform: translate(-50%, -50%) scale(1.15); }

.boardArea { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 6px; }
.boardWrap { position: relative; }
.boardWrap .frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.board { position: absolute; touch-action: none; }
#cells, #pieces, #fx { position: absolute; inset: 0; }
#pieces { overflow: hidden; }
#fx { pointer-events: none; z-index: 4; overflow: visible; }
.cell { position: absolute; background-size: 100% 100%; opacity: .92; }
.pc { position: absolute; left: 0; top: 0; display: grid; place-items: center; will-change: transform; transition-property: transform; transition-timing-function: cubic-bezier(.35, .05, .55, 1); }
.pc img { width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0,0,0,.28)); transition: transform .15s; }
.pc.sel img { transform: scale(1.16); filter: drop-shadow(0 0 6px #fff) drop-shadow(0 3px 2px rgba(0,0,0,.28)); }
.pc.born img { animation: born .3s ease-out; }
@keyframes born { from { transform: scale(.2); } 70% { transform: scale(1.2); } }
.pc.pop { z-index: 2; }
.pc.pop img, .pc.pop .orb { animation: pop .24s ease-in forwards; }
@keyframes pop { 30% { transform: scale(1.25); opacity: 1; } to { transform: scale(.1); opacity: 0; } }
.pc.hint img, .pc.hint .orb { animation: wiggle .9s ease-in-out infinite; }
@keyframes wiggle { 20% { transform: rotate(-10deg) scale(1.08); } 40% { transform: rotate(10deg) scale(1.08); } 60% { transform: rotate(-6deg); } 80% { transform: none; } }
/* Особые фишки. Пока художник не нарисовал свои — рисуем поверх обычной. */
.pc.sp-h::after, .pc.sp-v::after { content: ''; position: absolute; inset: 14%; border-radius: 30%; pointer-events: none; mix-blend-mode: screen; animation: shine 1.2s ease-in-out infinite; }
.pc.sp-h::after { background: repeating-linear-gradient(0deg, rgba(255,255,255,.0) 0 18%, rgba(255,255,255,.85) 18% 27%); }
.pc.sp-v::after { background: repeating-linear-gradient(90deg, rgba(255,255,255,.0) 0 18%, rgba(255,255,255,.85) 18% 27%); }
.pc.sp-h::before, .pc.sp-v::before { content: ''; position: absolute; width: 20%; height: 20%; z-index: 1; border: solid #fff; border-width: 3px 3px 0 0; filter: drop-shadow(0 0 3px rgba(0,0,0,.6)); }
.pc.sp-h::before { right: 4%; top: 40%; transform: rotate(45deg); box-shadow: none; }
.pc.sp-v::before { left: 40%; top: 4%; transform: rotate(-45deg); }
@keyframes shine { 50% { opacity: .55; } }
.pc .glow { position: absolute; inset: -4%; width: 108%; height: 108%; object-fit: contain; animation: spin 4s linear infinite; pointer-events: none; }
.pc.sp-b img:not(.glow) { transform: scale(1.04); }
@keyframes spin { to { transform: rotate(360deg); } }
.pc .orb { width: 78%; height: 78%; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #fff 0 18%, rgba(255,255,255,0) 48%), conic-gradient(#ff4d6d, #ffbe0b, #3ddc84, #3a86ff, #b14aed, #ff4d6d); box-shadow: 0 0 10px rgba(255,255,255,.9), inset 0 0 8px rgba(255,255,255,.8); animation: spin 2.4s linear infinite; }

.fxBeam { position: absolute; background: linear-gradient(var(--dir, 90deg), rgba(255,255,255,0), #fff 30%, #fff 70%, rgba(255,255,255,0)); box-shadow: 0 0 16px 6px rgba(255,236,170,.85); border-radius: 999px; animation: beam .34s ease-out forwards; }
.fxBeam.h { transform-origin: var(--ox) 50%; }
.fxBeam.v { transform-origin: 50% var(--oy); }
@keyframes beam { from { opacity: 1; transform: scale(.05, 1); } 60% { opacity: 1; } to { opacity: 0; transform: scale(1, 1); } }
.fxBeam.v { animation-name: beamV; }
@keyframes beamV { from { opacity: 1; transform: scale(1, .05); } 60% { opacity: 1; } to { opacity: 0; transform: scale(1, 1); } }
.fxRing { position: absolute; object-fit: contain; animation: ring .42s ease-out forwards; }
@keyframes ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.fxFlash { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.95), rgba(255,255,255,0) 70%); animation: ring .5s ease-out forwards; }

.boosters { display: flex; justify-content: center; gap: 18px; padding: 2px 10px calc(env(safe-area-inset-bottom, 0px) + 10px); }
.boost { position: relative; width: 74px; height: 74px; transition: transform .12s; }
.boost:active { transform: scale(.93); }
.boost > img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 4px rgba(0,0,0,.35)); }
.boost .badge { position: absolute; right: -4px; bottom: -2px; width: 30px; height: 30px; display: grid; place-items: center; }
.boost .badge img { position: absolute; inset: 0; width: 100%; height: 100%; }
.boost .badge b { position: relative; font-size: 15px; font-weight: 1000; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.boost.on { transform: scale(1.1); }
.boost.on > img { filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 4px #fff); }
.boost.off { opacity: .5; pointer-events: none; }
.pickBanner { position: absolute !important; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translateX(-50%); z-index: 6 !important; padding: 8px 16px; border-radius: 14px; background: rgba(0,0,0,.72); color: #fff; font-weight: 900; text-align: center; display: none; white-space: nowrap; }
.pickBanner small { display: block; font-weight: 600; font-size: 12px; opacity: .8; }
.pickBanner.on { display: block; }
.comboText { position: absolute !important; left: 0; right: 0; top: 46%; z-index: 7 !important; text-align: center; font-size: 40px; font-weight: 1000; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 18px var(--accent); pointer-events: none; opacity: 0; }
.comboText.on { animation: combo 1s ease-out forwards; }
@keyframes combo { from { opacity: 0; transform: scale(.4); } 25% { opacity: 1; transform: scale(1.1); } 70% { opacity: 1; transform: scale(1); } to { opacity: 0; transform: translateY(-30px); } }

/* ---------- окна ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 6, 20, .62); }
.sheet.on { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card { width: 100%; max-width: 380px; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 22px 20px 18px; border-radius: 24px; background: var(--card); color: var(--ink); border: 3px solid var(--cardEdge); box-shadow: 0 18px 40px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 10px; animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(24px) scale(.96); } }
.card h2 { margin: 0 0 4px; text-align: center; font-size: 25px; font-weight: 1000; }
.card p { margin: 0; text-align: center; font-size: 16px; line-height: 1.4; }
.btn { width: 100%; min-height: 52px; padding: 10px 16px; border-radius: 16px; background: var(--btn); color: var(--btnInk); font-size: 18px; font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--accent); color: var(--accentInk); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.btn small { font-size: 13px; font-weight: 700; opacity: .85; }
.btn:disabled { opacity: .55; }
.bigStars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: 92px; }
.bigStars img { width: 74px; height: 74px; opacity: 0; transform: scale(.3); }
.bigStars img:nth-child(2) { width: 88px; height: 88px; }
.bigStars img.in { animation: starIn .35s ease-out forwards; }
@keyframes starIn { from { opacity: 0; transform: scale(.3) rotate(-30deg); } 70% { opacity: 1; transform: scale(1.2); } to { opacity: 1; transform: scale(1); } }
.score b { font-size: 22px; }
.toggles { display: flex; gap: 8px; }
.toggles .btn { font-size: 15px; min-height: 46px; }
.btn.offTg { opacity: .6; }
.gift { font-weight: 800; color: var(--accent); }
.gift:empty { display: none; }
.leftGoals { display: flex; justify-content: center; gap: 16px; }
.leftGoals .goal img { width: 44px; height: 44px; }
.leftGoals .goal b { color: var(--ink); }
.adIcon { display: grid; place-items: center; }
.adIcon img { width: 96px; height: 96px; object-fit: contain; }
.ptxt { font-size: 15px; line-height: 1.5; text-align: left; }
.ptxt p { text-align: left; margin: 0 0 10px; }
.card.world { padding-top: 0; overflow: hidden; }
.worldPic { height: 170px; margin: 0 -20px 6px; background-size: cover; background-position: center 30%; }

.guide { position: fixed; left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); z-index: 15; display: none; align-items: flex-end; gap: 4px; pointer-events: none; }
.guide.on { display: flex; animation: rise .3s ease-out; }
.guide img { width: 96px; height: auto; flex: none; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.guide p { margin: 0 0 18px; padding: 12px 14px; border-radius: 18px 18px 18px 4px; background: #fff; color: #3b2140; font-size: 15px; font-weight: 800; line-height: 1.35; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 70px); z-index: 30; transform: translate(-50%, -20px); max-width: 88%; padding: 10px 16px; border-radius: 14px; background: rgba(0,0,0,.8); color: #fff; font-size: 15px; font-weight: 800; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#flyLayer { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
.fly { position: absolute; left: 0; top: 0; object-fit: contain; transition: transform .5s cubic-bezier(.4, 0, .6, 1), opacity .5s; }

@media (prefers-reduced-motion: reduce) {
  .lvBtn.cur .coin, .pc .glow, .pc .orb, .pc.hint img { animation: none; }
}
@media (max-height: 640px) {
  .hud { height: 70px; }
  .goal img { width: 32px; height: 32px; }
  .moves b { font-size: 26px; }
  .boost { width: 62px; height: 62px; }
}
