/* ================================================================
   تم — فیروزه‌ای/لاکی. رنگ‌ها همه متغیرند تا تم تخته با یک کلاس عوض شود.
   هیچ فونت یا تصویری از بیرون لود نمی‌شود.
   ================================================================ */
:root {
  --ink: #0d1416;
  --panel: #152025;
  --raised: #1d2c32;
  --line: #27383e;
  --firuzeh: #35c2b0;
  --firuzeh-dim: #1f7d72;
  --saffron: #e5a53f;
  --danger: #e2685f;
  --text: #e9f1f2;
  --muted: #8aa3a8;
  --radius: 15px;
  --fa: "Vazirmatn", "IRANSansX", "IRANSans", Tahoma, system-ui, sans-serif;

  --sq-light: #d3ddd8;
  --sq-dark: #48706b;
  --hl-last: rgba(226, 170, 82, 0.30);
  --hl-sel: rgba(53, 194, 176, 0.36);
  --hint-ink: rgba(16, 28, 30, 0.30);
  --hint-ink-d: rgba(16, 28, 30, 0.48);
  --coord-l: var(--sq-dark);
  --coord-d: var(--sq-light);

  /* سبک کلاسیک: پرکنندگی تخت، خط دور تیره، جزئیات داخلی به رنگ مخالف */
  --pw-fill: #ffffff;
  --pw-stroke: #16171a;
  --pw-detail: #16171a;
  --pb-fill: #1d1e20;
  --pb-stroke: #000000;
  --pb-detail: #ffffff;
}
.theme-wood {
  --sq-light: #f0d9b5;
  --sq-dark: #b58863;
  --hint-ink: rgba(60, 34, 18, 0.30);
  --hint-ink-d: rgba(52, 26, 10, 0.46);
}
.theme-blue {
  --sq-light: #e9eef7;
  --sq-dark: #b3c3da;
  --hint-ink: rgba(30, 48, 78, 0.28);
  --hint-ink-d: rgba(30, 48, 78, 0.34);
  --hl-last: rgba(246, 212, 84, 0.55);
  --hl-sel: rgba(112, 196, 132, 0.5);
  --coord-l: #93a7c6;
  --coord-d: #f2f6fc;
}
.theme-night {
  --sq-light: #b7c1d1;
  --sq-dark: #3d4a63;
  --hint-ink: rgba(14, 18, 30, 0.32);
  --hint-ink-d: rgba(226, 236, 255, 0.32);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--fa);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; }
.hidden { display: none !important; }
.wrap { max-width: 520px; margin: 0 auto; padding: 12px 12px 28px; }

/* ---------------------------------------------------------------- سربرگ */
header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--firuzeh), var(--firuzeh-dim));
  color: #06201d; padding: 4px;
}
.brand .mark svg { width: 100%; height: 100%; }
.brand .mark .body { fill: #06201d; stroke: none; }
.brand .mark .dt { fill: var(--firuzeh); }
.hdr-right { display: flex; align-items: center; gap: 8px; }
.who { font-size: 13px; color: var(--muted); text-align: left; line-height: 1.3; }
.who b { display: block; color: var(--saffron); font-variant-numeric: tabular-nums; font-size: 15px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); font-size: 17px;
}

