:root {
  --ink: #1f2540;
  --paper: #fffaf0;
  --line: #1f2540;
  --muted: #6b6f86;
  --up: #2f8a4a;
  --down: #c8343e;
  --gold: #ffcf3f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #79c3f0; color: var(--ink); font-family: Rubik, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; overflow: hidden; transition: background 0.8s; }
#app.sky-day { background: linear-gradient(#6ab8ec, #d7efff 70%); }
#app.sky-night { background: linear-gradient(#141a3a, #3a4170 75%); }
#app.sky-green { background: linear-gradient(#74c983, #e4f7d6 70%); }
#app.sky-stripes { background: repeating-linear-gradient(#79c3f0 0 34px, #f4fbff 34px 68px); }
#app.sky-dots { background: radial-gradient(circle, #fff 0 7px, transparent 8px) 0 0 / 46px 46px, linear-gradient(#6ab8ec, #cfeaff); }
#app.sky-void { background: radial-gradient(circle at 50% 30%, #2a2a33, #050508 70%); }
#app.sky-night #hud, #app.sky-void #hud { color: #f4f0e0; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }

#sky { position: absolute; inset: 0; pointer-events: none; }
#sky svg { display: block; }
.cloud { animation: drift 60s linear infinite alternate; }
.cloud.c1 { animation-duration: 80s; animation-direction: alternate-reverse; }
.cloud.c2 { animation-duration: 95s; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(60px); } }
.sun .rays { transform-box: fill-box; transform-origin: center; animation: spin 40s linear infinite; }
.sun.blink { animation: blinksun 1.2s steps(1) infinite; }
@keyframes blinksun { 50% { opacity: 0.05; } }
@keyframes spin { to { transform: rotate(360deg); } }

#planet { position: absolute; left: 0; right: 0; bottom: 0; height: 34%; pointer-events: none; }
#planet svg { display: block; overflow: visible; }
#planet.hit { animation: hit 0.45s; }
@keyframes hit { 20% { transform: translate(-4px, 3px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-2px, 1px); } }
.man { animation: bob 1.6s ease-in-out infinite; }
.man.m1 { animation-delay: -0.4s; } .man.m2 { animation-delay: -0.8s; } .man.m3 { animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-2px); } }
.granny { animation: fly 5s ease-in-out infinite; } .granny.g1 { animation-delay: -1.6s; } .granny.g2 { animation-delay: -3.1s; }
@keyframes fly { 50% { transform: translate(14px, -10px); } }
.dragon { animation: fly 4s ease-in-out infinite; }
.spin { animation: spin 3s linear infinite; }
.tail { animation: wag 0.5s ease-in-out infinite alternate; }
@keyframes wag { to { transform: rotate(-25deg); } }
@keyframes signfade { from { opacity: 0; } }

#ladder { display: none; position: absolute; z-index: 3; left: 50%; width: 46px; margin-left: -23px; top: 14vh; bottom: 18%; background: repeating-linear-gradient(transparent 0 22px, #8a5a33 22px 28px), linear-gradient(90deg, #8a5a33 0 6px, transparent 6px 40px, #8a5a33 40px); animation: grow 2s ease-out both; transform-origin: bottom; }
.end-zealot #ladder { display: block; }
@keyframes grow { from { transform: scaleY(0); } }
.end-crowd #planet { animation: swell 3s ease-in both; transform-origin: 50% 100%; }
@keyframes swell { 80% { transform: scale(1.25, 1.4); opacity: 1; } 100% { transform: scale(1.5, 1.7); opacity: 0; } }

/* ---------- верх ---------- */
#hud { position: relative; z-index: 3; width: 100%; max-width: 760px; display: flex; align-items: center; gap: 12px; padding: calc(8px + env(safe-area-inset-top)) 16px 4px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat b { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12px; opacity: 0.75; font-weight: 500; }
.stat.right { text-align: right; margin-left: auto; }
.faithbox { flex: 1; max-width: 200px; margin: 0 auto; align-items: center; }
#faith { position: relative; width: 100%; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.55); border: 2px solid var(--line); overflow: hidden; }
#faith::before, #faith::after { content: ''; position: absolute; top: 0; bottom: 0; width: 12%; background: repeating-linear-gradient(45deg, rgba(200, 52, 62, 0.35) 0 4px, transparent 4px 8px); z-index: 1; }
#faith::before { left: 0; } #faith::after { right: 0; }
#faith i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); transition: width 0.7s cubic-bezier(.2, .8, .2, 1); }
#faith.low i, #faith.high i { background: #ff7a5a; }
.bump { animation: bump 0.5s; }
@keyframes bump { 30% { transform: scale(1.35); color: var(--down); } }
#mute { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: rgba(255, 255, 255, 0.7); display: grid; place-items: center; flex: none; color: var(--ink); }
#mute .x { display: none; } #mute.off .x { display: inline; } #mute.off .w { display: none; }

