/* دردسرهای سوزن‌بان — استایل‌ها
   سبک: تصویرسازی خطی روی کاغذ کرم، یک رنگ تأکیدی نارنجی، انیمیشن‌های ریز همه‌جا */

/* فونت استعداد (Estedad، مجوز SIL OFL) — روی خود سرور میزبانی می‌شود تا در قطعی اینترنت بین‌الملل هم لود شود */
@font-face {
  font-family: 'Estedad';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/estedad-arabic.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Estedad';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(/fonts/estedad-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f5eedf;
  --paper-2: #e9dec8;
  --ink: #1e1b2b;
  --ink-soft: #6f6879;
  --accent: #e8553a;
  --on-accent: #fffaf0;
  --teal: #2f9c8f;
  --mustard: #edb33c;
  --lilac: #9b87e0;
  --sage: #9cc08a;
  --rose: #f09aae;
  --blue: #4b7be5;
  --red: #e0413b;
  --navy: #34508a;
  --gray: #bdb6aa;
  --gold: #f4c23f;
  --tea: #c2502a;
  --bread: #e3b577;
  --wood: #b97b4a;
  --money: #8fcb7e;
  --green: #4cc26e;
  --sky: #8fd0f5;
  --fog: #f1ebde;
  --glass: #dcedf0;
  --rope: #c08a4e;
  --skin: #fbf6ec;
  --shadow: var(--ink);
  --radius: 16px;
  --font: 'Estedad', Tahoma, 'Segoe UI', sans-serif;
  --spring: cubic-bezier(.3, 1.6, .5, 1);
  --out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17151f;
    --paper-2: #242131;
    --ink: #f3ebdc;
    --ink-soft: #9a93a6;
    --on-accent: #fffaf0;
    --skin: #2a2637;
    --fog: #2b2838;
    --glass: #2b3d4a;
    --gray: #8d877d;
    --navy: #5272b8;
    --shadow: #000;
    color-scheme: dark;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.2px);
  background-size: 22px 22px;
  line-height: 1.9;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.has-result { padding-bottom: 120px; }

button { font-family: inherit; }
b { font-weight: 800; }

