/* =========================================================
   ۲۰۴۸ چالش — استایل موبایل‌فرست، فارسی/RTL، دو تم
   ========================================================= */

@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap; src: url("fonts/Vazirmatn-Regular.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 600; font-display: swap; src: url("fonts/Vazirmatn-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 800; font-display: swap; src: url("fonts/Vazirmatn-ExtraBold.woff2") format("woff2"); }

/* ---------- توکن‌ها ---------- */
:root {
  --bg-1: #0F1020;
  --bg-2: #1B1D3A;
  --surface: rgba(35, 38, 74, .78);
  --surface-solid: #23264A;
  --surface-2: rgba(255,255,255,.06);
  --border: rgba(255,255,255,.08);
  --text: #F1F2FF;
  --text-2: #9EA3C7;
  --accent: #7C5CFF;
  --accent-2: #4FD1FF;
  --success: #2ED8A3;
  --gold: #FFC24B;
  --danger: #FF6B5C;
  --board: #171933;
  --cell: rgba(255,255,255,.055);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 20px;
  --tab-h: 64px;

  --board-size: min(92vw, 56dvh, 460px);
  --gap: calc(var(--board-size) * 0.028);
  --cell-size: calc((var(--board-size) - var(--gap) * 5) / 4);
  --step: calc(var(--cell-size) + var(--gap));
  --speed: 110ms;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-1: #F6F5FF;
  --bg-2: #E9E7FF;
  --surface: rgba(255,255,255,.82);
  --surface-solid: #FFFFFF;
  --surface-2: rgba(27,29,58,.05);
  --border: rgba(27,29,58,.08);
  --text: #1B1D3A;
  --text-2: #6B6F93;
  --board: #DCDAF5;
  --cell: rgba(27,29,58,.07);
  --shadow: 0 10px 30px rgba(60,50,140,.15);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-1: #F6F5FF;
    --bg-2: #E9E7FF;
    --surface: rgba(255,255,255,.82);
    --surface-solid: #FFFFFF;
    --surface-2: rgba(27,29,58,.05);
    --border: rgba(27,29,58,.08);
    --text: #1B1D3A;
    --text-2: #6B6F93;
    --board: #DCDAF5;
    --cell: rgba(27,29,58,.07);
    --shadow: 0 10px 30px rgba(60,50,140,.15);
    color-scheme: light;
  }
}

/* ---------- پایه ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% -10%, var(--bg-2), var(--bg-1) 60%);
  background-attachment: fixed;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { text-decoration: none; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
svg { display: block; }

.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.bg-orbs i {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .35;
  animation: float 18s ease-in-out infinite alternate;
}
.bg-orbs i:nth-child(1) { width: 60vw; height: 60vw; background: var(--accent); top: -20vw; inset-inline-end: -20vw; }
.bg-orbs i:nth-child(2) { width: 45vw; height: 45vw; background: var(--accent-2); bottom: 10vh; inset-inline-start: -20vw; animation-delay: -6s; }
.bg-orbs i:nth-child(3) { width: 35vw; height: 35vw; background: #D14BD9; bottom: -15vw; inset-inline-end: 10vw; animation-delay: -12s; }
@keyframes float { to { transform: translate(6vw, 4vh) scale(1.1); } }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
}

/* ---------- هدر ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.profile-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  max-width: 55%;
}
.nick { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.avatar-lg { width: 56px; height: 56px; font-size: 24px; }
.xp-chip {
  margin-inline-start: auto; display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px; font-size: 14px;
  color: var(--gold); background: rgba(255,194,75,.12); border: 1px solid rgba(255,194,75,.25);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.ico-sun { display: none; }
:root[data-theme="light"] .ico-sun { display: block; }
:root[data-theme="light"] .ico-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .ico-sun { display: block; }
  :root:not([data-theme="dark"]) .ico-moon { display: none; }
}

/* ---------- نماها ---------- */
.view { flex: 1; display: flex; flex-direction: column; animation: view-in .28s cubic-bezier(.2,.8,.2,1); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.view-head h2 { font-size: 22px; font-weight: 800; }
.counter { color: var(--text-2); font-size: 14px; }
.sub-head { font-size: 16px; font-weight: 800; margin: 20px 0 10px; }

/* ---------- امتیاز ---------- */
.scores-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.score-card {
  position: relative; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 2px;
}
.score-label { font-size: 12px; color: var(--text-2); }
.score-container, .best-container { position: relative; font-size: 24px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.score-addition {
  position: absolute; inset-inline-start: 0; top: 0; font-size: 18px; font-weight: 800; color: var(--success);
  animation: move-up .7s ease-out both; pointer-events: none;
}
@keyframes move-up { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-34px); } }

