/* ===========================================================================
   چوگان — سیستم طراحی مشترک
   همه‌ی صفحه‌ها و بازی‌ها فقط از توکن‌های همین فایل استفاده می‌کنند.
   هیچ رنگ یا اندازه‌ی خامی داخل بازی‌ها نوشته نمی‌شود.
   =========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn-variable.woff2') format('woff2-variations'),
       url('../fonts/vazirmatn-variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------- توکن‌ها */
:root {
  color-scheme: light;

  /* پالت پاستلی گرم */
  --c-bg:          #FBF6EF;
  --c-bg-tint:     #F4EADD;
  --c-surface:     #FFFFFF;
  --c-surface-2:   #F7F1E8;
  --c-surface-3:   #EFE6D9;
  --c-line:        #E7DACA;
  --c-text:        #2C2620;
  --c-text-dim:    #7C7063;
  --c-text-faint:  #A99C8C;

  --c-accent:      #E07A5F;
  --c-accent-soft: #FBE7DF;
  --c-accent-ink:  #FFFFFF;

  --c-good:        #5C9A6B;
  --c-good-soft:   #E1F0E4;
  --c-warn:        #C8912F;
  --c-warn-soft:   #F8EDD6;
  --c-bad:         #C8574B;
  --c-bad-soft:    #FAE3E0;
  --c-gold:        #D9A441;

  /* رده‌های لیگ */
  --c-tier-1: #B08050;
  --c-tier-2: #9AA3AB;
  --c-tier-3: #D9A441;
  --c-tier-4: #6BB6C4;
  --c-tier-5: #A57BD1;

  /* شعاع */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* فاصله */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* سایه‌ی نرم و گرم */
  --sh-1: 0 1px 2px rgba(78, 58, 38, .06), 0 2px 6px rgba(78, 58, 38, .05);
  --sh-2: 0 2px 6px rgba(78, 58, 38, .07), 0 8px 20px rgba(78, 58, 38, .07);
  --sh-3: 0 6px 14px rgba(78, 58, 38, .09), 0 18px 40px rgba(78, 58, 38, .10);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, .6);

  /* تایپوگرافی */
  --f: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --fs-3xl: 42px;

  /* حرکت */
  --t-fast: 120ms;
  --t-mid: 220ms;
  --t-slow: 360ms;
  --ease: cubic-bezier(.2, .8, .3, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);

  /* چیدمان */
  --w-page: 560px;
  --w-wide: 900px;
  --nav-h: 62px;
  --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);
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  /* پیش‌فرض روشن است؛ تاریک فقط زیر مدیا یا با انتخاب دستی */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg:          #15120E;
    --c-bg-tint:     #1D1913;
    --c-surface:     #211C16;
    --c-surface-2:   #2A241C;
    --c-surface-3:   #342C22;
    --c-line:        #3A3128;
    --c-text:        #F4EEE4;
    --c-text-dim:    #A99C8B;
    --c-text-faint:  #7C7162;
    --c-accent:      #E8917A;
    --c-accent-soft: #3A2620;
    --c-accent-ink:  #201410;
    --c-good:        #7ABE8A;
    --c-good-soft:   #24301F;
    --c-warn:        #DFB45E;
    --c-warn-soft:   #33291A;
    --c-bad:         #E0796C;
    --c-bad-soft:    #362020;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .25);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .3);
    --sh-3: 0 6px 14px rgba(0, 0, 0, .4), 0 18px 40px rgba(0, 0, 0, .38);
    --sh-inset: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg:          #15120E;
  --c-bg-tint:     #1D1913;
  --c-surface:     #211C16;
  --c-surface-2:   #2A241C;
  --c-surface-3:   #342C22;
  --c-line:        #3A3128;
  --c-text:        #F4EEE4;
  --c-text-dim:    #A99C8B;
  --c-text-faint:  #7C7162;
  --c-accent:      #E8917A;
  --c-accent-soft: #3A2620;
  --c-accent-ink:  #201410;
  --c-good:        #7ABE8A;
  --c-good-soft:   #24301F;
  --c-warn:        #DFB45E;
  --c-warn-soft:   #33291A;
  --c-bad:         #E0796C;
  --c-bad-soft:    #362020;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px rgba(0, 0, 0, .25);
  --sh-2: 0 2px 6px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .3);
  --sh-3: 0 6px 14px rgba(0, 0, 0, .4), 0 18px 40px rgba(0, 0, 0, .38);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ------------------------------------------------------------------ پایه */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f);
  font-size: var(--fs-md);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body.ch-noscroll {
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

h1, h2, h3 { margin: 0; font-weight: 800; line-height: 1.35; letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0; }
a  { color: var(--c-accent); text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.ch-dim   { color: var(--c-text-dim); }
.ch-faint { color: var(--c-text-faint); }
.ch-sm    { font-size: var(--fs-sm); }
.ch-xs    { font-size: var(--fs-xs); }
.ch-bold  { font-weight: 800; }
.ch-num   { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.ch-center { text-align: center; }
.ch-hidden { display: none !important; }
.ch-row   { display: flex; align-items: center; gap: var(--s-3); }
.ch-col   { display: flex; flex-direction: column; gap: var(--s-3); }
.ch-grow  { flex: 1; min-width: 0; }
.ch-wrap  { flex-wrap: wrap; }

/* --------------------------------------------------------------- چیدمان */
.ch-page {
  max-width: var(--w-page);
  margin: 0 auto;
  padding:
    calc(var(--s-4) + var(--safe-t))
    calc(var(--s-4) + var(--safe-r))
    calc(var(--nav-h) + var(--s-7) + var(--safe-b))
    calc(var(--s-4) + var(--safe-l));
}
.ch-page--wide { max-width: var(--w-wide); }
.ch-page--flat { padding-bottom: calc(var(--s-6) + var(--safe-b)); }

.ch-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
/* دکمه‌ی تمام‌صفحه کنار سکه‌ها، فقط جایی که مرورگر پشتیبانی می‌کند */
.ch-head .ch-iconbtn { flex: none; }
.ch-head__title { flex: 1; min-width: 0; }
.ch-head h1 { font-size: var(--fs-2xl); }
.ch-head p { color: var(--c-text-dim); font-size: var(--fs-sm); }

.ch-section { margin-bottom: var(--s-6); }
.ch-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.ch-section__head h2 { font-size: var(--fs-lg); }

/* ----------------------------------------------------------------- کارت */
.ch-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: var(--s-4);
  border: 1px solid transparent;
}
.ch-card--flat { box-shadow: var(--sh-1); }
.ch-card--tint { background: var(--c-surface-2); box-shadow: none; border-color: var(--c-line); }

.ch-tap {
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  -webkit-user-select: none;
  user-select: none;
}
.ch-tap:active { transform: scale(.975); box-shadow: var(--sh-1); }

/* کارت بازی */
.ch-games { display: grid; gap: var(--s-3); }
@media (min-width: 620px) { .ch-games { grid-template-columns: 1fr 1fr; } }

.ch-game {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  position: relative;
  overflow: hidden;
}
.ch-game__icon {
  width: 62px; height: 62px;
  flex: 0 0 62px;
  border-radius: var(--r-md);
  background: var(--game-soft, var(--c-surface-2));
  display: grid; place-items: center;
  overflow: hidden;
}
.ch-game__icon svg, .ch-game__icon img { width: 100%; height: 100%; display: block; }
.ch-game__body { flex: 1; min-width: 0; }
.ch-game__name { font-weight: 800; font-size: var(--fs-lg); }
.ch-game__sum {
  color: var(--c-text-dim);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-game__meta { display: flex; gap: var(--s-2); margin-top: var(--s-1); flex-wrap: wrap; }

/* --------------------------------------------------------------- نشان‌ها */
.ch-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--c-surface-3);
  color: var(--c-text-dim);
  line-height: 1.8;
  white-space: nowrap;
}
.ch-badge--accent { background: var(--game-soft, var(--c-accent-soft)); color: var(--game, var(--c-accent)); }
.ch-badge--good   { background: var(--c-good-soft); color: var(--c-good); }
.ch-badge--warn   { background: var(--c-warn-soft); color: var(--c-warn); }
.ch-badge--bad    { background: var(--c-bad-soft); color: var(--c-bad); }
.ch-badge--gold   { background: var(--c-warn-soft); color: var(--c-gold); }

/* ----------------------------------------------------------------- دکمه */
.ch-btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: var(--r-pill);
  padding: 0 var(--s-5);
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  cursor: pointer;
  background: var(--c-surface-2);
  color: var(--c-text);
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.ch-btn:active { transform: scale(.96); }
.ch-btn:disabled { opacity: .45; cursor: default; transform: none; }
.ch-btn--primary {
  background: var(--game, var(--c-accent));
  color: var(--c-accent-ink);
  box-shadow: var(--sh-2);
}
.ch-btn--ghost { background: transparent; color: var(--c-text-dim); }
.ch-btn--soft  { background: var(--game-soft, var(--c-accent-soft)); color: var(--game, var(--c-accent)); }
.ch-btn--danger { background: var(--c-bad-soft); color: var(--c-bad); }
.ch-btn--sm { min-height: 38px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.ch-btn--block { width: 100%; }
.ch-btn--icon { padding: 0; width: 48px; height: 48px; border-radius: var(--r-md); }

.ch-btn__ripple { position: relative; overflow: hidden; }

/* --------------------------------------------------------- نوار ناوبری */
.ch-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 6px calc(var(--s-2) + var(--safe-r)) calc(6px + var(--safe-b)) calc(var(--s-2) + var(--safe-l));
  background: var(--c-surface);
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--c-line);
}
.ch-nav__in { display: flex; width: 100%; max-width: var(--w-page); }
.ch-nav__item {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  color: var(--c-text-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  min-height: 50px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: color var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ch-nav__item svg { width: 24px; height: 24px; display: block; transition: transform var(--t-mid) var(--ease-back); }
.ch-nav__item[aria-selected="true"] { color: var(--c-accent); }
.ch-nav__item[aria-selected="true"] svg { transform: translateY(-2px) scale(1.08); }
.ch-nav__item:active svg { transform: scale(.9); }

/* ------------------------------------------------- سربرگ داخل بازی‌ها */
.ch-gamebar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding:
    calc(var(--s-2) + var(--safe-t))
    calc(var(--s-3) + var(--safe-r))
    var(--s-2)
    calc(var(--s-3) + var(--safe-l));
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  flex: 0 0 auto;
  z-index: 10;
}
.ch-gamebar__title {
  font-weight: 800;
  font-size: var(--fs-md);
  /* بدون این، نام بازی روی عددهای سربرگ سرریز می‌کرد */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-gamebar__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  min-width: 52px;
}
.ch-gamebar__stat b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.ch-gamebar__stat span { font-size: 10px; color: var(--c-text-faint); font-weight: 700; }

.ch-iconbtn {
  border: 0;
  background: var(--c-surface-2);
  color: var(--c-text);
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ch-iconbtn:active { transform: scale(.92); }
.ch-iconbtn svg { width: 22px; height: 22px; }
.ch-iconbtn--plain { background: transparent; }
.ch-iconbtn--gold { background: var(--c-warn-soft); color: var(--c-gold); }
/* کلاس‌های خودمان display می‌گذارند و بر [hidden] مرورگر می‌چربند */
[hidden] { display: none !important; }
.ch-iconbtn[aria-pressed="true"] { background: var(--game-soft, var(--c-accent-soft)); color: var(--game, var(--c-accent)); }

/* روی صفحه‌های باریک، سربرگ بازی جا کم می‌آورد: دکمه‌ی بازگشت، نام بازی،
   دو سه عدد و دو سه دکمه. اول فضا را از عددها و فاصله‌ها می‌گیریم، و زیر
   ۳۶۰ پیکسل نام بازی کلاً کنار می‌رود — بریدنش به «س…» از نشان ندادنش بدتر
   است، و کاربر همین الان از منو آمده و می‌داند کدام بازی را باز کرده. */
@media (max-width: 420px) {
  .ch-gamebar { gap: 6px; }
  .ch-gamebar__stat { min-width: 44px; }
}
@media (max-width: 360px) {
  .ch-gamebar__title { display: none; }
  .ch-gamebar__stat { min-width: 40px; }
  .ch-iconbtn { width: 40px; height: 40px; }
}

/* پوسته‌ی صفحه‌ی بازی */
.ch-gameroot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
}
.ch-gamemain {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-3) calc(var(--s-3) + var(--safe-r)) calc(var(--s-3) + var(--safe-b)) calc(var(--s-3) + var(--safe-l));
  gap: var(--s-3);
  overflow: hidden;
}
.ch-gamemain--scroll { justify-content: flex-start; overflow-y: auto; overscroll-behavior: contain; }
.ch-board { max-width: min(100%, 620px); width: 100%; }