#sign { position: relative; z-index: 1; font-family: Neucha, cursive; font-size: clamp(34px, 7vh, 64px); line-height: 1; letter-spacing: 0.3em; margin: 2px 0 -8px 0.3em; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 2px 0 rgba(60, 100, 160, 0.35); animation: signfade 1.5s both; pointer-events: none; }
#sign[hidden] { display: none; }

/* ---------- бог ---------- */
#godwrap { position: relative; z-index: 2; height: clamp(140px, 25vh, 290px); aspect-ratio: 1; flex: none; pointer-events: none; }
#god, #god svg { width: 100%; height: 100%; display: block; }
#god svg { overflow: visible; }
#god * { transform-box: fill-box; }
.headg { transform-origin: center; animation: sway 6s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(2deg) translateY(3px); } }
.halo { transform-origin: center; animation: halo 3.4s ease-in-out infinite; }
@keyframes halo { 50% { transform: translate(6px, -4px) rotate(4deg); } }
.skin { fill: #ffd9ad; transition: fill 0.4s; }
.pl, .pr { transition: transform 0.35s; }
.pl { animation: wander 7s ease-in-out infinite; }
@keyframes wander { 30% { transform: translate(-4px, 2px); } 60% { transform: translate(3px, -3px); } }
.m { display: none; } .m-idle { display: inline; }
.vein, .sweat, .steam { opacity: 0; transition: opacity 0.3s; }
.drool { transform-origin: top; animation: drool 3s ease-in-out infinite; }
@keyframes drool { 50% { transform: scaleY(1.5); } }
.tongue { transition: transform 0.3s; }
.hand-r { transition: transform 0.25s; transform-origin: 100% 100%; }
.finger { transform-origin: top; transform: scaleY(0); transition: transform 0.15s; }
.blink .eye-l, .blink .eye-r { transform: scaleY(0.12); transform-origin: center; }
.eye-l, .eye-r { transition: transform 0.07s; }

[data-face=think] .pl { transform: translate(-10px, -16px); animation: none; }
[data-face=think] .pr { transform: translate(8px, -10px); }
[data-face=think] .tongue { transform: translate(10px, 6px) rotate(20deg); }
[data-face=think] .steam, [data-face=strain] .steam { opacity: 1; }
.puff { animation: puff 0.9s ease-out infinite; }
.puff.p2 { animation-delay: -0.45s; }
@keyframes puff { from { transform: translateY(6px) scale(0.7); opacity: 0.2; } to { transform: translateY(-18px) scale(1.2); opacity: 1; } }
[data-face=strain] .skin { fill: #ff9a82; }
[data-face=strain] .vein, [data-face=strain] .sweat, [data-face=oops] .sweat { opacity: 1; }
[data-face=strain] .m-idle, [data-face=zap] .m-idle, [data-face=oops] .m-idle, [data-face=proud] .m-idle { display: none; }
[data-face=strain] .m-strain { display: inline; }
[data-face=strain] .headg { animation: shake 0.12s linear infinite; }
@keyframes shake { 25% { transform: translate(-3px, 1px); } 75% { transform: translate(3px, -1px); } }
[data-face=strain] .pl { transform: translate(14px, 0); animation: none; } [data-face=strain] .pr { transform: translate(-14px, 6px); }
[data-face=zap] .m-o, [data-face=oops] .m-o { display: inline; }
[data-face=zap] .hand-r { transform: translate(-70px, 34px) rotate(-12deg); }
[data-face=zap] .finger { transform: scaleY(1); }
[data-face=oops] .pl { transform: translate(6px, 4px) scale(0.6); animation: none; } [data-face=oops] .pr { transform: translate(-6px, 6px) scale(0.6); }
[data-face=proud] .m-smile { display: inline; }
[data-face=proud] .pl { transform: translate(6px, -8px); animation: none; } [data-face=proud] .pr { transform: translate(-4px, -4px); }
[data-face=gone] { opacity: 0.12; filter: grayscale(1); transition: opacity 2.5s, filter 2.5s; }

#bubble { position: absolute; left: 78%; top: 18%; width: max-content; max-width: min(200px, 42vw); padding: 8px 12px; background: #fff; border: 2px solid var(--line); border-radius: 18px; font-family: Neucha, cursive; font-size: 19px; line-height: 1.15; opacity: 0; transform: scale(0.6); transform-origin: 0 100%; transition: opacity 0.2s, transform 0.2s; }
#bubble::before, #bubble::after { content: ''; position: absolute; border: 2px solid var(--line); background: #fff; border-radius: 50%; }
#bubble::before { width: 12px; height: 12px; left: -12px; bottom: -6px; }
#bubble::after { width: 7px; height: 7px; left: -22px; bottom: -14px; }
#bubble.on { opacity: 1; transform: none; }

/* ---------- молитва ---------- */
#card, #end { position: relative; z-index: 4; width: calc(100% - 32px); max-width: 520px; margin-top: -6px; background: var(--paper); border: 2.5px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 5px 0 var(--line), 0 14px 30px rgba(20, 30, 60, 0.18); }
#card.in { animation: cardin 0.35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes cardin { from { transform: translateY(16px) scale(0.97); opacity: 0; } }
.head { display: flex; gap: 12px; align-items: flex-start; }
#ava { width: 54px; height: 54px; flex: none; border-radius: 50%; border: 2px solid var(--line); overflow: hidden; background: #ffe9c7; }
#ava svg { width: 100%; height: 100%; display: block; }
#who { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#ask { font-size: 19px; font-weight: 700; line-height: 1.22; margin-top: 2px; }
#opts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; transition: opacity 0.3s; }
#opts.fade { opacity: 0.25; }
.opt { display: flex; gap: 10px; align-items: center; text-align: left; width: 100%; min-height: 48px; padding: 9px 12px; background: #fff; border: 2px solid var(--line); border-radius: 12px; box-shadow: 0 3px 0 var(--line); font-size: 16px; font-weight: 500; line-height: 1.2; animation: optin 0.3s both; transition: transform 0.08s, box-shadow 0.08s, opacity 0.25s, background 0.2s; }
.opt b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 13px; }
.opt:hover:not(:disabled) { background: #fff4cf; }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.opt.chosen { background: #fff4cf; }
.opt.gone { display: none; }
.opt:disabled { cursor: default; }
@keyframes optin { from { opacity: 0; transform: translateX(-10px); } }
#more { display: flex; align-items: center; gap: 6px; margin: 10px auto 0; padding: 6px 12px; background: none; border: 0; color: var(--muted); font-size: 14px; font-weight: 500; border-radius: 10px; }
#more em { font-style: normal; color: var(--down); font-weight: 700; }
#more:hover:not(:disabled) { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
#more[hidden] { display: none; }
#res { margin-top: 10px; animation: optin 0.35s both; }
#res p { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 500; }
.delta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.delta .up { color: var(--up); } .delta .down { color: var(--down); }
#next, #end button { display: block; width: 100%; margin-top: 12px; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; font-size: 17px; box-shadow: 0 3px 0 #000; }
#next:active, #end button:active { transform: translateY(3px); box-shadow: none; }
#next[hidden] { display: none; }

#end { text-align: center; animation: cardin 0.5s both; }
#end[hidden] { display: none; }
.etext { margin: 4px 0 10px; font-size: 21px; font-weight: 700; line-height: 1.25; }
.edays { margin: 0; font-size: 17px; font-weight: 500; }
.ebest { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

#fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }

@media (min-width: 760px) {
  #ask { font-size: 21px; }
  .opt { font-size: 17px; }
  #bubble { font-size: 22px; }
}
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  #app { display: grid; grid-template-columns: minmax(400px, 34vw) 1fr; grid-template-rows: auto auto auto 1fr; justify-items: center; }
  #hud { grid-column: 1 / -1; max-width: none; }
  #sign { grid-column: 2; grid-row: 2; }
  #app #godwrap { grid-column: 2; grid-row: 3; height: clamp(160px, 32vh, 320px); }
  #card, #end { grid-column: 1; grid-row: 2 / 5; align-self: center; width: calc(100% - 24px); margin: 0 0 6vh max(24px, 3vw); }
  #ladder { left: 67%; }
  #planet { height: 42%; }
}
@media (max-height: 640px) {
  #godwrap { height: 22vh; }
  #ask { font-size: 17px; }
  .opt { min-height: 42px; padding: 7px 10px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  #card.in, .opt, #res, #end { animation-duration: 0.12s; }
}