/* ---------------------------------------------------------------- کارت‌ها */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.hint-text { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

.btn {
  display: block; width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--line); font-weight: 600;
  transition: transform 0.06s, filter 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: linear-gradient(160deg, var(--firuzeh), var(--firuzeh-dim)); color: #06201d; border-color: transparent; }
.btn.warn { color: var(--danger); border-color: #3a2523; background: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.4; cursor: default; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row.tight { margin-top: 8px; }

label.field { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
select, input[type=text] {
  width: 100%; margin-top: 5px; padding: 11px; border-radius: 11px;
  background: var(--ink); color: var(--text); border: 1px solid var(--line);
}

.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 8px 0 4px; }
.lv { padding: 9px 0; border-radius: 10px; background: var(--raised); border: 1px solid var(--line);
      color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.lv[aria-pressed="true"] { background: var(--firuzeh); color: #06201d; border-color: transparent; }
.lv-name { text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.lv-name b { color: var(--text); }

/* ================================================================
   تخته
   ================================================================ */
.board {
  position: relative; width: 100%; aspect-ratio: 1; direction: ltr;
  border-radius: 10px; overflow: hidden; touch-action: none; user-select: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.board > div { position: absolute; inset: 0; }
.sqs { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; }
.sq.l { background: var(--sq-light); }
.sq.d { background: var(--sq-dark); }
.sq i {
  position: absolute; font-style: normal; font-weight: 700; font-size: 9px;
  opacity: 0.75; line-height: 1;
}
.sq.l i { color: var(--coord-l); }
.sq.d i { color: var(--coord-d); }
.sq .cf { bottom: 2px; right: 3px; }
.sq .cr { top: 2px; left: 3px; }

.marks, .hints { pointer-events: none; }
.mk, .hint, .pc { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; }
.mk.last { background: var(--hl-last); }
.mk.sel { background: var(--hl-sel); }
.mk.hover { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6); }
.mk.check {
  background: radial-gradient(circle, rgba(226, 104, 95, 0.95) 8%, rgba(226, 104, 95, 0.45) 40%, transparent 72%);
}
.mk.hintmv { box-shadow: inset 0 0 0 3px var(--saffron); border-radius: 3px; }
/* نقطه و حلقه با گرادیان ساخته می‌شوند تا با اندازه‌ی تخته مقیاس بخورند */
/* خانه‌ی تیره جوهر پررنگ‌تری لازم دارد، وگرنه نقطه گم می‌شود */
.hint { background: radial-gradient(circle, var(--hint-ink) 0 17%, transparent 17.5%); }
.hint.on-d { --hint-ink: var(--hint-ink-d); }
.hint.cap { background: radial-gradient(circle, transparent 0 60%, var(--hint-ink) 60.5% 76%, transparent 76.5%); }

.pc {
  z-index: 2; cursor: grab;
  transition: transform 0.24s cubic-bezier(0.25, 0.75, 0.28, 1);
  will-change: transform;
}
/* سایه‌ی زمین. بر حسب em است تا با اندازه‌ی خانه بزرگ و کوچک شود. */
.pc svg {
  width: 100%; height: 100%; display: block; transition: transform 0.14s;
}
.pc .body { stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; }
.pc .ln { fill: none; stroke-linecap: round; }
.pc .dt { stroke: none; }
.pc.c-w .body { fill: var(--pw-fill); stroke: var(--pw-stroke); }
.pc.c-w .ln { stroke: var(--pw-detail); }
.pc.c-w .dt { fill: var(--pw-detail); }
.pc.c-b .body { fill: var(--pb-fill); stroke: var(--pb-stroke); }
/* بدون این، مهره‌ی سیاه روی خانه‌ی تیره سیلوئتش را از دست می‌دهد — خط دورش
   هم سیاه است. هاله بر حسب em است تا با اندازه‌ی خانه مقیاس بخورد. */
.pc.c-b svg { filter: drop-shadow(0 0 0.022em rgba(255, 255, 255, 0.55)); }
.pc.c-b .ln { stroke: var(--pb-detail); }
.pc.c-b .dt { fill: var(--pb-detail); }

.pc.dragging { z-index: 9; transition: none; cursor: grabbing; }
.pc.dragging svg { transform: scale(1.14); filter: drop-shadow(0 7px 9px rgba(0, 0, 0, 0.5)); }
.pc.gone { transition: opacity 0.2s ease-in; opacity: 0; z-index: 1; }
.pc.appear { animation: pop 0.24s ease-out; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }

/* ================================================================
   نوار بازیکن
   ================================================================ */
.pl { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.ava {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; flex: 0 0 auto;
  background: linear-gradient(150deg, #2b3f45, #1a282d); color: var(--firuzeh);
  border: 1px solid var(--line);
}
.pl.bot .ava { color: var(--saffron); }
.ava svg { width: 78%; height: 78%; }
.ava .body { fill: currentColor; stroke: none; }
.ava .dt { fill: var(--panel); }
.pl .info { flex: 1; min-width: 0; }
.pl .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .nm span { color: var(--muted); font-weight: 400; font-size: 12px; }
.taken { display: flex; align-items: center; height: 17px; margin-top: 1px; direction: ltr;
         max-width: 100%; overflow: hidden; }
.taken .pc-mini { position: static; width: 16px; height: 16px; margin-left: -5px;
                  opacity: 0.8; cursor: default; transition: none; }
.taken .pc-mini:first-child { margin-left: 0; }
.taken .pc-mini svg { width: 100%; height: 100%; display: block; }
.taken .adv { font-size: 12px; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

.clk {
  position: relative; overflow: hidden; flex: 0 0 auto;
  min-width: 92px; text-align: center; padding: 7px 12px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line);
}
.clk .bar { position: absolute; inset: 0; transform-origin: right; background: var(--raised); z-index: 0; transition: transform 0.25s linear; }
.clk .t { position: relative; z-index: 1; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
.clk.on { border-color: var(--firuzeh); }
.clk.on .bar { background: rgba(53, 194, 176, 0.16); }
.clk.low .t { color: var(--danger); }
.clk.low.on { border-color: var(--danger); }
.clk.low.on .bar { background: rgba(226, 104, 95, 0.2); }

/* ---------------------------------------------------------------- زنجیره */
.streak { display: flex; align-items: center; gap: 6px; }
.streak .n {
  font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums;
  color: var(--text); transition: color 0.3s;
}
.streak .lbl { font-size: 12px; color: var(--muted); }
/* سه پله: عادی، طلایی، داغ */
.streak.warm .n { color: var(--saffron); }
.streak.hot .n { color: #ff6a3d; }
.streak .flame { width: 0; opacity: 0; transition: width 0.3s, opacity 0.3s; }
.streak.hot .flame { width: 15px; opacity: 1; }
.streak .flame svg { width: 100%; height: 21px; display: block; }
.streak .f-out { fill: #ff6a3d; }
.streak .f-in { fill: #ffd24a; }
.streak.hot .flame svg { animation: flicker 1.1s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30%      { transform: scale(1.1, 0.95) rotate(-3deg); }
  60%      { transform: scale(0.95, 1.08) rotate(2deg); }
}
/* پرش کوتاه موقع بالا رفتن عدد */
.streak.pop .n { animation: streakpop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes streakpop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.55); }
  100% { transform: scale(1); }
}

.cheer { animation: cheerin 0.35s ease-out; }
@keyframes cheerin { from { opacity: 0; transform: translateY(6px); } }

.puzzle-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 12px; font-size: 14px; color: var(--muted);
}
.puzzle-head b { color: var(--saffron); font-variant-numeric: tabular-nums; }

.link-cta { color: var(--firuzeh); font-size: 13px; font-weight: 600; padding: 6px 4px; }

.seg { display: flex; background: var(--ink); border: 1px solid var(--line); border-radius: 11px; padding: 3px; margin: 4px 0 10px; }
.seg button { flex: 1; padding: 8px 0; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); }

.otp-input {
  width: 100%; margin: 4px 0 12px; padding: 12px; border-radius: 11px;
  background: var(--ink); color: var(--text); border: 1px solid var(--line);
  text-align: center; font-size: 22px; letter-spacing: 8px; font-variant-numeric: tabular-nums;
}
label.field .opt { color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- حرکت‌ها */
.moves {
  margin-top: 10px; padding: 9px 12px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); max-height: 96px; overflow-y: auto;
  font-size: 13px; color: var(--muted); direction: ltr; text-align: left;
  font-variant-numeric: tabular-nums; word-spacing: 3px;
}
.moves b { color: var(--text); font-weight: 600; }

.banner { margin-top: 10px; padding: 11px 13px; border-radius: 12px; font-size: 14px;
          background: var(--raised); border: 1px solid var(--line); }
.banner.good { border-color: var(--firuzeh); }
.banner.bad { border-color: var(--danger); }
.banner .link { direction: ltr; display: inline-block; color: var(--saffron); word-break: break-all; }

.lobby-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
             padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lobby-row:last-child { border-bottom: 0; }
.lobby-row button { padding: 7px 15px; border-radius: 10px; background: var(--firuzeh); color: #06201d; font-weight: 700; }
.tag { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- شیت‌ها */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(5, 10, 11, 0.74); animation: fade 0.16s ease-out;
}
.sheet .card { max-width: 340px; width: 100%; margin: 0; animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

.promo { display: flex; gap: 8px; }
.promo button { flex: 1; aspect-ratio: 1; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); padding: 6px; }
.promo button:active { background: var(--firuzeh); }
.promo .pc { position: static; width: 100%; height: 100%; }

.result { text-align: center; }
.result .big { font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.result .big.win { color: var(--firuzeh); }
.result .big.lose { color: var(--danger); }
.result .big.draw { color: var(--saffron); }
.result .why { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.result .delta { font-size: 14px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.result .delta b.up { color: var(--firuzeh); }
.result .delta b.down { color: var(--danger); }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 30px; height: 30px; border-radius: 9px; background: var(--raised); border: 1px solid var(--line); font-weight: 700; font-size: 17px; }
.stepper b { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }

.opt-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.opt-row:last-of-type { border-bottom: 0; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 34px; height: 26px; border-radius: 8px; border: 2px solid transparent; overflow: hidden; display: flex; }
.swatch[aria-pressed="true"] { border-color: var(--firuzeh); }
.swatch i { flex: 1; }
.toggle { width: 46px; height: 27px; border-radius: 99px; background: var(--raised); border: 1px solid var(--line); position: relative; }
.toggle::after { content: ""; position: absolute; top: 2px; right: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--muted); transition: 0.16s; }
.toggle[aria-pressed="true"] { background: var(--firuzeh-dim); border-color: transparent; }
.toggle[aria-pressed="true"]::after { right: calc(100% - 23px); background: #eafffb; }

.toast {
  position: fixed; bottom: 18px; right: 50%; transform: translateX(50%);
  background: var(--raised); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 12px; font-size: 13px; z-index: 60; max-width: 90vw;
  animation: rise 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *, .pc { transition: none !important; animation: none !important; }
}