/* ---------------------------------------------------------------- سکه */
.ch-coin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--c-gold);
  background: var(--c-warn-soft);
  border-radius: var(--r-pill);
  padding: 4px 12px 4px 8px;
  font-size: var(--fs-sm);
}
[dir="rtl"] .ch-coin { padding: 4px 8px 4px 12px; }
.ch-coin svg { width: 18px; height: 18px; }

/* --------------------------------------------------------------- سوییچ */
.ch-switch {
  position: relative;
  width: 52px; height: 32px;
  flex: 0 0 52px;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  border: 0;
  cursor: pointer;
  transition: background var(--t-mid) var(--ease);
  padding: 0;
}
.ch-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform var(--t-mid) var(--ease-back);
}
.ch-switch[aria-checked="true"] { background: var(--c-good); }
.ch-switch[aria-checked="true"]::after { transform: translateX(20px); }
[dir="rtl"] .ch-switch[aria-checked="true"]::after { transform: translateX(-20px); }

/* -------------------------------------------------------------- فهرست */
.ch-list { display: flex; flex-direction: column; }
.ch-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-1);
  min-height: 52px;
  border-bottom: 1px solid var(--c-line);
}
.ch-item:last-child { border-bottom: 0; }
.ch-item__label { flex: 1; min-width: 0; font-weight: 600; }
.ch-item__hint { font-size: var(--fs-xs); color: var(--c-text-faint); font-weight: 400; }