/* ───────── رنگ‌ها و خطوط SVG ───────── */
.ln { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sh { fill: var(--paper); stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ink { fill: var(--ink); }
.hair { fill: var(--ink); transition: fill .6s ease; }
.hair.gray { fill: var(--gray); stroke: var(--ink); stroke-width: 1.4; }
.skin { fill: var(--skin); }
.thin { stroke-width: 1.5; }
.thick { stroke-width: 3.2; }
.eye { stroke-width: 2.8; }
.rope { fill: none; stroke: var(--rope); stroke-width: 2.6; stroke-linecap: round; }
.chain { stroke: var(--gold); stroke-width: 2.2; }
.stripe { stroke: var(--paper); stroke-width: 3; }
.spark { stroke: var(--gold); stroke-width: 2.6; }
.wood-leg { stroke: var(--wood); stroke-width: 4.4; }
.hair-line { stroke: var(--ink-soft); stroke-width: 1.3; }
.lever-stick { stroke-width: 4.4; }
.scr { fill: var(--sky); stroke: none; }
.tx { fill: var(--ink); font-family: var(--font); font-weight: 800; stroke: none; }
.tx.on-accent { fill: var(--on-accent); }
.tx.red { fill: var(--red); }
.f-paper { fill: var(--paper); }
.f-paper2 { fill: var(--paper-2); }
.f-ink { fill: var(--ink); }
.f-accent { fill: var(--accent); }
.f-teal { fill: var(--teal); }
.f-mustard { fill: var(--mustard); }
.f-lilac { fill: var(--lilac); }
.f-sage { fill: var(--sage); }
.f-rose { fill: var(--rose); }
.f-blue { fill: var(--blue); }
.f-red { fill: var(--red); }
.f-navy { fill: var(--navy); }
.f-gray { fill: var(--gray); }
.f-gold { fill: var(--gold); }
.f-tea { fill: var(--tea); }
.f-bread { fill: var(--bread); }
.f-wood { fill: var(--wood); }
.f-money { fill: var(--money); }
.f-green { fill: var(--green); }
.f-sky { fill: var(--sky); }
.f-fog { fill: var(--fog); stroke-width: 1.8; }
.f-glass { fill: var(--glass); }

.bg { fill: none; stroke: var(--ink-soft); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .5; }
.bg-sun { fill: var(--paper-2); stroke: var(--ink-soft); stroke-width: 1.6; opacity: .7; }
.bg-cloud { fill: var(--paper); stroke: var(--ink-soft); stroke-width: 1.6; opacity: .8; }
.rail { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tie { stroke: var(--ink-soft); stroke-width: 3; stroke-linecap: round; opacity: .75; }
.measure { fill: none; stroke: none; pointer-events: none; }
.stamp-box { fill: color-mix(in srgb, var(--paper) 80%, transparent); stroke: var(--red); stroke-width: 3.4; stroke-dasharray: 10 3; }
.tx.stamp-text { fill: var(--red); }
.bubble { stroke-width: 2.6; }
.tx.bubble-text { font-size: 15px; }
.fog-q { fill: var(--ink-soft); }

/* ───────── میکروانیمیشن‌های صحنه ───────── */
.item .body,
.coin-float, .twinkle, .zz, .note, .blink, .flag, .wifi, .sparkle, .money-float, .lit,
.heart, .tear, .exhaust, .tail, .glow, .fog-q, .steam, .sun, .cloud, .birds, .trolley-bob,
.lever-wrap, .sw-body, .headlight, .loop-mark, .form-note,
.fish, .wag, .swirl, .future, .dice-mark, .driver-tea {
  transform-box: fill-box;
  transform-origin: center;
}
.item .body { transform-origin: 50% 100%; }
.item.human .body { animation: shiver 2.8s ease-in-out infinite; }
.svg-paused .item .body { animation-play-state: paused; }
@keyframes shiver {
  0%, 55%, 100% { transform: rotate(0); }
  62% { transform: rotate(-2.4deg); }
  70% { transform: rotate(2.2deg); }
  78% { transform: rotate(-1.6deg); }
  86% { transform: rotate(1deg); }
}
.pv-pull .items-bottom .item.human .body,
.pv-stay .items-top .item.human .body { animation: panic .32s linear infinite; }
@keyframes panic {
  0%, 100% { transform: rotate(-2.6deg) translateY(0); }
  50% { transform: rotate(2.6deg) translateY(-1.5px); }
}
.is-hit .body { animation: none !important; }
.bumped .hair { fill: var(--gray); }
.scene[data-level="lifespan"] .bumped .body { filter: saturate(.4); }

.trolley-bob { animation: bob .42s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-1.2px); } }
.headlight { animation: glow-light 1.6s ease-in-out infinite alternate; }
@keyframes glow-light { to { filter: drop-shadow(0 0 4px var(--gold)); } }

.steam { animation: steam 2.4s ease-in-out infinite; }
.steam.s2 { animation-delay: -1.2s; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(6px) scaleY(.8); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scaleY(1.1); }
}
.coin-float { animation: coin 1.8s ease-in-out infinite; }
@keyframes coin { 50% { transform: translateY(-5px) rotateY(180deg); } }
.twinkle { animation: twinkle 1.6s ease-in-out infinite; }
.twinkle.t2 { animation-delay: -.8s; }
@keyframes twinkle { 0%, 100% { transform: scale(.5); opacity: .3; } 50% { transform: scale(1.1); opacity: 1; } }
.zz { animation: zz 2.6s ease-in-out infinite; }
.zz.z2 { animation-delay: -.8s; }
.zz.z3 { animation-delay: -1.6s; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -8px); } }
.note { animation: note 1.4s ease-in-out infinite; }
.note.n2 { animation-delay: -.7s; }
@keyframes note { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-6px) rotate(8deg); } }
.blink { animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { fill: var(--paper); } }
.flag { transform-origin: 0% 50%; animation: flag 1s ease-in-out infinite; }
@keyframes flag { 50% { transform: skewY(-8deg) scaleX(.9); } }
.wifi { animation: wifi 1.4s ease-in-out infinite; }
@keyframes wifi { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.sparkle { animation: sparkle .5s linear infinite; }
@keyframes sparkle { 50% { transform: rotate(45deg) scale(1.3); } }
.money-float { animation: money 2s ease-in-out infinite; }
.money-float.m2 { animation-delay: -1s; }
@keyframes money { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.lit { animation: lit 1s ease-in-out infinite alternate; }
@keyframes lit { to { filter: drop-shadow(0 0 3px var(--green)); } }
.heart { animation: heart 1s ease-in-out infinite; }
@keyframes heart { 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.15); } 60% { transform: scale(1); } }
.tear { animation: tear 2s ease-in infinite; }
@keyframes tear { 0% { opacity: 0; transform: translateY(-2px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(8px); } }
.exhaust { animation: steam 1.2s ease-out infinite; }
.exhaust.e2 { animation-delay: -.6s; }
.tail { transform-origin: 0% 100%; animation: tail 1.6s ease-in-out infinite; }
@keyframes tail { 50% { transform: rotate(-12deg); } }
.glow { animation: twinkle 2s ease-in-out infinite; }
.fog-q { animation: note 2.2s ease-in-out infinite; }
.fog-q.q2 { animation-delay: -.7s; }
.fog-q.q3 { animation-delay: -1.4s; }
.sun { animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cloud { animation: drift 26s ease-in-out infinite alternate; }
.cloud.c2 { animation-duration: 34s; animation-direction: alternate-reverse; }
@keyframes drift { to { transform: translateX(46px); } }
.birds { animation: birds 18s linear infinite; }
@keyframes birds { 0% { transform: translate(0, 0); } 50% { transform: translate(-120px, -10px) scaleY(.7); } 100% { transform: translate(-240px, 0); } }
.loop-mark { animation: heart 1.8s ease-in-out infinite; }
.form-note { animation: note 3s ease-in-out infinite; }
.sw-body { transform-origin: 50% 100%; animation: breathe 3.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scaleY(1.015); } }

/* مرحله‌های نسخه‌ی ۲ */
.blush { fill: var(--rose); opacity: .75; }
.collar { stroke: var(--accent); stroke-width: 3.2; }
.shine { stroke: var(--paper); opacity: .8; }
.soot { stroke: var(--ink-soft); opacity: .55; }
.soot-f { fill: var(--ink-soft); opacity: .35; }
.stripe-ink { stroke: var(--ink); stroke-width: 2.6; }
.smog { fill: var(--ink-soft); stroke: var(--ink); opacity: .7; }
.fish { animation: fish 2.6s ease-in-out infinite; }
.fish.f2 { animation-duration: 3.2s; animation-direction: reverse; }
@keyframes fish { 50% { transform: translate(3px, -1.5px); } }
.wag { transform-origin: 0% 100%; animation: wag .45s ease-in-out infinite alternate; }
@keyframes wag { to { transform: rotate(-16deg); } }
.swirl { animation: spin 2.4s linear infinite; }
.future { opacity: .55; animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker { 50% { opacity: .35; } }
.driver-tea { animation: note 2.6s ease-in-out infinite; }
.dice-mark { animation: note 2.4s ease-in-out infinite; transition: opacity .4s; }
.dice-mark.dim { opacity: .35; }
.dice-mark.picked { animation: dice-pick .9s var(--spring) both; }
.dice-mark.picked rect { fill: var(--mustard); }
@keyframes dice-pick { 0% { transform: rotate(0) scale(1); } 60% { transform: rotate(380deg) scale(1.7); } 100% { transform: rotate(360deg) scale(1.45); } }
.one-track .pv-line-pull { stroke: var(--accent); }

.veiled { opacity: 0; transition: opacity .6s ease .15s; }
.veiled.unveiled { opacity: 1; }

/* پیش‌نمایش مسیر با هاور روی دکمه‌ها */
.preview-line { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 14; opacity: 0; transition: opacity .25s ease; }
.pv-line-pull { stroke: var(--accent); }
.pv-line-stay { stroke: var(--teal); }
.pv-pull .pv-line-pull, .pv-stay .pv-line-stay { opacity: .85; animation: march .6s linear infinite; }
@keyframes march { to { stroke-dashoffset: 16; } }
.lever-wrap { transform-box: view-box; transform-origin: 650px 331px; transition: transform .35s var(--spring); }
.pv-pull .lever-wrap { transform: rotate(6deg); }
.decided .lever-wrap { transform: none; }

/* انیمیشن «طراحی با قلم» */
.sketching :is(path, line, circle, ellipse, rect, polyline) {
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1.01;
  animation: sk-draw .85s var(--d, 0s) cubic-bezier(.55, .1, .3, 1) forwards, sk-fill .45s calc(var(--d, 0s) + .5s) both !important;
}
.sketching text { animation: sk-fade .5s calc(var(--d, 0s) + .4s) both !important; }
@keyframes sk-draw { to { stroke-dashoffset: 0; } }
@keyframes sk-fill { from { fill-opacity: 0; } to { fill-opacity: 1; } }
@keyframes sk-fade { from { opacity: 0; } to { opacity: 1; } }

/* ───────── لودر ───────── */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: var(--paper);
  transition: clip-path .8s cubic-bezier(.7, 0, .2, 1), opacity .3s ease .55s;
  clip-path: circle(150% at 50% 50%);
}
.loader.done { clip-path: circle(0% at 50% 50%); opacity: 0; pointer-events: none; }
.loader-art { width: min(420px, 82vw); overflow: visible; }
.loader-art line, .loader-art .ld-rail, .loader-art .ld-line {
  fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
.ld-ties line { stroke: var(--ink-soft); stroke-width: 3; opacity: .7; }
.ld-rail { stroke-dasharray: 420; stroke-dashoffset: 420; animation: ld-draw .9s .1s var(--out) forwards; }
.ld-rail + .ld-rail { animation-delay: .25s; }
.ld-ties line { opacity: 0; animation: ld-pop .3s var(--spring) forwards; }
.ld-ties line:nth-child(n) { animation-delay: calc(.2s + var(--n, 0) * 40ms); }
.ld-ties line:nth-child(1) { --n: 10; } .ld-ties line:nth-child(2) { --n: 9; } .ld-ties line:nth-child(3) { --n: 8; }
.ld-ties line:nth-child(4) { --n: 7; } .ld-ties line:nth-child(5) { --n: 6; } .ld-ties line:nth-child(6) { --n: 5; }
.ld-ties line:nth-child(7) { --n: 4; } .ld-ties line:nth-child(8) { --n: 3; } .ld-ties line:nth-child(9) { --n: 2; }
.ld-ties line:nth-child(10) { --n: 1; } .ld-ties line:nth-child(11) { --n: 0; }
.ld-trolley { transform: translateX(500px); animation: ld-run 2.6s .5s cubic-bezier(.45, .05, .4, 1) infinite; }
.ld-trolley .ld-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ld-draw 1s .4s ease forwards; }
.ld-fill { fill: var(--accent) !important; fill-opacity: 0; animation: ld-draw 1s .4s ease forwards, ld-fill .5s 1s forwards !important; }
.ld-spoke { transform-box: fill-box; transform-origin: center; animation: ld-draw 1s .4s ease forwards, spin .5s linear infinite !important; }
.ld-puffs circle { fill: var(--paper); stroke: var(--ink-soft); stroke-width: 1.6; opacity: 0; transform-box: fill-box; transform-origin: center; animation: ld-puff 2.6s .5s ease-out infinite; }
.ld-puffs circle:nth-child(2) { animation-delay: .8s; }
.ld-puffs circle:nth-child(3) { animation-delay: 1.1s; }
@keyframes ld-draw { to { stroke-dashoffset: 0; } }
@keyframes ld-fill { to { fill-opacity: 1; } }
@keyframes ld-pop { from { opacity: 0; transform: scaleY(0); } to { opacity: .7; transform: none; } }
@keyframes ld-run {
  0% { transform: translateX(500px); }
  45%, 55% { transform: translateX(210px); }
  100% { transform: translateX(-120px); }
}
@keyframes ld-puff {
  0% { opacity: 0; transform: translate(500px, 0) scale(.3); }
  45% { opacity: 0; transform: translate(266px, -6px) scale(.4); }
  55% { opacity: .9; transform: translate(276px, -20px) scale(1); }
  100% { opacity: 0; transform: translate(300px, -60px) scale(1.8); }
}
.loader-title {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -.5px;
  animation: rise .7s .5s var(--out) both;
}
.loader-hint { color: var(--ink-soft); font-size: .95rem; animation: rise .7s .7s var(--out) both, pulse 1.4s 1.4s ease-in-out infinite; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pulse { 50% { opacity: .45; } }

/* ───────── هدر ───────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  font-size: 1.15rem;
  justify-self: start;
}
.brand svg { width: 34px; height: 34px; transition: transform .4s var(--spring); }
.brand svg .lever-stick, .brand svg circle.f-accent { transform-box: view-box; transform-origin: 20px 30px; transition: transform .45s var(--spring); }
.brand:hover svg .lever-stick, .brand:hover svg circle.f-accent { transform: rotate(-38deg); }
.level-head { text-align: center; min-width: 0; }
.game-title { font-weight: 900; font-size: clamp(1.05rem, 2.6vw, 1.5rem); line-height: 1.4; }
.level-sub { font-size: clamp(.78rem, 1.8vw, .95rem); color: var(--ink-soft); min-height: 1.4em; line-height: 1.5; }
.level-sub.swap { animation: sub-in .5s var(--out); }
@keyframes sub-in { from { opacity: 0; transform: translateY(-6px); filter: blur(2px); } }
.tools { justify-self: end; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s var(--spring);
}
.icon-btn:hover { background: var(--paper-2); border-color: var(--ink); transform: rotate(-6deg); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn .mute { opacity: 0; }
.icon-btn .wave { transition: opacity .2s; animation: wifi 1.6s ease-in-out infinite; }
.icon-btn .w2 { animation-delay: .3s; }
.icon-btn.off .wave { opacity: 0; animation: none; }
.icon-btn.off .mute { opacity: 1; }
.deaths {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 12px 3px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  background: var(--paper);
  box-shadow: -2px 2px 0 var(--shadow);
}
.deaths svg { width: 22px; height: 22px; }
.deaths.bump { animation: bump .6s var(--spring); }
@keyframes bump { 30% { transform: scale(1.3) rotate(-8deg); background: var(--accent); color: var(--on-accent); } }

.progress { padding: 0 clamp(14px, 3vw, 28px); }
.progress-rail { position: relative; height: 10px; max-width: 980px; margin: 0 auto; border-top: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); background: repeating-linear-gradient(90deg, transparent 0 14px, color-mix(in srgb, var(--ink-soft) 50%, transparent) 14px 16px); }
.progress-fill { position: absolute; inset: -2px 0 -2px auto; width: calc(var(--p, 0) * 100%); background: var(--accent); border-radius: 2px; transition: width .8s var(--out); }
.progress-dot {
  position: absolute; top: 50%;
  right: calc(var(--p, 0) * 100%);
  width: 18px; height: 18px;
  translate: 50% -50%;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  transition: right .8s var(--out);
  box-shadow: 0 0 0 3px var(--paper);
}

/* ───────── صفحه‌ها ───────── */
main { max-width: 1060px; margin: 0 auto; padding: 8px clamp(14px, 3vw, 28px) 40px; }
.screen { will-change: transform, opacity; }

.intro { text-align: center; padding-top: 4px; }
.hero { max-width: 900px; margin: 0 auto; }
.hero-art { width: 100%; height: auto; overflow: visible; }
.hero-run { animation: hero-run 7s linear infinite; }
@keyframes hero-run { from { transform: translateX(1080px); } to { transform: translateX(-200px); } }
.hero-art .wheel path { transform-box: fill-box; transform-origin: center; animation: spin .45s linear infinite reverse; }
.hero-sw { transform-box: fill-box; }
.hero-sw > path:nth-of-type(3) { transform-box: fill-box; transform-origin: 100% 100%; animation: wave .9s ease-in-out infinite; }
@keyframes wave { 50% { transform: rotate(-24deg); } }
.intro-title {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 4rem);
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: -1px;
}
.lead { max-width: 640px; margin: 10px auto 22px; font-size: clamp(1rem, 2.3vw, 1.2rem); color: var(--ink-soft); animation: rise .7s .35s var(--out) both; }
.cta { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; animation: rise .7s .5s var(--out) both; }
.fine { color: var(--ink-soft); font-size: .92rem; margin-top: 18px; animation: rise .7s .65s var(--out) both; }
.fine.alt { margin-top: 6px; animation-delay: .75s; }
.credit { margin: 28px 0 0; font-size: .8rem; color: var(--ink-soft); text-align: center; animation: rise .7s 1.1s var(--out) both; }
.credit a { color: inherit; font-weight: 700; text-decoration: none; border-bottom: 1px dashed currentColor; direction: ltr; unicode-bidi: isolate; }
.credit a:hover { color: var(--accent); }
.alt-link {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 2px dashed var(--accent);
  padding: 0 2px;
  transition: background .2s, color .2s;
}
.alt-link:hover { background: var(--accent); color: var(--on-accent); border-bottom-color: transparent; border-radius: 4px; }
.howto { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; padding: 0; margin: 26px 0 0; color: var(--ink-soft); }
.howto li { display: flex; align-items: center; gap: 8px; animation: rise .6s var(--out) both; }
.howto li:nth-child(1) { animation-delay: .8s; }
.howto li:nth-child(2) { animation-delay: .9s; }
.howto li:nth-child(3) { animation-delay: 1s; }
.howto .k { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 50%; font-weight: 800; color: var(--ink); }

/* کلمه به کلمه آمدن متن */
.w { display: inline-block; animation: word .55s calc(var(--i) * 28ms + .35s) var(--out) both; }
@keyframes word { from { opacity: 0; transform: translateY(10px) rotate(2deg); filter: blur(3px); } }
.intro-title .w { animation-delay: calc(var(--i) * 120ms + .1s); animation-duration: .8s; }

/* ───────── صحنه‌ی بازی ───────── */
.stage {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  aspect-ratio: 900 / 440;
  container-type: inline-size;
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay > * { position: absolute; translate: -50% -100%; white-space: nowrap; }
.track-label, .item-tag {
  font-size: clamp(10px, 1.55cqw, 15px);
  font-weight: 800;
  padding: .15em .8em;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: -2px 2px 0 var(--shadow);
  opacity: 0;
}
.item-tag { background: var(--mustard); color: #1e1b2b; padding: .05em .6em; border-radius: 10px 10px 10px 2px; }
.drawn .track-label, .drawn .item-tag { animation: pop-in .55s var(--spring) forwards; }
.drawn .overlay > :nth-child(2) { animation-delay: .12s; }
.drawn .overlay > :nth-child(3) { animation-delay: .24s; }
.drawn .overlay > :nth-child(4) { animation-delay: .36s; }
@keyframes pop-in { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
.decided .track-label { transition: opacity .3s; }
.went-top .overlay > .track-label:nth-child(2),
.went-bottom .overlay > .track-label:first-child { opacity: .45; }
.scene-note {
  font-size: clamp(11px, 1.8cqw, 17px);
  font-weight: 900;
  padding: .3em 1em;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: -3px 3px 0 var(--shadow);
  animation: pop-in .5s var(--spring) both;
  z-index: 2;
}
.scene-note.bad { background: var(--accent); color: var(--on-accent); }
.scene-note.good { background: var(--sage); color: #1e1b2b; }
.scene-note.calm { background: var(--lilac); color: #1e1b2b; }
.pop-text {
  font-weight: 900;
  font-size: clamp(11px, 1.9cqw, 18px);
  color: var(--accent);
  -webkit-text-stroke: .5px var(--ink);
  animation: pop-float 1.4s ease-out forwards;
}
@keyframes pop-float {
  0% { opacity: 0; transform: translateY(8px) scale(.5); }
  20% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-26px) scale(1); }
}
.smoke { stroke: var(--ink-soft); stroke-width: 1.6; }

.question {
  max-width: 820px;
  margin: 6px auto 18px;
  font-size: clamp(1.05rem, 2.5vw, 1.45rem);
  font-weight: 600;
  line-height: 2;
  text-align: center;
  text-wrap: pretty;
}
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }

/* ───────── دکمه‌ها ───────── */
.btn {
  --sx: -4px;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .55em;
  padding: .7em 1.6em;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--sx) 4px 0 var(--shadow);
  cursor: pointer;
  transition: transform .18s var(--spring), box-shadow .18s ease, background .2s, opacity .3s, filter .3s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { transform: translate(2px, -3px) rotate(-1deg); box-shadow: -7px 7px 0 var(--shadow); }
.btn:active { transform: translate(-3px, 3px) scale(.98); box-shadow: 0 0 0 var(--shadow); transition-duration: .06s; }
.btn:focus-visible { outline: 3px dashed var(--accent); outline-offset: 4px; }
.btn-pull { background: var(--accent); color: var(--on-accent); }
.btn-stay { background: var(--paper); }
.btn .key {
  display: inline-grid; place-items: center;
  width: 1.5em; height: 1.5em;
  font-size: .72em;
  border: 2px solid currentColor;
  border-radius: 6px;
  opacity: .7;
}
.choice { animation: rise .6s var(--out) both; }
.choice:nth-child(1) { animation-delay: .9s; }
.choice:nth-child(2) { animation-delay: 1s; }
.chosen .choice { pointer-events: none; }
.chosen .choice:not(.picked) { opacity: .3; filter: grayscale(1); transform: scale(.94); }
.chosen .choice.picked { animation: picked .5s var(--spring); }
@keyframes picked { 40% { transform: scale(1.08) rotate(-2deg); } }
.btn-next .arrow { display: inline-block; transition: transform .25s var(--spring); }
.btn-next:hover .arrow { transform: translateX(-6px); }

/* ───────── نوار نتیجه ───────── */
.result-bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  background: var(--paper);
  border-top: 2.5px solid var(--ink);
  transform: translateY(115%);
  visibility: hidden;
  transition: transform .65s var(--spring), visibility 0s .65s;
  padding: 12px clamp(14px, 3vw, 28px) calc(12px + env(safe-area-inset-bottom));
}
.result-bar.show { transform: none; visibility: visible; transition: transform .65s var(--spring); }
.rb-inner { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; justify-content: center; }
.pie { width: 52px; height: 52px; flex: none; transform: rotate(-90deg); }
.pie-bg { fill: var(--paper-2); stroke: var(--ink); stroke-width: 2; }
.pie-fg {
  fill: none;
  stroke: var(--ink);
  stroke-width: 31.83;
  stroke-dasharray: 0 100;
  transform: scale(.5);
  transform-origin: center;
  transition: stroke-dasharray 1.1s var(--out) .15s;
}
.result-bar[data-choice="pull"] .pie-fg { stroke: var(--accent); }
.result-bar[data-choice="stay"] .pie-fg { stroke: var(--teal); }
.result-bar.show .pie { animation: pie-in .7s var(--spring); }
.result-bar.no-stats .pie { display: none; }
@keyframes pie-in { from { transform: rotate(-270deg) scale(.3); } }
.rb-text { flex: 1 1 320px; min-width: 0; line-height: 1.7; }
.rb-main { font-size: clamp(1rem, 2.3vw, 1.2rem); font-weight: 700; }
.rb-main .pct { font-size: 1.35em; color: var(--accent); }
.result-bar[data-choice="stay"] .rb-main .pct { color: var(--teal); }
.rb-main .dis { font-weight: 800; }
.rb-sub { font-size: .88rem; color: var(--ink-soft); }
.rb-sub .offline { color: var(--accent); }
.rb-sub .seg { display: inline-block; unicode-bidi: isolate; margin-inline-end: .9em; }
.rb-sub .seg + .seg::before { content: '•'; margin-inline-end: .9em; opacity: .5; }
.rb-deaths {
  font-weight: 800;
  padding: 4px 12px;
  border: 2px dashed var(--ink);
  border-radius: 10px;
  white-space: nowrap;
}
.rb-deaths .skull { color: var(--accent); }
.rb-deaths .ok { color: var(--teal); }
.result-bar.show .rb-text { animation: rise .6s .15s var(--out) both; }
.result-bar.show .rb-deaths { animation: pop-in .5s .35s var(--spring) both; }
.result-bar.show .btn-next { animation: pop-in .5s .45s var(--spring) both; }

/* ───────── صفحه‌ی پایان ───────── */
.end { text-align: center; position: relative; }
.end-hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); margin: 10px 0 0; font-weight: 900; line-height: 1.4; }
.big-stat { display: flex; flex-direction: column; align-items: center; margin: 4px 0 20px; }
.big-stat .num { font-size: clamp(4rem, 15vw, 8rem); font-weight: 900; line-height: 1.1; color: var(--accent); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; animation: pop-in .7s .2s var(--spring) both; }
.big-stat .lbl { color: var(--ink-soft); font-weight: 600; }
.arch-card {
  display: flex; gap: 18px; align-items: center; text-align: start;
  max-width: 640px; margin: 0 auto 22px;
  padding: 18px 22px;
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  background: var(--paper-2);
  box-shadow: -6px 6px 0 var(--shadow);
  animation: card-in .8s .5s var(--spring) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(30px) rotate(3deg) scale(.9); } }