/* ---------- صفحه بازی ---------- */
.board-wrap { display: flex; justify-content: center; margin-bottom: 14px; }
.game-container {
  position: relative; width: var(--board-size); height: var(--board-size);
  padding: var(--gap); border-radius: var(--radius);
  background: var(--board); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.04);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.grid-container { position: absolute; inset: var(--gap); z-index: 1; display: flex; flex-direction: column; gap: var(--gap); }
.grid-row { display: flex; gap: var(--gap); flex: 1; }
.grid-cell { flex: 1; border-radius: calc(var(--radius) * .55); background: var(--cell); }
.game-message { display: none; } /* نتیجه در overlay جدا نمایش داده می‌شود */

.tile-container { position: absolute; inset: var(--gap); z-index: 2; }
.tile, .tile .tile-inner {
  width: var(--cell-size); height: var(--cell-size);
  line-height: var(--cell-size);
}
.tile {
  position: absolute; left: 0; top: 0;
  transition: transform var(--speed) ease-in-out;
}
.tile .tile-inner {
  border-radius: calc(var(--radius) * .55);
  background: #E9EAF7; color: #1B1D3A;
  text-align: center; font-weight: 800;
  font-size: clamp(22px, calc(var(--cell-size) * .5), 48px);
  font-family: "Vazirmatn", system-ui, sans-serif; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.35);
}

/* موقعیت‌ها (۱ تا ۴) */
.tile.tile-position-1-1 { transform: translate(0, 0); }
.tile.tile-position-1-2 { transform: translate(0, var(--step)); }
.tile.tile-position-1-3 { transform: translate(0, calc(var(--step) * 2)); }
.tile.tile-position-1-4 { transform: translate(0, calc(var(--step) * 3)); }
.tile.tile-position-2-1 { transform: translate(var(--step), 0); }
.tile.tile-position-2-2 { transform: translate(var(--step), var(--step)); }
.tile.tile-position-2-3 { transform: translate(var(--step), calc(var(--step) * 2)); }
.tile.tile-position-2-4 { transform: translate(var(--step), calc(var(--step) * 3)); }
.tile.tile-position-3-1 { transform: translate(calc(var(--step) * 2), 0); }
.tile.tile-position-3-2 { transform: translate(calc(var(--step) * 2), var(--step)); }
.tile.tile-position-3-3 { transform: translate(calc(var(--step) * 2), calc(var(--step) * 2)); }
.tile.tile-position-3-4 { transform: translate(calc(var(--step) * 2), calc(var(--step) * 3)); }
.tile.tile-position-4-1 { transform: translate(calc(var(--step) * 3), 0); }
.tile.tile-position-4-2 { transform: translate(calc(var(--step) * 3), var(--step)); }
.tile.tile-position-4-3 { transform: translate(calc(var(--step) * 3), calc(var(--step) * 2)); }
.tile.tile-position-4-4 { transform: translate(calc(var(--step) * 3), calc(var(--step) * 3)); }