.ch-seg {
  display: inline-flex;
  background: var(--c-surface-2);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.ch-seg button {
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-text-dim);
  padding: 7px 16px;
  min-height: 38px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ch-seg button[aria-selected="true"] {
  background: var(--c-surface);
  color: var(--game, var(--c-accent));
  box-shadow: var(--sh-1);
}

/* ------------------------------------------------------------ پیمایه */
.ch-bar {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface-3);
  overflow: hidden;
}
.ch-bar__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--game, var(--c-accent));
  transition: width var(--t-slow) var(--ease);
}

/* ------------------------------------------------------- پنجره و شیت */
.ch-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(24, 18, 12, .48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  animation: ch-fade var(--t-mid) var(--ease);
}
.ch-modal {
  width: min(100%, 420px);
  max-height: calc(100dvh - var(--s-7));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  padding: var(--s-5);
  animation: ch-pop var(--t-slow) var(--ease-back);
}
.ch-card__img { display: block; width: 100%; height: auto; border-radius: var(--r-md); box-shadow: var(--sh-2); }
.ch-modal__head { display: flex; align-items: flex-start; gap: var(--s-2); margin-bottom: var(--s-2); }
.ch-modal__head h2 { flex: 1; margin: 0; min-width: 0; }
.ch-modal__head .ch-iconbtn { flex: none; width: 34px; height: 34px; margin-block-start: -2px; }
.ch-modal__head .ch-iconbtn svg { width: 20px; height: 20px; }
.ch-modal h2 { margin-bottom: var(--s-2); }
.ch-modal__actions { display: flex; gap: var(--s-2); margin-top: var(--s-5); }
.ch-modal__actions .ch-btn { flex: 1; }