.arch-icon { font-size: 3rem; line-height: 1; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(10deg) scale(1.08); } }
.arch-kicker { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.arch-name { font-size: 1.6rem; font-weight: 900; color: var(--accent); line-height: 1.5; }
.arch-card p { margin: 4px 0 0; }
.mini-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.mini-stats > div {
  display: flex; flex-direction: column; align-items: center;
  min-width: 150px; padding: 10px 14px;
  border: 2px solid var(--ink); border-radius: 16px; background: var(--paper);
  animation: rise .6s var(--out) both;
}
.mini-stats > div:nth-child(1) { animation-delay: .7s; }
.mini-stats > div:nth-child(2) { animation-delay: .8s; }
.mini-stats > div:nth-child(3) { animation-delay: .9s; }
.mini-stats b { font-size: 1.8rem; line-height: 1.4; }
.mini-stats span { font-size: .85rem; color: var(--ink-soft); }
.list-title { margin: 36px 0 10px; font-size: 1.3rem; }
.lv-list { list-style: none; padding: 0; margin: 0 auto; max-width: 760px; display: grid; gap: 8px; text-align: start; }
.lv-list li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto 120px;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  animation: rise .5s calc(1s + var(--i) * 45ms) var(--out) both;
  transition: transform .2s var(--spring), box-shadow .2s;
}
.lv-list li:hover { transform: translateX(-4px); box-shadow: -4px 4px 0 var(--shadow); }
.lv-n { font-weight: 800; color: var(--ink-soft); }
.lv-t { font-weight: 700; }
.chip { font-size: .8rem; font-weight: 800; padding: 1px 10px; border-radius: 999px; border: 2px solid var(--ink); white-space: nowrap; }
.chip.pull { background: var(--accent); color: var(--on-accent); }
.chip.stay { background: var(--teal); color: var(--on-accent); }
.lv-agree { position: relative; height: 22px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--paper-2); }
.lv-agree i { position: absolute; inset: 0 0 0 auto; width: var(--w); background: var(--mustard); animation: grow 1s 1.3s var(--out) both; }
.lv-agree.few { border-style: dashed; background: transparent; }
.lv-agree.few b { color: var(--ink-soft); }
.lv-agree b { position: relative; display: block; text-align: center; font-size: .75rem; line-height: 18px; color: #1e1b2b; }
@keyframes grow { from { width: 0; } }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -20px; width: 18px; height: 18px; animation: fall 3s cubic-bezier(.3, .2, .6, 1) forwards; }
.confetti svg { width: 100%; height: 100%; overflow: visible; }
.confetti path { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

/* ───────── پیام کوتاه ───────── */
.toast {
  position: fixed; top: 16px; left: 50%;
  z-index: 60;
  translate: -50% -150%;
  padding: 8px 20px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--mustard);
  color: #1e1b2b;
  font-weight: 800;
  box-shadow: -4px 4px 0 var(--shadow);
  transition: translate .5s var(--spring), visibility 0s .5s;
  visibility: hidden;
}
.toast.show { translate: -50% 0; visibility: visible; transition: translate .5s var(--spring); }
.noscript { text-align: center; padding: 40px; }