/* پالت کاشی‌ها: سرد → گرم → طلایی */
.tile.tile-2 .tile-inner    { background: #E9EAF7; color: #1B1D3A; }
.tile.tile-4 .tile-inner    { background: #CFD4F5; color: #1B1D3A; }
.tile.tile-8 .tile-inner    { background: #8EA7FF; color: #fff; }
.tile.tile-16 .tile-inner   { background: #6B8CFF; color: #fff; }
.tile.tile-32 .tile-inner   { background: #7C5CFF; color: #fff; }
.tile.tile-64 .tile-inner   { background: #A054F2; color: #fff; }
.tile.tile-128 .tile-inner  { background: #D14BD9; color: #fff; font-size: clamp(20px, calc(var(--cell-size) * .42), 42px); box-shadow: 0 4px 14px rgba(209,75,217,.45), inset 0 1px 0 rgba(255,255,255,.35); }
.tile.tile-256 .tile-inner  { background: #F2529E; color: #fff; font-size: clamp(20px, calc(var(--cell-size) * .42), 42px); box-shadow: 0 4px 16px rgba(242,82,158,.5), inset 0 1px 0 rgba(255,255,255,.35); }
.tile.tile-512 .tile-inner  { background: #FF6B5C; color: #fff; font-size: clamp(20px, calc(var(--cell-size) * .42), 42px); box-shadow: 0 4px 18px rgba(255,107,92,.5), inset 0 1px 0 rgba(255,255,255,.35); }
.tile.tile-1024 .tile-inner { background: #FF9340; color: #fff; font-size: clamp(17px, calc(var(--cell-size) * .34), 36px); box-shadow: 0 4px 20px rgba(255,147,64,.55), inset 0 1px 0 rgba(255,255,255,.35); }
.tile.tile-2048 .tile-inner {
  background: linear-gradient(160deg, #FFD98A, #FFC24B 55%, #FFA726); color: #2A1F05;
  font-size: clamp(17px, calc(var(--cell-size) * .34), 36px);
  box-shadow: 0 0 0 3px rgba(255,194,75,.35), 0 6px 28px rgba(255,194,75,.65), inset 0 1px 0 rgba(255,255,255,.6);
  animation: glow 1.6s ease-in-out infinite alternate;
}
@keyframes glow { to { box-shadow: 0 0 0 5px rgba(255,194,75,.2), 0 8px 36px rgba(255,194,75,.9), inset 0 1px 0 rgba(255,255,255,.6); } }
.tile.tile-super .tile-inner {
  background: #1C1F3F; color: #fff; font-size: clamp(15px, calc(var(--cell-size) * .3), 30px);
  box-shadow: 0 0 0 2px var(--accent-2), 0 0 24px rgba(79,209,255,.6);
}

.tile-new .tile-inner { animation: appear .22s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes appear { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }
.tile-merged .tile-inner { z-index: 20; animation: pop .22s ease both; }
@keyframes pop { 0% { transform: scale(0); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
.tile.tile-merged.tile-128 .tile-inner, .tile.tile-merged.tile-256 .tile-inner,
.tile.tile-merged.tile-512 .tile-inner, .tile.tile-merged.tile-1024 .tile-inner,
.tile.tile-merged.tile-2048 .tile-inner { animation: pop .22s ease both, flash .5s ease-out; }
@keyframes flash { 0% { filter: brightness(1.7); } 100% { filter: brightness(1); } }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: transform .12s, filter .15s; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  border: 0; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(124,92,255,.35);
}
.btn-ghost { background: var(--surface-2); }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.link-btn { color: var(--accent-2); font-size: 13px; font-weight: 600; padding: 4px 0; }
.actions-row { display: flex; gap: 10px; justify-content: center; }
.actions-row .btn-primary { flex: 1; max-width: 240px; }
.hint { text-align: center; color: var(--text-2); font-size: 13px; margin-top: 14px; }
.hint b { color: var(--gold); }

/* ---------- تب‌بار ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-around; max-width: 480px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 22px 22px 0 0;
}
.tab {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; color: var(--text-2); font-size: 11px; font-weight: 600; border-radius: 14px;
  transition: color .2s, transform .12s;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab:active { transform: scale(.92); }
.tab.is-active { color: var(--accent-2); }
.tab.is-active::after { content: ""; position: absolute; top: 0; width: 20px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tab .dot { position: absolute; top: 6px; inset-inline-end: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface-solid); }

/* ---------- سگمنت ---------- */
.segment { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.segment button { padding: 6px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .2s; }
.segment button.is-active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* ---------- رتبه‌بندی ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; align-items: end; margin-bottom: 14px; min-height: 150px; }
.podium:empty { display: none; }
.pod {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border); text-align: center;
  animation: view-in .4s both;
}
.pod .avatar { width: 44px; height: 44px; font-size: 18px; }
.pod .pod-name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pod-score { font-size: 15px; font-weight: 800; }
.pod .pod-rank { font-size: 22px; line-height: 1; }
.pod-1 { order: 2; padding-top: 18px; background: linear-gradient(180deg, rgba(255,194,75,.22), var(--surface)); border-color: rgba(255,194,75,.45); }
.pod-1 .avatar { width: 56px; height: 56px; font-size: 22px; background: linear-gradient(135deg, #FFD98A, #FFA726); color: #2A1F05; box-shadow: 0 0 0 3px rgba(255,194,75,.4); }
.pod-2 { order: 1; background: linear-gradient(180deg, rgba(200,205,230,.18), var(--surface)); }
.pod-2 .avatar { background: linear-gradient(135deg, #E6E8F5, #AEB4D0); color: #1B1D3A; }
.pod-3 { order: 3; background: linear-gradient(180deg, rgba(205,127,50,.18), var(--surface)); }
.pod-3 .avatar { background: linear-gradient(135deg, #E0A370, #B36A2B); }

.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.lb-row.is-me { border-color: var(--accent); background: linear-gradient(90deg, rgba(124,92,255,.18), var(--surface)); }
.lb-rank { width: 26px; text-align: center; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { font-size: 11px; color: var(--text-2); display: block; font-weight: 400; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-me {
  position: sticky; bottom: 0; margin-top: 10px; padding: 10px 14px; border-radius: 14px; text-align: center; font-weight: 600; font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 8px 20px rgba(124,92,255,.35);
}
.empty { text-align: center; color: var(--text-2); padding: 40px 20px; font-size: 14px; }
.empty svg { width: 80px; height: 80px; margin: 0 auto 12px; opacity: .6; }
.skeleton { height: 54px; border-radius: 14px; background: linear-gradient(90deg, var(--surface-2), rgba(255,255,255,.12), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- نشان‌ها ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-card {
  position: relative; aspect-ratio: 1 / 1; border-radius: 18px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); text-align: center;
  transition: transform .12s;
}
.badge-card:active { transform: scale(.95); }
.badge-card .b-icon { font-size: 34px; line-height: 1; filter: grayscale(1) opacity(.45); transition: filter .3s; }
.badge-card .b-title { font-size: 12px; font-weight: 600; color: var(--text-2); line-height: 1.3; }
.badge-card .b-lock { position: absolute; top: 8px; inset-inline-end: 8px; font-size: 11px; opacity: .7; }
.badge-card .b-bar { width: 70%; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.badge-card .b-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }
.badge-card .b-prog { font-size: 10px; color: var(--text-2); }
.badge-card.is-earned { background: linear-gradient(160deg, rgba(124,92,255,.35), rgba(79,209,255,.15)), var(--surface); border-color: rgba(124,92,255,.5); box-shadow: 0 6px 20px rgba(124,92,255,.25); }
.badge-card.is-earned .b-icon { filter: none; text-shadow: 0 4px 14px rgba(255,255,255,.35); }
.badge-card.is-earned .b-title { color: var(--text); }
.badge-card.is-new::before { content: "جدید"; position: absolute; top: 8px; inset-inline-start: 8px; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--danger); color: #fff; }

/* ---------- من ---------- */
.profile-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); }
.profile-main { flex: 1; min-width: 0; }
.profile-main h2 { font-size: 18px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-pill { display: flex; flex-direction: column; align-items: center; padding: 6px 12px; border-radius: 12px; background: rgba(255,194,75,.12); color: var(--gold); }
.xp-pill b { font-size: 16px; } .xp-pill span { font-size: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.stat b { font-size: 17px; font-weight: 800; } .stat span { font-size: 11px; color: var(--text-2); }
.codes-list { display: flex; flex-direction: column; gap: 10px; }
.ticket {
  position: relative; padding: 14px; border-radius: 16px; text-align: center;
  background: var(--surface-solid); border: 2px dashed rgba(255,194,75,.6);
}
.ticket::before, .ticket::after { content: ""; position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--bg-1); transform: translateY(-50%); }
.ticket::before { inset-inline-start: -11px; } .ticket::after { inset-inline-end: -11px; }
.ticket-head { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.ticket-code { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 24px; font-weight: 800; letter-spacing: 2px; color: var(--gold); word-break: break-all; }
.ticket-meta { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.ticket-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.credit { margin-top: 24px; text-align: center; font-size: 12px; color: var(--text-2); }
.credit a { color: var(--accent-2); }

/* ---------- Overlay / Sheet ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 11, 30, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade .2s both; padding: 0;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 480px; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0; background: var(--surface-solid); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
  animation: slide-up .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-handle { width: 44px; height: 5px; border-radius: 5px; background: var(--text-2); opacity: .4; margin: 0 auto 6px; }
.sheet h2 { font-size: 20px; font-weight: 800; }
.sheet p { color: var(--text-2); font-size: 14px; line-height: 1.7; }
.sheet input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; font-size: 16px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); outline: none;
}
.sheet input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
.help-cards { display: flex; flex-direction: column; gap: 10px; }
.help-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.help-card span { font-size: 28px; }
.help-card p { color: var(--text); }
.badge-sheet { align-items: center; text-align: center; }
.badge-big { font-size: 64px; line-height: 1; margin-top: 4px; filter: drop-shadow(0 8px 20px rgba(124,92,255,.5)); }
.bd-meta { display: flex; gap: 14px; color: var(--text-2); font-size: 13px; }

/* ---------- نتیجه ---------- */
#result-overlay { align-items: center; padding: 20px; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.result-card {
  position: relative; width: 100%; max-width: 400px; padding: 24px 20px; border-radius: 26px; text-align: center;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: slide-up .35s cubic-bezier(.2,.8,.2,1) both;
}
.result-emoji { font-size: 56px; line-height: 1; animation: bounce .9s ease both; }
@keyframes bounce { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
.result-card h2 { font-size: 26px; font-weight: 800; }
.result-card.is-win h2 { background: linear-gradient(90deg, #FFD98A, #FFA726); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-sub { color: var(--text-2); font-size: 14px; }
.result-score { display: flex; flex-direction: column; padding: 8px 24px; border-radius: 14px; background: var(--surface-2); }
.result-score span { font-size: 12px; color: var(--text-2); } .result-score b { font-size: 28px; font-weight: 800; }
.result-card .ticket { width: 100%; animation: flip .6s cubic-bezier(.2,.8,.2,1) both .25s; transform-origin: center; }
@keyframes flip { 0% { transform: perspective(600px) rotateX(-90deg); opacity: 0; } 100% { transform: perspective(600px) rotateX(0); opacity: 1; } }
.result-note { font-size: 13px; color: var(--text-2); }
.result-actions { display: flex; gap: 10px; width: 100%; margin-top: 6px; }
.result-actions .btn { flex: 1; padding: 0 10px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: calc(env(safe-area-inset-top) + 12px); left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; max-width: 92vw;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 600; animation: toast-in .35s cubic-bezier(.2,.8,.2,1) both; pointer-events: auto;
}
.toast.is-badge { border-color: rgba(124,92,255,.6); background: linear-gradient(90deg, rgba(124,92,255,.35), var(--surface-solid)); }
.toast .t-icon { font-size: 22px; line-height: 1; }
.toast small { display: block; font-weight: 400; color: var(--text-2); font-size: 12px; }
.toast.is-out { animation: toast-out .3s ease both; }
@keyframes toast-in { from { transform: translateY(-30px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-30px); opacity: 0; } }

/* ---------- کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bg-orbs { display: none; }
}

/* ---------- صفحه‌های کوتاه ---------- */
@media (max-height: 640px) {
  :root { --board-size: min(92vw, 50dvh, 460px); }
  .hint { display: none; }
  .scores-row { margin-bottom: 8px; }
}