/* ------------------------------------------------------------- اعلان */
/* نوار آپدیت، بالای نوار پایین صفحه */
.ch-update {
  position: fixed;
  inset-inline: var(--s-3);
  bottom: calc(var(--nav-h) + var(--s-3) + var(--safe-b));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 520px;
  margin-inline: auto;
  padding: 8px 8px 8px var(--s-3);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: ch-rise var(--t-mid) var(--ease);
}
.ch-update__t { flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-sm); line-height: 1.4; }
.ch-update .ch-iconbtn { width: 34px; height: 34px; flex: none; }
.ch-update .ch-iconbtn svg { width: 18px; height: 18px; }
.ch-toasts {
  position: fixed;
  top: calc(var(--s-3) + var(--safe-t));
  inset-inline: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  pointer-events: none;
  padding: 0 var(--s-4);
}
.ch-toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: var(--c-surface);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-3);
  padding: 8px 18px 8px 8px;
  max-width: min(100%, 400px);
  animation: ch-drop var(--t-slow) var(--ease-back);
  border: 1px solid var(--c-line);
}
[dir="rtl"] .ch-toast { padding: 8px 8px 8px 18px; }
.ch-toast--out { animation: ch-lift var(--t-mid) var(--ease) forwards; }
.ch-toast__icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--c-warn-soft);
  display: grid; place-items: center;
  flex: 0 0 40px;
}
.ch-toast__icon svg { width: 26px; height: 26px; }
.ch-toast__t { font-weight: 800; font-size: var(--fs-sm); line-height: 1.4; }
.ch-toast__s { font-size: var(--fs-xs); color: var(--c-text-dim); line-height: 1.4; }