/* ───────── اشتراک‌گذاری ───────── */
.share-btn { flex: none; }
.share-btn svg { width: 22px; height: 22px; }
.share-btn:hover { transform: rotate(6deg); }
.q-row { display: flex; align-items: flex-start; justify-content: center; gap: 12px; max-width: 820px; margin: 0 auto; }
.q-row .question { margin-inline: 0; flex: 1; }
.q-row .share-btn { margin-top: 14px; }
.rb-share { width: 44px; height: 44px; }
.intro .share-game { margin-top: 14px; animation: rise .7s .7s var(--out) both; }
.btn svg { width: 1.2em; height: 1.2em; flex: none; }
.btn svg .ln, .app-btn svg .ln { stroke: currentColor; }

body.sheet-open { overflow: hidden; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  opacity: 0;
  transition: opacity .25s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 18px 20px 16px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  box-shadow: -6px 6px 0 var(--shadow);
  text-align: center;
  transform: translateY(24px) scale(.96);
  transition: transform .4s var(--spring);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-close { position: absolute; top: 10px; left: 10px; width: 38px; height: 38px; }
.sheet-close svg { width: 20px; height: 20px; }
.sheet-title { margin: 0 0 10px; font-size: 1.25rem; font-weight: 900; }
.sheet-tabs { display: inline-flex; margin-bottom: 10px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.sheet-tabs button {
  font: inherit; font-weight: 800; font-size: .9rem;
  padding: 4px 16px; border: 0; background: var(--paper); color: var(--ink); cursor: pointer;
}
.sheet-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.sheet-preview {
  display: grid; place-items: center;
  height: min(46dvh, 400px);
  margin: 0 auto 14px;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border: 2px dashed var(--ink-soft);
  border-radius: 14px;
  background: var(--paper-2);
  overflow: hidden;
}
.sheet-preview[data-format="post"] { aspect-ratio: 4 / 5; }
@media (max-height: 760px) { .sheet-preview { height: min(34dvh, 300px); } .sheet-hint { font-size: .72rem; } }
.sheet-preview img { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-touch-callout: default; }
.sheet-preview img[hidden] { display: none; }
.sheet-wait { color: var(--ink-soft); font-size: .9rem; padding: 0 12px; animation: pulse 1.4s ease-in-out infinite; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sheet-actions .btn { padding: .55em 1.1em; font-size: 1rem; text-decoration: none; }
.sheet-actions .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.sheet-actions .btn[hidden] { display: none; }
.sheet-native { flex-basis: 100%; justify-content: center; }
.sheet-apps { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.app-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 76px; padding: 8px 10px;
  border: 2px solid var(--ink); border-radius: 14px;
  color: var(--ink); text-decoration: none; font-weight: 800; font-size: .82rem;
  background: var(--paper);
  transition: transform .18s var(--spring), background .2s;
}
.app-btn:hover { background: var(--paper-2); transform: translateY(-2px) rotate(-2deg); }
.app-btn:focus-visible, .sheet-tabs button:focus-visible { outline: 3px dashed var(--accent); outline-offset: 3px; }
.app-btn svg { width: 26px; height: 26px; }
.sheet-hint { margin: 12px 0 0; font-size: .78rem; color: var(--ink-soft); line-height: 1.7; }

/* دکمه‌ی موسیقی */
.music-btn .note-off { opacity: 0; }
.music-btn .notes { transform-box: fill-box; transform-origin: center; animation: note 1.6s ease-in-out infinite; }
.music-btn.off .notes { animation: none; opacity: .45; }
.music-btn.off .note-off { opacity: 1; }

/* ───────── ریسپانسیو ───────── */
@media (max-width: 640px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .brand span { display: none; }
  .game-title { font-size: 1rem; }
  .level-sub { font-size: .75rem; }
  .deaths { padding: 2px 10px 2px 6px; font-size: .9rem; }
  .icon-btn { width: 36px; height: 36px; }
  .tools { gap: 5px; }
  .rb-share { width: 40px; height: 40px; }
  .sheet { padding: 14px 14px 12px; }
  .app-btn { min-width: 0; flex: 1; }
  .choices { gap: 10px; }
  .choices .btn { flex: 1 1 140px; justify-content: center; padding: .7em 1em; }
  .btn .key { display: none; }
  .rb-inner { gap: 8px 12px; }
  .pie { width: 42px; height: 42px; }
  .rb-text { flex-basis: calc(100% - 60px); }
  .rb-sub { font-size: .78rem; }
  .btn-next { flex: 1 1 auto; justify-content: center; }
  body.has-result { padding-bottom: 190px; }
  .lv-list li { grid-template-columns: 1.8em 1fr auto; }
  .lv-agree { grid-column: 2 / -1; }
  .arch-card { flex-direction: column; text-align: center; }
  .mini-stats > div { min-width: 100px; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* قطار صفحه‌ی اول بی‌حرکت، سمت راست و پیش از اهرم می‌ایستد (همان HERO_TROLLEY_PARK در art.js) */
  .hero-run { animation: none !important; transform: translateX(720px); }
}
