:root {
  --ink: #1D2B4F;
  --ink-2: #4C5B7E;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #DCE3EE;
  --primary: #2FA36B;
  --primary-2: #1E8A55;
  --gold: #FFB020;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #CFEBDD; color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
html.large-text { font-size: 118%; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; }
#bg { position: absolute; inset: 0; width: 100%; height: 100%; }
#screens { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 14px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 14px); max-width: 560px; margin: 0 auto; }
.ico { display: inline-flex; width: 22px; height: 22px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.ico.tiny { width: 15px; height: 15px; vertical-align: -2px; }
.muted { color: var(--ink-2); font-size: .92rem; }
.center { text-align: center; }
.warn { background: #FFF4D6; border-radius: 12px; padding: 8px 12px; font-size: .85rem; }
h1, h2, h3 { margin: .2em 0 .35em; line-height: 1.15; }
h1:focus, h2:focus { outline: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 16px; border: 0; background: #fff; box-shadow: 0 3px 0 #C9D3E3, 0 8px 18px rgba(30, 50, 90, .12); font-weight: 700; font-size: 1.05rem; cursor: pointer; transition: transform .12s, box-shadow .12s, filter .12s; position: relative; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #C9D3E3, 0 4px 10px rgba(30, 50, 90, .12); }
.btn:focus-visible, .icon-btn:focus-visible, .ctl:focus-visible, .lvl:focus-visible, .coin-pill:focus-visible { outline: 3px solid #2360B2; outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: grayscale(.4); }
.btn.primary { background: linear-gradient(#45C784, var(--primary)); color: #fff; box-shadow: 0 3px 0 var(--primary-2), 0 8px 18px rgba(30, 120, 80, .3); text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
.btn.big { min-height: 64px; flex-direction: column; gap: 0; font-size: 1.35rem; }
.btn.big small { font-size: .8rem; font-weight: 500; opacity: .9; }
.btn.ghost { background: rgba(255, 255, 255, .7); box-shadow: 0 2px 0 #D5DDE9; }
.btn.toggle.on { background: #E7F7EE; box-shadow: 0 3px 0 #9BD8B6; }
.btn .tag { position: absolute; right: 12px; font-style: normal; font-size: .75rem; background: var(--gold); color: #fff; border-radius: 99px; padding: 2px 8px; }
.btn .tag.ok { background: #8EC9A8; }
.tag.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--panel); box-shadow: 0 2px 0 #CBD5E4; display: grid; place-items: center; cursor: pointer; }
.icon-btn .ico { width: 24px; height: 24px; }

/* top bar */
.topbar { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; min-height: 48px; }
.topbar .title { margin: 0 auto; max-width: 100%; text-align: center; font-size: 1.2rem; font-weight: 800; color: #fff; background: rgba(18, 30, 58, .62); padding: 2px 14px; border-radius: 99px; text-shadow: 0 1px 0 rgba(0, 0, 0, .3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coin-pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 8px; border-radius: 99px; border: 0; background: var(--panel); box-shadow: 0 2px 0 #CBD5E4; font-weight: 800; font-size: 1.05rem; cursor: pointer; min-width: 44px; }
.coin-pill.bump { animation: bump .5s ease; }
@keyframes bump { 30% { transform: scale(1.18); } }
.sub { align-self: center; text-align: center; color: #fff; font-weight: 700; font-size: .9rem; margin-top: 4px; background: rgba(18, 30, 58, .5); padding: 0 12px; border-radius: 99px; }

/* progress */
.progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px 0 14px; font-weight: 700; }
.progress-wrap span { background: var(--panel); padding: 0 10px; border-radius: 99px; font-size: .9rem; }
.progress { width: 100%; height: 12px; border-radius: 99px; background: rgba(255, 255, 255, .6); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12); }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #FFC531, #FF9F1C); border-radius: 99px; transition: width .4s ease; }
.progress.thin { height: 6px; margin: 6px auto 0; width: 70%; }

/* splash / logo */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.loader { width: 160px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .6); overflow: hidden; }
.loader i { display: block; height: 100%; width: 40%; background: var(--primary); border-radius: 99px; animation: load 1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.logo { display: flex; flex-direction: column; align-items: center; margin: 6px 0 4px; }
.logo-snake { width: 210px; height: 56px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .2)); }
.logo-text { display: flex; flex-direction: column; align-items: center; line-height: .82; font-weight: 800; letter-spacing: 1px; }
.logo-text span { font-size: 4.2rem; background: linear-gradient(#FFE27A, #FFB020 60%, #F08A00); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 2px #7A3E00; filter: drop-shadow(0 4px 0 rgba(90, 40, 0, .35)); }
.logo-text span:last-child { background: linear-gradient(#9FE7FF, #3DB4F2 60%, #1A7BCF); -webkit-background-clip: text; background-clip: text; -webkit-text-stroke: 2px #0C3D73; }
.logo.small .logo-snake { width: 130px; height: 36px; }
.logo.small .logo-text span { font-size: 2.4rem; }

/* home */
.home { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.home-top { grid-template-columns: 44px 1fr auto; }
.menu { display: flex; flex-direction: column; gap: 12px; margin-top: auto; margin-bottom: auto; padding: 4px 2px 10px; }

/* cards / scroll screens */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 2px 20px; }
.card-screen { background: var(--panel); border-radius: 24px; padding: 18px; box-shadow: 0 10px 30px rgba(20, 40, 80, .18); margin-top: 10px; }
.scroll.card-screen { flex: 1; }

/* onboarding */
.onboard { margin: auto 0; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.onboard .tut-board { height: min(44vh, 320px); position: relative; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 99px; background: #C9D3E3; }
.dots i.on { background: var(--primary); width: 22px; }
.econ-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.econ-cards div { background: #F4F7FB; border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; }
.econ-cards .ico { width: 30px; height: 30px; }
.econ-cards b { font-size: 1.2rem; }
.econ-cards small { color: var(--ink-2); }

/* game */
.screen-game #screens, .screen-game { }
.board-wrap { flex: 1; min-height: 200px; position: relative; margin: 8px -6px 6px; }
.board-canvas { position: absolute; inset: 0; touch-action: none; outline: none; border-radius: 20px; }
.board-canvas:focus-visible { box-shadow: inset 0 0 0 2px rgba(35, 96, 178, .35); }
.controls { display: grid; grid-template-columns: 1fr 1fr 1.25fr 1.25fr; gap: 8px; }
.ctl { min-height: 56px; border: 0; border-radius: 16px; background: var(--panel); box-shadow: 0 3px 0 #C9D3E3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-weight: 700; font-size: .82rem; cursor: pointer; padding: 4px; }
.ctl:active { transform: translateY(2px); box-shadow: 0 1px 0 #C9D3E3; }
.ctl:disabled { opacity: .5; cursor: not-allowed; }
.ctl.hint { background: linear-gradient(#FFF7DD, #FFE9A8); box-shadow: 0 3px 0 #E7C35A; }
.ctl b { display: inline-flex; align-items: center; gap: 2px; }

/* levels */
.world { margin-bottom: 18px; }
.world h3 { display: flex; justify-content: space-between; align-items: center; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 14px; font-size: 1rem; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; margin-top: 8px; }
.lvl { aspect-ratio: 1; min-height: 52px; border: 0; border-radius: 14px; background: var(--panel); box-shadow: 0 3px 0 #C9D3E3; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; font-size: 1.15rem; }
.lvl.done { background: #E9F8EF; box-shadow: 0 3px 0 #9BD8B6; }
.lvl.current { background: linear-gradient(#FFF1C4, #FFDC75); box-shadow: 0 3px 0 #E0B030; animation: pulse 1.6s infinite; }
.lvl.locked { opacity: .55; cursor: not-allowed; background: rgba(255, 255, 255, .6); }
.lvl .stars { font-size: .7rem; color: #E7A400; letter-spacing: -1px; }
.lvl .ico { width: 20px; height: 20px; }

/* daily */
.thumb-wrap { height: min(36vh, 300px); margin: 6px 0 10px; }
.thumb-wrap canvas { width: 100%; height: 100%; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.facts div { background: #F4F7FB; border-radius: 12px; padding: 8px 12px; }
.facts dt { font-size: .8rem; color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 800; }

/* calendar */
.streak { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.streak b { font-size: 3rem; color: #F08A00; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 14px; }
.day { border-radius: 12px; background: #F4F7FB; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; font-size: .8rem; border: 2px solid transparent; }
.day b { font-size: 1.1rem; }
.day.claimed { background: #E2F6EA; color: #1E8A55; }
.day.missed { background: #F1F1F4; color: #9AA3B5; }
.day.today { background: #FFF1C4; border-color: var(--gold); }
.day.is-today { border-color: var(--gold); }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.month b { font-size: .75rem; color: var(--ink-2); }
.month i { font-style: normal; padding: 6px 0; border-radius: 10px; font-size: .85rem; position: relative; }
.month i.c { background: #E2F6EA; color: #1E8A55; font-weight: 800; }
.month i.dc::after { content: '★'; position: absolute; top: -3px; right: 2px; font-size: .6rem; color: #E7A400; }
.month i.t { outline: 2px solid var(--gold); }
.legend { font-size: .8rem; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: #E2F6EA; }
.legend i.dc { background: none; }
.legend i.dc::before { content: '★'; color: #E7A400; }

/* settings */
.settings section { margin-bottom: 14px; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.settings input[type=checkbox] { width: 48px; height: 28px; appearance: none; background: #C9D3E3; border-radius: 99px; position: relative; cursor: pointer; transition: background .2s; }
.settings input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 99px; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.settings input[type=checkbox]:checked { background: var(--primary); }
.settings input[type=checkbox]:checked::after { left: 23px; }
.settings input[type=range] { width: 50%; accent-color: var(--primary); }
.settings select { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; background: #fff; }
.settings .btn { margin: 6px 0; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.swatches span { font-size: .7rem; text-align: center; border-radius: 10px; padding: 4px 2px; background: var(--c); color: #fff; text-shadow: 0 1px 1px var(--d); border: 2px solid var(--d); display: flex; flex-direction: column; }
.swatches small { opacity: .9; }

/* help */
.help ul { padding-left: 20px; }

/* modals */
#modal-root { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 25, 50, .45); display: flex; align-items: center; justify-content: center; padding: 20px; pointer-events: auto; animation: fade .18s ease; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 24px; padding: 20px; width: min(100%, 380px); box-shadow: 0 20px 50px rgba(10, 20, 50, .35); text-align: center; max-height: calc(100% - 20px); overflow-y: auto; animation: rise .22s ease; }
@keyframes rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.modal.pop { animation: popin .35s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes popin { from { transform: scale(.7); opacity: 0; } }
.modal textarea { width: 100%; border-radius: 12px; border: 1px solid var(--line); padding: 8px; font-family: ui-monospace, monospace; font-size: .75rem; }
.reward-big { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 2.4rem; font-weight: 800; color: #E08A00; }
.reward-big .ico { width: 44px; height: 44px; }
.star-row { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.star-row span { width: 54px; height: 54px; display: inline-flex; }
.star-row span .ico { width: 100%; height: 100%; }
.star-row span.got { animation: starin .5s cubic-bezier(.2, 1.6, .5, 1) both; animation-delay: var(--d); }
@keyframes starin { from { transform: scale(0) rotate(-40deg); } }
.earn { text-align: left; }
.celebrate h2 { color: #E08A00; }

/* toast */
#toast { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 92px); transform: translate(-50%, 20px); background: rgba(20, 30, 55, .92); color: #fff; padding: 10px 16px; border-radius: 99px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 32px); text-align: center; font-size: .95rem; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* short / landscape */
@media (max-height: 600px) {
  .logo-text span { font-size: 2.8rem; }
  .logo-snake { width: 150px; height: 40px; }
  .btn { min-height: 44px; }
  .btn.big { min-height: 54px; }
  .ctl { min-height: 48px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  #screens { max-width: 600px; }
}
html.reduced *, html.reduced *::before, html.reduced *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }

/* lives */
.lives { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.heart { width: 24px; height: 24px; display: inline-flex; }
.heart svg { width: 100%; height: 100%; }
.heart path { fill: #F24B57; stroke: #A8202C; stroke-width: 1.6; stroke-linejoin: round; }
.heart .shine { fill: none; stroke: #FFC2C7; stroke-width: 2; stroke-linecap: round; }
.heart.empty path { fill: rgba(255, 255, 255, .45); stroke: rgba(80, 90, 110, .55); }
.heart.empty .shine { display: none; }
.heart.lost { animation: heartlost .6s ease; }
@keyframes heartlost { 0% { transform: scale(1.5); filter: drop-shadow(0 0 6px #FF3B3B); } 40% { transform: scale(.7) rotate(-15deg); } 100% { transform: scale(1); } }
.board-wrap.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translate(-1px, 0); } 20%, 80% { transform: translate(3px, 1px); } 30%, 50%, 70% { transform: translate(-5px, -1px); } 40%, 60% { transform: translate(5px, 1px); } }
.out-of-lives .broken { width: 64px; height: 64px; margin: 0 auto; animation: heartlost .8s ease; }
.out-of-lives .broken path { fill: #C9D3E3; stroke: #8A94AD; stroke-width: 1.6; }
.out-of-lives .broken .shine { display: none; }