/* ----------------------------------------------------------- کانفتی */
.ch-confetti {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

/* ------------------------------------------------------------ حرکت */
@keyframes ch-fade { from { opacity: 0; } }
@keyframes ch-pop  { from { opacity: 0; transform: scale(.9) translateY(12px); } }
@keyframes ch-drop { from { opacity: 0; transform: translateY(-18px); } }
@keyframes ch-lift { to { opacity: 0; transform: translateY(-14px); } }
@keyframes ch-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes ch-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@keyframes ch-pulse { 50% { transform: scale(1.14); } }

.ch-enter { animation: ch-rise var(--t-slow) var(--ease) backwards; }
.ch-shake { animation: ch-shake 500ms var(--ease); }
.ch-pulse { animation: ch-pulse var(--t-slow) var(--ease-back); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: .001ms !important;
  transition-duration: .001ms !important;
}

/* ------------------------------------------------------------- تقویم */
.ch-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ch-cal__dow {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-faint);
  padding-bottom: var(--s-1);
}
.ch-day {
  aspect-ratio: 1;
  border: 0;
  background: var(--c-surface-2);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: transform var(--t-fast) var(--ease);
  touch-action: manipulation;
}
.ch-day:active { transform: scale(.92); }
.ch-day--empty { background: none; cursor: default; }
.ch-day--future { opacity: .35; cursor: default; }
.ch-day--today { box-shadow: inset 0 0 0 2px var(--c-accent); }
.ch-day--done { background: var(--c-good-soft); color: var(--c-good); }
.ch-day__dots { display: flex; gap: 2px; }
.ch-day__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c-text-faint); opacity: .35; }
.ch-day__dot--on { opacity: 1; }

/* --------------------------------------------------------------- لیگ */
.ch-tier {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-lg);
  background: var(--tier-c, var(--c-accent));
  background: linear-gradient(135deg, var(--tier-c, var(--c-accent)) 0%, color-mix(in srgb, var(--tier-c, var(--c-accent)) 60%, #fff) 100%);
  color: #fff;
  box-shadow: var(--sh-2);
}
.ch-tier__medal { width: 66px; height: 66px; flex: 0 0 66px; }
.ch-star-off { color: var(--c-text-faint); opacity: .45; }
.ch-rank {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-2);
  border-radius: var(--r-md);
  border-bottom: 1px solid var(--c-line);
}
.ch-rank--me { background: var(--c-accent-soft); border-bottom-color: transparent; }
.ch-rank__n {
  width: 30px;
  text-align: center;
  font-weight: 800;
  color: var(--c-text-faint);
  font-variant-numeric: tabular-nums;
}
.ch-rank__name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-rank__pts { font-weight: 800; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------- دستاوردها */
.ch-achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: var(--s-3); }
.ch-ach {
  text-align: center;
  padding: var(--s-3) var(--s-2);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.ch-ach:active { transform: scale(.94); }
.ch-ach--locked { opacity: .42; filter: grayscale(1); }
.ch-ach svg { width: 48px; height: 48px; }
.ch-ach__n { font-size: 11px; font-weight: 700; line-height: 1.4; margin-top: 4px; }

/* ----------------------------------------------------------- آماره‌ها */
.ch-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--s-3); }
.ch-stat {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: var(--s-3);
  text-align: center;
}
.ch-stat b { display: block; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; line-height: 1.3; }
.ch-stat span { font-size: var(--fs-xs); color: var(--c-text-dim); font-weight: 600; }

/* ------------------------------------------------------------- خالی */
.ch-empty {
  text-align: center;
  padding: var(--s-6) var(--s-4);
  color: var(--c-text-dim);
}
.ch-empty svg { width: 92px; height: 92px; margin-bottom: var(--s-3); }

/* --------------------------------------------------- خوشامدگویی اول */
/* صفحه‌ی اولین اجرا. عمداً جدا از .ch-tut است چون آموزش داخل بازی یک
   پنجره‌ی کوچک است و این یک صفحه‌ی تمام‌قد با گام‌های قابل افزودن. */
.ch-welcome {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--s-5) + var(--safe-t))
    calc(var(--s-4) + var(--safe-r))
    calc(var(--s-4) + var(--safe-b))
    calc(var(--s-4) + var(--safe-l));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ch-welcome__in {
  width: 100%;
  max-width: 460px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.ch-welcome__art { display: grid; place-items: center; }
.ch-welcome__art svg { max-width: 148px; height: auto; }
.ch-welcome h1 { font-size: var(--fs-2xl); text-align: center; }
.ch-welcome__sub { color: var(--c-text-dim); text-align: center; font-size: var(--fs-md); }
.ch-welcome__foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.ch-welcome__foot .ch-btn--primary { flex: 1; }

.ch-chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.ch-char {
  border: 2px solid var(--c-line);
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: var(--s-2) 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-dim);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  touch-action: manipulation;
  min-height: 88px;
}
.ch-char svg { width: 100%; height: auto; max-width: 56px; }
.ch-char:active { transform: scale(.94); }
.ch-char[aria-pressed="true"] {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

.ch-field {
  width: 100%;
  font: inherit;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-line);
  background: var(--c-surface-2);
  color: var(--c-text);
}
.ch-field:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; }

/* ------------------------------------------------------------ آموزش */
.ch-tut { text-align: center; }
.ch-tut__art { width: 100%; max-width: 260px; margin: 0 auto var(--s-4); display: block; }
.ch-tut__dots { display: flex; justify-content: center; gap: 6px; margin-top: var(--s-4); }
.ch-tut__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-surface-3); transition: all var(--t-mid) var(--ease); }
.ch-tut__dot--on { background: var(--c-accent); width: 22px; border-radius: var(--r-pill); }

/* --------------------------------------------------------- دسکتاپ */
@media (min-width: 900px) {
  :root { --fs-3xl: 48px; }
  .ch-nav { padding-bottom: 8px; }
}
@media (hover: hover) {
  .ch-tap:hover { transform: translateY(-2px); box-shadow: var(--sh-3); }
  .ch-btn:hover:not(:disabled) { filter: brightness(1.05); }
  .ch-nav__item:hover { color: var(--c-text-dim); }
  .ch-day:hover:not(.ch-day--empty):not(.ch-day--future) { background: var(--c-surface-3); }
}
